Is there a built in way to get the current screen ...
# compose
d
Is there a built in way to get the current screen orientation? Other than comparing width and height.
t
In Android
Copy code
LocalConfiguration.current.orientation
d
I'm looking for a common solution
s
Common as in you want orientation for Desktop too? Also, what do you need orientation for? Checking only width and height will give you false positives in various scenarios.
d
Sometimes there is a different layout for Landscape and Portrait. Common, so I can get it in common code.
s
What do you mean "Different layout for Landscape and Portrait"?
Is the difference in layout specifically when you are in landscape or portrait, or is it when you got different available space for your app to render in? You might be interested in this discussion https://kotlinlang.slack.com/archives/CJLTWPH7S/p1710953896708929?thread_ts=1710752750.247829&cid=CJLTWPH7S
d
Thats a good point. So I use size classes instead?
Is the difference in layout specifically when you are in landscape or portrait, or is it when you got different available space for your app to render in?
I just have a mobile design and a desktop design and want implement both in common code.
s
So I use size classes instead
Yup. You may very well be on a "mobile", and still have a "desktop-sized" available space to you. Or you may be on a desktop and the window is shrinked to the size of a mobile device. You wouldn't want to show the desktop UI on the shrinked window, nor the mobile UI on a huge table which has as much space available as a desktop would.
☝🏽 1
☝️ 1
👍 1