Scaffold
Default
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ScaffoldEx() {
var checked by remember { mutableStateOf(false) }
Scaffold(
topBar = {},
) {
Surface(
modifier = Modifier
.fillMaxSize()
.padding(it)
) {
}
}
}
TopAppBar, Content 추가
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ScaffoldEx() {
var checked by remember { mutableStateOf(false) }
Scaffold(
topBar = {
TopAppBar(
title = {
Text(text = "Scaffold App")
},
navigationIcon = {
IconButton(onClick = {}) {
Icon(imageVector = Icons.Filled.ArrowBack, contentDescription = "")
}
}
)
},
floatingActionButton = {
FloatingActionButton(onClick = {}) {
}
}
) {
Surface(
modifier = Modifier.padding(it)
) {
CheckBoxWithContent(
checked = checked,
toggleState = { checked = !checked }
) {
Text(text = "Text1")
}
}
}
}
@Composable
fun CheckBoxWithContent(
checked: Boolean,
toggleState: () -> Unit,
content: @Composable RowScope.() -> Unit
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.clickable { toggleState() }
) {
Checkbox(checked = checked, onCheckedChange = { toggleState() })
content()
}
}