Birthday entry type, relative dates, list/compact/cards views
- Task dialog: Appointment | Birthday switch. Birthday = name + "19.03." or "19.03.1986" (no time), live preview with weekday, age and days left - Birthday folders open the birthday form; yearly tasks in such folders are migrated once - Birthdays show "19. Maerz" instead of date + time; every task shows "in 15 days" / "3 days ago" (red when overdue) - View switch: list, compact (one line), cards (calendar tiles), persisted - ICS: birthdays as all-day events - 59 tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -194,6 +194,40 @@ namespace ReminderOrganizer.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- view mode ----------
|
||||
|
||||
public string ViewMode
|
||||
{
|
||||
get => _appData.ViewMode;
|
||||
set
|
||||
{
|
||||
if (_appData.ViewMode == value) return;
|
||||
_appData.ViewMode = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(IsViewList));
|
||||
OnPropertyChanged(nameof(IsViewCompact));
|
||||
OnPropertyChanged(nameof(IsViewCards));
|
||||
_ = SaveAsync();
|
||||
}
|
||||
}
|
||||
public bool IsViewList { get => ViewMode == "list"; set { if (value) ViewMode = "list"; } }
|
||||
public bool IsViewCompact { get => ViewMode == "compact"; set { if (value) ViewMode = "compact"; } }
|
||||
public bool IsViewCards { get => ViewMode == "cards"; set { if (value) ViewMode = "cards"; } }
|
||||
|
||||
/// <summary>"today", "tomorrow", "in 5 days", "yesterday", "3 days ago".</summary>
|
||||
public string RelativeText(DateTime date, DateTime now)
|
||||
{
|
||||
int days = (date.Date - now.Date).Days;
|
||||
return days switch
|
||||
{
|
||||
0 => L("RelToday"),
|
||||
1 => L("RelTomorrow"),
|
||||
-1 => L("RelYesterday"),
|
||||
> 1 => string.Format(L("RelInDays"), days),
|
||||
_ => string.Format(L("RelDaysAgo"), -days)
|
||||
};
|
||||
}
|
||||
|
||||
// ---------- undo ----------
|
||||
|
||||
private Action? _undoAction;
|
||||
@@ -271,6 +305,8 @@ namespace ReminderOrganizer.ViewModels
|
||||
_autostartService = autostartService;
|
||||
|
||||
ReminderTask.AgeFormatter = age => string.Format(L("TurnsAge"), age);
|
||||
ReminderTask.DisplayCulture = () => new System.Globalization.CultureInfo(_localizationService.CurrentLanguage == "de" ? "de-DE" : "en-US");
|
||||
ReminderTask.RelativeFormatter = RelativeText;
|
||||
|
||||
// Empty name = refresh every binding (all texts depend on the language).
|
||||
_localizationService.StringsChanged += (s, e) =>
|
||||
@@ -326,6 +362,7 @@ namespace ReminderOrganizer.ViewModels
|
||||
if (firstRun)
|
||||
await SaveAsync();
|
||||
|
||||
if (_appData.MigrateBirthdays() > 0) await SaveAsync();
|
||||
_isDarkMode = _appData.IsDarkMode.Value;
|
||||
_appData.Folders.CollectionChanged += (s, e) => { HookFolders(); ReindexTasks(); };
|
||||
HookFolders();
|
||||
@@ -513,7 +550,10 @@ namespace ReminderOrganizer.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
var taskWindow = new TaskWindow(null, IsDarkMode) { Owner = Application.Current.MainWindow };
|
||||
// Birthday folders (by name or because they mostly hold birthdays) open the birthday form.
|
||||
bool birthday = AppData.LooksLikeBirthdayFolder(folder.Name) ||
|
||||
(folder.Tasks.Count > 0 && folder.Tasks.Count(t => t.IsBirthday) * 2 > folder.Tasks.Count);
|
||||
var taskWindow = new TaskWindow(null, IsDarkMode, birthday) { Owner = Application.Current.MainWindow };
|
||||
if (taskWindow.ShowDialog() == true)
|
||||
{
|
||||
folder.Tasks.Add(taskWindow.TaskResult);
|
||||
|
||||
Reference in New Issue
Block a user