small bug fixes
This commit is contained in:
+223
-83
@@ -6,6 +6,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace cfs_tracker.ViewModels;
|
||||
|
||||
@@ -14,6 +15,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
private readonly HealthEntryRepository _healthEntryRepository;
|
||||
private readonly AppearanceRepository _appearanceRepository;
|
||||
private readonly AppearanceService _appearanceService;
|
||||
private readonly LocalizationService _localizationService;
|
||||
private readonly ActivityRepository _activityRepository;
|
||||
private readonly SymptomRepository _symptomRepository;
|
||||
private readonly NotificationScheduleRepository _notificationScheduleRepository;
|
||||
@@ -64,8 +66,15 @@ public partial class OptionsViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool isExportSymptomFilterExpanded;
|
||||
|
||||
[ObservableProperty]
|
||||
private LanguageOptionItemViewModel? selectedLanguageOption;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool requiresShellReload;
|
||||
|
||||
public ObservableCollection<AppearanceColorItemViewModel> AppearanceColors { get; } = new();
|
||||
public ObservableCollection<AppearanceTextItemViewModel> StatusTexts { get; } = new();
|
||||
public ObservableCollection<LanguageOptionItemViewModel> LanguageOptions { get; } = new();
|
||||
public ObservableCollection<ActivityManageItemViewModel> Activities { get; } = new();
|
||||
public ObservableCollection<SymptomManageItemViewModel> Symptoms { get; } = new();
|
||||
public ObservableCollection<NotificationScheduleItemViewModel> NotificationSchedules { get; } = new();
|
||||
@@ -78,7 +87,18 @@ public partial class OptionsViewModel : ObservableObject
|
||||
public bool IsExportTabSelected => SelectedTab == OptionsTab.Export;
|
||||
public bool IsLegalTabSelected => SelectedTab == OptionsTab.Legal;
|
||||
|
||||
public string NotificationVibrationButtonText => NotificationVibrationEnabled ? "Aktiv" : "Inaktiv";
|
||||
public string NotificationVibrationButtonText => NotificationVibrationEnabled
|
||||
? LocalizationService.Translate("Common_Active")
|
||||
: LocalizationService.Translate("Common_Inactive");
|
||||
|
||||
public string CurrentDatabasePathText => LocalizationService.Format("Options_Database_CurrentPathFormat", CurrentDatabasePath);
|
||||
|
||||
public string SelectedLanguageDescription => SelectedLanguageOption?.Code == LocalizationService.SystemLanguageCode
|
||||
? LocalizationService.Format("Options_Language_SystemHint", _localizationService.GetSystemLanguageDisplayName())
|
||||
: LocalizationService.Format(
|
||||
"Options_Language_SelectedHint",
|
||||
SelectedLanguageOption?.DisplayName ?? _localizationService.GetLanguageDisplayName(_localizationService.SelectedLanguageCode));
|
||||
|
||||
public bool IsDayViewExportLayoutSelected => SelectedExportLayout == ExportLayout.DayView;
|
||||
public bool IsWeekBlockExportLayoutSelected => SelectedExportLayout == ExportLayout.WeekBlock;
|
||||
public bool IsDaySummaryExportLayoutSelected => SelectedExportLayout == ExportLayout.DaySummary;
|
||||
@@ -92,16 +112,16 @@ public partial class OptionsViewModel : ObservableObject
|
||||
var totalDays = (end - start).Days + 1;
|
||||
|
||||
return totalDays == 1
|
||||
? $"1 Tag ausgewählt: {start:dd.MM.yyyy}"
|
||||
: $"{totalDays} Tage ausgewählt: {start:dd.MM.yyyy} bis {end:dd.MM.yyyy}";
|
||||
? LocalizationService.Format("Options_Export_RangeSingleFormat", FormatShortDate(start))
|
||||
: LocalizationService.Format("Options_Export_RangeMultipleFormat", totalDays, FormatShortDate(start), FormatShortDate(end));
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedExportLayoutDescription => SelectedExportLayout switch
|
||||
{
|
||||
ExportLayout.DayView => "Tagesansicht: Jeder Tag wird mit allen einzelnen Einträgen, Tätigkeiten, Dauer und Symptomen exportiert.",
|
||||
ExportLayout.WeekBlock => "Wochenblock: Pro Tag werden Vormittag und Nachmittag mit Status, T\u00e4tigkeiten, Gesamtdauer und Symptomen dargestellt.",
|
||||
_ => "Tageszusammenfassung: Jeder Tag erscheint kompakt in einer Zeile, ähnlich wie bei Monats- und Jahresexporten."
|
||||
ExportLayout.DayView => LocalizationService.Translate("Options_Export_LayoutDescription_DayView"),
|
||||
ExportLayout.WeekBlock => LocalizationService.Translate("Options_Export_LayoutDescription_WeekBlock"),
|
||||
_ => LocalizationService.Translate("Options_Export_LayoutDescription_DaySummary")
|
||||
};
|
||||
|
||||
public string ExportFilterSummary
|
||||
@@ -111,7 +131,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
var parts = new List<string>();
|
||||
|
||||
if (SelectedExportActivity?.Id is int)
|
||||
parts.Add($"T\u00e4tigkeit: {SelectedExportActivity.Name}");
|
||||
parts.Add(LocalizationService.Format("Options_Export_Filter_ActivityFormat", SelectedExportActivity.Name));
|
||||
|
||||
var selectedSymptoms = ExportSymptoms
|
||||
.Where(x => x.IsSelected)
|
||||
@@ -120,11 +140,11 @@ public partial class OptionsViewModel : ObservableObject
|
||||
.ToList();
|
||||
|
||||
if (selectedSymptoms.Count > 0)
|
||||
parts.Add($"Symptome: {string.Join(", ", selectedSymptoms)}");
|
||||
parts.Add(LocalizationService.Format("Options_Export_Filter_SymptomsFormat", string.Join(", ", selectedSymptoms)));
|
||||
|
||||
return parts.Count > 0
|
||||
? string.Join(" | ", parts)
|
||||
: "Keine Filter aktiv.";
|
||||
: LocalizationService.Translate("Options_Export_Filter_None");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,13 +153,14 @@ public partial class OptionsViewModel : ObservableObject
|
||||
get
|
||||
{
|
||||
var selectedCount = ExportSymptoms.Count(x => x.IsSelected);
|
||||
var countSuffix = selectedCount > 0
|
||||
? $" ({selectedCount} ausgewählt)"
|
||||
: string.Empty;
|
||||
|
||||
return IsExportSymptomFilterExpanded
|
||||
? $"Symptome ausblenden{countSuffix}"
|
||||
: $"Symptome auswählen{countSuffix}";
|
||||
return (IsExportSymptomFilterExpanded, selectedCount > 0) switch
|
||||
{
|
||||
(true, true) => LocalizationService.Format("Options_Export_SymptomsHideWithCount", selectedCount),
|
||||
(true, false) => LocalizationService.Translate("Options_Export_SymptomsHide"),
|
||||
(false, true) => LocalizationService.Format("Options_Export_SymptomsSelectWithCount", selectedCount),
|
||||
_ => LocalizationService.Translate("Options_Export_SymptomsSelect")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,6 +197,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
HealthEntryRepository healthEntryRepository,
|
||||
AppearanceRepository appearanceRepository,
|
||||
AppearanceService appearanceService,
|
||||
LocalizationService localizationService,
|
||||
ActivityRepository activityRepository,
|
||||
SymptomRepository symptomRepository,
|
||||
NotificationScheduleRepository notificationScheduleRepository,
|
||||
@@ -187,6 +209,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
_healthEntryRepository = healthEntryRepository;
|
||||
_appearanceRepository = appearanceRepository;
|
||||
_appearanceService = appearanceService;
|
||||
_localizationService = localizationService;
|
||||
_activityRepository = activityRepository;
|
||||
_symptomRepository = symptomRepository;
|
||||
_notificationScheduleRepository = notificationScheduleRepository;
|
||||
@@ -250,6 +273,16 @@ public partial class OptionsViewModel : ObservableObject
|
||||
OnPropertyChanged(nameof(NotificationVibrationButtonText));
|
||||
}
|
||||
|
||||
partial void OnCurrentDatabasePathChanged(string value)
|
||||
{
|
||||
OnPropertyChanged(nameof(CurrentDatabasePathText));
|
||||
}
|
||||
|
||||
partial void OnSelectedLanguageOptionChanged(LanguageOptionItemViewModel? value)
|
||||
{
|
||||
OnPropertyChanged(nameof(SelectedLanguageDescription));
|
||||
}
|
||||
|
||||
partial void OnExportStartDateChanged(DateTime value)
|
||||
{
|
||||
if (ExportEndDate.Date < value.Date)
|
||||
@@ -287,6 +320,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
await LoadAppearanceAsync();
|
||||
LoadLanguageOptions();
|
||||
await LoadActivitiesAsync();
|
||||
await LoadSymptomsAsync();
|
||||
await LoadSchedulesAsync();
|
||||
@@ -296,16 +330,22 @@ public partial class OptionsViewModel : ObservableObject
|
||||
ExternalDatabasePath = _databaseLocationService.ExternalDatabasePath;
|
||||
CurrentDatabasePath = _appDatabase.CurrentPath;
|
||||
StatusText = string.Empty;
|
||||
RequiresShellReload = false;
|
||||
}
|
||||
|
||||
public void ClearShellReloadFlag()
|
||||
{
|
||||
RequiresShellReload = false;
|
||||
}
|
||||
|
||||
private bool CanDeleteAllData() =>
|
||||
string.Equals(DeleteConfirmationText?.Trim(), "löschen", StringComparison.OrdinalIgnoreCase);
|
||||
LocalizationService.IsKnownTranslation("Options_Data_DeleteConfirmationKeyword", DeleteConfirmationText);
|
||||
|
||||
private async Task DeleteAllDataAsync()
|
||||
{
|
||||
await _healthEntryRepository.DeleteAllAsync();
|
||||
DeleteConfirmationText = string.Empty;
|
||||
StatusText = "Alle Einträge wurden gelöscht.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_AllDataDeleted");
|
||||
}
|
||||
|
||||
private async Task LoadAppearanceAsync()
|
||||
@@ -315,39 +355,39 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
var map = await _appearanceRepository.GetMapAsync();
|
||||
|
||||
AddColor(AppearanceKeys.AppBackground, "App-Hintergrund");
|
||||
AddColor(AppearanceKeys.SurfaceBackground, "Karten-Hintergrund");
|
||||
AddColor(AppearanceKeys.SurfaceBackgroundAlt, "Sekundäre Fläche");
|
||||
AddColor(AppearanceKeys.Border, "Rahmen");
|
||||
AddColor(AppearanceKeys.TextPrimary, "Haupttext");
|
||||
AddColor(AppearanceKeys.TextMuted, "Nebentext");
|
||||
AddColor(AppearanceKeys.AppBackground);
|
||||
AddColor(AppearanceKeys.SurfaceBackground);
|
||||
AddColor(AppearanceKeys.SurfaceBackgroundAlt);
|
||||
AddColor(AppearanceKeys.Border);
|
||||
AddColor(AppearanceKeys.TextPrimary);
|
||||
AddColor(AppearanceKeys.TextMuted);
|
||||
|
||||
AddColor(AppearanceKeys.StateGreen, "Statusfarbe Grün");
|
||||
AddColor(AppearanceKeys.StateYellow, "Statusfarbe Gelb");
|
||||
AddColor(AppearanceKeys.StateRed, "Statusfarbe Rot");
|
||||
AddColor(AppearanceKeys.StateGray, "Statusfarbe Schwarz / Grau");
|
||||
AddColor(AppearanceKeys.StateGreen);
|
||||
AddColor(AppearanceKeys.StateYellow);
|
||||
AddColor(AppearanceKeys.StateRed);
|
||||
AddColor(AppearanceKeys.StateGray);
|
||||
|
||||
AddColor(AppearanceKeys.ButtonPrimaryBackground, "Button Primär Hintergrund");
|
||||
AddColor(AppearanceKeys.ButtonPrimaryText, "Button Primär Text");
|
||||
AddColor(AppearanceKeys.ButtonSecondaryBackground, "Button Sekundär Hintergrund");
|
||||
AddColor(AppearanceKeys.ButtonSecondaryText, "Button Sekundär Text");
|
||||
AddColor(AppearanceKeys.ButtonPrimaryBackground);
|
||||
AddColor(AppearanceKeys.ButtonPrimaryText);
|
||||
AddColor(AppearanceKeys.ButtonSecondaryBackground);
|
||||
AddColor(AppearanceKeys.ButtonSecondaryText);
|
||||
|
||||
AddColor(AppearanceKeys.ShellBackground, "App-Leiste Hintergrund");
|
||||
AddColor(AppearanceKeys.ShellForeground, "App-Leiste Vordergrund");
|
||||
AddColor(AppearanceKeys.ShellTitle, "App-Leiste Titel");
|
||||
AddColor(AppearanceKeys.ShellUnselected, "App-Leiste Inaktiv");
|
||||
AddColor(AppearanceKeys.ShellBackground);
|
||||
AddColor(AppearanceKeys.ShellForeground);
|
||||
AddColor(AppearanceKeys.ShellTitle);
|
||||
AddColor(AppearanceKeys.ShellUnselected);
|
||||
|
||||
AddColor(AppearanceKeys.TabBarBackground, "Tableiste Hintergrund");
|
||||
AddColor(AppearanceKeys.TabBarForeground, "Tableiste Aktiv");
|
||||
AddColor(AppearanceKeys.TabBarTitle, "Tableiste Titel");
|
||||
AddColor(AppearanceKeys.TabBarUnselected, "Tableiste Inaktiv");
|
||||
AddColor(AppearanceKeys.TabBarBackground);
|
||||
AddColor(AppearanceKeys.TabBarForeground);
|
||||
AddColor(AppearanceKeys.TabBarTitle);
|
||||
AddColor(AppearanceKeys.TabBarUnselected);
|
||||
|
||||
AddText(AppearanceKeys.StatusGreenText, "Text für Grün");
|
||||
AddText(AppearanceKeys.StatusYellowText, "Text für Gelb");
|
||||
AddText(AppearanceKeys.StatusRedText, "Text für Rot");
|
||||
AddText(AppearanceKeys.StatusGrayText, "Text für Schwarz / Grau");
|
||||
AddText(AppearanceKeys.StatusGreenText);
|
||||
AddText(AppearanceKeys.StatusYellowText);
|
||||
AddText(AppearanceKeys.StatusRedText);
|
||||
AddText(AppearanceKeys.StatusGrayText);
|
||||
|
||||
void AddColor(string key, string title)
|
||||
void AddColor(string key)
|
||||
{
|
||||
var fallback = AppearanceDefaults.All[key];
|
||||
var value = map.TryGetValue(key, out var stored) ? stored : fallback;
|
||||
@@ -356,27 +396,57 @@ public partial class OptionsViewModel : ObservableObject
|
||||
AppearanceColors.Add(new AppearanceColorItemViewModel
|
||||
{
|
||||
Key = key,
|
||||
Title = title,
|
||||
Title = GetAppearanceColorTitle(key),
|
||||
Fallback = fallback,
|
||||
Value = ToHex(preview),
|
||||
PreviewColor = preview
|
||||
});
|
||||
}
|
||||
|
||||
void AddText(string key, string title)
|
||||
void AddText(string key)
|
||||
{
|
||||
var fallback = AppearanceDefaults.All[key];
|
||||
var fallback = LocalizationService.GetDefaultStatusText(key);
|
||||
if (string.IsNullOrWhiteSpace(fallback))
|
||||
fallback = AppearanceDefaults.All[key];
|
||||
|
||||
var value = map.TryGetValue(key, out var stored) ? stored : fallback;
|
||||
|
||||
StatusTexts.Add(new AppearanceTextItemViewModel
|
||||
{
|
||||
Key = key,
|
||||
Title = title,
|
||||
Title = GetAppearanceTextTitle(key),
|
||||
Value = value
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadLanguageOptions()
|
||||
{
|
||||
var currentCode = _localizationService.SelectedLanguageCode;
|
||||
|
||||
LanguageOptions.Clear();
|
||||
LanguageOptions.Add(new LanguageOptionItemViewModel
|
||||
{
|
||||
Code = LocalizationService.SystemLanguageCode,
|
||||
DisplayName = _localizationService.GetLanguageDisplayName(LocalizationService.SystemLanguageCode)
|
||||
});
|
||||
LanguageOptions.Add(new LanguageOptionItemViewModel
|
||||
{
|
||||
Code = LocalizationService.GermanLanguageCode,
|
||||
DisplayName = _localizationService.GetLanguageDisplayName(LocalizationService.GermanLanguageCode)
|
||||
});
|
||||
LanguageOptions.Add(new LanguageOptionItemViewModel
|
||||
{
|
||||
Code = LocalizationService.EnglishLanguageCode,
|
||||
DisplayName = _localizationService.GetLanguageDisplayName(LocalizationService.EnglishLanguageCode)
|
||||
});
|
||||
|
||||
SelectedLanguageOption = LanguageOptions.FirstOrDefault(x => x.Code == currentCode)
|
||||
?? LanguageOptions.FirstOrDefault();
|
||||
|
||||
OnPropertyChanged(nameof(SelectedLanguageDescription));
|
||||
}
|
||||
|
||||
private async Task LoadActivitiesAsync()
|
||||
{
|
||||
var selectedExportActivityId = SelectedExportActivity?.Id;
|
||||
@@ -447,6 +517,14 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
private async Task SaveAppearanceAsync()
|
||||
{
|
||||
RequiresShellReload = false;
|
||||
|
||||
var targetLanguageCode = SelectedLanguageOption?.Code ?? _localizationService.SelectedLanguageCode;
|
||||
var targetCulture = _localizationService.GetCultureForSelection(targetLanguageCode);
|
||||
|
||||
foreach (var item in StatusTexts)
|
||||
item.Value = LocalizationService.NormalizeStatusTextForCulture(item.Key, item.Value, targetCulture);
|
||||
|
||||
foreach (var item in AppearanceColors)
|
||||
{
|
||||
var normalized = ToHex(ColorUtility.ParseColor(item.Value, item.Fallback));
|
||||
@@ -458,23 +536,30 @@ public partial class OptionsViewModel : ObservableObject
|
||||
foreach (var item in StatusTexts)
|
||||
await _appearanceService.SaveTextAsync(item.Key, item.Value);
|
||||
|
||||
var languageChanged = _localizationService.SetSelectedLanguage(targetLanguageCode);
|
||||
await _appearanceService.ApplyAsync();
|
||||
await LoadAppearanceAsync();
|
||||
LoadLanguageOptions();
|
||||
|
||||
await _notificationScheduler.SyncAsync();
|
||||
StatusText = "Aussehen gespeichert.";
|
||||
RequiresShellReload = languageChanged;
|
||||
StatusText = LocalizationService.Translate("Options_Status_AppearanceSaved");
|
||||
}
|
||||
|
||||
private async Task ResetAppearanceAsync()
|
||||
{
|
||||
await _appearanceService.ResetAsync();
|
||||
await LoadAppearanceAsync();
|
||||
LoadLanguageOptions();
|
||||
await _notificationScheduler.SyncAsync();
|
||||
StatusText = "Aussehen auf Standard zurückgesetzt.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_AppearanceReset");
|
||||
}
|
||||
|
||||
private async Task AddActivityAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(NewActivityName))
|
||||
{
|
||||
StatusText = "Bitte zuerst einen Tätigkeitsnamen eingeben.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_ActivityNameRequired");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -483,7 +568,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
await _activityRepository.AddAsync(NewActivityName);
|
||||
NewActivityName = string.Empty;
|
||||
await LoadActivitiesAsync();
|
||||
StatusText = "Tätigkeit hinzugefügt.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_ActivityAdded");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -500,7 +585,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
{
|
||||
await _activityRepository.RenameAsync(item.Id, item.Name);
|
||||
await LoadActivitiesAsync();
|
||||
StatusText = "Tätigkeit gespeichert.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_ActivitySaved");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -515,7 +600,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
await _activityRepository.SetActiveAsync(item.Id, !item.IsActive);
|
||||
await LoadActivitiesAsync();
|
||||
StatusText = "Tätigkeit aktualisiert.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_ActivityUpdated");
|
||||
}
|
||||
|
||||
private async Task DeleteActivityAsync(ActivityManageItemViewModel? item)
|
||||
@@ -525,14 +610,17 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
await _activityRepository.DeleteOrDeactivateAsync(item.Id);
|
||||
await LoadActivitiesAsync();
|
||||
StatusText = item.IsUsed ? "Tätigkeit wurde deaktiviert." : "Tätigkeit wurde gelöscht.";
|
||||
StatusText = LocalizationService.Translate(
|
||||
item.IsUsed
|
||||
? "Options_Status_ActivityDisabled"
|
||||
: "Options_Status_ActivityDeleted");
|
||||
}
|
||||
|
||||
private async Task AddSymptomAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(NewSymptomName))
|
||||
{
|
||||
StatusText = "Bitte zuerst einen Symptomnamen eingeben.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_SymptomNameRequired");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -541,7 +629,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
await _symptomRepository.AddAsync(NewSymptomName);
|
||||
NewSymptomName = string.Empty;
|
||||
await LoadSymptomsAsync();
|
||||
StatusText = "Symptom hinzugefügt.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_SymptomAdded");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -558,7 +646,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
{
|
||||
await _symptomRepository.RenameAsync(item.Id, item.Name);
|
||||
await LoadSymptomsAsync();
|
||||
StatusText = "Symptom gespeichert.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_SymptomSaved");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -573,7 +661,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
await _symptomRepository.SetActiveAsync(item.Id, !item.IsActive);
|
||||
await LoadSymptomsAsync();
|
||||
StatusText = "Symptom aktualisiert.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_SymptomUpdated");
|
||||
}
|
||||
|
||||
private async Task DeleteSymptomAsync(SymptomManageItemViewModel? item)
|
||||
@@ -583,7 +671,10 @@ public partial class OptionsViewModel : ObservableObject
|
||||
|
||||
await _symptomRepository.DeleteOrDeactivateAsync(item.Id);
|
||||
await LoadSymptomsAsync();
|
||||
StatusText = item.IsUsed ? "Symptom wurde deaktiviert." : "Symptom wurde gelöscht.";
|
||||
StatusText = LocalizationService.Translate(
|
||||
item.IsUsed
|
||||
? "Options_Status_SymptomDisabled"
|
||||
: "Options_Status_SymptomDeleted");
|
||||
}
|
||||
|
||||
private Task AddScheduleAsync()
|
||||
@@ -599,7 +690,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
Friday = true
|
||||
});
|
||||
|
||||
StatusText = "Benachrichtigungszeit hinzugefügt.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_NotificationAdded");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -610,16 +701,17 @@ public partial class OptionsViewModel : ObservableObject
|
||||
var granted = await _notificationScheduler.EnsurePermissionAsync();
|
||||
if (!granted)
|
||||
{
|
||||
StatusText = OperatingSystem.IsAndroidVersionAtLeast(31)
|
||||
? "Bitte Benachrichtigungen, Push-Nachrichten und Alarme erlauben und danach erneut speichern."
|
||||
: "Bitte Benachrichtigungen und Push-Nachrichten erlauben und danach erneut speichern.";
|
||||
StatusText = LocalizationService.Translate(
|
||||
OperatingSystem.IsAndroidVersionAtLeast(31)
|
||||
? "Options_Status_NotificationPermissionAndroid31"
|
||||
: "Options_Status_NotificationPermissionLegacy");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (NotificationSchedules.Any(x => x.ToWeekdayMask() == 0))
|
||||
{
|
||||
StatusText = "Bitte pro Benachrichtigungszeit mindestens einen Wochentag auswählen.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_NotificationWeekdayRequired");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -636,9 +728,10 @@ public partial class OptionsViewModel : ObservableObject
|
||||
await _notificationScheduler.SyncAsync();
|
||||
await LoadSchedulesAsync();
|
||||
|
||||
StatusText = NotificationVibrationEnabled
|
||||
? "Benachrichtigungszeiten gespeichert. Vibration ist aktiv."
|
||||
: "Benachrichtigungszeiten gespeichert. Vibration ist aus.";
|
||||
StatusText = LocalizationService.Translate(
|
||||
NotificationVibrationEnabled
|
||||
? "Options_Status_NotificationsSavedActive"
|
||||
: "Options_Status_NotificationsSavedInactive");
|
||||
}
|
||||
|
||||
private Task DeleteScheduleAsync(NotificationScheduleItemViewModel? item)
|
||||
@@ -646,7 +739,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
if (item is not null)
|
||||
NotificationSchedules.Remove(item);
|
||||
|
||||
StatusText = "Benachrichtigungszeit entfernt.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_NotificationRemoved");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -655,7 +748,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
_databaseLocationService.UseExternalDatabase = UseExternalDatabase;
|
||||
_databaseLocationService.ExternalDatabasePath = ExternalDatabasePath?.Trim() ?? string.Empty;
|
||||
CurrentDatabasePath = _databaseLocationService.ResolveDatabasePath();
|
||||
StatusText = "Datenbankpfad gespeichert. Bitte App neu starten, damit der Pfad aktiv wird.";
|
||||
StatusText = LocalizationService.Translate("Options_Status_DatabaseSaved");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -670,7 +763,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
SelectedExportActivity?.Id,
|
||||
ExportSymptoms.Where(x => x.IsSelected).Select(x => x.Id).ToList());
|
||||
|
||||
StatusText = $"Export erstellt: {result.FileName}";
|
||||
StatusText = LocalizationService.Format("Options_Status_ExportCreated", result.FileName);
|
||||
await ExportUiHelper.ShowExportSavedActionsAsync(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -686,15 +779,17 @@ public partial class OptionsViewModel : ObservableObject
|
||||
ExportActivities.Add(new ActivityPickerItemViewModel
|
||||
{
|
||||
Id = null,
|
||||
Name = "Alle T\u00e4tigkeiten"
|
||||
Name = LocalizationService.Translate("Options_Export_AllActivities")
|
||||
});
|
||||
|
||||
foreach (var item in activities.Where(x => !string.Equals(x.Name, "Keine T\u00e4tigkeit", StringComparison.OrdinalIgnoreCase)))
|
||||
foreach (var item in activities.Where(x => !LocalizationService.IsNoActivityLabel(x.Name)))
|
||||
{
|
||||
ExportActivities.Add(new ActivityPickerItemViewModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.IsActive ? item.Name : $"{item.Name} (inaktiv)"
|
||||
Name = item.IsActive
|
||||
? item.Name
|
||||
: LocalizationService.Format("Common_InactiveSuffix", item.Name)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -711,7 +806,9 @@ public partial class OptionsViewModel : ObservableObject
|
||||
var exportItem = new SelectableSymptomItemViewModel
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.IsActive ? item.Name : $"{item.Name} (inaktiv)",
|
||||
Name = item.IsActive
|
||||
? item.Name
|
||||
: LocalizationService.Format("Common_InactiveSuffix", item.Name),
|
||||
IsSelected = selectedSymptomIds.Contains(item.Id)
|
||||
};
|
||||
|
||||
@@ -747,10 +844,10 @@ public partial class OptionsViewModel : ObservableObject
|
||||
private async Task ClearExportsAsync()
|
||||
{
|
||||
var confirm = await Shell.Current.DisplayAlertAsync(
|
||||
"Export entleeren",
|
||||
"Möchtest du wirklich alle lokal gespeicherten Exporte löschen?",
|
||||
"Ja",
|
||||
"Nein");
|
||||
LocalizationService.Translate("Options_Export_Clear"),
|
||||
LocalizationService.Translate("Options_Export_Clear_Confirm"),
|
||||
LocalizationService.Translate("Common_Yes"),
|
||||
LocalizationService.Translate("Common_No"));
|
||||
|
||||
if (!confirm)
|
||||
return;
|
||||
@@ -758,11 +855,54 @@ public partial class OptionsViewModel : ObservableObject
|
||||
var deleted = await _pdfExportService.ClearExportsAsync();
|
||||
|
||||
await Shell.Current.DisplayAlertAsync(
|
||||
"Export entleeren",
|
||||
LocalizationService.Translate("Options_Export_Clear"),
|
||||
deleted > 0
|
||||
? $"{deleted} Export-Datei(en) wurden gelöscht."
|
||||
: "Es waren keine Export-Dateien vorhanden.",
|
||||
"OK");
|
||||
? LocalizationService.Format("Options_Export_Clear_ResultDeletedFormat", deleted)
|
||||
: LocalizationService.Translate("Options_Export_Clear_ResultEmpty"),
|
||||
LocalizationService.Translate("Common_OK"));
|
||||
}
|
||||
|
||||
private static string GetAppearanceColorTitle(string key) => LocalizationService.Translate(key switch
|
||||
{
|
||||
AppearanceKeys.AppBackground => "Options_Appearance_Color_AppBackground",
|
||||
AppearanceKeys.SurfaceBackground => "Options_Appearance_Color_SurfaceBackground",
|
||||
AppearanceKeys.SurfaceBackgroundAlt => "Options_Appearance_Color_SurfaceBackgroundAlt",
|
||||
AppearanceKeys.Border => "Options_Appearance_Color_Border",
|
||||
AppearanceKeys.TextPrimary => "Options_Appearance_Color_TextPrimary",
|
||||
AppearanceKeys.TextMuted => "Options_Appearance_Color_TextMuted",
|
||||
AppearanceKeys.StateGreen => "Options_Appearance_Color_StateGreen",
|
||||
AppearanceKeys.StateYellow => "Options_Appearance_Color_StateYellow",
|
||||
AppearanceKeys.StateRed => "Options_Appearance_Color_StateRed",
|
||||
AppearanceKeys.StateGray => "Options_Appearance_Color_StateGray",
|
||||
AppearanceKeys.ButtonPrimaryBackground => "Options_Appearance_Color_ButtonPrimaryBackground",
|
||||
AppearanceKeys.ButtonPrimaryText => "Options_Appearance_Color_ButtonPrimaryText",
|
||||
AppearanceKeys.ButtonSecondaryBackground => "Options_Appearance_Color_ButtonSecondaryBackground",
|
||||
AppearanceKeys.ButtonSecondaryText => "Options_Appearance_Color_ButtonSecondaryText",
|
||||
AppearanceKeys.ShellBackground => "Options_Appearance_Color_ShellBackground",
|
||||
AppearanceKeys.ShellForeground => "Options_Appearance_Color_ShellForeground",
|
||||
AppearanceKeys.ShellTitle => "Options_Appearance_Color_ShellTitle",
|
||||
AppearanceKeys.ShellUnselected => "Options_Appearance_Color_ShellUnselected",
|
||||
AppearanceKeys.TabBarBackground => "Options_Appearance_Color_TabBarBackground",
|
||||
AppearanceKeys.TabBarForeground => "Options_Appearance_Color_TabBarForeground",
|
||||
AppearanceKeys.TabBarTitle => "Options_Appearance_Color_TabBarTitle",
|
||||
AppearanceKeys.TabBarUnselected => "Options_Appearance_Color_TabBarUnselected",
|
||||
_ => key
|
||||
});
|
||||
|
||||
private static string GetAppearanceTextTitle(string key) => LocalizationService.Translate(key switch
|
||||
{
|
||||
AppearanceKeys.StatusGreenText => "Options_Appearance_Text_Green",
|
||||
AppearanceKeys.StatusYellowText => "Options_Appearance_Text_Yellow",
|
||||
AppearanceKeys.StatusRedText => "Options_Appearance_Text_Red",
|
||||
AppearanceKeys.StatusGrayText => "Options_Appearance_Text_Gray",
|
||||
_ => key
|
||||
});
|
||||
|
||||
private static string FormatShortDate(DateTime date)
|
||||
{
|
||||
var culture = LocalizationService.GetCurrentCulture();
|
||||
var format = LocalizationService.Translate("Date_ShortNumericFormat");
|
||||
return date.ToString(format, culture);
|
||||
}
|
||||
|
||||
private static string ToHex(Color color)
|
||||
|
||||
Reference in New Issue
Block a user