ursus
01/09/2023, 10:16 PMSurface
as a root composable in every example? Isn’t it supposed to be some sort of Background
(which doesnt exist in material theme)?
(also, why not expose the BoxScope
in the content lambda? Now I need to add another needless Box
if I need alignment)
setContent {
MyTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.color.background
) {
...
}
}
}
mkrussel
01/09/2023, 10:25 PMSurface
is used a lot, because it correctly updates composition local colors to use the correct on
colors such as onPrimary
and onError
.ursus
01/09/2023, 10:27 PMbackground
ursus
01/09/2023, 10:31 PMmkrussel
01/09/2023, 10:32 PMonBackground
color until you change it or create another Surface.ursus
01/09/2023, 10:33 PMBackground
composable missingursus
01/09/2023, 10:33 PMMaterialTheme.colorScheme.background
etc.mkrussel
01/09/2023, 10:34 PMursus
01/09/2023, 10:35 PM@Composable
fun Scaffold(
... backgroundColor: Color = MaterialTheme.colors.background,
ursus
01/09/2023, 10:41 PMcontent
lambda is not BoxScope
😕ursus
01/09/2023, 11:27 PMon
colors wouldn’t be setup correctly as you said
any way around that?Filip Wiesner
01/10/2023, 7:08 AMwhy not expose theI guess the reason is that Box is just an implementation detail andin the content lambdaBoxScope
Surface
is not really a layout, just a convenience wrapper for your UI that gives you some properties. Some of them are the CompositionLocal values setup.
theYou can set them up yourself the same way Surface does.colors wouldn’t be setup correctly as you said. Any way around that?on
CompositionLocalProvider(
LocalContentColor provides contentColor
) { ... }