revert: WillPopScope migration

This reverts commit ef9b1d5c2d.

Why is this so hard to implement??? Are we missing something??
This commit is contained in:
Pun Butrach 2024-02-15 08:00:52 +00:00 committed by GitHub
parent 31a32eb11d
commit 3b0fed55e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 9 deletions

View file

@ -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(

View file

@ -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,
@ -108,6 +111,7 @@ class InstallerView extends StatelessWidget {
),
),
),
onWillPop: () => model.onWillPop(context),
),
);
}

View file

@ -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(