Proper drawer styling

This commit is contained in:
Tibo De Peuter 2023-04-14 13:49:28 +02:00
parent 064a9d3f31
commit 7c09aac5b3

View file

@ -12,9 +12,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import be.ugent.sel.studeez.R import be.ugent.sel.studeez.R
import be.ugent.sel.studeez.resources import be.ugent.sel.studeez.resources
import be.ugent.sel.studeez.ui.theme.StudeezTheme
@Composable @Composable
@ -22,31 +26,36 @@ fun Drawer(
openAndPopUp: (String, String) -> Unit, openAndPopUp: (String, String) -> Unit,
viewModel: DrawerViewModel = hiltViewModel() viewModel: DrawerViewModel = hiltViewModel()
) { ) {
Column (
Column(modifier = Modifier.fillMaxSize()) { modifier = Modifier.fillMaxWidth()
DrawerEntry( ) {
icon = Icons.Default.Home, Column (
text = resources().getString(R.string.home) modifier = Modifier.fillMaxWidth().weight(1f)
) { ) {
// TODO Go to home DrawerEntry(
} icon = Icons.Default.Home,
DrawerEntry( text = resources().getString(R.string.home)
icon = ImageVector.vectorResource(id = R.drawable.ic_timer), ) {
text = resources().getString(R.string.timers) // TODO Go to home
) { }
viewModel.onTimersClick(openAndPopUp) DrawerEntry(
} icon = ImageVector.vectorResource(id = R.drawable.ic_timer),
DrawerEntry( text = resources().getString(R.string.timers)
icon = Icons.Default.Settings, ) {
text = resources().getString(R.string.settings) viewModel.onTimersClick(openAndPopUp)
) { }
viewModel.onSettingsClick(openAndPopUp) DrawerEntry(
} icon = Icons.Default.Settings,
DrawerEntry( text = resources().getString(R.string.settings)
icon = ImageVector.vectorResource(id = R.drawable.ic_logout), ) {
text = resources().getString(R.string.log_out) viewModel.onSettingsClick(openAndPopUp)
) { }
viewModel.onLogoutClick(openAndPopUp) DrawerEntry(
icon = ImageVector.vectorResource(id = R.drawable.ic_logout),
text = resources().getString(R.string.log_out)
) {
viewModel.onLogoutClick(openAndPopUp)
}
} }
DrawerEntry( DrawerEntry(
@ -70,21 +79,29 @@ fun DrawerEntry(
.clickable(onClick = { onClick() }) .clickable(onClick = { onClick() })
.fillMaxWidth() .fillMaxWidth()
) { ) {
Box(modifier = Modifier.fillMaxWidth(0.25f)) { Box(
modifier = Modifier
.padding(vertical = 12.dp)
.fillMaxWidth(0.15f)
) {
Icon(imageVector = icon, contentDescription = text) Icon(imageVector = icon, contentDescription = text)
} }
Box(modifier = Modifier.fillMaxWidth(0.75f)) { Box(
modifier = Modifier
.padding(vertical = 12.dp)
.fillMaxWidth(0.85f)
) {
Text(text = text) Text(text = text)
} }
} }
} }
//@Preview @Preview
//@Composable @Composable
//fun DrawerPreview() { fun DrawerPreview() {
// StudeezTheme { StudeezTheme {
// Drawer( Drawer(
// {} {a, b -> {}}, hiltViewModel()
// ) )
// } }
//} }