generated from mpetuska/template-kmp-library
-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
MDCRadio.kt
40 lines (36 loc) · 902 Bytes
/
MDCRadio.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package showcases
import androidx.compose.runtime.*
import dev.petuska.katalog.runtime.*
import dev.petuska.katalog.runtime.layout.*
import dev.petuska.kmdc.form.field.*
import dev.petuska.kmdc.radio.*
import sandbox.control.*
private class MDCRadioVM {
val options = listOf("A", "B", "C", "D")
var disabled by mutableStateOf(false)
var touch by mutableStateOf(false)
var selected by mutableStateOf<String?>(null)
}
@Composable
@Showcase(id = "MDCRadio")
fun MDCRadio() = InteractiveShowcase(
viewModel = { MDCRadioVM() },
controls = {
BooleanControl("Disabled", ::disabled)
BooleanControl("Touch", ::touch)
},
) {
MDCFormField {
options.forEach { text ->
MDCRadio(
checked = (text == selected),
label = text,
disabled = disabled,
touch = touch,
attrs = {
onInput { selected = text }
}
)
}
}
}