Hey guys, question, what is the correct way to ups...
# compose-web
m
Hey guys, question, what is the correct way to upscale the size of my composables , if for example i need to set a certain height and width at a 1440 res, but need those sizes to become bigger if the resolution of the screen was higher. I've tried to create something custom but obviously it was full of lags when trying to resize the whole composable on every window resize. I did that for fonts however and had no issues, but obviously whole composables is a different story.
s
Not sure if I fully understand what you're trying to do, but
LocalDensity
is the way to go for scaling. You don't have to change anything about your composables with this, because all drawing/layout/placement operations use scaled values through density.
Just wrap whatever components you want to scale up (or the whole app, it's up to you) in a
CompositionLocalProvider
, passing in a custom value for LocalDensity:
Copy code
CompositionLocalProvider(
    LocalDensity provides Density(someValue)
) {
    // your component / app
}
How you calculate which density to use is up to you, whether it's by the user, or based on the viewport size, depends on what you need.