Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Preview
@Composable
fun TermsOfUseScreenCompletedPreview() {
val checkedState = remember {
mutableStateOf(false)
}
MaterialTheme {
Scaffold(
topBar = {
TopAppBar(
title = {
Text(modifier = Modifier.fillMaxWidth(), text = "利用規約")
},
navigationIcon = {
IconButton(onClick = {}) {
Icon(Icons.Filled.ArrowBack, contentDescription = "戻る")
}
}
)
},
content = {
Column(modifier = Modifier.padding(8.dp)) {
Text(modifier = Modifier.fillMaxWidth(), text = "この利用規約は以下...", fontSize = 16.sp)
Spacer(modifier = Modifier.size(16.dp))
Text(modifier = Modifier.fillMaxWidth().semantics { heading() }, text = "第1条", fontSize = 24.sp)
Spacer(modifier = Modifier.size(8.dp))
Text(modifier = Modifier.fillMaxWidth(), text = "1. 本規約は...", fontSize = 16.sp)
Spacer(modifier = Modifier.size(8.dp))
Text(modifier = Modifier.fillMaxWidth().semantics { heading() }, text = "第2条", fontSize = 24.sp)
Spacer(modifier = Modifier.size(8.dp))
Text(modifier = Modifier.fillMaxWidth(), text = "1. 本サービスは...", fontSize = 16.sp)
Spacer(modifier = Modifier.size(32.dp))
Row(
modifier = Modifier.fillMaxWidth().toggleable(
value = checkedState.value,
onValueChange = { checkedState.value = it },
role = Role.Checkbox
)
.padding(8.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically
) {
Checkbox(modifier = Modifier
.semantics { contentDescription = "利用規約同意" }
.size(32.dp),
checked = checkedState.value,
onCheckedChange = null)
Text(text = "同意する", fontSize = 16.sp)
}
Spacer(modifier = Modifier.size(8.dp))
val description = if (checkedState.value) {
"次へ進むことができます"
} else {
"次へ進むには利用規約に同意する必要があります"
}
Button(modifier = Modifier
.semantics {
liveRegion = LiveRegionMode.Polite
contentDescription = description
}
.fillMaxWidth()
.defaultMinSize(minHeight = 48.dp),
enabled = checkedState.value,
onClick = {}) {
Text(modifier = Modifier.align(Alignment.CenterVertically), text = "次へ進む", fontSize = 16.sp)
}
}
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment