Skip to content

Commit

Permalink
revert: WillPopScope migration
Browse files Browse the repository at this point in the history
This reverts commit ef9b1d5.

Why is this so hard to implement??? Are we missing something??
  • Loading branch information
validcube authored Feb 15, 2024
1 parent 31a32eb commit 3b0fed5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ class ManagerAPI {
return showDialog(
barrierDismissible: false,
context: context,
builder: (context) => PopScope(
canPop: false,
builder: (context) => WillPopScope(
onWillPop: () async => false,
child: AlertDialog(
title: Text(t.warning),
content: ValueListenableBuilder(
Expand Down
10 changes: 7 additions & 3 deletions lib/ui/views/installer/installer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ class InstallerView extends StatelessWidget {
return ViewModelBuilder<InstallerViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => PopScope(
onPopInvoked: (bool didPop) => model.onWillPop(context),
canPop: false,
builder: (context, model, child) => WillPopScope(
/*
TODO(any): migrate to [PopScope],
we've tried to migrate it two times but
reverted it because we couldn't exit out of the screen.
*/
child: SafeArea(
top: false,
bottom: model.isPatching,
Expand Down Expand Up @@ -108,6 +111,7 @@ class InstallerView extends StatelessWidget {
),
),
),
onWillPop: () => model.onWillPop(context),
),
);
}
Expand Down
12 changes: 8 additions & 4 deletions lib/ui/views/navigation/navigation_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ class NavigationView extends StatelessWidget {
return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(),
builder: (context, model, child) => PopScope(
canPop: model.currentIndex == 0,
onPopInvoked: (bool didPop) => {
if (!didPop) model.setIndex(0),
builder: (context, model, child) => WillPopScope(
onWillPop: () async {
if (model.currentIndex == 0) {
return true;
} else {
model.setIndex(0);
return false;
}
},
child: Scaffold(
body: PageTransitionSwitcher(
Expand Down

0 comments on commit 3b0fed5

Please sign in to comment.