Hi, what is the best way to use dimensions from single place in compose multiplatform like we used to do in android?
a
Alexander Zhirkevich
06/06/2023, 7:36 AM
Why not to just store them in separate Kotlin file? Are there so many different dimens that they cannot be bundled with the app?
s
Sunil Kumar
06/06/2023, 7:40 AM
You mean making a static class and then define dp constants and use them
a
Alexander Zhirkevich
06/06/2023, 7:42 AM
Something like that. You can even make it via expect/actual to automatically change dimens across platforms if needed
Alexander Zhirkevich
06/06/2023, 7:46 AM
Or create a dimens interface and provide it to compose using CompositionLocalProvider. Probably the cleanest solution
s
Sunil Kumar
06/06/2023, 7:52 AM
Cool, i will try CompositionLocalProvider solution. How i didnt got this solution earlier🤔 even when i was doing the same thing for passing the screen width and height down the tree using the composition local. Thanx.