Skip to content

Commit

Permalink
Fixing broken functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
guyluz11 committed Apr 21, 2024
1 parent fe681b0 commit 3338a4b
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 48 deletions.
17 changes: 10 additions & 7 deletions lib/presentation/atoms/text_atom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TextAtom extends StatelessWidget {
this.maxLines,
this.translationArgs,
this.translate = true,
this.veriant = TextVeriant.regular,
this.variant = TextVariant.regular,
});

final String text;
Expand All @@ -21,20 +21,22 @@ class TextAtom extends StatelessWidget {
final int? maxLines;
final List<String>? translationArgs;
final bool translate;
final TextVeriant veriant;
final TextVariant variant;

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final TextTheme textTheme = themeData.textTheme;
TextStyle? tempStyle = style;

switch (veriant) {
case TextVeriant.regular:
switch (variant) {
case TextVariant.regular:
break;
case TextVeriant.smallTitle:
case TextVariant.smallTitle:
tempStyle = textTheme.titleLarge;
case TextVeriant.medium:
case TextVariant.title:
tempStyle = textTheme.headlineMedium;
case TextVariant.medium:
tempStyle = textTheme.bodyMedium;
}

Expand All @@ -48,11 +50,12 @@ class TextAtom extends StatelessWidget {
}
}

enum TextVeriant {
enum TextVariant {
smallTitle,

/// define out side, trying to deprecate
regular,
medium,
title,
;
}
7 changes: 5 additions & 2 deletions lib/presentation/atoms/timer_atom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class TimerAtom extends StatelessWidget {

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final ColorScheme colorScheme = themeData.colorScheme;

return CircularCountDownTimer(
duration: timer.inSeconds,
controller: controller,
Expand All @@ -24,9 +27,9 @@ class TimerAtom extends StatelessWidget {
fillColor: Colors.purpleAccent[100]!,
strokeWidth: 20.0,
strokeCap: StrokeCap.round,
textStyle: const TextStyle(
textStyle: TextStyle(
fontSize: 33.0,
color: Colors.white,
color: colorScheme.onBackground,
fontWeight: FontWeight.bold,
),
textFormat: CountdownTextFormat.S,
Expand Down
54 changes: 26 additions & 28 deletions lib/presentation/organisms/timer_molecule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,33 @@ class TimerMolecule extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: TimerAtom(
controller,
duration,
onComplete,
),
),
const SeparatorAtom(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ButtonAtom(
variant: ButtonVariant.primary,
onPressed: controller.resume,
text: 'Continue',
),
ButtonAtom(
variant: ButtonVariant.secondary,
onPressed: controller.pause,
text: 'Pause',
),
],
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: TimerAtom(
controller,
duration,
onComplete,
),
],
),
),
const SeparatorAtom(),
Column(
children: [
ButtonAtom(
variant: ButtonVariant.primary,
onPressed: controller.resume,
text: 'Continue',
),
const SeparatorAtom(),
ButtonAtom(
variant: ButtonVariant.secondary,
onPressed: controller.pause,
text: 'Pause',
),
],
),
],
);
}
}
26 changes: 17 additions & 9 deletions lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class _HomePageState extends State<HomePage> {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const TextAtom('Study'),
const TextAtom(
'Study Timer',
variant: TextVariant.smallTitle,
),
TimerMolecule(
onTimerComplete,
StudyTypeAbstract.instance!.energy.duration,
Expand Down Expand Up @@ -81,14 +84,19 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const TextAtom('Maximize Study Efficiency'),
Expanded(
child: stateWidget(),
),
],
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
const TextAtom(
'Maximize Study Efficiency',
variant: TextVariant.title,
),
Expanded(
child: stateWidget(),
),
],
),
),
);
}
Expand Down
46 changes: 44 additions & 2 deletions lib/presentation/pages/intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class _IntroPageState extends State<IntroPage> {
GlobalKey<IntroductionScreenState>();

String studyType = '';
bool showNextButton = true;
IntroState state = IntroState.welcome;

void nextPage() {
// TODO: Hide next button for sertan pages until element get selected
_introKey.currentState?.next();
}

Expand Down Expand Up @@ -47,7 +48,7 @@ class _IntroPageState extends State<IntroPage> {
}),
),
PageViewModel(
title: 'Efficient $studyType Study',
title: 'Efficient $studyType Tips',
bodyWidget: TipsOrganism(),
),
PageViewModel(
Expand All @@ -62,9 +63,50 @@ class _IntroPageState extends State<IntroPage> {
showBackButton: true,
back: const Icon(Icons.arrow_back),
next: const Icon(Icons.arrow_forward),
showNextButton: showNextButton,
scrollPhysics: const NeverScrollableScrollPhysics(),
onChange: (int n) {
state = IntroState.getStateByPageNumber(n);
bool showNextButtonTemp = true;

if (state == IntroState.studyType &&
(StudyTypeAbstract.instance?.studyType == null ||
StudyTypeAbstract.instance!.studyType ==
StudyType.undefined)) {
showNextButtonTemp = false;
} else if (state == IntroState.energy &&
StudyTypeAbstract.instance!.energy == EnergyType.undefined) {
showNextButtonTemp = false;
}
setState(() {
showNextButton = showNextButtonTemp;
});
},
showDoneButton: false,
),
),
);
}
}

enum IntroState {
welcome(0),
studyType(1),
tips(2),
energy(3),
encouragementSentence(4),
;

const IntroState(this.pageNumber);

final int pageNumber;

static IntroState getStateByPageNumber(int number) {
for (final IntroState state in IntroState.values) {
if (state.pageNumber == number) {
return state;
}
}
return IntroState.welcome;
}
}

0 comments on commit 3338a4b

Please sign in to comment.