From f7ab29049899f3329fc2ac223dbb777efc203573 Mon Sep 17 00:00:00 2001 From: Merlin Dienst Date: Wed, 18 Dec 2024 21:32:55 +0100 Subject: [PATCH] added translations, finalized functionality --- lib/features/diary/diary_page.dart | 25 ++++--- .../presentation/widgets/day_info_widget.dart | 9 ++- lib/generated/intl/messages_de.dart | 9 +++ lib/generated/intl/messages_en.dart | 9 +++ lib/generated/intl/messages_tr.dart | 9 +++ lib/generated/l10n.dart | 65 +++++++++---------- lib/l10n/intl_de.arb | 7 ++ lib/l10n/intl_en.arb | 7 ++ lib/l10n/intl_tr.arb | 7 ++ 9 files changed, 95 insertions(+), 52 deletions(-) diff --git a/lib/features/diary/diary_page.dart b/lib/features/diary/diary_page.dart index f0c2924..0fb66fa 100644 --- a/lib/features/diary/diary_page.dart +++ b/lib/features/diary/diary_page.dart @@ -5,6 +5,7 @@ import 'package:opennutritracker/core/domain/entity/intake_entity.dart'; import 'package:opennutritracker/core/domain/entity/tracked_day_entity.dart'; import 'package:opennutritracker/core/domain/entity/user_activity_entity.dart'; import 'package:opennutritracker/core/utils/locator.dart'; +import 'package:opennutritracker/features/add_meal/presentation/add_meal_type.dart'; import 'package:opennutritracker/features/diary/presentation/bloc/calendar_day_bloc.dart'; import 'package:opennutritracker/features/diary/presentation/bloc/diary_bloc.dart'; import 'package:opennutritracker/features/diary/presentation/widgets/diary_table_calendar.dart'; @@ -77,8 +78,8 @@ class _DiaryPageState extends State with WidgetsBindingObserver { Widget _getLoadingContent() => const Center(child: CircularProgressIndicator()); - Widget _getLoadedContent(BuildContext context, - Map trackedDaysMap) { + Widget _getLoadedContent( + BuildContext context, Map trackedDaysMap) { return ListView( children: [ DiaryTableCalendar( @@ -119,8 +120,8 @@ class _DiaryPageState extends State with WidgetsBindingObserver { ); } - void _onDeleteIntakeItem(IntakeEntity intakeEntity, - TrackedDayEntity? trackedDayEntity) async { + void _onDeleteIntakeItem( + IntakeEntity intakeEntity, TrackedDayEntity? trackedDayEntity) async { await _calendarDayBloc.deleteIntakeItem( context, intakeEntity, trackedDayEntity?.day ?? DateTime.now()); _diaryBloc.add(const LoadDiaryYearEvent()); @@ -128,9 +129,7 @@ class _DiaryPageState extends State with WidgetsBindingObserver { _diaryBloc.updateHomePage(); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(S - .of(context) - .itemDeletedSnackbar))); + SnackBar(content: Text(S.of(context).itemDeletedSnackbar))); } } @@ -143,19 +142,17 @@ class _DiaryPageState extends State with WidgetsBindingObserver { _diaryBloc.updateHomePage(); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(S - .of(context) - .itemDeletedSnackbar))); + SnackBar(content: Text(S.of(context).itemDeletedSnackbar))); } } void _onCopyIntakeItem(IntakeEntity intakeEntity, - TrackedDayEntity? trackedDayEntity, IntakeTypeEntity? type) async { + TrackedDayEntity? trackedDayEntity, AddMealType? type) async { IntakeTypeEntity finalType; if (type == null) { finalType = intakeEntity.type; } else { - finalType = type; + finalType = type.getIntakeType(); } _mealDetailBloc.addIntake( context, @@ -172,8 +169,8 @@ class _DiaryPageState extends State with WidgetsBindingObserver { log.info("Should copy activity"); } - void _onDateSelected(DateTime newDate, - Map trackedDaysMap) { + void _onDateSelected( + DateTime newDate, Map trackedDaysMap) { setState(() { _selectedDate = newDate; _focusedDate = newDate; diff --git a/lib/features/diary/presentation/widgets/day_info_widget.dart b/lib/features/diary/presentation/widgets/day_info_widget.dart index faf75de..20f0db1 100644 --- a/lib/features/diary/presentation/widgets/day_info_widget.dart +++ b/lib/features/diary/presentation/widgets/day_info_widget.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:opennutritracker/core/domain/entity/intake_entity.dart'; -import 'package:opennutritracker/core/domain/entity/intake_type_entity.dart'; import 'package:opennutritracker/core/domain/entity/tracked_day_entity.dart'; import 'package:opennutritracker/core/domain/entity/user_activity_entity.dart'; import 'package:opennutritracker/core/presentation/widgets/activity_vertial_list.dart'; @@ -27,7 +26,7 @@ class DayInfoWidget extends StatelessWidget { final Function(UserActivityEntity userActivityEntity, TrackedDayEntity? trackedDayEntity) onDeleteActivity; final Function(IntakeEntity intake, TrackedDayEntity? trackedDayEntity, - IntakeTypeEntity? type) onCopyIntake; + AddMealType? type) onCopyIntake; final Function(UserActivityEntity userActivityEntity, TrackedDayEntity? trackedDayEntity) onCopyActivity; @@ -197,10 +196,10 @@ class DayInfoWidget extends StatelessWidget { void showCopyDialog(BuildContext context, IntakeEntity intakeEntity) async { const copyDialog = CopyDialog(); - final shouldCopyIntake = await showDialog( + final selectedMealType = await showDialog( context: context, builder: (context) => copyDialog); - if (shouldCopyIntake != null) { - onCopyIntake(intakeEntity, null, null); + if (selectedMealType != null) { + onCopyIntake(intakeEntity, null, selectedMealType); } } diff --git a/lib/generated/intl/messages_de.dart b/lib/generated/intl/messages_de.dart index 73f2111..f553d2b 100644 --- a/lib/generated/intl/messages_de.dart +++ b/lib/generated/intl/messages_de.dart @@ -84,6 +84,12 @@ class MessageLookup extends MessageLookupByLibrary { "chooseWeightGoalLabel": MessageLookupByLibrary.simpleMessage("Gewichtsziel wählen"), "cmLabel": MessageLookupByLibrary.simpleMessage("cm"), + "copyDialogTitle": MessageLookupByLibrary.simpleMessage( + "Zu welcher Mahlzeit hinzufügen?"), + "copyOrDeleteTimeDialogContent": MessageLookupByLibrary.simpleMessage( + "Auf \"Nach heute kopieren\" klicken, um die Mahlzeit nach heute zu kopieren. Mit \"Löschen\" kann die Mahlzeit entfernt werden"), + "copyOrDeleteTimeDialogTitle": + MessageLookupByLibrary.simpleMessage("Was soll getan werden?"), "createCustomDialogContent": MessageLookupByLibrary.simpleMessage( "Möchten Sie einen benutzerdefinierte Mahlzeit erstellen?"), "createCustomDialogTitle": MessageLookupByLibrary.simpleMessage( @@ -95,6 +101,9 @@ class MessageLookup extends MessageLookupByLibrary { "deleteTimeDialogTitle": MessageLookupByLibrary.simpleMessage("Eintrag löschen?"), "dialogCancelLabel": MessageLookupByLibrary.simpleMessage("ABBRECHEN"), + "dialogCopyLabel": + MessageLookupByLibrary.simpleMessage("NACH HEUTE KOPIEREN"), + "dialogDeleteLabel": MessageLookupByLibrary.simpleMessage("LÖSCHEN"), "dialogOKLabel": MessageLookupByLibrary.simpleMessage("OK"), "diaryLabel": MessageLookupByLibrary.simpleMessage("Tagebuch"), "dinnerExample": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index 6867887..547be12 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -84,6 +84,12 @@ class MessageLookup extends MessageLookupByLibrary { "chooseWeightGoalLabel": MessageLookupByLibrary.simpleMessage("Choose Weight Goal"), "cmLabel": MessageLookupByLibrary.simpleMessage("cm"), + "copyDialogTitle": MessageLookupByLibrary.simpleMessage( + "Which meal type di you want to copy to?"), + "copyOrDeleteTimeDialogContent": MessageLookupByLibrary.simpleMessage( + "With \"Copy to today\" you can copy the meal to today. With \"Delete\" you can delete the meal."), + "copyOrDeleteTimeDialogTitle": + MessageLookupByLibrary.simpleMessage("What do you want to do?"), "createCustomDialogContent": MessageLookupByLibrary.simpleMessage( "Do you want create a custom meal item?"), "createCustomDialogTitle": @@ -95,6 +101,9 @@ class MessageLookup extends MessageLookupByLibrary { "deleteTimeDialogTitle": MessageLookupByLibrary.simpleMessage("Delete Item?"), "dialogCancelLabel": MessageLookupByLibrary.simpleMessage("CANCEL"), + "dialogCopyLabel": + MessageLookupByLibrary.simpleMessage("COPY TO TODAY"), + "dialogDeleteLabel": MessageLookupByLibrary.simpleMessage("DELETE"), "dialogOKLabel": MessageLookupByLibrary.simpleMessage("OK"), "diaryLabel": MessageLookupByLibrary.simpleMessage("Diary"), "dinnerExample": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/intl/messages_tr.dart b/lib/generated/intl/messages_tr.dart index 9d56d44..c4ffea4 100644 --- a/lib/generated/intl/messages_tr.dart +++ b/lib/generated/intl/messages_tr.dart @@ -82,6 +82,12 @@ class MessageLookup extends MessageLookupByLibrary { "chooseWeightGoalLabel": MessageLookupByLibrary.simpleMessage("Kilo Hedefi Seçin"), "cmLabel": MessageLookupByLibrary.simpleMessage("cm"), + "copyDialogTitle": MessageLookupByLibrary.simpleMessage( + "Hangi öğüne eklemek istiyorsunuz?"), + "copyOrDeleteTimeDialogContent": MessageLookupByLibrary.simpleMessage( + "\"Bugüne kopyala\" seçeneğine tıklayarak öğünü bugüne kopyalayabilirsiniz. \"Sil\" seçeneği ile öğün kaldırılabilir."), + "copyOrDeleteTimeDialogTitle": + MessageLookupByLibrary.simpleMessage("Ne yapılmalı?"), "createCustomDialogContent": MessageLookupByLibrary.simpleMessage( "Özel bir yemek öğesi oluşturmak istiyor musunuz?"), "createCustomDialogTitle": MessageLookupByLibrary.simpleMessage( @@ -93,6 +99,9 @@ class MessageLookup extends MessageLookupByLibrary { "deleteTimeDialogTitle": MessageLookupByLibrary.simpleMessage("Öğe Silinsin mi?"), "dialogCancelLabel": MessageLookupByLibrary.simpleMessage("İPTAL"), + "dialogCopyLabel": + MessageLookupByLibrary.simpleMessage("BUGÜNE KOPYALA"), + "dialogDeleteLabel": MessageLookupByLibrary.simpleMessage("SİL"), "dialogOKLabel": MessageLookupByLibrary.simpleMessage("TAMAM"), "diaryLabel": MessageLookupByLibrary.simpleMessage("Günlük"), "dinnerExample": MessageLookupByLibrary.simpleMessage( diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 5035153..dff2065 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -891,82 +891,81 @@ class S { ); } - /// `Select meal to copy to` - String get copyDialogTitle { + /// `Delete Item?` + String get deleteTimeDialogTitle { return Intl.message( - 'Select meal to copy to', - name: 'copyDialogTitle', + 'Delete Item?', + name: 'deleteTimeDialogTitle', desc: '', args: [], ); } - - /// `What do you want to do?` - String get copyOrDeleteTimeDialogTitle { + /// `Do want to delete the selected item?` + String get deleteTimeDialogContent { return Intl.message( - 'What do you want to do?', - name: 'copyOrDeleteTimeDialogTitle', + 'Do want to delete the selected item?', + name: 'deleteTimeDialogContent', desc: '', args: [], ); } - /// `Click "Copy to today" to copy the content to the current day or click "Delete" to delete the item.` - String get copyOrDeleteTimeDialogContent { + /// `Item deleted` + String get itemDeletedSnackbar { return Intl.message( - 'Click "Copy to today" to copy the content to the current day or click "Delete" to delete the item.', - name: 'copyOrDeleteTimeDialogContent', + 'Item deleted', + name: 'itemDeletedSnackbar', desc: '', args: [], ); } - /// `COPY TO TODAY` - String get dialogCopyLabel { + /// `Which meal type di you want to copy to?` + String get copyDialogTitle { return Intl.message( - 'COPY TO TODAY', - name: 'dialogCopyLabel', + 'Which meal type di you want to copy to?', + name: 'copyDialogTitle', desc: '', args: [], ); } - /// `DELETE` - String get dialogDeleteLabel { + /// `What do you want to do?` + String get copyOrDeleteTimeDialogTitle { return Intl.message( - 'DELETE', - name: 'dialogDeleteLabel', + 'What do you want to do?', + name: 'copyOrDeleteTimeDialogTitle', desc: '', args: [], ); } - /// `Delete Item?` - String get deleteTimeDialogTitle { + /// `With "Copy to today" you can copy the meal to today. With "Delete" you can delete the meal.` + String get copyOrDeleteTimeDialogContent { return Intl.message( - 'Delete Item?', - name: 'deleteTimeDialogTitle', + 'With "Copy to today" you can copy the meal to today. With "Delete" you can delete the meal.', + name: 'copyOrDeleteTimeDialogContent', desc: '', args: [], ); } - /// `Do want to delete the selected item?` - String get deleteTimeDialogContent { + /// `COPY TO TODAY` + String get dialogCopyLabel { return Intl.message( - 'Do want to delete the selected item?', - name: 'deleteTimeDialogContent', + 'COPY TO TODAY', + name: 'dialogCopyLabel', desc: '', args: [], ); } - /// `Item deleted` - String get itemDeletedSnackbar { + /// `DELETE` + String get dialogDeleteLabel { return Intl.message( - 'Item deleted', - name: 'itemDeletedSnackbar', + 'DELETE', + name: 'dialogDeleteLabel', desc: '', args: [], ); diff --git a/lib/l10n/intl_de.arb b/lib/l10n/intl_de.arb index ac1bb05..e4f21bb 100644 --- a/lib/l10n/intl_de.arb +++ b/lib/l10n/intl_de.arb @@ -94,6 +94,13 @@ "deleteTimeDialogContent": "Möchten Sie den ausgewählten Eintrag löschen?", "itemDeletedSnackbar": "Eintrag gelöscht", + "copyDialogTitle": "Zu welcher Mahlzeit hinzufügen?", + + "copyOrDeleteTimeDialogTitle": "Was soll getan werden?", + "copyOrDeleteTimeDialogContent": "Auf \"Nach heute kopieren\" klicken, um die Mahlzeit nach heute zu kopieren. Mit \"Löschen\" kann die Mahlzeit entfernt werden", + "dialogCopyLabel": "NACH HEUTE KOPIEREN", + "dialogDeleteLabel": "LÖSCHEN", + "suppliedLabel": "zugeführt", "burnedLabel": "verbrannt", "kcalLeftLabel": "kcal übrig", diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 477e40d..a6cb207 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -94,6 +94,13 @@ "deleteTimeDialogContent": "Do want to delete the selected item?", "itemDeletedSnackbar": "Item deleted", + "copyDialogTitle": "Which meal type di you want to copy to?", + + "copyOrDeleteTimeDialogTitle": "What do you want to do?", + "copyOrDeleteTimeDialogContent": "With \"Copy to today\" you can copy the meal to today. With \"Delete\" you can delete the meal.", + "dialogCopyLabel": "COPY TO TODAY", + "dialogDeleteLabel": "DELETE", + "suppliedLabel": "supplied", "burnedLabel": "burned", "kcalLeftLabel": "kcal left", diff --git a/lib/l10n/intl_tr.arb b/lib/l10n/intl_tr.arb index b897435..9f82e44 100644 --- a/lib/l10n/intl_tr.arb +++ b/lib/l10n/intl_tr.arb @@ -94,6 +94,13 @@ "deleteTimeDialogContent": "Seçili öğeyi silmek istiyor musunuz?", "itemDeletedSnackbar": "Öğe silindi", + "copyDialogTitle": "Hangi öğüne eklemek istiyorsunuz?", + + "copyOrDeleteTimeDialogTitle": "Ne yapılmalı?", + "copyOrDeleteTimeDialogContent": "\"Bugüne kopyala\" seçeneğine tıklayarak öğünü bugüne kopyalayabilirsiniz. \"Sil\" seçeneği ile öğün kaldırılabilir.", + "dialogCopyLabel": "BUGÜNE KOPYALA", + "dialogDeleteLabel": "SİL", + "suppliedLabel": "alınan", "burnedLabel": "yakılan", "kcalLeftLabel": "kalan kalori",