in ConfidenceDemoApp/src/main/java/com/example/confidencedemoapp/MainActivity.kt [25:69]
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
// These are observable states where changed will "update the view"
val msgState = vm.message.observeAsState()
val colorState = vm.color.observeAsState()
val surfaceText = vm.surfaceText.observeAsState()
MyApplicationTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
Column {
Greeting(msgState.value.toString())
Button(onClick = {
vm.refreshUi()
}) {
Text("Refresh UI")
}
Button(onClick = {
vm.updateContext()
}) {
Text("Re-apply evaluationContext")
}
Button(onClick = { vm.multiput() }) {
Text("MultiPut")
}
Surface(
modifier = Modifier
.padding(20.dp)
.fillMaxWidth()
.height(500.dp),
color = colorState.value ?: Color.Gray
) {
Text(text = surfaceText.value ?: "N/A")
}
}
}
}
}
}