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:
2026-11-29 14:42:16 +01:00
parent 693d79019a
commit bb6612420d
28 changed files with 985 additions and 176 deletions

View File

@@ -1,6 +1,7 @@
#nullable enable
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using ReminderOrganizer.Core;
namespace ReminderOrganizer.Models
@@ -36,13 +37,13 @@ namespace ReminderOrganizer.Models
public DateTime ReminderDate
{
get => _reminderDate;
set { if (SetProperty(ref _reminderDate, value)) OnPropertyChanged(nameof(AgeText)); }
set { if (SetProperty(ref _reminderDate, value)) RaiseDisplay(); }
}
public bool IsNotified
{
get => _isNotified;
set => SetProperty(ref _isNotified, value);
set { if (SetProperty(ref _isNotified, value)) OnPropertyChanged(nameof(RelativeDate)); }
}
public bool IsRecurring
@@ -93,6 +94,59 @@ namespace ReminderOrganizer.Models
[System.Text.Json.Serialization.JsonIgnore]
public string? AgeText => UpcomingAge is int a ? (AgeFormatter?.Invoke(a) ?? a.ToString()) : null;
private bool _isBirthday;
/// <summary>Birthday: yearly, date only (no time shown), reminded at <see cref="BirthdayHour"/>.</summary>
public bool IsBirthday
{
get => _isBirthday;
set { if (SetProperty(ref _isBirthday, value)) RaiseDisplay(); }
}
public const int BirthdayHour = 9;
/// <summary>Set once by the app: culture for month names, relative-date formatter.</summary>
public static Func<CultureInfo>? DisplayCulture { get; set; }
public static Func<DateTime, DateTime, string>? RelativeFormatter { get; set; }
/// <summary>"19. März" for birthdays, otherwise "19.03.2027 09:00".</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string DisplayDate => IsBirthday
? ReminderDate.ToString(DayMonthPattern(DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture), DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture)
: ReminderDate.ToString("dd.MM.yyyy HH:mm", CultureInfo.InvariantCulture);
/// <summary>"heute", "morgen", "in 5 Tagen", "vor 2 Tagen".</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string RelativeDate => IsNotified ? "" : RelativeFormatter?.Invoke(ReminderDate, DateTime.Now) ?? "";
[System.Text.Json.Serialization.JsonIgnore]
public int DaysUntil => (ReminderDate.Date - DateTime.Today).Days;
/// <summary>Day number + short month for the card view.</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string DayText => ReminderDate.Day.ToString(CultureInfo.InvariantCulture);
[System.Text.Json.Serialization.JsonIgnore]
public string MonthText => ReminderDate.ToString("MMM", DisplayCulture?.Invoke() ?? CultureInfo.CurrentCulture).TrimEnd('.').ToUpperInvariant();
public static string DayMonthPattern(CultureInfo c) => c.TwoLetterISOLanguageName == "de" ? "d. MMMM" : "MMMM d";
private void RaiseDisplay()
{
OnPropertyChanged(nameof(DisplayDate));
OnPropertyChanged(nameof(RelativeDate));
OnPropertyChanged(nameof(DaysUntil));
OnPropertyChanged(nameof(DayText));
OnPropertyChanged(nameof(MonthText));
OnPropertyChanged(nameof(AgeText));
}
/// <summary>Next birthday on/after <paramref name="today"/> at BirthdayHour (29 Feb → 28 Feb in other years).</summary>
public static DateTime NextBirthday(int day, int month, DateTime today)
{
DateTime For(int year) => new(year, month, Math.Min(day, DateTime.DaysInMonth(year, month)), BirthdayHour, 0, 0);
var d = For(today.Year);
return d.Date >= today.Date ? d : For(today.Year + 1);
}
private string _folderName = "";
/// <summary>Runtime only: name of the folder holding this task (for the "Upcoming" view).</summary>
[System.Text.Json.Serialization.JsonIgnore]
@@ -242,5 +296,33 @@ namespace ReminderOrganizer.Models
public bool? IsDarkMode { get; set; }
public bool PlaySound { get; set; } = true;
public bool HideDone { get; set; }
/// <summary>"list", "compact" or "cards".</summary>
public string ViewMode { get; set; } = "list";
/// <summary>Folders and yearly tasks were checked for birthdays once.</summary>
public bool BirthdaysMigrated { get; set; }
public static bool LooksLikeBirthdayFolder(string? name) =>
name != null && (name.Contains("geburtstag", StringComparison.OrdinalIgnoreCase) ||
name.Contains("birthday", StringComparison.OrdinalIgnoreCase));
/// <summary>Yearly tasks in a "Geburtstage"/"Birthdays" folder become birthday entries (one-time).</summary>
public int MigrateBirthdays()
{
if (BirthdaysMigrated) return 0;
BirthdaysMigrated = true;
int n = 0;
foreach (var f in Folders)
{
if (!LooksLikeBirthdayFolder(f.Name)) continue;
foreach (var t in f.Tasks)
{
if (t.IsBirthday || !t.IsRecurring || t.RecurrenceType != RecurrenceType.Yearly) continue;
t.IsBirthday = true;
n++;
}
}
return n;
}
}
}