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