diff --git a/lib/domain/controllers/dnd_controller.dart b/lib/domain/controllers/dnd_controller.dart index 1ab069b..b4e62ea 100644 --- a/lib/domain/controllers/dnd_controller.dart +++ b/lib/domain/controllers/dnd_controller.dart @@ -13,7 +13,9 @@ abstract class DndController { void init(); - Future enableDnd(); + Future enable(); Future isDnd(); + + Future disable(); } diff --git a/lib/infrastructure/dnd_repository.dart b/lib/infrastructure/dnd_repository.dart index d9bb6cd..e4b0016 100644 --- a/lib/infrastructure/dnd_repository.dart +++ b/lib/infrastructure/dnd_repository.dart @@ -5,7 +5,7 @@ class _DndRepository extends DndController { void init() => supported = Platform.isAndroid; @override - Future enableDnd() async { + Future enable() async { if (!supported) { return; } @@ -21,6 +21,20 @@ class _DndRepository extends DndController { } } + @override + Future disable() async { + if (!supported) { + return; + } + + if (await PermissionsController.instance + .isNotificationPolicyAccessGranted()) { + await FlutterDnd.setInterruptionFilter( + FlutterDnd.INTERRUPTION_FILTER_ALL, + ); + } + } + @override Future isDnd() async { if (!supported) { diff --git a/lib/presentation/organisms/ready_for_session_organism.dart b/lib/presentation/organisms/ready_for_session_organism.dart index 531b4b1..6decb60 100644 --- a/lib/presentation/organisms/ready_for_session_organism.dart +++ b/lib/presentation/organisms/ready_for_session_organism.dart @@ -5,13 +5,15 @@ import 'package:infinite_horizons/domain/objects/work_type_abstract.dart'; import 'package:infinite_horizons/presentation/atoms/atoms.dart'; class ReadyForSessionOrganism extends StatefulWidget { - const ReadyForSessionOrganism( - this.onComplete, { + const ReadyForSessionOrganism({ + required this.onComplete, + this.onNextPressed, this.response, }); final VoidCallback onComplete; final String? response; + final VoidCallback? onNextPressed; @override State createState() => @@ -24,6 +26,7 @@ class _ReadyForSessionOrganismState extends State { bool confettiGotPlayed = false; void onPressed() { + widget.onNextPressed?.call(); setState(() { nextPressed = true; }); diff --git a/lib/presentation/organisms/timer_organism.dart b/lib/presentation/organisms/timer_organism.dart index c6a8f3c..2d4d6f1 100644 --- a/lib/presentation/organisms/timer_organism.dart +++ b/lib/presentation/organisms/timer_organism.dart @@ -161,6 +161,12 @@ class TimerOrganismState extends State { TimerState state = TimerStateManager.state; bool renderSizedBox = false; + void onComplete() { + TimerStateManager.incrementState(); + TimerStateManager.iterateOverTimerStates(); + setCurrentState(); + } + @override void initState() { super.initState(); @@ -219,11 +225,9 @@ class TimerOrganismState extends State { initialValue: timePassed, ); case TimerState.readyToStart: - return ReadyForSessionOrganism(() { - TimerStateManager.incrementState(); - TimerStateManager.iterateOverTimerStates(); - setCurrentState(); - }); + return ReadyForSessionOrganism( + onComplete: onComplete, + ); } } diff --git a/lib/presentation/organisms/tips_organism.dart b/lib/presentation/organisms/tips_organism.dart index c7d59a9..4816288 100644 --- a/lib/presentation/organisms/tips_organism.dart +++ b/lib/presentation/organisms/tips_organism.dart @@ -120,8 +120,12 @@ class _TipsOrganismState extends State { Icons.do_not_disturb_off_outlined, onIcon: Icons.do_not_disturb_on_outlined, onChange: (value) { - confettiController.play(); - DndController.instance.enableDnd(); + if (value) { + confettiController.play(); + DndController.instance.enable(); + return; + } + DndController.instance.disable(); }, initialValue: isDnd!, trailing: IconButton( @@ -134,7 +138,6 @@ class _TipsOrganismState extends State { ), icon: const Icon(Icons.arrow_forward), ), - lockOnToggleOn: true, ), ], ), diff --git a/lib/presentation/pages/intro_page.dart b/lib/presentation/pages/intro_page.dart index dea1819..4f96c7a 100644 --- a/lib/presentation/pages/intro_page.dart +++ b/lib/presentation/pages/intro_page.dart @@ -22,10 +22,19 @@ class _IntroPageState extends State { final GlobalKey _introKey = GlobalKey(); + bool showBackButton = true; bool showNextButton = true; + bool isFinish = false; IntroState state = IntroState.tips; final Duration selectionTransitionDelay = const Duration(milliseconds: 200); + void onNextPressed() { + isFinish = true; + setState(() { + showBackButton = false; + }); + } + void onIntroPageChange(int n) { state = IntroState.getStateByPageNumber(n); bool showNextButtonTemp = true; @@ -42,10 +51,15 @@ class _IntroPageState extends State { void nextPage() => _introKey.currentState?.next(); - void onDone(BuildContext context) => Navigator.of(context) + void onDone() => Navigator.of(context) .push(MaterialPageRoute(builder: (context) => ActivityPage())); - void previousPage() => _introKey.currentState?.previous(); + void previousPage() { + if (isFinish) { + return; + } + _introKey.currentState?.previous(); + } void onHorizontalDrag(DragEndDetails details) { if (details.primaryVelocity == 0) { @@ -120,10 +134,13 @@ class _IntroPageState extends State { }), ), customPageViewModel( - bodyWidget: ReadyForSessionPage(() => onDone(context)), + bodyWidget: ReadyForSessionPage( + onDone: onDone, + onNextPressed: onNextPressed, + ), ), ], - showBackButton: true, + showBackButton: showBackButton, back: const Icon(Icons.arrow_back), next: const Icon(Icons.arrow_forward), scrollPhysics: const NeverScrollableScrollPhysics(), diff --git a/lib/presentation/pages/ready_for_session_page.dart b/lib/presentation/pages/ready_for_session_page.dart index 6498b6a..e9a8905 100644 --- a/lib/presentation/pages/ready_for_session_page.dart +++ b/lib/presentation/pages/ready_for_session_page.dart @@ -6,13 +6,17 @@ import 'package:infinite_horizons/presentation/molecules/molecules.dart'; import 'package:infinite_horizons/presentation/organisms/organisms.dart'; class ReadyForSessionPage extends StatelessWidget { - const ReadyForSessionPage(this.callback); + const ReadyForSessionPage({ + required this.onDone, + required this.onNextPressed, + }); - final VoidCallback callback; + final VoidCallback onNextPressed; + final VoidCallback onDone; void handleCallback() { VibrationController.instance.vibrate(VibrationType.light); - callback(); + onDone(); } @override @@ -41,7 +45,8 @@ class ReadyForSessionPage extends StatelessWidget { scaffold: false, title: 'start_session', child: ReadyForSessionOrganism( - handleCallback, + onComplete: handleCallback, + onNextPressed: onNextPressed, response: text, ), );