Skip to content

Instantly share code, notes, and snippets.

@KatieBarnett
Created August 13, 2023 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KatieBarnett/042fe1c639217a45e5a41efab936fbdc to your computer and use it in GitHub Desktop.
Save KatieBarnett/042fe1c639217a45e5a41efab936fbdc to your computer and use it in GitHub Desktop.
ComplexModifierScene - First simplification
@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.background(backgroundColor)
.fillMaxHeight()
.aspectRatio(1f)
val updatedModifier = if (nighttime && torchon) {
boxModifier
.clip(CircleShape)
.shadow(elevation = 4.dp, shape = CircleShape)
} else if (!nighttime) {
boxModifier
} else {
boxModifier
.blur(20.dp)
}
Box(updatedModifier) {
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