diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index 23b7264..2b79e06 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -1,3 +1,30 @@ { - "start_with": "Tip: start with thinking about your last session" + "start_with": "Tip: start with thinking about your last session", + "study_efficiently": "Let’s Study Efficiently", + "study_type": "Study Type", + "efficient_tips": "Efficient {} Tips", + "energy": "Energy", + "lets_start": "Let’s Start", + "recommended_morning": "Recommended in the morning", + "recommended_evening": "Recommended in the evening", + "very_low": "Very Low", + "low": "Low", + "medium": "Medium", + "high": "High", + "very_high": "Very High", + "max": "Max", + "minutes_single": "m", + "classic_pomodoro": "Classic Pomodoro:", + "custom": "Custom:", + "study_timer": "Study Timer", + "ready_for_break": "Get ready for a break", + "take_break": "Take a break", + "ready_study": "Get ready to study", + "study_efficiency": "Maximize Study Efficiency", + "continue": "Continue", + "pause": "Pause", + "start": "Start", + "analytically": "Analytically", + "creatively": "Creatively", + "undefined": "Undefined" } \ No newline at end of file diff --git a/assets/translations/he-IL.json b/assets/translations/he-IL.json index 0ca52a4..b501869 100644 --- a/assets/translations/he-IL.json +++ b/assets/translations/he-IL.json @@ -1,3 +1,30 @@ { - "start_with": "טיפ: מומלץ להתחיל בחשיבה על הסאשן האחרון" + "start_with": "טיפ: מומלץ להתחיל בחשיבה על הסאשן האחרון", + "study_efficiently": "בוא נלמד ביעילות", + "study_type": "סוג לימודים", + "efficient_tips": "טיפים {} יעילים", + "energy": "אנרגיה", + "lets_start": "בוא נתחיל", + "recommended_morning": "מומלץ בבוקר", + "recommended_evening": "ממולץ בערב", + "very_low": "נמוך מאוד", + "low": "נמוך", + "medium": "בינוני", + "high": "גבוה", + "very_high": "גבוה מאוד", + "max": "מקסימום", + "minutes_single": "ד", + "classic_pomodoro": "פומדורו קלאסי:", + "custom": "מותאם אישית:", + "study_timer": "זמן לימוד", + "ready_for_break": "התכונן להפסקה", + "take_break": "קח הפסקה", + "ready_study": "התכונן לימוד", + "study_efficiency": "מקסם יעילות למידה", + "continue": "המשך", + "pause": "הפסק", + "start": "התחל", + "analytically": "אנליטי", + "creatively": "יצירתי", + "undefined": "לא מוגדר" } \ No newline at end of file diff --git a/lib/domain/study_type_abstract.dart b/lib/domain/study_type_abstract.dart index f959de0..8a81d2c 100644 --- a/lib/domain/study_type_abstract.dart +++ b/lib/domain/study_type_abstract.dart @@ -26,9 +26,9 @@ abstract class StudyTypeAbstract { } enum StudyType { - undefined('Undefined'), - analytically('Analytically'), - creatively('Creatively'), + undefined('undefined'), + analytically('analytically'), + creatively('creatively'), ; const StudyType(this.previewName); @@ -46,12 +46,12 @@ extension StudyTypeExtension on StudyType { enum EnergyType { undefined('undefined', Duration.zero), - veryLow('Very Low', Duration(minutes: 5)), - low('Low', Duration(minutes: 10)), - medium('Medium', Duration(minutes: 25)), - high('High', Duration(minutes: 40)), - veryHigh('Very High', Duration(minutes: 60)), - max('Max', Duration(minutes: 90)), + veryLow('very_low', Duration(minutes: 5)), + low('low', Duration(minutes: 10)), + medium('medium', Duration(minutes: 25)), + high('high', Duration(minutes: 40)), + veryHigh('very_high', Duration(minutes: 60)), + max('max', Duration(minutes: 90)), ; const EnergyType(this.previewName, this.duration); diff --git a/lib/presentation/atoms/button_atom.dart b/lib/presentation/atoms/button_atom.dart index 6c6ddc5..9a61706 100644 --- a/lib/presentation/atoms/button_atom.dart +++ b/lib/presentation/atoms/button_atom.dart @@ -23,6 +23,21 @@ class ButtonAtom extends StatelessWidget { final bool translate; final bool disableActionType; + Widget buttonConstraints({required Widget child}) => Container( + constraints: BoxConstraints( + minWidth: width, + ), + height: _height, + child: child, + ); + + Widget label(TextTheme textTheme) => TextAtom( + text ?? '', + translate: translate, + maxLines: 1, + style: textTheme.bodyLarge, + ); + @override Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); @@ -31,11 +46,7 @@ class ButtonAtom extends StatelessWidget { if (variant == ButtonVariant.primary) { if (icon == null) { - return Container( - constraints: BoxConstraints( - minWidth: width, - ), - height: _height, + return buttonConstraints( child: FilledButton( onPressed: onPressed, style: FilledButton.styleFrom().copyWith( @@ -44,20 +55,11 @@ class ButtonAtom extends StatelessWidget { ? MaterialStateProperty.all(colorScheme.outline) : null, ), - child: TextAtom( - text ?? '', - translate: translate, - maxLines: 1, - style: textTheme.bodyLarge, - ), + child: label(textTheme), ), ); } - return Container( - constraints: BoxConstraints( - minWidth: width, - ), - height: _height, + return buttonConstraints( child: FilledButton.icon( onPressed: onPressed, style: FilledButton.styleFrom().copyWith( @@ -67,21 +69,12 @@ class ButtonAtom extends StatelessWidget { : null, ), icon: Icon(icon), - label: TextAtom( - text ?? '', - translate: translate, - maxLines: 1, - style: textTheme.bodyLarge, - ), + label: label(textTheme), ), ); } else if (variant == ButtonVariant.secondary) { if (icon == null) { - return Container( - constraints: BoxConstraints( - minWidth: width, - ), - height: _height, + return buttonConstraints( child: FilledButton.tonal( onPressed: onPressed, style: FilledButton.styleFrom().copyWith( @@ -90,20 +83,11 @@ class ButtonAtom extends StatelessWidget { ? MaterialStateProperty.all(colorScheme.outline) : null, ), - child: TextAtom( - text ?? '', - translate: translate, - maxLines: 1, - style: textTheme.bodyLarge, - ), + child: label(textTheme), ), ); } - return Container( - constraints: BoxConstraints( - minWidth: width, - ), - height: _height, + return buttonConstraints( child: FilledButton.icon( onPressed: onPressed, style: FilledButton.styleFrom().copyWith( @@ -113,20 +97,11 @@ class ButtonAtom extends StatelessWidget { : null, ), icon: Icon(icon), - label: TextAtom( - text ?? '', - translate: translate, - maxLines: 1, - style: textTheme.bodyLarge, - ), + label: label(textTheme), ), ); } else if (variant == ButtonVariant.tertiary) { - return Container( - constraints: BoxConstraints( - minWidth: width, - ), - height: _height, + return buttonConstraints( child: FilledButton.icon( onPressed: onPressed, style: FilledButton.styleFrom().copyWith( @@ -136,12 +111,7 @@ class ButtonAtom extends StatelessWidget { : MaterialStateProperty.all(colorScheme.tertiaryContainer), ), icon: Icon(icon), - label: TextAtom( - text ?? '', - translate: translate, - maxLines: 1, - style: textTheme.bodyLarge, - ), + label: label(textTheme), ), ); } diff --git a/lib/presentation/atoms/list_tile_atom.dart b/lib/presentation/atoms/list_tile_atom.dart index 4ec4cc7..beb557a 100644 --- a/lib/presentation/atoms/list_tile_atom.dart +++ b/lib/presentation/atoms/list_tile_atom.dart @@ -2,17 +2,27 @@ import 'package:flutter/material.dart'; import 'package:infinite_horizons/presentation/atoms/atoms.dart'; class ListTileAtom extends StatelessWidget { - const ListTileAtom(this.title, this.leading, {this.subtitle}); + const ListTileAtom( + this.title, + this.leading, { + this.subtitle, + this.translateTitle = true, + this.translateSubtitle = true, + }); final String title; final String? subtitle; final Widget leading; + final bool translateTitle; + final bool translateSubtitle; @override Widget build(BuildContext context) { return ListTile( - title: TextAtom(title), - subtitle: subtitle == null ? null : TextAtom(subtitle!), + title: TextAtom(title, translate: translateTitle), + subtitle: subtitle == null + ? null + : TextAtom(subtitle!, translate: translateSubtitle), leading: leading, ); } diff --git a/lib/presentation/atoms/progress_indicator_atom.dart b/lib/presentation/atoms/progress_indicator_atom.dart index 1b7bb7a..c1fbf64 100644 --- a/lib/presentation/atoms/progress_indicator_atom.dart +++ b/lib/presentation/atoms/progress_indicator_atom.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; class ProgressIndicatorAtom extends StatefulWidget { const ProgressIndicatorAtom(this.totalDuration, this.callback); - /// In Seconds final Duration totalDuration; final VoidCallback callback; diff --git a/lib/presentation/atoms/separator_atom.dart b/lib/presentation/atoms/separator_atom.dart index b828707..7ee16a2 100644 --- a/lib/presentation/atoms/separator_atom.dart +++ b/lib/presentation/atoms/separator_atom.dart @@ -10,15 +10,15 @@ class SeparatorAtom extends StatelessWidget { Widget build(BuildContext context) { double spacing; switch (variant) { - case SeparatorVariant.extenstionOfElement: + case SeparatorVariant.extensionOfElement: spacing = 2; - case SeparatorVariant.reletedElements: + case SeparatorVariant.relatedElements: spacing = 5; case SeparatorVariant.closeWidgets: spacing = 10; case SeparatorVariant.generalSpacing: spacing = AppThemeData.generalSpacing; - case SeparatorVariant.farAppart: + case SeparatorVariant.farApart: spacing = 45; } return SizedBox( @@ -29,10 +29,10 @@ class SeparatorAtom extends StatelessWidget { } enum SeparatorVariant { - extenstionOfElement, - reletedElements, + extensionOfElement, + relatedElements, closeWidgets, generalSpacing, - farAppart, + farApart, ; } diff --git a/lib/presentation/molecules/energy_selection_molecule.dart b/lib/presentation/molecules/energy_selection_molecule.dart index 7300a77..f8f7b22 100644 --- a/lib/presentation/molecules/energy_selection_molecule.dart +++ b/lib/presentation/molecules/energy_selection_molecule.dart @@ -1,3 +1,4 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:infinite_horizons/domain/study_type_abstract.dart'; import 'package:infinite_horizons/presentation/atoms/atoms.dart'; @@ -29,66 +30,36 @@ class _EnergySelectionMoleculeState extends State { widget.callback(); } + Widget energyWidget(EnergyType type) { + return ListTileAtom( + '${type.previewName.tr()} - ${type.duration.inMinutes}${'minutes_single'.tr()}', + Radio( + value: type, + groupValue: energy, + onChanged: onChanged, + ), + translateTitle: false, + ); + } + @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const TextAtom('Classic Pomodoro:'), + const TextAtom('classic_pomodoro'), const SeparatorAtom(), - ListTileAtom( - '${EnergyType.medium.previewName} - ${EnergyType.medium.duration.inMinutes}m', - Radio( - value: EnergyType.medium, - groupValue: energy, - onChanged: onChanged, - ), - ), - const SeparatorAtom(variant: SeparatorVariant.farAppart), - const TextAtom('Custom:'), + energyWidget(EnergyType.medium), + const SeparatorAtom(variant: SeparatorVariant.farApart), + const TextAtom('custom'), const SeparatorAtom(), Column( children: [ - ListTileAtom( - '${EnergyType.max.previewName} - ${EnergyType.max.duration.inMinutes}m', - Radio( - value: EnergyType.max, - groupValue: energy, - onChanged: onChanged, - ), - ), - ListTileAtom( - '${EnergyType.veryHigh.previewName} - ${EnergyType.veryHigh.duration.inMinutes}m', - Radio( - value: EnergyType.veryHigh, - groupValue: energy, - onChanged: onChanged, - ), - ), - ListTileAtom( - '${EnergyType.high.previewName} - ${EnergyType.high.duration.inMinutes}m', - Radio( - value: EnergyType.high, - groupValue: energy, - onChanged: onChanged, - ), - ), - ListTileAtom( - '${EnergyType.low.previewName} - ${EnergyType.low.duration.inMinutes}m', - Radio( - value: EnergyType.low, - groupValue: energy, - onChanged: onChanged, - ), - ), - ListTileAtom( - '${EnergyType.veryLow.previewName} - ${EnergyType.veryLow.duration.inMinutes}m', - Radio( - value: EnergyType.veryLow, - groupValue: energy, - onChanged: onChanged, - ), - ), + energyWidget(EnergyType.max), + energyWidget(EnergyType.veryHigh), + energyWidget(EnergyType.high), + energyWidget(EnergyType.low), + energyWidget(EnergyType.veryLow), ], ), ], diff --git a/lib/presentation/molecules/study_type_selection_molecule.dart b/lib/presentation/molecules/study_type_selection_molecule.dart index b149ae3..0f1f8d6 100644 --- a/lib/presentation/molecules/study_type_selection_molecule.dart +++ b/lib/presentation/molecules/study_type_selection_molecule.dart @@ -47,7 +47,7 @@ class _StudyTypeSelectionMoleculeState groupValue: selectedType, onChanged: onChanged, ), - subtitle: 'Recommended in the morning', + subtitle: 'recommended_morning', ), ListTileAtom( StudyType.creatively.previewName, @@ -56,7 +56,7 @@ class _StudyTypeSelectionMoleculeState groupValue: selectedType, onChanged: onChanged, ), - subtitle: 'Recommended in the evening', + subtitle: 'recommended_evening', ), ], ); diff --git a/lib/presentation/organisms/intro/motivation_organism.dart b/lib/presentation/organisms/intro/motivation_organism.dart index 122902e..22a8797 100644 --- a/lib/presentation/organisms/intro/motivation_organism.dart +++ b/lib/presentation/organisms/intro/motivation_organism.dart @@ -28,16 +28,15 @@ class MotivationOrganism extends StatelessWidget { case EnergyType.max: text = "So much energy 🔋⚡🔋⚡🔋⚡🔋\nLet's begin"; } - // TODO: Center the elements on the page return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ TextAtom(text), - const SeparatorAtom(variant: SeparatorVariant.farAppart), + const SeparatorAtom(variant: SeparatorVariant.farApart), ButtonAtom( variant: ButtonVariant.primary, onPressed: callback, - text: 'Start', + text: 'start', ), ], ); diff --git a/lib/presentation/organisms/timer_molecule.dart b/lib/presentation/organisms/timer_molecule.dart index 7c5e606..0e4c69c 100644 --- a/lib/presentation/organisms/timer_molecule.dart +++ b/lib/presentation/organisms/timer_molecule.dart @@ -29,13 +29,13 @@ class TimerMolecule extends StatelessWidget { ButtonAtom( variant: ButtonVariant.primary, onPressed: controller.resume, - text: 'Continue', + text: 'continue', ), const SeparatorAtom(), ButtonAtom( variant: ButtonVariant.secondary, onPressed: controller.pause, - text: 'Pause', + text: 'pause', ), ], ), diff --git a/lib/presentation/pages/home_page.dart b/lib/presentation/pages/home_page.dart index 2ca86e1..7a70a4f 100644 --- a/lib/presentation/pages/home_page.dart +++ b/lib/presentation/pages/home_page.dart @@ -57,7 +57,7 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ const TextAtom( - 'Study Timer', + 'study_timer', variant: TextVariant.smallTitle, ), TimerMolecule( @@ -70,7 +70,7 @@ class _HomePageState extends State { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const TextAtom('Get ready for a break'), + const TextAtom('ready_for_break'), ProgressIndicatorAtom(getReadyDuration, onTimerComplete), ], ); @@ -78,7 +78,7 @@ class _HomePageState extends State { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const TextAtom('Take a break'), + const TextAtom('take_break'), TimerMolecule( onTimerComplete, Duration( @@ -93,8 +93,8 @@ class _HomePageState extends State { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const TextAtom('Get ready to study'), - const SeparatorAtom(variant: SeparatorVariant.farAppart), + const TextAtom('ready_study'), + const SeparatorAtom(variant: SeparatorVariant.farApart), const TextAtom('start_with'), ProgressIndicatorAtom(getReadyDuration, onTimerComplete), ], @@ -110,7 +110,7 @@ class _HomePageState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ const TextAtom( - 'Maximize Study Efficiency', + 'study_efficiency', variant: TextVariant.title, ), Expanded( diff --git a/lib/presentation/pages/intro_page.dart b/lib/presentation/pages/intro_page.dart index 94437c0..dfc2a12 100644 --- a/lib/presentation/pages/intro_page.dart +++ b/lib/presentation/pages/intro_page.dart @@ -1,3 +1,4 @@ +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:infinite_horizons/domain/study_type_abstract.dart'; import 'package:infinite_horizons/presentation/core/theme_data.dart'; @@ -35,11 +36,11 @@ class _IntroPageState extends State { key: _introKey, pages: [ PageViewModel( - title: 'Let’s Study Efficiently', + title: 'study_efficiently'.tr(), bodyWidget: WelcomeOrganism(), ), PageViewModel( - title: 'Study Type', + title: 'study_type'.tr(), bodyWidget: StudyTypeSelectionMolecule(() { setState(() { studyType = StudyTypeAbstract.instance!.studyType.previewName; @@ -48,15 +49,15 @@ class _IntroPageState extends State { }), ), PageViewModel( - title: 'Efficient $studyType Tips', + title: 'efficient_tips'.tr(args: [studyType.tr()]), bodyWidget: TipsOrganism(), ), PageViewModel( - title: 'Energy', + title: 'energy'.tr(), bodyWidget: EnergySelectionMolecule(nextPage), ), PageViewModel( - title: 'Let’s Start', + title: 'lets_start'.tr(), bodyWidget: MotivationOrganism(() => onDone(context)), ), ],