Hi, how can I add or remove components of my user interface at run time? tanks
y
Yann Badoual
11/22/2019, 10:43 AM
Use a
if
block,
ie:
Copy code
val shouldShow = +state { true }
if (shouldShow) {
Button(...)
}
// To show or hide button:
state.value = true
state.value = false
👍 1
Yann Badoual
11/22/2019, 10:43 AM
You can also use a
@Model
annotated class instead of a state
Copy code
@Model
class MyModel(
var shouldShowButton: Boolean = false
)
val model = +model { MyModel() }
if (model.shouldShowButton) {
Button(...)
}
model.shouldShowButton = false