Responsive Layouts
In ResponsiveLayouts
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
In ResponsiveLayouts
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
In ResponsiveLayouts
SupportingPane
var navigationIndex by remember { mutableStateOf(0) } val scope = rememberCoroutineScope() val widthSizeClass = calculateWindowSizeClass().widthSizeClass val navigationItems = listOf( mapOf("icon" to Icons.AutoMirrored.Outlined.Message, "label" to "Messages"), mapOf("icon" to Icons.Outlined.Photo, "label" to "Photos"), mapOf("icon" to Icons.Outlined.VideoCall, "label" to "Videos"), mapOf("icon" to Icons.Outlined.Games, "label" to "Games"), ) @Composable fun ContentPanel(modifier: Modifier = Modifier) { // TODO replace the contents of this composable with your own content Box(modifier.padding(16.dp).border(1.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(18.dp)).clip(RoundedCornerShape(18.dp)).background(MaterialColors.Gray[100])) } @Composable fun SupportPane(modifier: Modifier = Modifier) { // TODO replace the contents of this composable with your own content Box(modifier.padding(16.dp).border(1.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(18.dp)).clip(RoundedCornerShape(18.dp)).background(MaterialColors.Gray[100])) } if (widthSizeClass in listOf(WindowWidthSizeClass.Compact, WindowWidthSizeClass.Medium)) { val drawerState = rememberDrawerState(DrawerValue.Closed) ModalNavigationDrawer( modifier = Modifier.fillMaxHeight(), drawerState = drawerState, drawerContent = { ModalDrawerSheet { Column { Icon(imageVector = Icons.Rounded.Token, contentDescription = null, modifier = Modifier.padding(16.dp).size(48.dp), tint = MaterialTheme.colorScheme.primary) Spacer(Modifier.height(12.dp)) navigationItems.forEachIndexed { index, map -> val icon = map.get("icon") as ImageVector val label = map.get("label") as String NavigationDrawerItem(icon = { Icon(icon, contentDescription = null) }, label = { Text(label) }, selected = index == navigationIndex, onClick = { scope.launch { drawerState.close() } navigationIndex = index }, modifier = Modifier.padding(NavigationDrawerItemDefaults.ItemPadding)) } } } }, ) { Scaffold( topBar = { TopAppBar(title = { Text(navigationItems[navigationIndex].get("label") as String) }, navigationIcon = { IconButton(onClick = { scope.launch { drawerState.open() } }) { Icon(Icons.Rounded.Menu, "Show menu") } }) }, ) { contentPadding -> Column(Modifier.padding(contentPadding).fillMaxSize()) { ContentPanel(Modifier.weight(1f).fillMaxWidth()) HorizontalDivider() SupportPane(Modifier.weight(1f).fillMaxWidth()) } } } } else { Scaffold { PermanentNavigationDrawer(drawerContent = { PermanentDrawerSheet(Modifier.width(200.dp)) { Column(Modifier.padding(vertical = 24.dp)) { ExtendedFloatingActionButton( onClick = { /*TODO*/ }, modifier = Modifier.padding(horizontal = 12.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.Start)) { Icon(Icons.Outlined.Edit, null) Text("Compose") } } Spacer(Modifier.height(24.dp)) LazyColumn(verticalArrangement = Arrangement.spacedBy(4.dp)) { itemsIndexed(navigationItems) { index, map -> val item = navigationItems.get(index) val icon = item.get("icon") as ImageVector val label = item.get("label") as String NavigationDrawerItem(modifier = Modifier.padding(horizontal = 16.dp), selected = index == navigationIndex, icon = { Icon(icon, null) }, label = { Text(label) }, onClick = { navigationIndex = index }) } } } } }, content = { Row { ContentPanel(Modifier.weight(1f).fillMaxHeight()) VerticalDivider() SupportPane(Modifier.width(360.dp).fillMaxHeight()) } }) } }
In ResponsiveLayouts
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}
In ResponsiveLayouts
@Composable
fun NiceTry(){
Column {
BasicText("Nice try. Use code COMPOSE10 for a 10% discount on checkout ;)")
}
}