-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
906a984
commit 519632a
Showing
9 changed files
with
121 additions
and
36 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
lib/app/components/app_update_handler/app_update_handler.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:ion/app/components/app_update_handler/hooks/use_app_update.dart'; | ||
import 'package:ion/app/features/core/model/app_update_type.dart'; | ||
import 'package:ion/app/features/core/views/pages/app_update_modal.dart'; | ||
import 'package:ion/app/router/app_routes.c.dart'; | ||
import 'package:ion/app/router/utils/show_simple_bottom_sheet.dart'; | ||
|
||
class AppUpdateHandler extends HookConsumerWidget { | ||
const AppUpdateHandler({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final isModalShown = useAppUpdate(ref); | ||
|
||
if (!isModalShown) { | ||
WidgetsBinding.instance.addPostFrameCallback((_) { | ||
showSimpleBottomSheet<void>( | ||
isDismissible: false, | ||
context: rootNavigatorKey.currentContext!, | ||
child: const AppUpdateModal( | ||
appUpdateType: AppUpdateType.updateRequired, | ||
), | ||
); | ||
}); | ||
} | ||
|
||
return const SizedBox.shrink(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
lib/app/components/app_update_handler/hooks/use_app_update.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:ion/app/features/config/providers/force_update_provider.c.dart'; | ||
|
||
bool useAppUpdate(WidgetRef ref) { | ||
final isModalShown = useState(false); | ||
|
||
final forceUpdateState = ref.watch(forceUpdateProvider); | ||
|
||
useEffect( | ||
() { | ||
if (forceUpdateState.showUpdateModal && !isModalShown.value) { | ||
isModalShown.value = true; | ||
} | ||
|
||
return null; | ||
}, | ||
[forceUpdateState], | ||
); | ||
|
||
return isModalShown.value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters