revert: WillPopScope migration

This reverts commit ef9b1d5c2d72c6787246c4b6d11929044a13b54d.

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( return showDialog(
barrierDismissible: false, barrierDismissible: false,
context: context, context: context,
builder: (context) => PopScope( builder: (context) => WillPopScope(
canPop: false, onWillPop: () async => false,
child: AlertDialog( child: AlertDialog(
title: Text(t.warning), title: Text(t.warning),
content: ValueListenableBuilder( content: ValueListenableBuilder(

View File

@ -16,9 +16,12 @@ class InstallerView extends StatelessWidget {
return ViewModelBuilder<InstallerViewModel>.reactive( return ViewModelBuilder<InstallerViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context), onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => InstallerViewModel(), viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => PopScope( builder: (context, model, child) => WillPopScope(
onPopInvoked: (bool didPop) => model.onWillPop(context), /*
canPop: false, 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( child: SafeArea(
top: false, top: false,
bottom: model.isPatching, 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( return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context), onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(), viewModelBuilder: () => locator<NavigationViewModel>(),
builder: (context, model, child) => PopScope( builder: (context, model, child) => WillPopScope(
canPop: model.currentIndex == 0, onWillPop: () async {
onPopInvoked: (bool didPop) => { if (model.currentIndex == 0) {
if (!didPop) model.setIndex(0), return true;
} else {
model.setIndex(0);
return false;
}
}, },
child: Scaffold( child: Scaffold(
body: PageTransitionSwitcher( body: PageTransitionSwitcher(