diff --git a/lib/presentation/atoms/atoms.dart b/lib/presentation/atoms/atoms.dart index a5b130b..1a84501 100644 --- a/lib/presentation/atoms/atoms.dart +++ b/lib/presentation/atoms/atoms.dart @@ -7,6 +7,7 @@ export 'package:infinite_horizons/presentation/atoms/confetti_atom.dart'; export 'package:infinite_horizons/presentation/atoms/image_atom.dart'; export 'package:infinite_horizons/presentation/atoms/list_tile_atom.dart'; export 'package:infinite_horizons/presentation/atoms/margined_expanded_atom.dart'; +export 'package:infinite_horizons/presentation/atoms/popup_menu_entry_atom.dart'; export 'package:infinite_horizons/presentation/atoms/progress_indicator_atom.dart'; export 'package:infinite_horizons/presentation/atoms/separator_atom.dart'; export 'package:infinite_horizons/presentation/atoms/text_atom.dart'; diff --git a/lib/presentation/atoms/popup_menu_entry_atom.dart b/lib/presentation/atoms/popup_menu_entry_atom.dart new file mode 100644 index 0000000..9f8fe66 --- /dev/null +++ b/lib/presentation/atoms/popup_menu_entry_atom.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +class PopupMenuEntryAtom extends PopupMenuEntry { + const PopupMenuEntryAtom({ + required this.value, + required this.child, + required this.onTap, + }); + + final T value; + final Widget child; + final VoidCallback onTap; + + @override + double get height => 50.0; + + @override + bool represents(T? value) { + return value != null && value == this.value; + } + + @override + State createState() => _CustomPopupMenuEntryState(); +} + +class _CustomPopupMenuEntryState + extends State> { + @override + Widget build(BuildContext context) { + return ListTile( + title: widget.child, + onTap: widget.onTap, + ); + } +} diff --git a/lib/presentation/molecules/back_to_home_alert_dialog_molecule.dart b/lib/presentation/molecules/back_to_home_alert_dialog_molecule.dart new file mode 100644 index 0000000..3d2a6c8 --- /dev/null +++ b/lib/presentation/molecules/back_to_home_alert_dialog_molecule.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:infinite_horizons/presentation/molecules/molecules.dart'; +import 'package:infinite_horizons/presentation/pages/pages.dart'; + +void backToHomePopup(BuildContext context) { + openAlertDialog( + context, + const SizedBox( + height: 150, + child: PageEnclosureMolecule( + title: 'Exit Session', + subTitle: 'Navigate back to Home Page?', + expendChild: false, + child: SizedBox(), + ), + ), + onConfirm: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => HomePage(), + ), + ); + }, + ); +} diff --git a/lib/presentation/molecules/bottom_navigation_bar_home_molecule.dart b/lib/presentation/molecules/bottom_navigation_bar_home_molecule.dart index daccb0b..643e5cc 100644 --- a/lib/presentation/molecules/bottom_navigation_bar_home_molecule.dart +++ b/lib/presentation/molecules/bottom_navigation_bar_home_molecule.dart @@ -26,7 +26,7 @@ class BottomNavigationBarHomePage extends StatelessWidget { BottomNavigationBarItem( activeIcon: Icon(Icons.text_snippet), icon: Icon(Icons.text_snippet), - label: 'Text', + label: 'Notes', ), ], ); diff --git a/lib/presentation/molecules/molecules.dart b/lib/presentation/molecules/molecules.dart index 09cf571..3bfeca3 100644 --- a/lib/presentation/molecules/molecules.dart +++ b/lib/presentation/molecules/molecules.dart @@ -1,4 +1,5 @@ export 'package:infinite_horizons/presentation/molecules/alert_dialog_molecule.dart'; +export 'package:infinite_horizons/presentation/molecules/back_to_home_alert_dialog_molecule.dart'; export 'package:infinite_horizons/presentation/molecules/bottom_navigation_bar_home_molecule.dart'; export 'package:infinite_horizons/presentation/molecules/energy_selection_molecule.dart'; export 'package:infinite_horizons/presentation/molecules/page_enclosure_molecule.dart'; diff --git a/lib/presentation/molecules/page_enclosure_molecule.dart b/lib/presentation/molecules/page_enclosure_molecule.dart index d1af2d1..c129c77 100644 --- a/lib/presentation/molecules/page_enclosure_molecule.dart +++ b/lib/presentation/molecules/page_enclosure_molecule.dart @@ -13,6 +13,7 @@ class PageEnclosureMolecule extends StatelessWidget { this.topBarType = TopBarType.none, this.scaffold = true, this.topBarRightOnTap, + this.rightPopupMenu, this.expendChild = true, this.topBarRightIcon, super.key, @@ -27,6 +28,7 @@ class PageEnclosureMolecule extends StatelessWidget { final bool scaffold; final TopBarType topBarType; final VoidCallback? topBarRightOnTap; + final List>? rightPopupMenu; final bool expendChild; final IconData? topBarRightIcon; @@ -40,6 +42,7 @@ class PageEnclosureMolecule extends StatelessWidget { margin: false, translate: topBarTranslate, rightOnTap: topBarRightOnTap, + rightPopupMenu: rightPopupMenu, rightIcon: topBarRightIcon, ), if (subTitle != null) diff --git a/lib/presentation/molecules/top_bar_molecule.dart b/lib/presentation/molecules/top_bar_molecule.dart index f5f7b27..f5feceb 100644 --- a/lib/presentation/molecules/top_bar_molecule.dart +++ b/lib/presentation/molecules/top_bar_molecule.dart @@ -7,6 +7,7 @@ class TopBarMolecule extends StatelessWidget { this.title, this.leftOnTap, this.rightOnTap, + this.rightPopupMenu, this.translate = true, this.margin = true, this.rightIcon, @@ -16,6 +17,8 @@ class TopBarMolecule extends StatelessWidget { final String? title; final VoidCallback? leftOnTap; final VoidCallback? rightOnTap; + + final List? rightPopupMenu; final IconData? rightIcon; final bool translate; final bool margin; @@ -52,14 +55,20 @@ class TopBarMolecule extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ + if (rightPopupMenu != null) + PopupMenuButton( + icon: const Icon(Icons.more_vert), + itemBuilder: (BuildContext context) => + rightPopupMenu!, + ), if (rightOnTap != null) ButtonAtom( variant: ButtonVariant.lowEmphasisIcon, onPressed: rightOnTap!, translate: translate, icon: Icons.more_vert, - ) - else + ), + if (rightPopupMenu == null && rightOnTap == null) TextAtom( '', style: textTheme.headlineSmall, diff --git a/lib/presentation/organisms/timer_organism.dart b/lib/presentation/organisms/timer_organism.dart index 2d4d6f1..2b1c483 100644 --- a/lib/presentation/organisms/timer_organism.dart +++ b/lib/presentation/organisms/timer_organism.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:infinite_horizons/domain/controllers/controllers.dart'; import 'package:infinite_horizons/domain/objects/energy_level.dart'; import 'package:infinite_horizons/domain/objects/work_type_abstract.dart'; +import 'package:infinite_horizons/presentation/atoms/atoms.dart'; import 'package:infinite_horizons/presentation/atoms/progress_tracker_atom.dart'; import 'package:infinite_horizons/presentation/molecules/molecules.dart'; import 'package:infinite_horizons/presentation/organisms/organisms.dart'; @@ -250,7 +251,18 @@ class TimerOrganismState extends State { scaffold: false, expendChild: false, topMargin: false, - topBarRightOnTap: () => openAlertDialog(context, SettingsPage()), + rightPopupMenu: >[ + PopupMenuEntryAtom( + value: PopMenuEnum.navigationHome, + child: const TextAtom('Navigate Home'), + onTap: () => backToHomePopup(context), + ), + PopupMenuEntryAtom( + value: PopMenuEnum.setting, + child: const TextAtom('Settings'), + onTap: () => openAlertDialog(context, SettingsPage()), + ), + ], child: Column( children: [ ProgressTrackerAtom( @@ -288,3 +300,5 @@ extension TimerStateExtension on TimerState { ); } } + +enum PopMenuEnum { navigationHome, setting } diff --git a/lib/presentation/pages/activity_page.dart b/lib/presentation/pages/activity_page.dart index 7982aed..64599ed 100644 --- a/lib/presentation/pages/activity_page.dart +++ b/lib/presentation/pages/activity_page.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:infinite_horizons/domain/controllers/controllers.dart'; import 'package:infinite_horizons/presentation/molecules/molecules.dart'; import 'package:infinite_horizons/presentation/organisms/organisms.dart'; -import 'package:infinite_horizons/presentation/pages/home_page.dart'; class ActivityPage extends StatefulWidget { @override @@ -38,32 +37,9 @@ class _ActivityPageState extends State AppLifecycleState currentAppState = AppLifecycleState.resumed; - void backToHomePopup() { - openAlertDialog( - context, - const SizedBox( - height: 150, - child: PageEnclosureMolecule( - title: 'Exit Session', - subTitle: 'Navigate back to Home Page?', - expendChild: false, - child: SizedBox(), - ), - ), - onConfirm: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => HomePage(), - ), - ); - }, - ); - } - Future onWillPop(bool didPop, dynamic result) async { if (_currentTabNum == 0) { - backToHomePopup(); + backToHomePopup(context); } else { animateToPage(0); } diff --git a/lib/presentation/pages/intro_page.dart b/lib/presentation/pages/intro_page.dart index 4f96c7a..30bb0e6 100644 --- a/lib/presentation/pages/intro_page.dart +++ b/lib/presentation/pages/intro_page.dart @@ -28,7 +28,7 @@ class _IntroPageState extends State { IntroState state = IntroState.tips; final Duration selectionTransitionDelay = const Duration(milliseconds: 200); - void onNextPressed() { + void onLastNextPressed() { isFinish = true; setState(() { showBackButton = false; @@ -52,9 +52,16 @@ class _IntroPageState extends State { void nextPage() => _introKey.currentState?.next(); void onDone() => Navigator.of(context) - .push(MaterialPageRoute(builder: (context) => ActivityPage())); + .pushReplacement(MaterialPageRoute(builder: (context) => ActivityPage())); - void previousPage() { + bool isPop = false; + + Future previousPage() async { + if (state.pageNumber == 0 && !isPop) { + isPop = true; + Navigator.of(context).maybePop(); + return; + } if (isFinish) { return; } @@ -120,7 +127,6 @@ class _IntroPageState extends State { variant: ButtonVariant.lowEmphasisIcon, onPressed: previousPage, icon: FontAwesomeIcons.arrowLeft, - disabled: !showNextButton, ), ), pages: [ @@ -136,10 +142,11 @@ class _IntroPageState extends State { customPageViewModel( bodyWidget: ReadyForSessionPage( onDone: onDone, - onNextPressed: onNextPressed, + onNextPressed: onLastNextPressed, ), ), ], + showFirstBackButton: true, showBackButton: showBackButton, back: const Icon(Icons.arrow_back), next: const Icon(Icons.arrow_forward), diff --git a/pubspec.yaml b/pubspec.yaml index fbda8bf..0630e92 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,10 @@ dependencies: font_awesome_flutter: ^10.7.0 google_fonts: ^6.2.1 health: ^10.2.0 - introduction_screen: ^3.1.14 + introduction_screen: + git: + url: https://github.com/guyluz11/introduction_screen.git + ref: master # Small, easy to use and extensible logger which prints beautiful logs. liquid_progress_indicator_v2: ^0.5.0 logger: ^2.2.0