Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Created August 13, 2023 10:08
Show Gist options
  • Save KatieBarnett/937229350970f06b67d813a446ca2396 to your computer and use it in GitHub Desktop.
Save KatieBarnett/937229350970f06b67d813a446ca2396 to your computer and use it in GitHub Desktop.
ComplexModifierScene - First Conditional
@Composable
fun ComplexModifierScene(
nighttime: Boolean,
torchon: Boolean,
modifier: Modifier = Modifier
) {
val backgroundColor = if (nighttime && torchon) {
TorchLight
} else if (!nighttime) {
Sunlight
} else {
Night
}
val boxModifier = modifier
.conditional(nighttime && torchon, {
clip(CircleShape)
})
.fillMaxHeight()
.aspectRatio(1f)
.background(backgroundColor)
.conditional(nighttime && torchon, {
shadow(elevation = 4.dp, shape = CircleShape)
})
.conditional(nighttime && !torchon, {
blur(20.dp)
})
Box(boxModifier) {
Image(painterResource(R.drawable.outline_yard_24), "Scene", Modifier.fillMaxSize())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment