#67 fab unfixed pos
This commit is contained in:
		
							parent
							
								
									f74da5abc3
								
							
						
					
					
						commit
						e65c2fe002
					
				
					 4 changed files with 58 additions and 26 deletions
				
			
		|  | @ -2,7 +2,10 @@ package be.ugent.sel.studeez.common.composable | |||
| 
 | ||||
| import androidx.compose.animation.core.animateFloat | ||||
| import androidx.compose.animation.core.updateTransition | ||||
| import androidx.compose.foundation.layout.* | ||||
| import androidx.compose.foundation.layout.Arrangement | ||||
| import androidx.compose.foundation.layout.Column | ||||
| import androidx.compose.foundation.layout.Row | ||||
| import androidx.compose.foundation.layout.padding | ||||
| import androidx.compose.material.FloatingActionButton | ||||
| import androidx.compose.material.Icon | ||||
| import androidx.compose.material.IconButton | ||||
|  | @ -16,9 +19,12 @@ import androidx.compose.runtime.* | |||
| import androidx.compose.ui.Alignment | ||||
| import androidx.compose.ui.Modifier | ||||
| import androidx.compose.ui.draw.rotate | ||||
| import androidx.compose.ui.graphics.vector.ImageVector | ||||
| import androidx.compose.ui.tooling.preview.Preview | ||||
| import androidx.compose.ui.unit.dp | ||||
| import be.ugent.sel.studeez.resources | ||||
| import be.ugent.sel.studeez.ui.theme.StudeezTheme | ||||
| import be.ugent.sel.studeez.R.string as AppText | ||||
| 
 | ||||
| const val TRANSITION = "transition" | ||||
| val HEIGHT_DIFFERENCE = 30.dp | ||||
|  | @ -56,7 +62,9 @@ fun AddButton( | |||
|     ) { | ||||
|         // Show minis when expanded. | ||||
|         if (multiFloatingState == MultiFloatingState.Expanded) { | ||||
|             ExpandedAddButton(addButtonActions = addButtonActions) | ||||
|             ExpandedAddButton( | ||||
|                 addButtonActions = addButtonActions | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|         // The base add button | ||||
|  | @ -83,35 +91,57 @@ fun ExpandedAddButton( | |||
|     addButtonActions: AddButtonActions | ||||
| ) { | ||||
|     Row { | ||||
|         IconButton( | ||||
|         ExpandedEntry( | ||||
|             name = AppText.task, | ||||
|             imageVector = Icons.Default.Check, | ||||
|             onClick = addButtonActions.onTaskClick, | ||||
|             modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) | ||||
|         ) { | ||||
|             Column (horizontalAlignment = Alignment.CenterHorizontally) { | ||||
|                 Icon(imageVector = Icons.Default.Check, contentDescription = "Task") | ||||
|                 Text(text = "Task") | ||||
|             } | ||||
|         } | ||||
|         ) | ||||
| 
 | ||||
|         IconButton(onClick = addButtonActions.onFriendClick) { | ||||
|             Column (horizontalAlignment = Alignment.CenterHorizontally) { | ||||
|                 Icon(imageVector = Icons.Default.Person, contentDescription = "Friend") | ||||
|                 Text(text = "Friend") | ||||
|             } | ||||
|         } | ||||
|         ExpandedEntry( | ||||
|             name = AppText.friend, | ||||
|             imageVector = Icons.Default.Person, | ||||
|             onClick = addButtonActions.onFriendClick | ||||
|         ) | ||||
| 
 | ||||
|         IconButton( | ||||
|         ExpandedEntry( | ||||
|             name = AppText.session, | ||||
|             imageVector = Icons.Default.DateRange, | ||||
|             onClick = addButtonActions.onSessionClick, | ||||
|             modifier = Modifier.padding(36.dp, HEIGHT_DIFFERENCE, 36.dp, 0.dp) | ||||
|         ) { | ||||
|             Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||||
|                 Icon(imageVector = Icons.Default.DateRange, contentDescription = "Session") | ||||
|                 Text(text = "Session") | ||||
|             } | ||||
|         } | ||||
|         ) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @Composable | ||||
| fun ExpandedEntry( | ||||
|     name: Int, | ||||
|     imageVector: ImageVector, | ||||
|     onClick: () -> Unit, | ||||
|     modifier: Modifier = Modifier | ||||
| ) { | ||||
|     IconButton( | ||||
|         onClick = onClick, | ||||
|         modifier = modifier | ||||
|     ) { | ||||
|         Column(horizontalAlignment = Alignment.CenterHorizontally) { | ||||
|             Icon( | ||||
|                 imageVector = imageVector, | ||||
|                 contentDescription = resources().getString(name), | ||||
|                 // TODO Dark overlay | ||||
|                 //  tint = colors.surface | ||||
|             ) | ||||
|             Text( | ||||
|                 text = resources().getString(name), | ||||
|                 // TODO Dark overlay | ||||
|                 //  color = colors.surface | ||||
|             ) | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| @Preview | ||||
| @Composable | ||||
| fun AddButtonPreview() { | ||||
|  | @ -123,7 +153,7 @@ fun AddButtonPreview() { | |||
| @Preview | ||||
| @Composable | ||||
| fun ExpandedAddButtonPreview() { | ||||
|     StudeezTheme { ExpandedAddButton( | ||||
|     StudeezTheme { ExpandedAddButton ( | ||||
|         addButtonActions = AddButtonActions({}, {}, {}) | ||||
|     ) } | ||||
| } | ||||
|  | @ -56,7 +56,7 @@ fun PrimaryScreenTemplate( | |||
| 
 | ||||
|         bottomBar = { NavigationBar(navigationBarActions) }, | ||||
|         floatingActionButtonPosition = FabPosition.Center, | ||||
|         isFloatingActionButtonDocked = false, | ||||
|         isFloatingActionButtonDocked = true, | ||||
|         floatingActionButton = { AddButton(AddButtonActions( | ||||
|             onTaskClick = navigationBarActions.onAddTaskClick, | ||||
|             onFriendClick = navigationBarActions.onAddFriendClick, | ||||
|  |  | |||
|  | @ -95,7 +95,7 @@ fun NavigationBar( | |||
|         ) | ||||
| 
 | ||||
|         // Hack to space the entries in the navigation bar, make space for fab | ||||
|         BottomNavigationItem(icon = {}, onClick = {}, selected = false) | ||||
|         BottomNavigationItem(icon = {}, onClick = {}, selected = false, enabled = false) | ||||
| 
 | ||||
|         BottomNavigationItem( | ||||
|             icon = { | ||||
|  |  | |||
|  | @ -12,7 +12,9 @@ import androidx.compose.ui.graphics.Color | |||
| private val DarkColorPalette = darkColors( | ||||
|     primary = Blue100, | ||||
|     primaryVariant = Blue120, | ||||
|     secondary = Yellow100 | ||||
|     secondary = Yellow100, | ||||
| 
 | ||||
|     onPrimary = Color.White | ||||
| ) | ||||
| 
 | ||||
| private val LightColorPalette = lightColors( | ||||
|  |  | |||
		Reference in a new issue