mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
Fix Folders navigation
Clicking on Folders in AppBar when inside a Folder wouldn't take you back to the Folder Listing.
This commit is contained in:
@ -84,19 +84,38 @@ class AppDrawer extends StatelessWidget {
|
|||||||
title: "Folders",
|
title: "Folders",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
var m = ModalRoute.of(context);
|
var m = ModalRoute.of(context);
|
||||||
// FIXME: This is a terrible hack, I should figure out how to make
|
if (m.settings.name == '/') {
|
||||||
// transitions work with named routes
|
|
||||||
if (m.settings.name == null) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
} else {
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
PageTransition(
|
PageTransition(
|
||||||
type: PageTransitionType.fade,
|
type: PageTransitionType.fade,
|
||||||
child: FolderListingScreen(),
|
child: FolderListingScreen(),
|
||||||
|
settings: const RouteSettings(name: '/folders'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else if (m.settings.name == '/folders') {
|
||||||
|
Navigator.pop(context);
|
||||||
|
} else {
|
||||||
|
// Check if '/folders' is a parent
|
||||||
|
var wasParent = false;
|
||||||
|
Navigator.popUntil(
|
||||||
|
context,
|
||||||
|
(route) {
|
||||||
|
wasParent = route.settings.name == '/folders';
|
||||||
|
return wasParent;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (!wasParent) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
PageTransition(
|
||||||
|
type: PageTransitionType.fade,
|
||||||
|
child: FolderListingScreen(),
|
||||||
|
settings: const RouteSettings(name: '/folders'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selected: currentRoute == null,
|
selected: currentRoute == null,
|
||||||
|
Reference in New Issue
Block a user