now takes viewmodel and open function. Also uses viewmodel functions
This commit is contained in:
		
							parent
							
								
									71a42a28e2
								
							
						
					
					
						commit
						f5940e4743
					
				
					 1 changed files with 15 additions and 11 deletions
				
			
		|  | @ -1,4 +1,4 @@ | ||||||
| package be.ugent.sel.studeez.common.composable | package be.ugent.sel.studeez.screens.navbar | ||||||
| 
 | 
 | ||||||
| import androidx.compose.material.BottomNavigation | import androidx.compose.material.BottomNavigation | ||||||
| import androidx.compose.material.BottomNavigationItem | import androidx.compose.material.BottomNavigationItem | ||||||
|  | @ -12,10 +12,14 @@ import androidx.compose.material.icons.outlined.DateRange | ||||||
| import androidx.compose.runtime.Composable | import androidx.compose.runtime.Composable | ||||||
| import androidx.compose.ui.tooling.preview.Preview | import androidx.compose.ui.tooling.preview.Preview | ||||||
| import androidx.compose.ui.unit.dp | import androidx.compose.ui.unit.dp | ||||||
|  | import androidx.hilt.navigation.compose.hiltViewModel | ||||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||||
| 
 | 
 | ||||||
| @Composable | @Composable | ||||||
| fun NavigationBar() { | fun NavigationBar( | ||||||
|  |     popUpAndOpen: (String, String) -> Unit, | ||||||
|  |     viewModel: NavigationBarViewModel = hiltViewModel() | ||||||
|  | ) { | ||||||
|     // TODO Pass functions and new screens. |     // TODO Pass functions and new screens. | ||||||
|     // TODO Pass which screen is selected. |     // TODO Pass which screen is selected. | ||||||
|     // TODO Disabled -> HIGH/MEDIUM_EMPHASIS if the page is implemented |     // TODO Disabled -> HIGH/MEDIUM_EMPHASIS if the page is implemented | ||||||
|  | @ -26,14 +30,14 @@ fun NavigationBar() { | ||||||
|             icon = { Icon(imageVector = Icons.Default.List, "Home") }, |             icon = { Icon(imageVector = Icons.Default.List, "Home") }, | ||||||
|             label = { Text(text = "Home") }, |             label = { Text(text = "Home") }, | ||||||
|             selected = false, // TODO |             selected = false, // TODO | ||||||
|             onClick = { /* TODO */ } |             onClick = { viewModel.onHomeClick(popUpAndOpen) } | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         BottomNavigationItem( |         BottomNavigationItem( | ||||||
|             icon = { Icon(imageVector = Icons.Default.Check, "Tasks") }, |             icon = { Icon(imageVector = Icons.Default.Check, "Tasks") }, | ||||||
|             label = { Text(text = "Tasks") }, |             label = { Text(text = "Tasks") }, | ||||||
|             selected = false, // TODO |             selected = false, // TODO | ||||||
|             onClick = { /* TODO */ } |             onClick = { viewModel.onTasksClick(popUpAndOpen) } | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         // Hack to space the entries in the navigation bar, make space for fab |         // Hack to space the entries in the navigation bar, make space for fab | ||||||
|  | @ -43,21 +47,21 @@ fun NavigationBar() { | ||||||
|             icon = { Icon(imageVector = Icons.Outlined.DateRange, "Sessions") }, |             icon = { Icon(imageVector = Icons.Outlined.DateRange, "Sessions") }, | ||||||
|             label = { Text(text = "Sessions") }, |             label = { Text(text = "Sessions") }, | ||||||
|             selected = false, // TODO |             selected = false, // TODO | ||||||
|             onClick = { /* TODO */ } |             onClick = { viewModel.onSessionsClick(popUpAndOpen) } | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         BottomNavigationItem( |         BottomNavigationItem( | ||||||
|             icon = { Icon(imageVector = Icons.Default.Person, "Profile") }, |             icon = { Icon(imageVector = Icons.Default.Person, "Profile") }, | ||||||
|             label = { Text(text = "Profile") }, |             label = { Text(text = "Profile") }, | ||||||
|             selected = false, // TODO |             selected = false, // TODO | ||||||
|             onClick = { /* TODO */ } |             onClick = { viewModel.onProfileClick(popUpAndOpen) } | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @Preview(showBackground = true) | //@Preview(showBackground = true) | ||||||
| @Composable | //@Composable | ||||||
| fun NavigationBarPreview() { | //fun NavigationBarPreview() { | ||||||
|     StudeezTheme { NavigationBar() } | //    StudeezTheme { NavigationBar() } | ||||||
| } | //} | ||||||
		Reference in a new issue
	
	 lbarraga
						lbarraga