Skip to content

Commit

Permalink
Merge pull request #192 from guyluz11/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
guyluz11 authored Nov 9, 2024
2 parents 7f3a1ef + 67e69d3 commit e4f97c3
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 35 deletions.
1 change: 1 addition & 0 deletions lib/presentation/atoms/atoms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
35 changes: 35 additions & 0 deletions lib/presentation/atoms/popup_menu_entry_atom.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/material.dart';

class PopupMenuEntryAtom<T extends Enum> extends PopupMenuEntry<T> {
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<T>();
}

class _CustomPopupMenuEntryState<T extends Enum>
extends State<PopupMenuEntryAtom<T>> {
@override
Widget build(BuildContext context) {
return ListTile(
title: widget.child,
onTap: widget.onTap,
);
}
}
26 changes: 26 additions & 0 deletions lib/presentation/molecules/back_to_home_alert_dialog_molecule.dart
Original file line number Diff line number Diff line change
@@ -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(),
),
);
},
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BottomNavigationBarHomePage extends StatelessWidget {
BottomNavigationBarItem(
activeIcon: Icon(Icons.text_snippet),
icon: Icon(Icons.text_snippet),
label: 'Text',
label: 'Notes',
),
],
);
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/molecules/molecules.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 3 additions & 0 deletions lib/presentation/molecules/page_enclosure_molecule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -27,6 +28,7 @@ class PageEnclosureMolecule extends StatelessWidget {
final bool scaffold;
final TopBarType topBarType;
final VoidCallback? topBarRightOnTap;
final List<PopupMenuEntryAtom<Enum>>? rightPopupMenu;
final bool expendChild;
final IconData? topBarRightIcon;

Expand All @@ -40,6 +42,7 @@ class PageEnclosureMolecule extends StatelessWidget {
margin: false,
translate: topBarTranslate,
rightOnTap: topBarRightOnTap,
rightPopupMenu: rightPopupMenu,
rightIcon: topBarRightIcon,
),
if (subTitle != null)
Expand Down
13 changes: 11 additions & 2 deletions lib/presentation/molecules/top_bar_molecule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class TopBarMolecule extends StatelessWidget {
this.title,
this.leftOnTap,
this.rightOnTap,
this.rightPopupMenu,
this.translate = true,
this.margin = true,
this.rightIcon,
Expand All @@ -16,6 +17,8 @@ class TopBarMolecule extends StatelessWidget {
final String? title;
final VoidCallback? leftOnTap;
final VoidCallback? rightOnTap;

final List<PopupMenuEntryAtom>? rightPopupMenu;
final IconData? rightIcon;
final bool translate;
final bool margin;
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion lib/presentation/organisms/timer_organism.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -250,7 +251,18 @@ class TimerOrganismState extends State<TimerOrganism> {
scaffold: false,
expendChild: false,
topMargin: false,
topBarRightOnTap: () => openAlertDialog(context, SettingsPage()),
rightPopupMenu: <PopupMenuEntryAtom<PopMenuEnum>>[
PopupMenuEntryAtom<PopMenuEnum>(
value: PopMenuEnum.navigationHome,
child: const TextAtom('Navigate Home'),
onTap: () => backToHomePopup(context),
),
PopupMenuEntryAtom<PopMenuEnum>(
value: PopMenuEnum.setting,
child: const TextAtom('Settings'),
onTap: () => openAlertDialog(context, SettingsPage()),
),
],
child: Column(
children: [
ProgressTrackerAtom(
Expand Down Expand Up @@ -288,3 +300,5 @@ extension TimerStateExtension on TimerState {
);
}
}

enum PopMenuEnum { navigationHome, setting }
26 changes: 1 addition & 25 deletions lib/presentation/pages/activity_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,32 +37,9 @@ class _ActivityPageState extends State<ActivityPage>

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<bool> onWillPop(bool didPop, dynamic result) async {
if (_currentTabNum == 0) {
backToHomePopup();
backToHomePopup(context);
} else {
animateToPage(0);
}
Expand Down
17 changes: 12 additions & 5 deletions lib/presentation/pages/intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class _IntroPageState extends State<IntroPage> {
IntroState state = IntroState.tips;
final Duration selectionTransitionDelay = const Duration(milliseconds: 200);

void onNextPressed() {
void onLastNextPressed() {
isFinish = true;
setState(() {
showBackButton = false;
Expand All @@ -52,9 +52,16 @@ class _IntroPageState extends State<IntroPage> {
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;
}
Expand Down Expand Up @@ -120,7 +127,6 @@ class _IntroPageState extends State<IntroPage> {
variant: ButtonVariant.lowEmphasisIcon,
onPressed: previousPage,
icon: FontAwesomeIcons.arrowLeft,
disabled: !showNextButton,
),
),
pages: [
Expand All @@ -136,10 +142,11 @@ class _IntroPageState extends State<IntroPage> {
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),
Expand Down
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4f97c3

Please sign in to comment.