commit
						ef267e3477
					
				
					 12 changed files with 221 additions and 159 deletions
				
			
		|  | @ -11,6 +11,7 @@ import androidx.compose.material.Surface | |||
| import androidx.compose.material.rememberScaffoldState | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.ReadOnlyComposable | ||||
| import androidx.compose.runtime.getValue | ||||
| import androidx.compose.runtime.remember | ||||
| import androidx.compose.runtime.rememberCoroutineScope | ||||
| import androidx.compose.ui.Modifier | ||||
|  | @ -21,9 +22,14 @@ import androidx.hilt.navigation.compose.hiltViewModel | |||
| import androidx.navigation.NavHostController | ||||
| import androidx.navigation.compose.NavHost | ||||
| import androidx.navigation.compose.composable | ||||
| import androidx.navigation.compose.currentBackStackEntryAsState | ||||
| import androidx.navigation.compose.rememberNavController | ||||
| 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 | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel | ||||
| import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions | ||||
| import be.ugent.sel.studeez.common.snackbar.SnackbarManager | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||
| import be.ugent.sel.studeez.screens.home.HomeRoute | ||||
|  | @ -89,43 +95,52 @@ fun StudeezNavGraph( | |||
|     val drawerViewModel: DrawerViewModel = hiltViewModel() | ||||
|     val navBarViewModel: NavigationBarViewModel = hiltViewModel() | ||||
| 
 | ||||
|     val backStackEntry by appState.navController.currentBackStackEntryAsState() | ||||
|     val getCurrentScreen: () -> String? = { backStackEntry?.destination?.route } | ||||
| 
 | ||||
|     val goBack: () -> Unit = { appState.popUp() } | ||||
|     val open: (String) -> Unit = { appState.navigate(it) } | ||||
|     val openAndPopUp: (String, String) -> Unit = | ||||
|         { route, popUp -> appState.navigateAndPopUp(route, popUp) } | ||||
| 
 | ||||
|     val drawerActions: DrawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp) | ||||
|     val navigationBarActions: NavigationBarActions = | ||||
|         getNavigationBarActions(navBarViewModel, open, getCurrentScreen) | ||||
| 
 | ||||
