commit
						41e30df2a2
					
				
					 15 changed files with 262 additions and 94 deletions
				
			
		|  | @ -19,7 +19,7 @@ import androidx.navigation.compose.rememberNavController | |||
| import be.ugent.sel.studeez.common.snackbar.SnackbarManager | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||
| import be.ugent.sel.studeez.screens.home.HomeScreen | ||||
| import be.ugent.sel.studeez.screens.sign_in.LoginScreen | ||||
| import be.ugent.sel.studeez.screens.log_in.LoginScreen | ||||
| import be.ugent.sel.studeez.screens.sign_up.SignUpScreen | ||||
| import be.ugent.sel.studeez.screens.splash.SplashScreen | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
|  | @ -89,6 +89,8 @@ fun NavGraphBuilder.studeezGraph(appState: StudeezAppstate) { | |||
|     } | ||||
| 
 | ||||
|     composable(StudeezDestinations.HOME_SCREEN) { | ||||
|         HomeScreen(openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) }) | ||||
|         HomeScreen( | ||||
|             openAndPopUp = { route, popUp -> appState.navigateAndPopUp(route, popUp) } | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,89 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import androidx.compose.foundation.clickable | ||||
| import androidx.compose.foundation.layout.* | ||||
| import androidx.compose.material.Icon | ||||
| import androidx.compose.material.Text | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.filled.Home | ||||
| import androidx.compose.material.icons.filled.Settings | ||||
| import androidx.compose.material.icons.outlined.Info | ||||
| 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 be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| 
 | ||||
| 
 | ||||
| @Composable | ||||
| fun Drawer( | ||||
|     onLogoutClick: () -> Unit | ||||
| ) { | ||||
|     Column(modifier = Modifier.fillMaxSize()) { | ||||
|         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) | ||||
|         ) { | ||||
|             // TODO Go to timers | ||||
|         } | ||||
|         DrawerEntry( | ||||
|             icon = Icons.Default.Settings, | ||||
|             text = resources().getString(R.string.settings) | ||||
|         ) { | ||||
|             // TODO Go to settings | ||||
|         } | ||||
|         DrawerEntry( | ||||
|             icon = ImageVector.vectorResource(id = R.drawable.ic_logout), | ||||
|             text = resources().getString(R.string.log_out) | ||||
|         ) { | ||||
|             onLogoutClick() | ||||
|         } | ||||
| 
 | ||||
|         DrawerEntry( | ||||
|             icon = Icons.Outlined.Info, | ||||
|             text = resources().getString(R.string.about) | ||||
|         ) { | ||||
|             // TODO Go to about | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Composable | ||||
| fun DrawerEntry( | ||||
|     icon: ImageVector, | ||||
|     text: String, | ||||
|     onClick: () -> Unit | ||||
| ) { | ||||
|     Row( | ||||
|         horizontalArrangement = Arrangement.Center, | ||||
|         modifier = Modifier | ||||
|             .clickable(onClick = { onClick() }) | ||||
|             .fillMaxWidth() | ||||
|     ) { | ||||
|         Box(modifier = Modifier.fillMaxWidth(0.25f)) { | ||||
|             Icon(imageVector = icon, contentDescription = text) | ||||
|         } | ||||
|         Box(modifier = Modifier.fillMaxWidth(0.75f)) { | ||||
|             Text(text = text) | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun DrawerPreview() { | ||||
|     StudeezTheme { | ||||
|         Drawer( | ||||
|             {} | ||||
|         ) | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,66 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| 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.R | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.launch | ||||
| 
 | ||||
| @Composable | ||||
| fun PrimaryScreenTemplate( | ||||
|     title: String, | ||||
|     onLogoutClick: () -> 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(R.string.menu) | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
|         ) }, | ||||
| 
 | ||||
|         drawerContent = { | ||||
|             Drawer( | ||||
|                 onLogoutClick = { onLogoutClick() } | ||||
|             ) | ||||
|         }, | ||||
| 
 | ||||
|         bottomBar = { NavigationBar() }, // TODO Pass arguments so that the current tab etc can be shown | ||||
|         floatingActionButtonPosition = FabPosition.Center, | ||||
|         isFloatingActionButtonDocked = true, | ||||
|         floatingActionButton = { CollapsedAddButton() } | ||||
|     ) { | ||||
|         content(it) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun PrimaryScreenPreview() { | ||||
|     StudeezTheme { | ||||
|         PrimaryScreenTemplate( | ||||
|             "Preview screen", | ||||
|             {} | ||||
|         ) {} | ||||
|     } | ||||
| } | ||||
|  | @ -0,0 +1,47 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| import androidx.compose.material.* | ||||
| import androidx.compose.material.icons.Icons | ||||
| import androidx.compose.material.icons.filled.ArrowBack | ||||
| import androidx.compose.runtime.Composable | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| 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, | ||||
|     content: @Composable (PaddingValues) -> Unit | ||||
| ) { | ||||
|     Scaffold( | ||||
|         // Everything at the top of the screen | ||||
|         topBar = { TopAppBar( | ||||
|             title = { Text(text = title) }, | ||||
|             navigationIcon = { | ||||
|                 IconButton(onClick = { popUp() }) { | ||||
|                     Icon( | ||||
|                         imageVector = Icons.Default.ArrowBack, | ||||
|                         contentDescription = resources().getString(R.string.go_back) | ||||
|                     ) | ||||
|                 } | ||||
|             } | ||||
|         ) }, | ||||
|     ) { paddingValues -> | ||||
|         content(paddingValues) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun SecondaryScreenToolbarPreview() { | ||||
|     StudeezTheme { SecondaryScreenTemplate( | ||||
|         "Preview screen", | ||||
|         {} | ||||
|     ) {} } | ||||
| } | ||||
|  | @ -1,77 +0,0 @@ | |||
| package be.ugent.sel.studeez.common.composable | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.PaddingValues | ||||
| 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.ui.tooling.preview.Preview | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| 
 | ||||
| // TODO Add option for button in top right corner as extra button | ||||
| 
 | ||||
| @Composable | ||||
| // Contains floatingActionButton and bottom bar, used in the main four screens. | ||||
| fun PrimaryScreenToolbar( | ||||
|     title: String, | ||||
|     content: @Composable (PaddingValues) -> Unit | ||||
| ) { | ||||
|     Scaffold( | ||||
|         // Everything at the top of the screen | ||||
|         topBar = { TopAppBar( | ||||
|             title = { Text(text = title) }, | ||||
|             navigationIcon = { | ||||
|                 IconButton(onClick = { /* TODO open sidemenu */ }) { | ||||
|                     Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu") | ||||
|                 } | ||||
|             } | ||||
|         ) }, | ||||
| 
 | ||||
|         // Everything at the bottom of the screen | ||||
|         bottomBar = { NavigationBar() }, // TODO Pass arguments so that the current tab etc can be shown | ||||
|         floatingActionButtonPosition = FabPosition.Center, | ||||
|         isFloatingActionButtonDocked = true, | ||||
|         floatingActionButton = { CollapsedAddButton() } | ||||
|     ) { paddingValues -> | ||||
|         content(paddingValues) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Composable | ||||
| // Does not contain floatingActionButton and bottom bar, used in all the other screens | ||||
| fun SecondaryScreenToolbar( | ||||
|     title: String, | ||||
|     content: @Composable (PaddingValues) -> Unit | ||||
| ) { | ||||
|     Scaffold( | ||||
|         // Everything at the top of the screen | ||||
|         topBar = { TopAppBar( | ||||
|             title = { Text(text = title) }, | ||||
|             navigationIcon = { | ||||
|                 IconButton(onClick = { /* TODO open sidemenu */ }) { | ||||
|                     Icon(imageVector = Icons.Default.Menu, contentDescription = "Menu") | ||||
|                 } | ||||
|             } | ||||
|         ) }, | ||||
|     ) { paddingValues -> | ||||
|         content(paddingValues) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun PrimaryScreenToolbarPreview() { | ||||
|     StudeezTheme { PrimaryScreenToolbar( | ||||
|         "Preview screen", | ||||
|         {} | ||||
|     ) } | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun SecondaryScreenToolbarPreview() { | ||||
|     StudeezTheme { SecondaryScreenToolbar( | ||||
|         "Preview screen", | ||||
|         {} | ||||
|     )} | ||||
| } | ||||
|  | @ -18,8 +18,6 @@ package be.ugent.sel.studeez.domain.implementation | |||
| 
 | ||||
| import be.ugent.sel.studeez.data.local.models.User | ||||
| import be.ugent.sel.studeez.domain.AccountDAO | ||||
| import be.ugent.sel.studeez.domain.trace | ||||
| import com.google.firebase.auth.EmailAuthProvider | ||||
| import com.google.firebase.auth.FirebaseAuth | ||||
| import kotlinx.coroutines.channels.awaitClose | ||||
| import kotlinx.coroutines.flow.Flow | ||||
|  |  | |||
|  | @ -5,8 +5,7 @@ import androidx.compose.ui.Modifier | |||
| import androidx.hilt.navigation.compose.hiltViewModel | ||||
| import be.ugent.sel.studeez.R | ||||
| import be.ugent.sel.studeez.common.composable.BasicButton | ||||
| import be.ugent.sel.studeez.common.composable.PrimaryScreenToolbar | ||||
| import be.ugent.sel.studeez.common.composable.SecondaryScreenToolbar | ||||
| import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate | ||||
| import be.ugent.sel.studeez.common.ext.basicButton | ||||
| import be.ugent.sel.studeez.resources | ||||
| 
 | ||||
|  | @ -15,9 +14,10 @@ fun HomeScreen( | |||
|     openAndPopUp: (String, String) -> Unit, | ||||
|     viewModel: HomeViewModel = hiltViewModel() | ||||
| ) { | ||||
| 
 | ||||
|     PrimaryScreenToolbar(title = resources().getString(R.string.home)) { | ||||
|         // "Start session" button | ||||
|     PrimaryScreenTemplate( | ||||
|         title = resources().getString(R.string.home), | ||||
|         onLogoutClick = { viewModel.onLogoutClick(openAndPopUp) } | ||||
|     ) { | ||||
|         BasicButton(R.string.start_session, Modifier.basicButton()) { | ||||
|             viewModel.onStartSessionClick(openAndPopUp) | ||||
|         } | ||||
|  |  | |||
|  | @ -1,14 +1,31 @@ | |||
| package be.ugent.sel.studeez.screens.home | ||||
| 
 | ||||
| import androidx.compose.material.ScaffoldState | ||||
| import androidx.compose.material.rememberScaffoldState | ||||
| import be.ugent.sel.studeez.data.local.models.User | ||||
| import be.ugent.sel.studeez.domain.AccountDAO | ||||
| import be.ugent.sel.studeez.domain.LogService | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.LOGIN_SCREEN | ||||
| import be.ugent.sel.studeez.screens.StudeezViewModel | ||||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||||
| import kotlinx.coroutines.flow.Flow | ||||
| import javax.inject.Inject | ||||
| 
 | ||||
| @HiltViewModel | ||||
| class HomeViewModel @Inject constructor(logService: LogService) : StudeezViewModel(logService) { | ||||
| class HomeViewModel @Inject constructor( | ||||
|     private val accountDAO: AccountDAO, | ||||
|     logService: LogService | ||||
| ) : StudeezViewModel(logService) { | ||||
| 
 | ||||
|     fun onStartSessionClick(openAndPopUp: (String, String) -> Unit) { | ||||
|         // openAndPopUp(StudeezDestinations.xxx, StudeezDestinations.HOME_SCREEN) | ||||
|         // TODO openAndPopUp(StudeezDestinations.xxx, StudeezDestinations.HOME_SCREEN) | ||||
|     } | ||||
| 
 | ||||
|     fun onLogoutClick(openAndPopup: (String, String) -> Unit) { | ||||
|         launchCatching { | ||||
|             accountDAO.signOut() | ||||
|             openAndPopup(LOGIN_SCREEN, HOME_SCREEN) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -1,4 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.sign_in | ||||
| package be.ugent.sel.studeez.screens.log_in | ||||
| 
 | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.layout.Column | ||||
|  | @ -26,7 +26,8 @@ fun LoginScreen( | |||
| ) { | ||||
|     val uiState by viewModel.uiState | ||||
| 
 | ||||
|     SecondaryScreenToolbar(title = resources().getString(AppText.sign_in)) { | ||||
|     // TODO Make this a separate kind of screen? | ||||
|     SecondaryScreenTemplate(title = resources().getString(AppText.sign_in), {}) { | ||||
|         Column( | ||||
|             modifier = modifier | ||||
|                 .fillMaxWidth() | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| package be.ugent.sel.studeez.screens.sign_in | ||||
| package be.ugent.sel.studeez.screens.log_in | ||||
| 
 | ||||
| data class LoginUiState( | ||||
|     val email: String = "", | ||||
|  |  | |||
|  | @ -1,11 +1,10 @@ | |||
| package be.ugent.sel.studeez.screens.sign_in | ||||
| package be.ugent.sel.studeez.screens.log_in | ||||
| 
 | ||||
| import androidx.compose.runtime.mutableStateOf | ||||
| import be.ugent.sel.studeez.common.ext.isValidEmail | ||||
| import be.ugent.sel.studeez.common.snackbar.SnackbarManager | ||||
| import be.ugent.sel.studeez.domain.AccountDAO | ||||
| import be.ugent.sel.studeez.domain.LogService | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.HOME_SCREEN | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.LOGIN_SCREEN | ||||
| import be.ugent.sel.studeez.navigation.StudeezDestinations.SIGN_UP_SCREEN | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ fun SignUpScreen( | |||
|     val uiState by viewModel.uiState | ||||
|     val fieldModifier = Modifier.fieldModifier() | ||||
| 
 | ||||
|     SecondaryScreenToolbar(title = resources().getString(AppText.create_account)) { | ||||
|     SecondaryScreenTemplate(title = resources().getString(AppText.create_account), {}) { | ||||
|         Column( | ||||
|             modifier = modifier | ||||
|                 .fillMaxWidth() | ||||
|  |  | |||
							
								
								
									
										5
									
								
								app/src/main/res/drawable/ic_logout.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/src/main/res/drawable/ic_logout.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | |||
| <vector android:autoMirrored="true" android:height="24dp" | ||||
|     android:tint="#000000" android:viewportHeight="24" | ||||
|     android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <path android:fillColor="@android:color/white" android:pathData="M17,7l-1.41,1.41L18.17,11H8v2h10.17l-2.58,2.58L17,17l5,-5zM4,5h8V3H4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h8v-2H4V5z"/> | ||||
| </vector> | ||||
							
								
								
									
										5
									
								
								app/src/main/res/drawable/ic_timer.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/src/main/res/drawable/ic_timer.xml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | |||
| <vector android:height="24dp" android:tint="#000000" | ||||
|     android:viewportHeight="24" android:viewportWidth="24" | ||||
|     android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||||
|     <path android:fillColor="@android:color/white" android:pathData="M15,1H9v2h6V1zM11,14h2V8h-2V14zM19.03,7.39l1.42,-1.42c-0.43,-0.51 -0.9,-0.99 -1.41,-1.41l-1.42,1.42C16.07,4.74 14.12,4 12,4c-4.97,0 -9,4.03 -9,9s4.02,9 9,9s9,-4.03 9,-9C21,10.88 20.26,8.93 19.03,7.39zM12,20c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7s7,3.13 7,7S15.87,20 12,20z"/> | ||||
| </vector> | ||||
|  | @ -8,6 +8,8 @@ | |||
|     <string name="email_error">Please insert a valid email.</string> | ||||
|     <string name="cancel">Cancel</string> | ||||
|     <string name="try_again">Try again</string> | ||||
|     <string name="go_back">Go back</string> | ||||
|     <string name="menu">Menu</string> | ||||
| 
 | ||||
|     <!-- SignUpScreen --> | ||||
|     <string name="create_account">Create account</string> | ||||
|  | @ -27,4 +29,18 @@ | |||
|     <string name="home">Home</string> | ||||
|     <string name="start_session">Start session</string> | ||||
| 
 | ||||
|     <!-- Drawer / SideMenu --> | ||||
|     <string name="log_out">Log out</string> | ||||
|     <string name="profile_picture_description">Profile Picture</string> | ||||
|     <string name="user_description">Normal user</string> | ||||
| 
 | ||||
|     <!-- Timers --> | ||||
|     <string name="timers">Timers</string> | ||||
| 
 | ||||
|     <!-- Settings --> | ||||
|     <string name="settings">Settings</string> | ||||
| 
 | ||||
|     <!-- About --> | ||||
|     <string name="about">About Studeez</string> | ||||
| 
 | ||||
| </resources> | ||||
|  |  | |||
		Reference in a new issue
	
	 GitHub Enterprise
							GitHub Enterprise