Skip to content

Commit

Permalink
Fix some back button issues (thunder-app#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Dec 15, 2023
1 parent 2603ba7 commit f42b1c5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/feed/view/feed_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,10 @@ class _FeedViewState extends State<FeedView> {
}

FutureOr<bool> _handleBack(bool stopDefaultButtonEvent, RouteInfo info) async {
final bool topOfNavigationStack = ModalRoute.of(context)?.isCurrent ?? false;

// If the sidebar is open, close it
if (showCommunitySidebar) {
if (topOfNavigationStack && showCommunitySidebar) {
setState(() => showCommunitySidebar = false);
return true;
}
Expand Down
23 changes: 15 additions & 8 deletions lib/user/pages/user_page_success.dart
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,21 @@ class _UserPageSuccessState extends State<UserPageSuccess> with TickerProviderSt
FutureOr<bool> _handleBack(bool stopDefaultButtonEvent, RouteInfo info) async {
final bool topOfNavigationStack = ModalRoute.of(context)?.isCurrent ?? false;

if (topOfNavigationStack && savedToggle!.value) {
setState(() {
selectedUserOption = 0;
_selectedUserOption![0] = true;
_selectedUserOption![1] = false;
savedToggle!.value = false;
});
return true;
if (topOfNavigationStack) {
if (_displaySidebar) {
setState(() {
_displaySidebar = false;
});
return true;
} else if (savedToggle!.value) {
setState(() {
selectedUserOption = 0;
_selectedUserOption![0] = true;
_selectedUserOption![1] = false;
savedToggle!.value = false;
});
return true;
}
}

return false;
Expand Down

0 comments on commit f42b1c5

Please sign in to comment.