Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
- Fixed the Drawer >:D
- cleaned up code just a bit
- Broke the Mobile UI...
--- Mobile UI is now not usable (especially in Portrait orientation)
--- Foldable layout is has also some issues in different orientations (seems like it's time to remove ModalDrawer fully)
  • Loading branch information
arutemu committed Apr 2, 2024
1 parent df55141 commit 4a90ebc
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 137 deletions.
249 changes: 114 additions & 135 deletions app/src/main/java/com/mukuro/pedalboard/ui/PedalboardApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,16 @@ private fun PedalboardNavigationWrapper(
navigateToDetail: (Long, PedalboardContentType) -> Unit,
toggleSelectedPlugin: (Long) -> Unit
) {
val drawerState = rememberDrawerState(initialValue = DrawerValue.Open)
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
val scope = rememberCoroutineScope()
//val isNavigationRailVisible = remember { mutableStateOf(true) }
//val onDrawerClicked = rememberDrawerState(initialValue = DrawerValue.Closed)

val navController = rememberNavController()
val navigationActions = remember(navController) {
PedalboardNavigationActions(navController)
}
val navBackStackEntry by navController.currentBackStackEntryAsState()
val selectedDestination =
navBackStackEntry?.destination?.route ?: PedalboardRoute.QUICK
val selectedDestination = navBackStackEntry?.destination?.route ?: PedalboardRoute.QUICK


// TODO - move NavRail here
Expand All @@ -205,157 +203,138 @@ private fun PedalboardNavigationWrapper(
)*/


Column(modifier = Modifier){
PedalboardTopBar(onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
Column(modifier = Modifier){
PedalboardTopBar(onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
else {
scope.launch {
drawerState.open()
}
}
else {
scope.launch {
drawerState.open()
}
})

Box(modifier = Modifier) {

Row(modifier = Modifier){
Column(modifier = Modifier.width(80.dp)){ }
if (navigationType == PedalboardNavigationType.DISMISSIBLE_NAVIGATION_DRAWER) {

// TODO check on custom width of PermanentNavigationDrawer: b/232495216
DismissibleNavigationDrawer(drawerState = drawerState, drawerContent = {

// TODO - move NavRail here?

/* PedalboardNavigationRail(
selectedDestination = selectedDestination,
navigationContentPosition = navigationContentPosition,
navigateToTopLevelDestination = navigationActions::navigateTo,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
}
else {
scope.launch {
drawerState.open()
}
}
}
)*/

DismissibleNavigationDrawerContent(
selectedDestination = selectedDestination,
navigationContentPosition = navigationContentPosition,
navigateToTopLevelDestination = navigationActions::navigateTo,
drawerState = drawerState
)
}
) {
PedalboardAppContent(
navigationType = navigationType,
contentType = contentType,
displayFeatures = displayFeatures,
navigationContentPosition = navigationContentPosition,
pedalboardHomeUIState = pedalboardHomeUIState,
navController = navController,
selectedDestination = selectedDestination,
navigateToTopLevelDestination = navigationActions::navigateTo,
closeDetailScreen = closeDetailScreen,
navigateToDetail = navigateToDetail,
toggleSelectedPlugin = toggleSelectedPlugin,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
}
else {
scope.launch {
drawerState.open()
}
}
},
isNavigationRailVisible = true,//!(drawerState.isOpen || (drawerState.isClosed && drawerState.isAnimationRunning)),//(drawerState.isClosed) || (drawerState.isClosed && drawerState.isAnimationRunning),//drawerState.isAnimationRunning || drawerState.isClosed,
drawerState = drawerState
)
}
})

}
} else {
ModalNavigationDrawer(
//gesturesEnabled = false,
drawerContent = {
ModalNavigationDrawerContent(
selectedDestination = selectedDestination,
navigationContentPosition = navigationContentPosition,
navigateToTopLevelDestination = navigationActions::navigateTo,
onDrawerClicked = {
scope.launch {
drawerState.close()
}
Box(modifier = Modifier) {

Row(modifier = Modifier){
Column(modifier = Modifier.width(80.dp)){ }
if (navigationType == PedalboardNavigationType.DISMISSIBLE_NAVIGATION_DRAWER) { // TODO probably modify the condition and layout for mobile screens (should cover Column above too)

// TODO check on custom width of PermanentNavigationDrawer: b/232495216
DismissibleNavigationDrawer(drawerState = drawerState, drawerContent = {
DismissibleNavigationDrawerContent(
selectedDestination = selectedDestination,
navigationContentPosition = navigationContentPosition,
navigateToTopLevelDestination = navigationActions::navigateTo,
drawerState = drawerState
)
}
) {
PedalboardAppContent(
navigationType = navigationType,
contentType = contentType,
displayFeatures = displayFeatures,
navigationContentPosition = navigationContentPosition,
pedalboardHomeUIState = pedalboardHomeUIState,
navController = navController,
selectedDestination = selectedDestination,
navigateToTopLevelDestination = navigationActions::navigateTo,
closeDetailScreen = closeDetailScreen,
navigateToDetail = navigateToDetail,
toggleSelectedPlugin = toggleSelectedPlugin,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
}
else {
scope.launch {
drawerState.open()
}
)
}
},
isNavigationRailVisible = true, // TODO - probably should remove this property at all
drawerState = drawerState
) {
PedalboardAppContent(
navigationType = navigationType,
contentType = contentType,
displayFeatures = displayFeatures,
navigationContentPosition = navigationContentPosition,
pedalboardHomeUIState = pedalboardHomeUIState,
navController = navController,
)

}
} else {
ModalNavigationDrawer(
//gesturesEnabled = false,
drawerContent = {
ModalNavigationDrawerContent(
selectedDestination = selectedDestination,
navigationContentPosition = navigationContentPosition,
navigateToTopLevelDestination = navigationActions::navigateTo,
closeDetailScreen = closeDetailScreen,
navigateToDetail = navigateToDetail,
toggleSelectedPlugin = toggleSelectedPlugin,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
scope.launch {
drawerState.close()
}
else {
scope.launch {
drawerState.open()
}
}
},
isNavigationRailVisible = false,
drawerState = drawerState
}
)
}
},
drawerState = drawerState
) {
PedalboardAppContent(
navigationType = navigationType,
contentType = contentType,
displayFeatures = displayFeatures,
navigationContentPosition = navigationContentPosition,
pedalboardHomeUIState = pedalboardHomeUIState,
navController = navController,
selectedDestination = selectedDestination,
navigateToTopLevelDestination = navigationActions::navigateTo,
closeDetailScreen = closeDetailScreen,
navigateToDetail = navigateToDetail,
toggleSelectedPlugin = toggleSelectedPlugin,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
}
else {
scope.launch {
drawerState.open()
}
}
},
isNavigationRailVisible = false,
drawerState = drawerState
)
}
}
}

PedalboardNavigationRail(
selectedDestination = selectedDestination,
navigationContentPosition = PedalboardNavigationContentPosition.CENTER ,
navigateToTopLevelDestination = navigationActions::navigateTo,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}



PedalboardNavigationRail(
selectedDestination = selectedDestination,
navigationContentPosition = PedalboardNavigationContentPosition.CENTER ,
navigateToTopLevelDestination = navigationActions::navigateTo,
onDrawerClicked = {
if (drawerState.isOpen) {
scope.launch {
drawerState.close()
}
else {
scope.launch {
drawerState.open()
}
}
else {
scope.launch {
drawerState.open()
}
},
drawerState = drawerState
)
}
}
)



}
}
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ fun PedalboardNavigationRail(
selectedDestination: String,
navigationContentPosition: PedalboardNavigationContentPosition,
navigateToTopLevelDestination: (PedalboardTopLevelDestination) -> Unit,
onDrawerClicked: () -> Unit = {},
drawerState: DrawerState
onDrawerClicked: () -> Unit = {}
) {
NavigationRail(
modifier = Modifier.fillMaxHeight(),
Expand Down

0 comments on commit 4a90ebc

Please sign in to comment.