Skip to content

Commit

Permalink
added translations, finalized functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
doktormerlin committed Dec 18, 2024
1 parent b156393 commit f7ab290
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 52 deletions.
25 changes: 11 additions & 14 deletions lib/features/diary/diary_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -77,8 +78,8 @@ class _DiaryPageState extends State<DiaryPage> with WidgetsBindingObserver {
Widget _getLoadingContent() =>
const Center(child: CircularProgressIndicator());

Widget _getLoadedContent(BuildContext context,
Map<String, TrackedDayEntity> trackedDaysMap) {
Widget _getLoadedContent(
BuildContext context, Map<String, TrackedDayEntity> trackedDaysMap) {
return ListView(
children: [
DiaryTableCalendar(
Expand Down Expand Up @@ -119,18 +120,16 @@ class _DiaryPageState extends State<DiaryPage> 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());
_calendarDayBloc.add(LoadCalendarDayEvent(_selectedDate));
_diaryBloc.updateHomePage();
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(S
.of(context)
.itemDeletedSnackbar)));
SnackBar(content: Text(S.of(context).itemDeletedSnackbar)));
}
}

Expand All @@ -143,19 +142,17 @@ class _DiaryPageState extends State<DiaryPage> 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,
Expand All @@ -172,8 +169,8 @@ class _DiaryPageState extends State<DiaryPage> with WidgetsBindingObserver {
log.info("Should copy activity");
}

void _onDateSelected(DateTime newDate,
Map<String, TrackedDayEntity> trackedDaysMap) {
void _onDateSelected(
DateTime newDate, Map<String, TrackedDayEntity> trackedDaysMap) {
setState(() {
_selectedDate = newDate;
_focusedDate = newDate;
Expand Down
9 changes: 4 additions & 5 deletions lib/features/diary/presentation/widgets/day_info_widget.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -197,10 +196,10 @@ class DayInfoWidget extends StatelessWidget {

void showCopyDialog(BuildContext context, IntakeEntity intakeEntity) async {
const copyDialog = CopyDialog();
final shouldCopyIntake = await showDialog<bool>(
final selectedMealType = await showDialog<AddMealType>(
context: context, builder: (context) => copyDialog);
if (shouldCopyIntake != null) {
onCopyIntake(intakeEntity, null, null);
if (selectedMealType != null) {
onCopyIntake(intakeEntity, null, selectedMealType);
}
}

Expand Down
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_tr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
65 changes: 32 additions & 33 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions lib/l10n/intl_tr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f7ab290

Please sign in to comment.