Skip to content

Commit

Permalink
⏪ Revert migration WillPopScope as it breaks the navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
iqfareez committed Dec 4, 2023
1 parent 0c71d95 commit 4df7824
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/components/zone_selector_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '../providers/location_provider.dart';

enum CurrentView { state, zone }

/// Dialog manually select prayer time zone
class ZoneSelectorDialog extends StatefulWidget {
const ZoneSelectorDialog({super.key});

Expand Down Expand Up @@ -35,21 +36,20 @@ class _ZoneSelectorDialogState extends State<ZoneSelectorDialog> {
allZones.firstWhere((element) => element.jakimCode == jakimCode);
}

bool _checkCanPop(bool isWideScreen) {
if (isWideScreen) return true;
if (currentView == CurrentView.zone) {
setState(() => currentView = CurrentView.state);
return false;
}
return true;
}

@override
Widget build(BuildContext context) {
bool isWideScreen = MediaQuery.of(context).size.width > 768;

return PopScope(
canPop: _checkCanPop(isWideScreen),
// Use [WillPopScope] over [PopScope] for now. Using [PopScope] may introoduce unwanted behavior https://imgur.com/a/prW2NsL
return WillPopScope(
onWillPop: () async {
if (isWideScreen) return true;
if (currentView == CurrentView.zone) {
setState(() => currentView = CurrentView.state);
return false;
}
return true;
},
child: Scaffold(
appBar: AppBar(
title: Text(currentView == CurrentView.state
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: App waktu solat seluruh Malaysia

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 2.10.0+136
version: 2.10.1+137

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit 4df7824

Please sign in to comment.