This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch(initialEnabled: Boolean) { | |
var checked by remember { mutableStateOf(initialEnabled) } | |
Switch( | |
checked = checked, | |
onCheckedChange = { | |
checked = it | |
} | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch(initialEnabled: Boolean) { | |
val checked = remember { mutableStateOf(initialEnabled) } | |
Switch( | |
checked = checked.value, | |
onCheckedChange = { | |
checked.value = it | |
} | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
val checked = mutableStateOf(false) | |
println("MySwitch(): $checked") | |
Switch( | |
checked = checked.value, | |
onCheckedChange = { | |
checked.value = it | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
// remember{} is used. | |
var checked = remember { mutableStateOf(false) } | |
Switch( | |
checked = checked.value, | |
onCheckedChange = { | |
checked.value = it | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
// remember{} is not used. | |
var checked = mutableStateOf(false) | |
Switch( | |
checked = checked.value, | |
onCheckedChange = { | |
checked.value = it | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
// MutableState | |
val checked = remember { mutableStateOf(false) } | |
// ****↓Add**** | |
println("MySwitch(): $checked") | |
// ****↑Add**** | |
Switch( | |
checked = checked.value, | |
onCheckedChange = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
// I have a State in Compose's MutableState | |
val checked = remember { mutableStateOf(false) } | |
Switch( | |
// Observe the State by accessing the value property | |
checked = checked.value, | |
onCheckedChange = { | |
checked.value = it | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MySwitch() { | |
// I have a Kotlin variable with a State of check. | |
var checked = false | |
Switch( | |
checked = checked, | |
onCheckedChange = { | |
checked = it | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
inline fun MyVerticalBox( | |
name: String, | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit = {} | |
) { | |
Layout( | |
content = { content() }, | |
modifier = modifier | |
) { measurables: List<Measurable>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
inline fun MyVerticalBox( | |
name: String, | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit = {} | |
) { | |
Layout( | |
content = { content() }, | |
modifier = modifier | |
) { measurables: List<Measurable>, |