refactor: PopScope Migration (#1674)

Co-authored-by: Benjamin Halko <benjaminhalko@hotmail.com>
This commit is contained in:
Pun Butrach
2024-02-18 08:32:32 +07:00
committed by GitHub
parent f5ba84d81e
commit 3b58d229da
4 changed files with 28 additions and 30 deletions

View File

@ -13,13 +13,11 @@ 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 {
builder: (context, model, child) => PopScope(
canPop: model.currentIndex == 0,
onPopInvoked: (bool didPop) {
if (!didPop) {
model.setIndex(0);
return false;
}
},
child: Scaffold(