diff --git a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt index a6830a5..c9b0963 100644 --- a/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt +++ b/app/src/main/java/be/ugent/sel/studeez/StudeezApp.kt @@ -141,8 +141,7 @@ fun StudeezNavGraph( open, openAndPopUp, viewModel = hiltViewModel(), - drawerViewModel = drawerViewModel, - navBarViewModel = navBarViewModel, + drawerViewModel = drawerViewModel ) } diff --git a/app/src/main/java/be/ugent/sel/studeez/common/composable/DrawerScreenComposable.kt b/app/src/main/java/be/ugent/sel/studeez/common/composable/DrawerScreenComposable.kt new file mode 100644 index 0000000..e6f55f7 --- /dev/null +++ b/app/src/main/java/be/ugent/sel/studeez/common/composable/DrawerScreenComposable.kt @@ -0,0 +1,51 @@ +package be.ugent.sel.studeez.common.composable + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.RowScope +import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Menu +import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope +import be.ugent.sel.studeez.common.composable.drawer.Drawer +import be.ugent.sel.studeez.common.composable.drawer.DrawerActions +import be.ugent.sel.studeez.resources +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch +import be.ugent.sel.studeez.R.string as AppText + +@Composable +fun DrawerScreenTemplate( + title: String, + drawerActions: DrawerActions, + action: @Composable RowScope.() -> Unit = {}, + content: @Composable (PaddingValues) -> Unit +) { + val scaffoldState: ScaffoldState = rememberScaffoldState() + val coroutineScope: CoroutineScope = rememberCoroutineScope() + + Scaffold( + scaffoldState = scaffoldState, + + topBar = { TopAppBar( + title = { Text(text = title) }, + navigationIcon = { + IconButton(onClick = { + coroutineScope.launch { scaffoldState.drawerState.open() } + }) { + Icon( + imageVector = Icons.Default.Menu, + contentDescription = resources().getString(AppText.menu) + ) + } + }, + actions = action + )}, + + drawerContent = { + Drawer(drawerActions) + } + ) { + content(it) + } +} \ No newline at end of file diff --git a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt index fafdf02..9537965 100644 --- a/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt +++ b/app/src/main/java/be/ugent/sel/studeez/screens/timer_overview/TimerOverviewScreen.kt @@ -10,10 +10,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import be.ugent.sel.studeez.R -import be.ugent.sel.studeez.common.composable.BasicButton -import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate -import be.ugent.sel.studeez.common.composable.StealthButton -import be.ugent.sel.studeez.common.composable.TimerEntry +import be.ugent.sel.studeez.common.composable.* import be.ugent.sel.studeez.common.composable.drawer.DrawerActions import be.ugent.sel.studeez.common.composable.drawer.DrawerViewModel import be.ugent.sel.studeez.common.composable.drawer.getDrawerActions @@ -48,30 +45,25 @@ fun TimerOverviewRoute( open: (String) -> Unit, openAndPopUp: (String, String) -> Unit, viewModel: TimerOverviewViewModel, - drawerViewModel: DrawerViewModel, - navBarViewModel: NavigationBarViewModel, + drawerViewModel: DrawerViewModel ) { TimerOverviewScreen( timerOverviewActions = getTimerOverviewActions(viewModel), - drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp), - navigationBarActions = getNavigationBarActions(navBarViewModel, open), + drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp) ) } @Composable fun TimerOverviewScreen( timerOverviewActions: TimerOverviewActions, - drawerActions: DrawerActions, - navigationBarActions: NavigationBarActions, + drawerActions: DrawerActions ) { val timers = timerOverviewActions.getUserTimers().collectAsState(initial = emptyList()) - // TODO moet geen primary screen zijn: geen navbar nodig - PrimaryScreenTemplate( + DrawerScreenTemplate( title = resources().getString(R.string.timers), - drawerActions = drawerActions, - navigationBarActions = navigationBarActions, + drawerActions = drawerActions ) { Column { LazyColumn( @@ -112,7 +104,6 @@ fun TimerOverviewPreview() { { flowOf() }, { listOf(customTimer, customTimer) }, {}), - drawerActions = DrawerActions({}, {}, {}, {}, {}), - navigationBarActions = NavigationBarActions({}, {}, {}, {}) + drawerActions = DrawerActions({}, {}, {}, {}, {}) ) }