|     NavHost( | ||||
|         navController = appState.navController, | ||||
|         startDestination = StudeezDestinations.SPLASH_SCREEN, | ||||
|         modifier = modifier, | ||||
|     ) { | ||||
|         val goBack: () -> Unit = { | ||||
|             appState.popUp() | ||||
|         } | ||||
| 
 | ||||
|         val open: (String) -> Unit = { route -> | ||||
|             appState.navigate(route) | ||||
|         } | ||||
| 
 | ||||
|         val openAndPopUp: (String, String) -> Unit = { route, popUp -> | ||||
|             appState.navigateAndPopUp(route, popUp) | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|         composable(StudeezDestinations.SPLASH_SCREEN) { | ||||
|             SplashRoute(openAndPopUp, viewModel = hiltViewModel()) | ||||
|             SplashRoute( | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.LOGIN_SCREEN) { | ||||
|             LoginRoute(openAndPopUp, viewModel = hiltViewModel()) | ||||
|             LoginRoute( | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.SIGN_UP_SCREEN) { | ||||
|             SignUpRoute(openAndPopUp, viewModel = hiltViewModel()) | ||||
|             SignUpRoute( | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.HOME_SCREEN) { | ||||
|             HomeRoute( | ||||
|                 open, | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|                 drawerViewModel = drawerViewModel, | ||||
|                 navBarViewModel = navBarViewModel, | ||||
|                 drawerActions = drawerActions, | ||||
|                 navigationBarActions = navigationBarActions, | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|  | @ -133,21 +148,26 @@ fun StudeezNavGraph( | |||
|         // TODO Sessions screen | ||||
| 
 | ||||
|         composable(StudeezDestinations.PROFILE_SCREEN) { | ||||
|             ProfileRoute(open, openAndPopUp, viewModel = hiltViewModel()) | ||||
|             ProfileRoute( | ||||
|                 open, | ||||
|                 viewModel = hiltViewModel(), | ||||
|                 drawerActions = drawerActions, | ||||
|                 navigationBarActions = navigationBarActions, | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.TIMER_OVERVIEW_SCREEN) { | ||||
|             TimerOverviewRoute( | ||||
|                 open, | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|                 drawerViewModel = drawerViewModel, | ||||
|                 navBarViewModel = navBarViewModel, | ||||
|                 drawerActions = drawerActions, | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.SESSION_SCREEN) { | ||||
|             SessionRoute(open, viewModel = hiltViewModel()) | ||||
|             SessionRoute( | ||||
|                 open, | ||||
|                 viewModel = hiltViewModel() | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         // TODO Timers screen | ||||
|  | @ -155,16 +175,18 @@ fun StudeezNavGraph( | |||
| 
 | ||||
|         // Edit screens | ||||
|         composable(StudeezDestinations.EDIT_PROFILE_SCREEN) { | ||||
|             EditProfileRoute(goBack, openAndPopUp, viewModel = hiltViewModel()) | ||||
|             EditProfileRoute( | ||||
|                 goBack, | ||||
|                 openAndPopUp, | ||||
|                 viewModel = hiltViewModel(), | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         composable(StudeezDestinations.TIMER_SELECTION_SCREEN) { | ||||
|             TimerSelectionRoute( | ||||
|                 open, | ||||
|                 openAndPopUp, | ||||
|                 goBack, | ||||
|                 viewModel = hiltViewModel(), | ||||
|                 drawerViewModel = drawerViewModel, | ||||
|                 navBarViewModel = navBarViewModel, | ||||
|             ) | ||||
|         } | ||||
|     } | ||||
|  |  | |||
|  | @ -3,15 +3,9 @@ package be.ugent.sel.studeez.common.composable | |||
| import androidx.annotation.StringRes | ||||
| import androidx.compose.foundation.BorderStroke | ||||
| import androidx.compose.foundation.shape.RoundedCornerShape | ||||
| import androidx.compose.material.Button | ||||
| import androidx.compose.material.ButtonColors | ||||
| import androidx.compose.material.ButtonDefaults | ||||
| import androidx.compose.material.MaterialTheme | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.material.TextButton | ||||
| import androidx.compose.material.* | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.graphics.Color | ||||
| import androidx.compose.ui.res.stringResource | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
|  | @ -21,7 +15,6 @@ import be.ugent.sel.studeez.common.ext.basicButton | |||
| import be.ugent.sel.studeez.common.ext.card | ||||
| 
 | ||||
| @Composable | ||||
| 
 | ||||
| fun BasicTextButton(@StringRes text: Int, modifier: Modifier, action: () -> Unit) { | ||||
|     TextButton(onClick = action, modifier = modifier) { Text(text = stringResource(text)) } | ||||
| } | ||||
|  | @ -64,10 +57,10 @@ fun StealthButton( | |||
|         onClick = onClick, | ||||
|         modifier = Modifier.card(), | ||||
|         colors = ButtonDefaults.buttonColors( | ||||
|             backgroundColor = Color.Transparent, | ||||
|             contentColor = Color.DarkGray, | ||||
|             backgroundColor = MaterialTheme.colors.surface, | ||||
|             contentColor = MaterialTheme.colors.onSurface | ||||
|         ), | ||||
|         border = BorderStroke(3.dp, Color.DarkGray), | ||||
|         border = BorderStroke(1.dp, MaterialTheme.colors.onSurface) | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,64 @@ | |||
| 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 androidx.compose.ui.tooling.preview.Preview | ||||
| 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 be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.launch | ||||
| import be.ugent.sel.studeez.R.string as AppText | ||||
| 
 | ||||
| @Composable | ||||
| fun DrawerScreenTemplate( | ||||
|     title: String, | ||||
|     drawerActions: DrawerActions, | ||||
|     barAction: @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 = barAction | ||||
|         )}, | ||||
| 
 | ||||
|         drawerContent = { | ||||
|             Drawer(drawerActions) | ||||
|         } | ||||
|     ) { | ||||
|         content(it) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun DrawerScreenPreview() { | ||||
|     StudeezTheme { DrawerScreenTemplate( | ||||
|         title = "Drawer screen preview", | ||||
|         drawerActions =DrawerActions({}, {}, {}, {}, {}) | ||||
|     ) { | ||||
|         Text(text = "Preview content") | ||||
|     } } | ||||
| } | ||||
|  | @ -2,26 +2,19 @@ package be.ugent.sel.studeez.common.composable | |||
| 
 | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.foundation.layout.RowScope | ||||
| import androidx.compose.material.FabPosition | ||||
| import androidx.compose.material.Icon | ||||
| import androidx.compose.material.IconButton | ||||
| import androidx.compose.material.Scaffold | ||||
| import androidx.compose.material.ScaffoldState | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.material.TopAppBar | ||||
| import androidx.compose.material.* | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.filled.Edit | ||||
| import androidx.compose.material.icons.filled.Menu | ||||
| import androidx.compose.material.rememberScaffoldState | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.rememberCoroutineScope | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.common.composable.drawer.Drawer | ||||
| import be.ugent.sel.studeez.common.composable.drawer.DrawerActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBar | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.launch | ||||
|  | @ -31,7 +24,7 @@ fun PrimaryScreenTemplate( | |||
|     title: String, | ||||
|     drawerActions: DrawerActions, | ||||
|     navigationBarActions: NavigationBarActions, | ||||
|     action: @Composable RowScope.() -> Unit = {}, | ||||
|     barAction: @Composable RowScope.() -> Unit = {}, | ||||
|     content: @Composable (PaddingValues) -> Unit | ||||
| ) { | ||||
|     val scaffoldState: ScaffoldState = rememberScaffoldState() | ||||
|  | @ -53,7 +46,7 @@ fun PrimaryScreenTemplate( | |||
|                         ) | ||||
|                     } | ||||
|                 }, | ||||
|                 actions = action | ||||
|                 actions = barAction | ||||
|             ) | ||||
|         }, | ||||
| 
 | ||||
|  | @ -77,7 +70,7 @@ fun PrimaryScreenPreview() { | |||
|         PrimaryScreenTemplate( | ||||
|             "Preview screen", | ||||
|             DrawerActions({}, {}, {}, {}, {}), | ||||
|             NavigationBarActions({}, {}, {}, {}), | ||||
|             NavigationBarActions({ false }, {}, {}, {}, {}), | ||||
|             { | ||||
|                 IconButton(onClick = { /*TODO*/ }) { | ||||
|                     Icon( | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| 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.ArrowBack | ||||
|  | @ -10,13 +11,12 @@ import be.ugent.sel.studeez.R | |||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| 
 | ||||
| // TODO Add option for button in top right corner as extra button | ||||
| 
 | ||||
| @Composable | ||||
| // Does not contain floatingActionButton and bottom bar, used in all the other screens | ||||
| fun SecondaryScreenTemplate( | ||||
|     title: String, | ||||
|     popUp: () -> Unit, | ||||
|     barAction: @Composable RowScope.() -> Unit = {}, | ||||
|     content: @Composable (PaddingValues) -> Unit | ||||
| ) { | ||||
|     Scaffold( | ||||
|  | @ -30,7 +30,8 @@ fun SecondaryScreenTemplate( | |||
|                         contentDescription = resources().getString(R.string.go_back) | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
|             }, | ||||
|             actions = barAction | ||||
|         ) }, | ||||
|     ) { paddingValues -> | ||||
|         content(paddingValues) | ||||
|  |  | |||
|  | @ -1,10 +1,6 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.foundation.layout.fillMaxWidth | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.foundation.layout.* | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.Alignment | ||||
|  | @ -20,24 +16,39 @@ import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo | |||
| @Composable | ||||
| fun TimerEntry( | ||||
|     timerInfo: TimerInfo, | ||||
|     button: @Composable () -> Unit, | ||||
|     rightButton: @Composable () -> Unit = {}, | ||||
|     leftButton: @Composable () -> Unit = {} | ||||
| ) { | ||||
|     Row( | ||||
|         verticalAlignment = Alignment.CenterVertically, | ||||
|         modifier = Modifier.fillMaxWidth(), | ||||
|         horizontalArrangement = Arrangement.SpaceBetween | ||||
|         modifier = Modifier.fillMaxWidth() | ||||
|     ) { | ||||
|         Column( | ||||
|             Modifier.padding(horizontal = 10.dp) | ||||
|         Row( | ||||
|             modifier = Modifier.weight(1f) | ||||
|         ) { | ||||
|             Text( | ||||
|                 text = timerInfo.name, fontWeight = FontWeight.Bold, fontSize = 20.sp | ||||
|             ) | ||||
|             Text( | ||||
|                 text = timerInfo.description, fontWeight = FontWeight.Light, fontSize = 15.sp | ||||
|             ) | ||||
|             Box(modifier = Modifier.align(alignment = Alignment.CenterVertically)) { | ||||
|                 leftButton() | ||||
|             } | ||||
| 
 | ||||
|             Column( | ||||
|                 Modifier.padding( | ||||
|                     horizontal = 20.dp, | ||||
|                     vertical = 11.dp | ||||
|                 ) | ||||
|             ) { | ||||
|                 Text( | ||||
|                     text = timerInfo.name, | ||||
|                     fontWeight = FontWeight.Medium, | ||||
|                     fontSize = 20.sp | ||||
|                 ) | ||||
|                 Text( | ||||
|                     text = timerInfo.description, fontWeight = FontWeight.Light, fontSize = 14.sp | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         Box(modifier = Modifier.align(alignment = Alignment.CenterVertically)) { | ||||
|             rightButton() | ||||
|         } | ||||
|         button() | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,6 @@ | |||
| package be.ugent.sel.studeez.common.composable.navbar | ||||
| 
 | ||||
| import android.util.Log | ||||
| import androidx.compose.material.BottomNavigation | ||||
| import androidx.compose.material.BottomNavigationItem | ||||
| import androidx.compose.material.Icon | ||||
|  | @ -12,11 +13,14 @@ import androidx.compose.material.icons.outlined.DateRange | |||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.PROFILE_SCREEN | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| import be.ugent.sel.studeez.R.string as AppText | ||||
| 
 | ||||
| data class NavigationBarActions( | ||||
|     val isSelectedTab: (String) -> Boolean, | ||||
|     val onHomeClick: () -> Unit, | ||||
|     val onTasksClick: () -> Unit, | ||||
|     val onSessionsClick: () -> Unit, | ||||
|  | @ -26,29 +30,38 @@ data class NavigationBarActions( | |||
| fun getNavigationBarActions( | ||||
|     navigationBarViewModel: NavigationBarViewModel, | ||||
|     open: (String) -> Unit, | ||||
|     getCurrentScreen: () -> String? | ||||
| ): NavigationBarActions { | ||||
|     return NavigationBarActions( | ||||
|         onHomeClick = { navigationBarViewModel.onHomeClick(open) }, | ||||
|         onTasksClick = { navigationBarViewModel.onTasksClick(open) }, | ||||
|         onSessionsClick = { navigationBarViewModel.onSessionsClick(open) }, | ||||
|         onProfileClick = { navigationBarViewModel.onProfileClick(open) }, | ||||
|         isSelectedTab = { screen -> | ||||
|             screen == getCurrentScreen() | ||||
|         }, | ||||
|         onHomeClick = { | ||||
|             navigationBarViewModel.onHomeClick(open) | ||||
|         }, | ||||
|         onTasksClick = { | ||||
|             navigationBarViewModel.onTasksClick(open) | ||||
|         }, | ||||
|         onSessionsClick = { | ||||
|             navigationBarViewModel.onSessionsClick(open) | ||||
|         }, | ||||
|         onProfileClick = { | ||||
|             navigationBarViewModel.onProfileClick(open) | ||||
|         }, | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
| @Composable | ||||
| fun NavigationBar( | ||||
|     navigationBarActions: NavigationBarActions, | ||||
|     navigationBarActions: NavigationBarActions | ||||
| ) { | ||||
|     // TODO Pass functions and new screens. | ||||
|     // TODO Pass which screen is selected. | ||||
|     // TODO Disabled -> HIGH/MEDIUM_EMPHASIS if the page is implemented | ||||
|     BottomNavigation( | ||||
|         elevation = 10.dp | ||||
|     ) { | ||||
|         BottomNavigationItem( | ||||
|             icon = { Icon(imageVector = Icons.Default.List, resources().getString(AppText.home)) }, | ||||
|             label = { Text(text = resources().getString(AppText.home)) }, | ||||
|             selected = false, // TODO | ||||
|             selected = navigationBarActions.isSelectedTab(HOME_SCREEN), | ||||
|             onClick = navigationBarActions.onHomeClick | ||||
|         ) | ||||
| 
 | ||||
|  | @ -59,7 +72,8 @@ fun NavigationBar( | |||
|                 ) | ||||
|             }, | ||||
|             label = { Text(text = resources().getString(AppText.tasks)) }, | ||||
|             selected = false, // TODO | ||||
|             // TODO selected = navigationBarActions.isSelectedTab(TASKS_SCREEN), | ||||
|             selected = false, | ||||
|             onClick = navigationBarActions.onTasksClick | ||||
|         ) | ||||
| 
 | ||||
|  | @ -73,7 +87,8 @@ fun NavigationBar( | |||
|                 ) | ||||
|             }, | ||||
|             label = { Text(text = resources().getString(AppText.sessions)) }, | ||||
|             selected = false, // TODO | ||||
|             // TODO selected = navigationBarActions.isSelectedTab(SESSIONS_SCREEN), | ||||
|             selected = false, | ||||
|             onClick = navigationBarActions.onSessionsClick | ||||
|         ) | ||||
| 
 | ||||
|  | @ -84,7 +99,7 @@ fun NavigationBar( | |||
|                 ) | ||||
|             }, | ||||
|             label = { Text(text = resources().getString(AppText.profile)) }, | ||||
|             selected = false, // TODO | ||||
|             selected = navigationBarActions.isSelectedTab(PROFILE_SCREEN), | ||||
|             onClick = navigationBarActions.onProfileClick | ||||
|         ) | ||||
| 
 | ||||
|  | @ -95,6 +110,8 @@ fun NavigationBar( | |||
| @Composable | ||||
| fun NavigationBarPreview() { | ||||
|     StudeezTheme { | ||||
|         NavigationBar(NavigationBarActions({}, {}, {}, {})) | ||||
|         NavigationBar( | ||||
|             navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}), | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|  | @ -11,26 +11,21 @@ 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.drawer.DrawerActions | ||||
| import be.ugent.sel.studeez.common.composable.drawer.DrawerViewModel | ||||
| import be.ugent.sel.studeez.common.composable.drawer.getDrawerActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel | ||||
| import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions | ||||
| import be.ugent.sel.studeez.common.ext.basicButton | ||||
| import be.ugent.sel.studeez.resources | ||||
| 
 | ||||
| @Composable | ||||
| fun HomeRoute( | ||||
|     open: (String) -> Unit, | ||||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     viewModel: HomeViewModel, | ||||
|     drawerViewModel: DrawerViewModel, | ||||
|     navBarViewModel: NavigationBarViewModel, | ||||
|     drawerActions: DrawerActions, | ||||
|     navigationBarActions: NavigationBarActions, | ||||
| ) { | ||||
|     HomeScreen( | ||||
|         onStartSessionClick = { viewModel.onStartSessionClick(open) }, | ||||
|         drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp), | ||||
|         navigationBarActions = getNavigationBarActions(navBarViewModel, open), | ||||
|         drawerActions = drawerActions, | ||||
|         navigationBarActions = navigationBarActions, | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
|  | @ -40,12 +35,11 @@ fun HomeScreen( | |||
|     drawerActions: DrawerActions, | ||||
|     navigationBarActions: NavigationBarActions, | ||||
| ) { | ||||
| 
 | ||||
|     PrimaryScreenTemplate( | ||||
|         title = resources().getString(R.string.home), | ||||
|         drawerActions = drawerActions, | ||||
|         navigationBarActions = navigationBarActions, | ||||
|         action = { FriendsAction() } | ||||
|         barAction = { FriendsAction() } | ||||
|     ) { | ||||
|         BasicButton(R.string.start_session, Modifier.basicButton()) { | ||||
|             onStartSessionClick() | ||||
|  | @ -69,6 +63,6 @@ fun HomeScreenPreview() { | |||
|     HomeScreen( | ||||
|         onStartSessionClick = {}, | ||||
|         drawerActions = DrawerActions({}, {}, {}, {}, {}), | ||||
|         navigationBarActions = NavigationBarActions({}, {}, {}, {}) | ||||
|         navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}) | ||||
|     ) | ||||
| } | ||||
|  |  | |||
|  | @ -11,15 +11,12 @@ import androidx.compose.runtime.mutableStateOf | |||
| import androidx.compose.runtime.remember | ||||
| import androidx.compose.runtime.setValue | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.hilt.navigation.compose.hiltViewModel | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.common.composable.Headline | ||||
| import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.common.composable.drawer.DrawerActions | ||||
| import be.ugent.sel.studeez.common.composable.drawer.getDrawerActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions | ||||
| import be.ugent.sel.studeez.resources | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import be.ugent.sel.studeez.R.string as AppText | ||||
| 
 | ||||
|  | @ -41,13 +38,14 @@ fun getProfileActions( | |||
| @Composable | ||||
| fun ProfileRoute( | ||||
|     open: (String) -> Unit, | ||||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     viewModel: ProfileViewModel, | ||||
|     drawerActions: DrawerActions, | ||||
|     navigationBarActions: NavigationBarActions, | ||||
| ) { | ||||
|     ProfileScreen( | ||||
|         profileActions = getProfileActions(viewModel, open), | ||||
|         drawerActions = getDrawerActions(hiltViewModel(), open, openAndPopUp), | ||||
|         navigationBarActions = getNavigationBarActions(hiltViewModel(), open), | ||||
|         drawerActions = drawerActions, | ||||
|         navigationBarActions = navigationBarActions, | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
|  | @ -65,7 +63,7 @@ fun ProfileScreen( | |||
|         title = resources().getString(AppText.profile), | ||||
|         drawerActions = drawerActions, | ||||
|         navigationBarActions = navigationBarActions, | ||||
|         action = { EditAction(onClick = profileActions.onEditProfileClick) } | ||||
|         barAction = { EditAction(onClick = profileActions.onEditProfileClick) } | ||||
|     ) { | ||||
|         Headline(text = (username ?: resources().getString(R.string.no_username))) | ||||
|     } | ||||
|  | @ -90,6 +88,6 @@ fun ProfileScreenPreview() { | |||
|     ProfileScreen( | ||||
|         profileActions = ProfileActions({ null }, {}), | ||||
|         drawerActions = DrawerActions({}, {}, {}, {}, {}), | ||||
|         navigationBarActions = NavigationBarActions({}, {}, {}, {}) | ||||
|         navigationBarActions = NavigationBarActions({ false }, {}, {}, {}, {}) | ||||
|     ) | ||||
| } | ||||
|  | @ -1,6 +1,5 @@ | |||
| package be.ugent.sel.studeez.screens.splash | ||||
| 
 | ||||
| import android.window.SplashScreen | ||||
| import androidx.compose.foundation.background | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.layout.Column | ||||
|  |  | |||
|  | @ -1,6 +1,5 @@ | |||
| package be.ugent.sel.studeez.screens.timer_overview | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.lazy.LazyColumn | ||||
| import androidx.compose.foundation.lazy.items | ||||
|  | @ -8,18 +7,12 @@ import androidx.compose.runtime.Composable | |||
| import androidx.compose.runtime.collectAsState | ||||
| 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.DrawerScreenTemplate | ||||
| import be.ugent.sel.studeez.common.composable.StealthButton | ||||
| import be.ugent.sel.studeez.common.composable.TimerEntry | ||||
| 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 | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel | ||||
| import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions | ||||
| import be.ugent.sel.studeez.common.ext.basicButton | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.CustomTimerInfo | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo | ||||
|  | @ -45,38 +38,29 @@ fun getTimerOverviewActions( | |||
| 
 | ||||
| @Composable | ||||
| fun TimerOverviewRoute( | ||||
|     open: (String) -> Unit, | ||||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     viewModel: TimerOverviewViewModel, | ||||
|     drawerViewModel: DrawerViewModel, | ||||
|     navBarViewModel: NavigationBarViewModel, | ||||
|     drawerActions: DrawerActions, | ||||
| ) { | ||||
|     TimerOverviewScreen( | ||||
|         timerOverviewActions = getTimerOverviewActions(viewModel), | ||||
|         drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp), | ||||
|         navigationBarActions = getNavigationBarActions(navBarViewModel, open), | ||||
|         drawerActions = drawerActions, | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
| @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( | ||||
|                 verticalArrangement = Arrangement.spacedBy(7.dp) | ||||
|             ) { | ||||
|             LazyColumn { | ||||
|                 // Default Timers, cannot be edited | ||||
|                 items(timerOverviewActions.getDefaultTimers()) { | ||||
|                     TimerEntry(timerInfo = it) {} | ||||
|  | @ -112,7 +96,6 @@ fun TimerOverviewPreview() { | |||
|             { flowOf() }, | ||||
|             { listOf(customTimer, customTimer) }, | ||||
|             {}), | ||||
|         drawerActions = DrawerActions({}, {}, {}, {}, {}), | ||||
|         navigationBarActions = NavigationBarActions({}, {}, {}, {}) | ||||
|         drawerActions = DrawerActions({}, {}, {}, {}, {}) | ||||
|     ) | ||||
| } | ||||
|  |  | |||
|  | @ -1,22 +1,14 @@ | |||
| package be.ugent.sel.studeez.screens.timer_selection | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.lazy.LazyColumn | ||||
| import androidx.compose.foundation.lazy.items | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.runtime.collectAsState | ||||
| 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.PrimaryScreenTemplate | ||||
| import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate | ||||
| import be.ugent.sel.studeez.common.composable.StealthButton | ||||
| import be.ugent.sel.studeez.common.composable.TimerEntry | ||||
| 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 | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions | ||||
| import be.ugent.sel.studeez.common.composable.navbar.NavigationBarViewModel | ||||
| import be.ugent.sel.studeez.common.composable.navbar.getNavigationBarActions | ||||
| import be.ugent.sel.studeez.data.local.models.timer_info.TimerInfo | ||||
| import be.ugent.sel.studeez.resources | ||||
| import kotlinx.coroutines.flow.Flow | ||||
|  | @ -40,41 +32,37 @@ fun getTimerSelectionActions( | |||
| @Composable | ||||
| fun TimerSelectionRoute( | ||||
|     open: (String) -> Unit, | ||||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     popUp: () -> Unit, | ||||
|     viewModel: TimerSelectionViewModel, | ||||
|     drawerViewModel: DrawerViewModel, | ||||
|     navBarViewModel: NavigationBarViewModel, | ||||
| ) { | ||||
|     TimerSelectionScreen( | ||||
|         timerSelectionActions = getTimerSelectionActions(viewModel, open), | ||||
|         drawerActions = getDrawerActions(drawerViewModel, open, openAndPopUp), | ||||
|         navigationBarActions = getNavigationBarActions(navBarViewModel, open), | ||||
|         popUp = popUp | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
| @Composable | ||||
| fun TimerSelectionScreen( | ||||
|     timerSelectionActions: TimerSelectionActions, | ||||
|     drawerActions: DrawerActions, | ||||
|     navigationBarActions: NavigationBarActions, | ||||
|     popUp: () -> Unit | ||||
| ) { | ||||
|     val timers = timerSelectionActions.getAllTimers().collectAsState(initial = emptyList()) | ||||
|     PrimaryScreenTemplate( | ||||
|     SecondaryScreenTemplate( | ||||
|         title = resources().getString(R.string.timers), | ||||
|         drawerActions = drawerActions, | ||||
|         navigationBarActions = navigationBarActions, | ||||
|         popUp = popUp | ||||
|     ) { | ||||
|         LazyColumn(verticalArrangement = Arrangement.spacedBy(7.dp)) { | ||||
|         LazyColumn { | ||||
|             // All timers | ||||
|             items(timers.value) { timerInfo -> | ||||
|                 TimerEntry( | ||||
|                     timerInfo = timerInfo, | ||||
|                 ) { | ||||
|                     StealthButton( | ||||
|                         text = R.string.start, | ||||
|                         onClick = { timerSelectionActions.startSession(timerInfo) } | ||||
|                     ) | ||||
|                 } | ||||
|                     leftButton = { | ||||
|                         StealthButton( | ||||
|                             text = R.string.start, | ||||
|                             onClick = { timerSelectionActions.startSession(timerInfo) } | ||||
|                         ) | ||||
|                     } | ||||
|                 ) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | @ -85,7 +73,6 @@ fun TimerSelectionScreen( | |||
| fun TimerSelectionPreview() { | ||||
|     TimerSelectionScreen( | ||||
|         timerSelectionActions = TimerSelectionActions({ flowOf() }, {}), | ||||
|         drawerActions = DrawerActions({}, {}, {}, {}, {}), | ||||
|         navigationBarActions = NavigationBarActions({}, {}, {}, {}), | ||||
|         popUp = {} | ||||
|     ) | ||||
| } | ||||
		Reference in a new issue
	
	 brreynie
						brreynie