From efe58eeea9c71c812a005ffde428fd4958df02b9 Mon Sep 17 00:00:00 2001 From: Kima Date: Sun, 15 Oct 2023 13:46:58 +0200 Subject: [PATCH] added clear goal button to goal planning --- .../lib/pages/absences/absences_page.dart | 5 +-- .../goal_planner/goal_state_screen.dart | 34 +++++++++++++++++-- .../goal_planner/goal_state_screen.i18n.dart | 15 ++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/filcnaplo_mobile_ui/lib/pages/absences/absences_page.dart b/filcnaplo_mobile_ui/lib/pages/absences/absences_page.dart index 81e8b5b..43e6518 100755 --- a/filcnaplo_mobile_ui/lib/pages/absences/absences_page.dart +++ b/filcnaplo_mobile_ui/lib/pages/absences/absences_page.dart @@ -285,8 +285,9 @@ class _AbsencesPageState extends State content: Text("attention_body".i18n), actions: [ ActionButton( - label: "Ok", - onTap: () => Navigator.of(context).pop()) + label: "Ok", + onTap: () => Navigator.of(context).pop(), + ), ], ), ); diff --git a/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.dart b/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.dart index 39123ed..ba577c8 100644 --- a/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.dart +++ b/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.dart @@ -6,10 +6,12 @@ import 'package:filcnaplo/models/settings.dart'; import 'package:filcnaplo_kreta_api/models/grade.dart'; import 'package:filcnaplo_kreta_api/models/subject.dart'; import 'package:filcnaplo_kreta_api/providers/grade_provider.dart'; +import 'package:filcnaplo_mobile_ui/common/action_button.dart'; import 'package:filcnaplo_mobile_ui/common/average_display.dart'; import 'package:filcnaplo_mobile_ui/common/panel/panel.dart'; import 'package:filcnaplo_mobile_ui/common/progress_bar.dart'; import 'package:filcnaplo_mobile_ui/common/round_border_icon.dart'; +import 'package:filcnaplo_premium/providers/goal_provider.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_planner.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/goal_state_screen.i18n.dart'; import 'package:filcnaplo_premium/ui/mobile/goal_planner/route_option.dart'; @@ -199,11 +201,39 @@ class _GoalStateScreenState extends State { ), child: Column( children: [ - const Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - BackButton(), + const BackButton(), + IconButton( + onPressed: () { + showDialog( + context: context, + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.0)), + title: Text("attention".i18n), + content: Text("attention_body".i18n), + actions: [ + ActionButton( + label: "delete".i18n, + onTap: () async { + // clear the goal + await Provider.of(context, + listen: false) + .clearGoal(widget.subject); + // close the modal and the goal page + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }, + ), + ], + ), + ); + }, + icon: const Icon(FeatherIcons.x), + ), ], ), const SizedBox(height: 22.0), diff --git a/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.i18n.dart b/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.i18n.dart index 6999dc8..19c56ed 100644 --- a/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.i18n.dart +++ b/filcnaplo_premium/lib/ui/mobile/goal_planner/goal_state_screen.i18n.dart @@ -22,6 +22,11 @@ extension Localization on String { "improved_by": "and improved your grade by %s", "detailed_stats": "See my detailed stats", "later": "Yay! I'll see my stats later.", + // sure delete modal + "delete": "Delete", + "attention": "Attention!", + "attention_body": + "Your goal and progress will be lost forever and cannot be restored.", }, "hu_hu": { // base page @@ -42,6 +47,11 @@ extension Localization on String { "improved_by": "%s-os javulást értél el!", "detailed_stats": "Részletes statisztikám", "later": "Hurrá! Megnézem máskor.", + // sure delete modal + "delete": "Törlés", + "attention": "Figyelem!", + "attention_body": + "A kitűzött célod és haladásod örökre elveszik és nem lesz visszaállítható.", }, "de_de": { // base page @@ -62,6 +72,11 @@ extension Localization on String { "improved_by": "Sie haben %s Verbesserung erreicht!", "detailed_stats": "Detaillierte Statistiken", "later": "Hurra! Ich schaue später nach.", + // sure delete modal + "delete": "Löschen", + "attention": "Achtung!", + "attention_body": + "Ihr Ziel und Ihr Fortschritt gehen für immer verloren und können nicht wiederhergestellt werden.", }, };