Codestyle #94
This commit is contained in:
		
							parent
							
								
									aea49295a0
								
							
						
					
					
						commit
						3ff2ed225b
					
				
					 2 changed files with 7 additions and 23 deletions
				
			
		|  | @ -26,10 +26,6 @@ import be.ugent.sel.studeez.R.string as AppText | ||||||
| 
 | 
 | ||||||
| const val TRANSITION = "transition" | const val TRANSITION = "transition" | ||||||
| val HEIGHT_DIFFERENCE = 30.dp | val HEIGHT_DIFFERENCE = 30.dp | ||||||
| enum class MultiFloatingState { |  | ||||||
|     Expanded, |  | ||||||
|     Collapsed |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| data class AddButtonActions( | data class AddButtonActions( | ||||||
|     val onTaskClick: () -> Unit, |     val onTaskClick: () -> Unit, | ||||||
|  | @ -41,18 +37,11 @@ data class AddButtonActions( | ||||||
| fun AddButton( | fun AddButton( | ||||||
|     addButtonActions: AddButtonActions |     addButtonActions: AddButtonActions | ||||||
| ) { | ) { | ||||||
|     var multiFloatingState by remember { |     var isExpanded by remember { mutableStateOf(false) } | ||||||
|         mutableStateOf(MultiFloatingState.Collapsed) |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Rotate the button when expanded, normal when collapsed. |     // Rotate the button when expanded, normal when collapsed. | ||||||
|     val transition = updateTransition(targetState = multiFloatingState, label = TRANSITION) |     val transition = updateTransition(targetState = isExpanded, label = TRANSITION) | ||||||
|     val rotate by transition.animateFloat(label = TRANSITION) { |     val rotate by transition.animateFloat(label = TRANSITION) { expanded -> if (expanded) 315f else 0f } | ||||||
|         when (it) { |  | ||||||
|             MultiFloatingState.Expanded -> 315f |  | ||||||
|             MultiFloatingState.Collapsed -> 0f |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     Column( |     Column( | ||||||
|         horizontalAlignment = Alignment.CenterHorizontally, |         horizontalAlignment = Alignment.CenterHorizontally, | ||||||
|  | @ -60,7 +49,7 @@ fun AddButton( | ||||||
|     ) { |     ) { | ||||||
|         Box { |         Box { | ||||||
|             // Show minis when expanded. |             // Show minis when expanded. | ||||||
|             if (multiFloatingState == MultiFloatingState.Expanded) { |             if (isExpanded) { | ||||||
|                 ExpandedAddButton( |                 ExpandedAddButton( | ||||||
|                     addButtonActions = addButtonActions |                     addButtonActions = addButtonActions | ||||||
|                 ) |                 ) | ||||||
|  | @ -71,12 +60,9 @@ fun AddButton( | ||||||
|         FloatingActionButton( |         FloatingActionButton( | ||||||
|             onClick = { |             onClick = { | ||||||
|                 // Toggle expanded/collapsed. |                 // Toggle expanded/collapsed. | ||||||
|                 multiFloatingState = when (transition.currentState) { |                 isExpanded = !isExpanded | ||||||
|                     MultiFloatingState.Collapsed -> MultiFloatingState.Expanded |  | ||||||
|                     MultiFloatingState.Expanded -> MultiFloatingState.Collapsed |  | ||||||
|                 } |  | ||||||
|             }, |             }, | ||||||
|             modifier = Modifier.padding(bottom = if (multiFloatingState == MultiFloatingState.Expanded) 78.dp else 0.dp) |             modifier = Modifier.padding(bottom = if (isExpanded) 78.dp else 0.dp) | ||||||
|         ) { |         ) { | ||||||
|             Icon( |             Icon( | ||||||
|                 imageVector = Icons.Default.Add, |                 imageVector = Icons.Default.Add, | ||||||
|  |  | ||||||
|  | @ -43,9 +43,7 @@ fun getDrawerActions( | ||||||
|         onTimersClick = { drawerViewModel.onTimersClick(open) }, |         onTimersClick = { drawerViewModel.onTimersClick(open) }, | ||||||
|         onSettingsClick = { drawerViewModel.onSettingsClick(open) }, |         onSettingsClick = { drawerViewModel.onSettingsClick(open) }, | ||||||
|         onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) }, |         onLogoutClick = { drawerViewModel.onLogoutClick(openAndPopUp) }, | ||||||
|         onAboutClick = { context -> |         onAboutClick = { context -> drawerViewModel.onAboutClick(open, context = context) }, | ||||||
|             drawerViewModel.onAboutClick(open, context = context) |  | ||||||
|         }, |  | ||||||
|     ) |     ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue