Skip to content

Commit

Permalink
Progress tracker to home page #10
Browse files Browse the repository at this point in the history
  • Loading branch information
guyluz11 committed Jul 15, 2024
1 parent 2b09d83 commit 23c5741
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 7 deletions.
40 changes: 40 additions & 0 deletions lib/presentation/atoms/progress_tracker_atom.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:progress_tracker/progress_tracker.dart';

class ProgressTrackerAtom extends StatelessWidget {
const ProgressTrackerAtom(this.states, this.currentState);

final List<String> states;
final String currentState;

@override
Widget build(BuildContext context) {
final int currentIndex = states.indexOf(currentState);
final List<Status> statusList = [];
bool active = true;

for (final String state in states) {
statusList.add(
Status(
name: state,
icon: state == currentState ? FontAwesomeIcons.caretDown : null,
active: active,
),
);
if (state == currentState) {
active = false;
}
}

final ThemeData themeData = Theme.of(context);
final ColorScheme colorScheme = themeData.colorScheme;

return ProgressTracker(
currentIndex: currentIndex,
statusList: statusList,
activeColor: colorScheme.onSurface,
inActiveColor: colorScheme.outlineVariant,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BottomNavigationBarHomePage extends StatelessWidget {
final ColorScheme colorScheme = themeData.colorScheme;

return BottomNavigationBar(
selectedItemColor: colorScheme.onSurface,
selectedItemColor: colorScheme.primary,
unselectedItemColor: colorScheme.onSurfaceVariant,
currentIndex: pageIndex,
onTap: callback,
Expand Down
4 changes: 3 additions & 1 deletion lib/presentation/molecules/page_enclosure_molecule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PageEnclosureMolecule extends StatelessWidget {
required this.child,
this.subTitle,
this.margin = true,
this.topMargin = true,
this.topBarTranslate = true,
this.topBarType = TopBarType.none,
this.scaffold = true,
Expand All @@ -21,6 +22,7 @@ class PageEnclosureMolecule extends StatelessWidget {
final String? subTitle;
final bool topBarTranslate;
final bool margin;
final bool topMargin;
final bool scaffold;
final TopBarType topBarType;
final VoidCallback? topBarRightOnTap;
Expand All @@ -41,7 +43,7 @@ class PageEnclosureMolecule extends StatelessWidget {
subTitle!,
variant: TextVariant.smallTitle,
),
const SeparatorAtom(variant: SeparatorVariant.farApart),
if (topMargin) const SeparatorAtom(variant: SeparatorVariant.farApart),
Expanded(
child: child,
),
Expand Down
26 changes: 21 additions & 5 deletions 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/study_type_abstract.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';
import 'package:infinite_horizons/presentation/pages/pages.dart';
Expand Down Expand Up @@ -225,18 +226,33 @@ class TimerOrganismState extends State<TimerOrganism> {
title: title,
scaffold: false,
expendChild: false,
topMargin: false,
topBarRightOnTap: () => openAlertDialog(context, SettingsPage()),
child: renderSizedBox ? const SizedBox() : stateWidget(),
child: Column(
children: [
ProgressTrackerAtom(
TimerState.values.map((e) => e.spacedName).toList(),
state.spacedName,
),
Expanded(
child: renderSizedBox ? const SizedBox() : stateWidget(),
),
],
),
);
}
}

enum TimerState {
study,
getReadyForBreak,
breakTime,
readyToStart,
study('Study'),
getReadyForBreak('Before Break'),
breakTime('Break Time'),
readyToStart('Complete'),
;

const TimerState(this.spacedName);

final String spacedName;
}

extension TimerStateExtension on TimerState {
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/pages/intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class _IntroPageState extends State<IntroPage> {
scrollPhysics: const NeverScrollableScrollPhysics(),
onChange: onIntroPageChange,
showDoneButton: false,
showNextButton: showNextButton,
),
),
);
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ dependencies:
liquid_progress_indicator_v2: ^0.5.0
logger: ^2.2.0
permission_handler: ^11.3.1
progress_tracker:
git:
url: https://github.com/guyluz11/progress-tracker.git
ref: main
shared_preferences: ^2.2.3
url_launcher: ^6.2.6
vibration: ^1.8.4
Expand Down

0 comments on commit 23c5741

Please sign in to comment.