refactor: Replace deprecated WillPopScope (#1604)

This commit is contained in:
Benjamin 2024-01-13 19:34:04 -08:00 committed by GitHub
parent fd2780624a
commit ef9b1d5c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 12 deletions

View File

@ -595,8 +595,8 @@ class ManagerAPI {
return showDialog(
barrierDismissible: false,
context: context,
builder: (context) => WillPopScope(
onWillPop: () async => false,
builder: (context) => PopScope(
canPop: false,
child: AlertDialog(
title: I18nText('warning'),
content: ValueListenableBuilder(

View File

@ -15,7 +15,7 @@ class InstallerView extends StatelessWidget {
return ViewModelBuilder<InstallerViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => WillPopScope(
builder: (context, model, child) => PopScope(
child: SafeArea(
top: false,
bottom: model.isPatching,
@ -111,7 +111,7 @@ class InstallerView extends StatelessWidget {
),
),
),
onWillPop: () => model.onWillPop(context),
onPopInvoked: (bool didPop) => model.onWillPop(context),
),
);
}

View File

@ -13,14 +13,10 @@ class NavigationView extends StatelessWidget {
return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(),
builder: (context, model, child) => WillPopScope(
onWillPop: () async {
if (model.currentIndex == 0) {
return true;
} else {
model.setIndex(0);
return false;
}
builder: (context, model, child) => PopScope(
canPop: model.currentIndex == 0,
onPopInvoked: (bool didPop) => {
if (!didPop) model.setIndex(0),
},
child: Scaffold(
body: PageTransitionSwitcher(