Hi there, I am starting a KMP project and I would ...
# compose-desktop
h
Hi there, I am starting a KMP project and I would like to have different UI for desktop vs mobile, I am confused if I need to add my UI code in the shared/desktopMain or desktopApp. I noticed in this template desktopApp references and launches desktopMain but since it is inside shared module but I wont be sharing the UI with mobile hence the question, looking for best practices, recommendation, thanks in advance.
i
I would keep desktop UI in desktopApp,since it will not be shared with other platforms. Usually,in shared I keep only the shared UI for Android and iOS, or shared UI components that are reusable on multiple platforms.
thank you color 1
s
In general: • Anything inside
shared
is part of your common code. Because your
commonMain
code may define
expect
functions that require
actual
implementations for each platform, there are subdirectories like
desktopMain
in here. • The top-level
desktopApp
,
androidApp
are the actual "entry point" applications. Generally, anything that is shared goes in the shared module: Composables, functions that have expect/actuals, and so on. If you have functionality that is truly exclusive to a platform, or that works on the level of the entry point of the app (e.g. window management on Desktop). that's the kind of code that would go in your
desktopApp
. Hope that helps!
1
🙌 1
thank you color 1
c
How different is the UI? what happens on android if viewing on a tablet. does it look like the desktop UI?
h
Good question Colton, as today is not defined, but you opened my mind that probably could look like the Desktop layout.
c
yeah. i think you might be better off just creating a single UI. but thats just me.
thank you color 1