[mob][photos] Migrate use of WillPopScope to PopScope (#1473)
## Description [Documentation followed for the migration](https://docs.flutter.dev/release/breaking-changes/android-predictive-back) ## Tests - [x] Tested screens in which migration wasn't straight forward (HomeScreen)
This commit is contained in:
parent
d430616ccb
commit
dac0ddf41c
8 changed files with 40 additions and 35 deletions
|
@ -59,9 +59,9 @@ class _RecoveryPageState extends State<RecoveryPage> {
|
|||
Navigator.of(context).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
child: const PasswordEntryPage(
|
||||
return const PopScope(
|
||||
canPop: false,
|
||||
child: PasswordEntryPage(
|
||||
mode: PasswordEntryMode.reset,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -27,8 +27,8 @@ class LinearProgressDialogState extends State<LinearProgressDialog> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async => false,
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: AlertDialog(
|
||||
title: Text(
|
||||
widget.message,
|
||||
|
|
|
@ -155,8 +155,8 @@ class ProgressDialog {
|
|||
barrierColor: _barrierColor,
|
||||
builder: (BuildContext context) {
|
||||
_dismissingContext = context;
|
||||
return WillPopScope(
|
||||
onWillPop: () async => _barrierDismissible,
|
||||
return PopScope(
|
||||
canPop: _barrierDismissible,
|
||||
child: Dialog(
|
||||
backgroundColor: _backgroundColor,
|
||||
insetAnimationCurve: _insetAnimCurve,
|
||||
|
|
|
@ -52,8 +52,15 @@ class _PaymentWebPageState extends State<PaymentWebPage> {
|
|||
if (initPaymentUrl == null) {
|
||||
return const EnteLoadingWidget();
|
||||
}
|
||||
return WillPopScope(
|
||||
onWillPop: (() async => _buildPageExitWidget(context)),
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) async {
|
||||
if (didPop) return;
|
||||
final shouldPop = await _buildPageExitWidget(context);
|
||||
if (shouldPop) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(S.of(context).subscription),
|
||||
|
|
|
@ -83,8 +83,8 @@ class _AppUpdateDialogState extends State<AppUpdateDialog> {
|
|||
);
|
||||
final shouldForceUpdate =
|
||||
UpdateService.instance.shouldForceUpdate(widget.latestVersionInfo!);
|
||||
return WillPopScope(
|
||||
onWillPop: () async => !shouldForceUpdate,
|
||||
return PopScope(
|
||||
canPop: !shouldForceUpdate,
|
||||
child: AlertDialog(
|
||||
key: const ValueKey("updateAppDialog"),
|
||||
title: Column(
|
||||
|
|
|
@ -315,7 +315,23 @@ class _HomeWidgetState extends State<HomeWidget> {
|
|||
final enableDrawer = LocalSyncService.instance.hasCompletedFirstImport();
|
||||
final action = AppLifecycleService.instance.mediaExtensionAction.action;
|
||||
return UserDetailsStateWidget(
|
||||
child: WillPopScope(
|
||||
child: PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) async {
|
||||
if (didPop) return;
|
||||
if (_selectedTabIndex == 0) {
|
||||
if (isSettingsOpen) {
|
||||
Navigator.pop(context);
|
||||
} else if (Platform.isAndroid && action == IntentAction.main) {
|
||||
unawaited(MoveToBackground.moveTaskToBack());
|
||||
} else {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
} else {
|
||||
Bus.instance
|
||||
.fire(TabChangedEvent(0, TabChangedEventSource.backButton));
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
drawerScrimColor: getEnteColorScheme(context).strokeFainter,
|
||||
drawerEnableOpenDragGesture: false,
|
||||
|
@ -341,24 +357,6 @@ class _HomeWidgetState extends State<HomeWidget> {
|
|||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
),
|
||||
onWillPop: () async {
|
||||
if (_selectedTabIndex == 0) {
|
||||
if (isSettingsOpen) {
|
||||
Navigator.pop(context);
|
||||
return false;
|
||||
}
|
||||
if (Platform.isAndroid && action == IntentAction.main) {
|
||||
unawaited(MoveToBackground.moveTaskToBack());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Bus.instance
|
||||
.fire(TabChangedEvent(0, TabChangedEventSource.backButton));
|
||||
return false;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -137,9 +137,9 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
}
|
||||
|
||||
Widget get _lockScreen {
|
||||
return WillPopScope(
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: this.widget.lockScreen,
|
||||
onWillPop: () => Future.value(false),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) async {
|
||||
if (_hasBeenEdited()) {
|
||||
await _showExitConfirmationDialog(context);
|
||||
} else {
|
||||
replacePage(context, DetailPage(widget.detailPageConfig));
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
|
|
Loading…
Reference in a new issue