What is the best approach to specifying `Dp` values in layouts? Should they be hardcoded like ```Mod...
r
What is the best approach to specifying
Dp
values in layouts? Should they be hardcoded like
Copy code
Modifier.padding(16.dp)
or extracted into some constants for reuse
j
Not sure if best approach or not but I have like
MyTheme.dimensions.componentPadding
Like:
Copy code
object MyTheme {

    val dimensions: MyDimensions
        @Composable
        @ReadOnlyComposable
        get() = LocalMyDimensions.current
}
The LocalMyDimensions is maybe overkill, but its useful for my usecase 🙂
MyDimensions can then be interface or static object, refer to all padding values you want to re-use 🙂
Its also nice, so can re-use that for font sizes, icon sizes, insets etc as well.
r
If you are reusing them for font sizes as well, does it mean your LocalMyDemensions class is holding regular integer values?
j
No, TextUnit requires em or sp as font dimensions. Also cant call Local composition from another class provided by local composition. Like call dimensions from typography. So have to do that internally between those.