Denis
02/08/2021, 2:21 PM@Preview
to draw wireframes? Most of the time it shows them, but sometimes there are no wireframes or just a part of it.Denis
02/08/2021, 2:21 PMChris Sinco [G]
02/08/2021, 8:05 PMChris Sinco [G]
02/08/2021, 8:05 PMDenis
02/09/2021, 4:23 AMDenis
02/09/2021, 4:28 AMChris Sinco [G]
02/09/2021, 4:42 PMDenis
02/09/2021, 6:05 PMclass MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var dark by remember { mutableStateOf(false) }
ExperimentsTheme(darkTheme = dark) {
Surface(color = MaterialTheme.colors.background) {
ListItemsApp(dark, setDark = { dark = it })
}
}
}
}
}
@Preview(showBackground = true)
@Composable
fun ListItemsAppPreview() {
ListItemsApp(false, {})
}
@Composable
fun ListItemsApp(dark: Boolean, setDark: (Boolean) -> Unit) {
LazyColumn {
val paddingModifier = Modifier.padding(bottom = 8.dp)
item {
ListItem(
modifier = Modifier.clickable(onClick = { setDark(false) }),
trailing = { RadioButton(selected = !dark, onClick = { setDark(false) }) },
text = { Text("Light") },
)
ListItem(
modifier = Modifier.clickable(onClick = { setDark(true) }),
trailing = { RadioButton(selected = dark, onClick = { setDark(true) }) },
text = { Text("Dark") },
)
Divider()
}
for (i in (1..7)) {
item {
Text(
"Block $i",
modifier = Modifier.padding(16.dp),
style = MaterialTheme.typography.subtitle1
)
ListItem(
text = { Text("$i. List item with switch") },
secondaryText = { Text("Short secondary text") },
trailing = { Switch(checked = i % 4 == 0, onCheckedChange = {}) },
)
ListItem(
text = { Text("$i. List item with radio button") },
secondaryText = {
Text(
"Somewhat long secondary text that may wrap on the second line, but I'm not sure about that",
modifier = paddingModifier
)
},
)
}
}
}
}
Denis
02/09/2021, 6:05 PMDenis
02/09/2021, 6:12 PMDenis
02/09/2021, 6:18 PM@Preview
@Composable
fun LazyColumnPreview() {
Surface {
LazyColumn {
item {
Column {
Text("ABC")
Text("DEF")
}
}
item {
Text("GHI")
}
}
}
}
@Preview
@Composable
fun ColumnPreview() {
Surface {
Column {
Column {
Text("ABC")
Text("DEF")
}
Column {
Text("GHI")
}
}
}
}
Chris Sinco [G]
02/10/2021, 10:55 PM