Skip to content

Commit

Permalink
Fixed home page timer state when checking phone notifications on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
guyluz11 committed Jun 25, 2024
1 parent e21da71 commit 678b791
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
flutter_channel: 'stable' # or: 'dev' or 'beta'
flutter_version: '3.22.0'
flutter_version: '3.22.2'

jobs:
build:
Expand Down
19 changes: 18 additions & 1 deletion lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,29 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
TimerStateManager.iterateOverTimerStates();
}

AppLifecycleState currentAppState = AppLifecycleState.resumed;

void setAppState(AppLifecycleState val) {
if (val == AppLifecycleState.paused || val == AppLifecycleState.resumed) {
currentAppState = val;
}
}

@override
Future didChangeAppLifecycleState(AppLifecycleState appState) async {
switch (appState) {
case AppLifecycleState.detached:
case AppLifecycleState.inactive:
case AppLifecycleState.hidden:
setAppState(appState);
return;
case AppLifecycleState.resumed:
if (currentAppState == AppLifecycleState.resumed) {
return;
}

setAppState(appState);

NotificationsController.instance.cancelAllNotifications();

final DateTime preferencePausedTime =
Expand All @@ -66,6 +81,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
);
return;
case AppLifecycleState.paused:
setAppState(appState);

final bool isTimerRunning = TimerStateManager.isTimerRunning();

TimerStateManager.pauseTimer();
Expand Down Expand Up @@ -139,7 +156,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
body: PageView(
onPageChanged: (index) {
setState(() {
if (index == 0){
if (index == 0) {
FocusScope.of(context).unfocus();
}
_currentTabNum = index;
Expand Down

0 comments on commit 678b791

Please sign in to comment.