MrPowerGamerBR
08/02/2021, 3:47 PMvar disableButton by remember { mutableStateOf(false) }
Button(attrs = {
style {
width(100.percent)
}
if (disableButton)
disabled()
}) {
Text("This is a button")
}
Button(attrs = {
onClick {
disableButton = !disableButton
}
}) {
Text("Toggle button")
}
Clicking the second button disables the first button... but it also removes the style (the width: 100%) of the first button!MrPowerGamerBR
08/02/2021, 4:33 PMOleksandr Karpovich [JB]
08/02/2021, 4:36 PMOleksandr Karpovich [JB]
08/02/2021, 4:44 PMobject MyStylesheet : StyleSheet() {
val buttonClass by style {
width(100.percent)
}
}
fun main() {
renderComposableInBody {
var disableButton by remember { mutableStateOf(false) }
Style(MyStylesheet)
Button(attrs = {
classes(MyStylesheet.buttonClass)
if (disableButton)
disabled()
}) {
Text("This is a button")
}
Button(attrs = {
onClick {
disableButton = !disableButton
}
}) {
Text("Toggle button")
}
}
}
MrPowerGamerBR
08/02/2021, 6:00 PMOleksandr Karpovich [JB]
08/03/2021, 9:55 AM