Export Option
Added export function
This commit is contained in:
@@ -21,3 +21,10 @@ public enum EntrySource : byte
|
||||
Notification = 2,
|
||||
Import = 3
|
||||
}
|
||||
|
||||
public enum ExportLayout : byte
|
||||
{
|
||||
DayView = 0,
|
||||
WeekBlock = 1,
|
||||
DaySummary = 2
|
||||
}
|
||||
|
||||
@@ -158,10 +158,12 @@ public sealed class AndroidNotificationScheduler : INotificationScheduler
|
||||
requestCode,
|
||||
intent,
|
||||
BuildPendingIntentFlags());
|
||||
if (pendingIntent is null)
|
||||
return;
|
||||
|
||||
var when = triggerAt.ToUnixTimeMilliseconds();
|
||||
|
||||
if (CanUseExactAlarms(context, alarmManager))
|
||||
if (OperatingSystem.IsAndroidVersionAtLeast(23) && CanUseExactAlarms(alarmManager))
|
||||
{
|
||||
alarmManager.SetExactAndAllowWhileIdle(AlarmType.RtcWakeup, when, pendingIntent);
|
||||
return;
|
||||
@@ -203,28 +205,50 @@ public sealed class AndroidNotificationScheduler : INotificationScheduler
|
||||
|
||||
var smallIcon = context.ApplicationInfo?.Icon ?? global::Android.Resource.Drawable.IcDialogInfo;
|
||||
|
||||
var builder = new NotificationCompat.Builder(context, channelId)
|
||||
.SetSmallIcon(smallIcon)
|
||||
.SetContentTitle(title)
|
||||
.SetContentText(message)
|
||||
.SetPriority((int)NotificationPriority.High)
|
||||
.SetAutoCancel(true)
|
||||
.SetContentIntent(openPendingIntent)
|
||||
.SetOnlyAlertOnce(true)
|
||||
.AddAction(0, yellowLabel, yellowPendingIntent)
|
||||
.AddAction(0, redLabel, redPendingIntent)
|
||||
.AddAction(0, grayLabel, grayPendingIntent);
|
||||
var builder = new NotificationCompat.Builder(context, channelId);
|
||||
builder.SetSmallIcon(smallIcon);
|
||||
builder.SetContentTitle(title);
|
||||
builder.SetContentText(message);
|
||||
builder.SetPriority((int)NotificationPriority.High);
|
||||
builder.SetAutoCancel(true);
|
||||
builder.SetOnlyAlertOnce(true);
|
||||
|
||||
if (openPendingIntent is not null)
|
||||
builder.SetContentIntent(openPendingIntent);
|
||||
|
||||
if (yellowPendingIntent is not null)
|
||||
builder.AddAction(0, yellowLabel, yellowPendingIntent);
|
||||
|
||||
if (redPendingIntent is not null)
|
||||
builder.AddAction(0, redLabel, redPendingIntent);
|
||||
|
||||
if (grayPendingIntent is not null)
|
||||
builder.AddAction(0, grayLabel, grayPendingIntent);
|
||||
|
||||
if (vibrationEnabled && !OperatingSystem.IsAndroidVersionAtLeast(26))
|
||||
builder.SetVibrate(NotificationVibrationPattern);
|
||||
|
||||
NotificationManagerCompat.From(context).Notify(notificationId, builder.Build());
|
||||
var notification = builder.Build();
|
||||
if (notification is null)
|
||||
return;
|
||||
|
||||
var notificationManager = NotificationManagerCompat.From(context);
|
||||
notificationManager?.Notify(notificationId, notification);
|
||||
}
|
||||
|
||||
private static PendingIntent CreateOpenQuickEntryPendingIntent(Context context, int notificationId, string date)
|
||||
private static PendingIntent? CreateOpenQuickEntryPendingIntent(Context context, int notificationId, string date)
|
||||
{
|
||||
var launchIntent = context.PackageManager?.GetLaunchIntentForPackage(context.PackageName)
|
||||
?? new Intent(context, typeof(MainActivity));
|
||||
Intent launchIntent;
|
||||
var packageName = context.PackageName;
|
||||
if (!string.IsNullOrWhiteSpace(packageName))
|
||||
{
|
||||
launchIntent = context.PackageManager?.GetLaunchIntentForPackage(packageName)
|
||||
?? new Intent(context, typeof(MainActivity));
|
||||
}
|
||||
else
|
||||
{
|
||||
launchIntent = new Intent(context, typeof(MainActivity));
|
||||
}
|
||||
|
||||
launchIntent.SetAction(ActionOpenQuickEntry);
|
||||
launchIntent.AddFlags(ActivityFlags.SingleTop | ActivityFlags.ClearTop | ActivityFlags.NewTask);
|
||||
@@ -239,7 +263,7 @@ public sealed class AndroidNotificationScheduler : INotificationScheduler
|
||||
BuildPendingIntentFlags());
|
||||
}
|
||||
|
||||
private static PendingIntent CreateSaveStatusPendingIntent(Context context, int notificationId, string status, string date)
|
||||
private static PendingIntent? CreateSaveStatusPendingIntent(Context context, int notificationId, string status, string date)
|
||||
{
|
||||
var intent = new Intent(context, typeof(CfsNotificationReceiver));
|
||||
intent.SetAction(ActionSaveStatus);
|
||||
@@ -313,14 +337,17 @@ public sealed class AndroidNotificationScheduler : INotificationScheduler
|
||||
intent,
|
||||
BuildPendingIntentFlags());
|
||||
|
||||
alarmManager.Cancel(pendingIntent);
|
||||
NotificationManagerCompat.From(context).Cancel(BuildNotificationId(scheduleId, day));
|
||||
if (pendingIntent is not null)
|
||||
alarmManager.Cancel(pendingIntent);
|
||||
|
||||
var notificationManager = NotificationManagerCompat.From(context);
|
||||
notificationManager?.Cancel(BuildNotificationId(scheduleId, day));
|
||||
}
|
||||
|
||||
Preferences.Default.Remove(PrefScheduledIds);
|
||||
}
|
||||
|
||||
private static bool CanUseExactAlarms(Context context, AlarmManager alarmManager)
|
||||
private static bool CanUseExactAlarms(AlarmManager alarmManager)
|
||||
{
|
||||
if (!OperatingSystem.IsAndroidVersionAtLeast(31))
|
||||
return true;
|
||||
@@ -387,4 +414,4 @@ public sealed class AndroidNotificationScheduler : INotificationScheduler
|
||||
if (flags.HasFlag(NotificationWeekdays.Saturday)) yield return DayOfWeek.Saturday;
|
||||
if (flags.HasFlag(NotificationWeekdays.Sunday)) yield return DayOfWeek.Sunday;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ public sealed class CfsNotificationReceiver : BroadcastReceiver
|
||||
private void HandleSaveStatus(Context context, Intent intent)
|
||||
{
|
||||
var pendingResult = GoAsync();
|
||||
if (pendingResult is null)
|
||||
return;
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
@@ -76,7 +78,8 @@ public sealed class CfsNotificationReceiver : BroadcastReceiver
|
||||
timestamp: DateTime.Now,
|
||||
source: EntrySource.App);
|
||||
|
||||
NotificationManagerCompat.From(context).Cancel(notificationId);
|
||||
var notificationManager = NotificationManagerCompat.From(context);
|
||||
notificationManager?.Cancel(notificationId);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -117,4 +120,4 @@ public sealed class CfsNotificationReceiver : BroadcastReceiver
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using cfs_tracker.Models;
|
||||
|
||||
namespace cfs_tracker.Services;
|
||||
|
||||
public interface IPdfExportService
|
||||
@@ -8,6 +10,7 @@ public interface IPdfExportService
|
||||
Task<ExportResult> ExportMonthAsync(int year, int month);
|
||||
Task<ExportResult> ExportYearAsync(DateTime date);
|
||||
Task<ExportResult> ExportYearAsync(int year);
|
||||
Task<ExportResult> ExportRangeAsync(DateTime startDate, DateTime endDate, ExportLayout layout);
|
||||
|
||||
Task<int> ClearExportsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,209 @@ public sealed class PdfExportService : IPdfExportService
|
||||
public Task<ExportResult> ExportYearAsync(int year)
|
||||
=> ExportYearHtmlAsync(year);
|
||||
|
||||
public Task<ExportResult> ExportRangeAsync(DateTime startDate, DateTime endDate, ExportLayout layout)
|
||||
{
|
||||
var (rangeStart, rangeEnd) = NormalizeDateRange(startDate, endDate);
|
||||
|
||||
return layout switch
|
||||
{
|
||||
ExportLayout.DayView => ExportDayRangeHtmlAsync(rangeStart, rangeEnd),
|
||||
ExportLayout.WeekBlock => ExportWeekBlockRangeHtmlAsync(rangeStart, rangeEnd),
|
||||
_ => ExportDaySummaryRangeHtmlAsync(rangeStart, rangeEnd)
|
||||
};
|
||||
}
|
||||
|
||||
private async Task<ExportResult> ExportDayRangeHtmlAsync(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var entries = await _healthEntryRepository.GetEntriesBetweenAsync(startDate, endDate.AddDays(1));
|
||||
var activityNames = await GetActivityNamesAsync();
|
||||
var symptomNamesByEntry = await GetSymptomNamesByEntryAsync(entries.Select(x => x.Id));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("<h1>Export - Tagesansicht</h1>");
|
||||
sb.AppendLine($"<p class=\"summary-note\">Zeitraum: {Encode(FormatDateRange(startDate, endDate))}</p>");
|
||||
|
||||
var currentDay = startDate.Date;
|
||||
var isFirstSection = true;
|
||||
|
||||
while (currentDay <= endDate.Date)
|
||||
{
|
||||
var dayEntries = entries
|
||||
.Where(x => x.EntryDate.Date == currentDay)
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.ThenBy(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
if (dayEntries.Count == 0)
|
||||
{
|
||||
currentDay = currentDay.AddDays(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFirstSection)
|
||||
sb.AppendLine("<div class=\"page-break\"></div>");
|
||||
|
||||
sb.AppendLine("<section class=\"export-section\">");
|
||||
sb.AppendLine($"<h2>{Encode(currentDay.ToString("dddd, dd.MM.yyyy", DateHelper.GermanCulture))}</h2>");
|
||||
AppendDayDetailTable(sb, dayEntries, activityNames, symptomNamesByEntry);
|
||||
sb.AppendLine("</section>");
|
||||
|
||||
currentDay = currentDay.AddDays(1);
|
||||
isFirstSection = false;
|
||||
}
|
||||
|
||||
if (isFirstSection)
|
||||
sb.AppendLine("<p>Keine Einträge im gewählten Zeitraum vorhanden.</p>");
|
||||
|
||||
return await SaveHtmlAsync(
|
||||
fileName: $"export-tagesansicht-{startDate:yyyy-MM-dd}-bis-{endDate:yyyy-MM-dd}.html",
|
||||
title: $"Export Tagesansicht {FormatDateRange(startDate, endDate)}",
|
||||
bodyHtml: sb.ToString());
|
||||
}
|
||||
|
||||
private async Task<ExportResult> ExportWeekBlockRangeHtmlAsync(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var entries = await _healthEntryRepository.GetEntriesBetweenAsync(startDate, endDate.AddDays(1));
|
||||
var activityNames = await GetActivityNamesAsync();
|
||||
var symptomNamesByEntry = await GetSymptomNamesByEntryAsync(entries.Select(x => x.Id));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("<h1>Export - Wochenblock</h1>");
|
||||
sb.AppendLine($"<p class=\"summary-note\">Zeitraum: {Encode(FormatDateRange(startDate, endDate))}</p>");
|
||||
|
||||
var weekStart = StartOfWeekMonday(startDate);
|
||||
var isFirstSection = true;
|
||||
|
||||
while (weekStart <= endDate.Date)
|
||||
{
|
||||
var daysInBlock = Enumerable.Range(0, 7)
|
||||
.Select(offset => weekStart.AddDays(offset))
|
||||
.Where(day => day.Date >= startDate.Date && day.Date <= endDate.Date)
|
||||
.ToList();
|
||||
|
||||
if (daysInBlock.Count == 0)
|
||||
{
|
||||
weekStart = weekStart.AddDays(7);
|
||||
continue;
|
||||
}
|
||||
|
||||
var weekEntries = entries
|
||||
.Where(x => x.EntryDate.Date >= daysInBlock[0].Date && x.EntryDate.Date <= daysInBlock[^1].Date)
|
||||
.ToList();
|
||||
|
||||
if (weekEntries.Count == 0)
|
||||
{
|
||||
weekStart = weekStart.AddDays(7);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isFirstSection)
|
||||
sb.AppendLine("<div class=\"page-break\"></div>");
|
||||
|
||||
sb.AppendLine("<section class=\"export-section\">");
|
||||
sb.AppendLine($"<h2>Woche {Encode(weekStart.ToString("dd.MM.yyyy"))} bis {Encode(weekStart.AddDays(6).ToString("dd.MM.yyyy"))}</h2>");
|
||||
sb.AppendLine("<table>");
|
||||
sb.AppendLine("<thead><tr><th>Tag</th><th>Vormittag</th><th>Nachmittag</th><th>Anzahl</th><th>Tätigkeiten</th><th>Symptome</th></tr></thead>");
|
||||
sb.AppendLine("<tbody>");
|
||||
|
||||
foreach (var currentDay in daysInBlock)
|
||||
{
|
||||
var dayEntries = entries
|
||||
.Where(x => x.EntryDate.Date == currentDay.Date)
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.ThenBy(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
var morningState = CalculateWorstState(FilterEntriesForDayPart(dayEntries, DayPart.Morning).ToList());
|
||||
var afternoonState = CalculateWorstState(FilterEntriesForDayPart(dayEntries, DayPart.Afternoon).ToList());
|
||||
|
||||
sb.AppendLine("<tr>");
|
||||
sb.AppendLine($"<td>{Encode(currentDay.ToString("ddd, dd.MM.yyyy", DateHelper.GermanCulture))}</td>");
|
||||
sb.AppendLine(morningState.HasValue
|
||||
? StateCell(morningState.Value, GetStateText(morningState.Value))
|
||||
: "<td>—</td>");
|
||||
sb.AppendLine(afternoonState.HasValue
|
||||
? StateCell(afternoonState.Value, GetStateText(afternoonState.Value))
|
||||
: "<td>—</td>");
|
||||
sb.AppendLine($"<td>{dayEntries.Count}</td>");
|
||||
sb.AppendLine($"<td>{Encode(BuildDistinctActivityList(dayEntries, activityNames))}</td>");
|
||||
sb.AppendLine($"<td>{Encode(BuildDistinctSymptomList(dayEntries, symptomNamesByEntry))}</td>");
|
||||
sb.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
sb.AppendLine("</tbody></table>");
|
||||
sb.AppendLine("</section>");
|
||||
|
||||
weekStart = weekStart.AddDays(7);
|
||||
isFirstSection = false;
|
||||
}
|
||||
|
||||
if (isFirstSection)
|
||||
sb.AppendLine("<p>Keine Einträge im gewählten Zeitraum vorhanden.</p>");
|
||||
|
||||
return await SaveHtmlAsync(
|
||||
fileName: $"export-wochenblock-{startDate:yyyy-MM-dd}-bis-{endDate:yyyy-MM-dd}.html",
|
||||
title: $"Export Wochenblock {FormatDateRange(startDate, endDate)}",
|
||||
bodyHtml: sb.ToString(),
|
||||
compactA4: true);
|
||||
}
|
||||
|
||||
private async Task<ExportResult> ExportDaySummaryRangeHtmlAsync(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var entries = await _healthEntryRepository.GetEntriesBetweenAsync(startDate, endDate.AddDays(1));
|
||||
var activityNames = await GetActivityNamesAsync();
|
||||
var symptomNamesByEntry = await GetSymptomNamesByEntryAsync(entries.Select(x => x.Id));
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("<h1>Export - Tageszusammenfassung</h1>");
|
||||
sb.AppendLine($"<p class=\"summary-note\">Zeitraum: {Encode(FormatDateRange(startDate, endDate))}</p>");
|
||||
sb.AppendLine("<table>");
|
||||
sb.AppendLine("""
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="summary-day">Tag</th>
|
||||
<th class="compact-count">Anzahl</th>
|
||||
<th>Status</th>
|
||||
<th class="compact-activity">Tätigkeiten</th>
|
||||
<th class="compact-symptoms">Symptome</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
""");
|
||||
|
||||
var currentDay = startDate.Date;
|
||||
while (currentDay <= endDate.Date)
|
||||
{
|
||||
var dayEntries = entries
|
||||
.Where(x => x.EntryDate.Date == currentDay.Date)
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.ThenBy(x => x.Id)
|
||||
.ToList();
|
||||
|
||||
var worstState = CalculateWorstState(dayEntries);
|
||||
|
||||
sb.AppendLine("<tr>");
|
||||
sb.AppendLine($"<td class=\"summary-day\">{Encode(currentDay.ToString("ddd, dd.MM.yyyy", DateHelper.GermanCulture))}</td>");
|
||||
sb.AppendLine($"<td class=\"compact-count\">{dayEntries.Count}</td>");
|
||||
sb.AppendLine(worstState.HasValue
|
||||
? StateCellCompact(worstState.Value, GetStateText(worstState.Value))
|
||||
: "<td>—</td>");
|
||||
sb.AppendLine($"<td class=\"compact-activity\">{Encode(BuildDistinctActivityList(dayEntries, activityNames))}</td>");
|
||||
sb.AppendLine($"<td class=\"compact-symptoms\">{Encode(BuildDistinctSymptomList(dayEntries, symptomNamesByEntry))}</td>");
|
||||
sb.AppendLine("</tr>");
|
||||
|
||||
currentDay = currentDay.AddDays(1);
|
||||
}
|
||||
|
||||
sb.AppendLine("</tbody></table>");
|
||||
|
||||
return await SaveHtmlAsync(
|
||||
fileName: $"export-tageszusammenfassung-{startDate:yyyy-MM-dd}-bis-{endDate:yyyy-MM-dd}.html",
|
||||
title: $"Export Tageszusammenfassung {FormatDateRange(startDate, endDate)}",
|
||||
bodyHtml: sb.ToString(),
|
||||
compactA4: true);
|
||||
}
|
||||
|
||||
private async Task<ExportResult> ExportDayHtmlAsync(DateTime date)
|
||||
{
|
||||
var entries = await _healthEntryRepository.GetEntriesForDateAsync(date);
|
||||
@@ -315,6 +518,88 @@ public sealed class PdfExportService : IPdfExportService
|
||||
.ToList());
|
||||
}
|
||||
|
||||
private void AppendDayDetailTable(
|
||||
StringBuilder sb,
|
||||
IReadOnlyList<HealthEntry> entries,
|
||||
IReadOnlyDictionary<int, string> activityNames,
|
||||
IReadOnlyDictionary<int, List<string>> symptomNamesByEntry)
|
||||
{
|
||||
var conflicts = DetectDayExportConflicts(entries);
|
||||
if (conflicts.Count > 0)
|
||||
sb.AppendLine(BuildConflictHtml(conflicts));
|
||||
|
||||
sb.AppendLine("<table>");
|
||||
sb.AppendLine("<thead><tr><th>Zeit</th><th>Status</th><th>Tätigkeit</th><th>Dauer</th><th>Symptome</th></tr></thead>");
|
||||
sb.AppendLine("<tbody>");
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
var symptoms = symptomNamesByEntry.TryGetValue(entry.Id, out var symptomList) && symptomList.Count > 0
|
||||
? string.Join(", ", symptomList)
|
||||
: "—";
|
||||
|
||||
var activity = entry.ActivityId.HasValue && activityNames.TryGetValue(entry.ActivityId.Value, out var activityName)
|
||||
? activityName
|
||||
: "—";
|
||||
|
||||
sb.AppendLine("<tr>");
|
||||
sb.AppendLine($"<td>{Encode(GetDayTimeLabel(entry))}</td>");
|
||||
sb.AppendLine(StateCell(entry.State, GetStateText(entry.State)));
|
||||
sb.AppendLine($"<td>{Encode(activity)}</td>");
|
||||
sb.AppendLine($"<td>{Encode(FormatDuration(entry.ActivityDurationMinutes))}</td>");
|
||||
sb.AppendLine($"<td>{Encode(symptoms)}</td>");
|
||||
sb.AppendLine("</tr>");
|
||||
}
|
||||
|
||||
if (entries.Count == 0)
|
||||
sb.AppendLine("<tr><td colspan=\"5\">Keine Einträge vorhanden.</td></tr>");
|
||||
|
||||
sb.AppendLine("</tbody></table>");
|
||||
}
|
||||
|
||||
private string BuildDistinctActivityList(IEnumerable<HealthEntry> entries, IReadOnlyDictionary<int, string> activityNames)
|
||||
{
|
||||
var activities = entries
|
||||
.Where(x => x.ActivityId.HasValue && activityNames.ContainsKey(x.ActivityId.Value))
|
||||
.Select(x => activityNames[x.ActivityId!.Value])
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Where(x => !string.Equals(x, "Keine Tätigkeit", StringComparison.OrdinalIgnoreCase))
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
|
||||
return activities.Count > 0
|
||||
? string.Join(", ", activities)
|
||||
: "—";
|
||||
}
|
||||
|
||||
private static string BuildDistinctSymptomList(IEnumerable<HealthEntry> entries, IReadOnlyDictionary<int, List<string>> symptomNamesByEntry)
|
||||
{
|
||||
var symptoms = entries
|
||||
.Where(x => symptomNamesByEntry.ContainsKey(x.Id))
|
||||
.SelectMany(x => symptomNamesByEntry[x.Id])
|
||||
.Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
|
||||
return symptoms.Count > 0
|
||||
? string.Join(", ", symptoms)
|
||||
: "—";
|
||||
}
|
||||
|
||||
private static IEnumerable<HealthEntry> FilterEntriesForDayPart(IEnumerable<HealthEntry> entries, DayPart part)
|
||||
{
|
||||
return entries.Where(x =>
|
||||
{
|
||||
if (x.DayPart.HasValue)
|
||||
return x.DayPart == part;
|
||||
|
||||
return part == DayPart.Morning
|
||||
? x.Timestamp.Hour < 12
|
||||
: x.Timestamp.Hour >= 12;
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<ExportResult> SaveHtmlAsync(
|
||||
string fileName,
|
||||
string title,
|
||||
@@ -378,6 +663,23 @@ public sealed class PdfExportService : IPdfExportService
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
private static (DateTime StartDate, DateTime EndDate) NormalizeDateRange(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var rangeStart = startDate.Date;
|
||||
var rangeEnd = endDate.Date;
|
||||
|
||||
return rangeEnd < rangeStart
|
||||
? (rangeEnd, rangeStart)
|
||||
: (rangeStart, rangeEnd);
|
||||
}
|
||||
|
||||
private static string FormatDateRange(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
return startDate.Date == endDate.Date
|
||||
? startDate.ToString("dd.MM.yyyy", DateHelper.GermanCulture)
|
||||
: $"{startDate:dd.MM.yyyy} bis {endDate:dd.MM.yyyy}";
|
||||
}
|
||||
|
||||
private static DateTime StartOfWeekMonday(DateTime date)
|
||||
{
|
||||
var diff = ((int)date.DayOfWeek + 6) % 7;
|
||||
@@ -467,6 +769,24 @@ public sealed class PdfExportService : IPdfExportService
|
||||
font-size: {{(compactA4 ? "18px" : "28px")}};
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: {{(compactA4 ? "8px" : "16px")}} 0 {{(compactA4 ? "6px" : "10px")}} 0;
|
||||
font-size: {{(compactA4 ? "15px" : "22px")}};
|
||||
}
|
||||
|
||||
.summary-note {
|
||||
margin: 0 0 {{(compactA4 ? "8px" : "14px")}} 0;
|
||||
}
|
||||
|
||||
.export-section + .export-section {
|
||||
margin-top: {{(compactA4 ? "8px" : "14px")}};
|
||||
}
|
||||
|
||||
.page-break {
|
||||
break-before: page;
|
||||
page-break-before: always;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
@@ -512,6 +832,11 @@ public sealed class PdfExportService : IPdfExportService
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
.summary-day {
|
||||
width: 18%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.conflict-box {
|
||||
border: 1px solid #000000;
|
||||
background: #fff8e1;
|
||||
@@ -609,4 +934,4 @@ public sealed class PdfExportService : IPdfExportService
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,15 @@ public partial class OptionsViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private OptionsTab selectedTab = OptionsTab.Notifications;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime exportStartDate = DateTime.Today;
|
||||
|
||||
[ObservableProperty]
|
||||
private DateTime exportEndDate = DateTime.Today;
|
||||
|
||||
[ObservableProperty]
|
||||
private ExportLayout selectedExportLayout = ExportLayout.DaySummary;
|
||||
|
||||
public ObservableCollection<AppearanceColorItemViewModel> AppearanceColors { get; } = new();
|
||||
public ObservableCollection<AppearanceTextItemViewModel> StatusTexts { get; } = new();
|
||||
public ObservableCollection<ActivityManageItemViewModel> Activities { get; } = new();
|
||||
@@ -57,8 +66,33 @@ public partial class OptionsViewModel : ObservableObject
|
||||
public bool IsAppearanceTabSelected => SelectedTab == OptionsTab.Appearance;
|
||||
public bool IsNotificationsTabSelected => SelectedTab == OptionsTab.Notifications;
|
||||
public bool IsDataManagementTabSelected => SelectedTab == OptionsTab.DataManagement;
|
||||
public bool IsExportTabSelected => SelectedTab == OptionsTab.Export;
|
||||
|
||||
public string NotificationVibrationButtonText => NotificationVibrationEnabled ? "Aktiv" : "Inaktiv";
|
||||
public bool IsDayViewExportLayoutSelected => SelectedExportLayout == ExportLayout.DayView;
|
||||
public bool IsWeekBlockExportLayoutSelected => SelectedExportLayout == ExportLayout.WeekBlock;
|
||||
public bool IsDaySummaryExportLayoutSelected => SelectedExportLayout == ExportLayout.DaySummary;
|
||||
|
||||
public string ExportRangeSummary
|
||||
{
|
||||
get
|
||||
{
|
||||
var start = ExportStartDate.Date;
|
||||
var end = ExportEndDate.Date;
|
||||
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}";
|
||||
}
|
||||
}
|
||||
|
||||
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: Der Zeitraum wird in Wochen gruppiert. Pro Tag siehst du Vormittag, Nachmittag und die wichtigsten Details.",
|
||||
_ => "Tageszusammenfassung: Jeder Tag erscheint kompakt in einer Zeile, ähnlich wie bei Monats- und Jahresexporten."
|
||||
};
|
||||
|
||||
public IAsyncRelayCommand DeleteAllDataCommand { get; }
|
||||
public IAsyncRelayCommand SaveAppearanceCommand { get; }
|
||||
@@ -76,10 +110,15 @@ public partial class OptionsViewModel : ObservableObject
|
||||
public IAsyncRelayCommand<NotificationScheduleItemViewModel> DeleteScheduleCommand { get; }
|
||||
public IAsyncRelayCommand SaveDatabaseLocationCommand { get; }
|
||||
public IAsyncRelayCommand ClearExportsCommand { get; }
|
||||
public IAsyncRelayCommand ExportSelectedRangeCommand { get; }
|
||||
public IRelayCommand ToggleNotificationVibrationCommand { get; }
|
||||
public IRelayCommand ShowAppearanceTabCommand { get; }
|
||||
public IRelayCommand ShowNotificationsTabCommand { get; }
|
||||
public IRelayCommand ShowDataManagementTabCommand { get; }
|
||||
public IRelayCommand ShowExportTabCommand { get; }
|
||||
public IRelayCommand SelectDayViewExportLayoutCommand { get; }
|
||||
public IRelayCommand SelectWeekBlockExportLayoutCommand { get; }
|
||||
public IRelayCommand SelectDaySummaryExportLayoutCommand { get; }
|
||||
|
||||
public OptionsViewModel(
|
||||
HealthEntryRepository healthEntryRepository,
|
||||
@@ -120,6 +159,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
DeleteScheduleCommand = new AsyncRelayCommand<NotificationScheduleItemViewModel>(DeleteScheduleAsync);
|
||||
SaveDatabaseLocationCommand = new AsyncRelayCommand(SaveDatabaseLocationAsync);
|
||||
ClearExportsCommand = new AsyncRelayCommand(ClearExportsAsync);
|
||||
ExportSelectedRangeCommand = new AsyncRelayCommand(ExportSelectedRangeAsync);
|
||||
|
||||
ToggleNotificationVibrationCommand = new RelayCommand(() =>
|
||||
{
|
||||
@@ -129,6 +169,11 @@ public partial class OptionsViewModel : ObservableObject
|
||||
ShowAppearanceTabCommand = new RelayCommand(() => SelectedTab = OptionsTab.Appearance);
|
||||
ShowNotificationsTabCommand = new RelayCommand(() => SelectedTab = OptionsTab.Notifications);
|
||||
ShowDataManagementTabCommand = new RelayCommand(() => SelectedTab = OptionsTab.DataManagement);
|
||||
ShowExportTabCommand = new RelayCommand(() => SelectedTab = OptionsTab.Export);
|
||||
|
||||
SelectDayViewExportLayoutCommand = new RelayCommand(() => SelectedExportLayout = ExportLayout.DayView);
|
||||
SelectWeekBlockExportLayoutCommand = new RelayCommand(() => SelectedExportLayout = ExportLayout.WeekBlock);
|
||||
SelectDaySummaryExportLayoutCommand = new RelayCommand(() => SelectedExportLayout = ExportLayout.DaySummary);
|
||||
}
|
||||
|
||||
partial void OnDeleteConfirmationTextChanged(string value)
|
||||
@@ -141,6 +186,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
OnPropertyChanged(nameof(IsAppearanceTabSelected));
|
||||
OnPropertyChanged(nameof(IsNotificationsTabSelected));
|
||||
OnPropertyChanged(nameof(IsDataManagementTabSelected));
|
||||
OnPropertyChanged(nameof(IsExportTabSelected));
|
||||
}
|
||||
|
||||
partial void OnNotificationVibrationEnabledChanged(bool value)
|
||||
@@ -148,6 +194,30 @@ public partial class OptionsViewModel : ObservableObject
|
||||
OnPropertyChanged(nameof(NotificationVibrationButtonText));
|
||||
}
|
||||
|
||||
partial void OnExportStartDateChanged(DateTime value)
|
||||
{
|
||||
if (ExportEndDate.Date < value.Date)
|
||||
ExportEndDate = value.Date;
|
||||
|
||||
OnPropertyChanged(nameof(ExportRangeSummary));
|
||||
}
|
||||
|
||||
partial void OnExportEndDateChanged(DateTime value)
|
||||
{
|
||||
if (ExportStartDate.Date > value.Date)
|
||||
ExportStartDate = value.Date;
|
||||
|
||||
OnPropertyChanged(nameof(ExportRangeSummary));
|
||||
}
|
||||
|
||||
partial void OnSelectedExportLayoutChanged(ExportLayout value)
|
||||
{
|
||||
OnPropertyChanged(nameof(IsDayViewExportLayoutSelected));
|
||||
OnPropertyChanged(nameof(IsWeekBlockExportLayoutSelected));
|
||||
OnPropertyChanged(nameof(IsDaySummaryExportLayoutSelected));
|
||||
OnPropertyChanged(nameof(SelectedExportLayoutDescription));
|
||||
}
|
||||
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
await LoadAppearanceAsync();
|
||||
@@ -509,6 +579,24 @@ public partial class OptionsViewModel : ObservableObject
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task ExportSelectedRangeAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _pdfExportService.ExportRangeAsync(
|
||||
ExportStartDate.Date,
|
||||
ExportEndDate.Date,
|
||||
SelectedExportLayout);
|
||||
|
||||
StatusText = $"Export erstellt: {result.FileName}";
|
||||
await ExportUiHelper.ShowExportSavedActionsAsync(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StatusText = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ClearExportsAsync()
|
||||
{
|
||||
var confirm = await Shell.Current.DisplayAlertAsync(
|
||||
@@ -544,6 +632,7 @@ public partial class OptionsViewModel : ObservableObject
|
||||
{
|
||||
Appearance,
|
||||
Notifications,
|
||||
DataManagement
|
||||
DataManagement,
|
||||
Export
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
x:Name="RootPage"
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:cfs_tracker.Views"
|
||||
xmlns:viewModels="clr-namespace:cfs_tracker.ViewModels"
|
||||
x:DataType="viewModels:MonthViewModel"
|
||||
Title="Monat"
|
||||
@@ -76,7 +77,7 @@
|
||||
Padding="6"
|
||||
MinimumHeightRequest="58">
|
||||
<Border.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.OpenDayCommand}"
|
||||
<TapGestureRecognizer Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.OpenDayCommand, x:DataType=views:MonthPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Border.GestureRecognizers>
|
||||
|
||||
@@ -94,4 +95,4 @@
|
||||
</CollectionView.ItemTemplate>
|
||||
</CollectionView>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</ContentPage>
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace cfs_tracker.Views;
|
||||
public partial class MonthPage : ContentPage
|
||||
{
|
||||
private readonly MonthViewModel _viewModel;
|
||||
public MonthViewModel ViewModel => _viewModel;
|
||||
|
||||
public MonthPage(MonthViewModel viewModel)
|
||||
{
|
||||
|
||||
+130
-21
@@ -3,6 +3,7 @@
|
||||
x:Name="RootPage"
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:cfs_tracker.Views"
|
||||
xmlns:viewModels="clr-namespace:cfs_tracker.ViewModels"
|
||||
x:DataType="viewModels:OptionsViewModel"
|
||||
Title="Optionen"
|
||||
@@ -91,6 +92,21 @@
|
||||
</DataTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button Text="Export"
|
||||
Style="{StaticResource OptionsTabButtonStyle}"
|
||||
Command="{Binding ShowExportTabCommand}">
|
||||
<Button.Triggers>
|
||||
<DataTrigger TargetType="Button"
|
||||
Binding="{Binding IsExportTabSelected}"
|
||||
Value="True">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{DynamicResource ButtonSecondaryBackground}" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{DynamicResource ButtonSecondaryText}" />
|
||||
</DataTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
</FlexLayout>
|
||||
</Border>
|
||||
|
||||
@@ -332,7 +348,7 @@
|
||||
|
||||
<Button Text="Entfernen"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.DeleteScheduleCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.DeleteScheduleCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</VerticalStackLayout>
|
||||
</Border>
|
||||
@@ -347,6 +363,112 @@
|
||||
</Border>
|
||||
</VerticalStackLayout>
|
||||
|
||||
<VerticalStackLayout IsVisible="{Binding IsExportTabSelected}"
|
||||
Spacing="16">
|
||||
<Border Padding="12"
|
||||
Stroke="{DynamicResource Border}"
|
||||
BackgroundColor="{DynamicResource SurfaceBackground}">
|
||||
<VerticalStackLayout Spacing="12">
|
||||
<Label Text="Export"
|
||||
FontSize="20"
|
||||
FontAttributes="Bold"
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
|
||||
<Label Text="Lege Zeitraum und Darstellung fest. Nach dem Erstellen kannst du den Export direkt öffnen oder teilen."
|
||||
TextColor="{DynamicResource TextMuted}" />
|
||||
|
||||
<Grid ColumnDefinitions="*,*"
|
||||
ColumnSpacing="12">
|
||||
<VerticalStackLayout Spacing="4">
|
||||
<Label Text="Von"
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
<DatePicker Date="{Binding ExportStartDate}"
|
||||
MaximumDate="{Binding ExportEndDate}" />
|
||||
</VerticalStackLayout>
|
||||
|
||||
<VerticalStackLayout Grid.Column="1"
|
||||
Spacing="4">
|
||||
<Label Text="Bis"
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
<DatePicker Date="{Binding ExportEndDate}"
|
||||
MinimumDate="{Binding ExportStartDate}" />
|
||||
</VerticalStackLayout>
|
||||
</Grid>
|
||||
|
||||
<Label Text="{Binding ExportRangeSummary}"
|
||||
TextColor="{DynamicResource TextMuted}" />
|
||||
|
||||
<Label Text="Exportmodus"
|
||||
FontAttributes="Bold"
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
|
||||
<FlexLayout Direction="Row"
|
||||
Wrap="Wrap"
|
||||
AlignItems="Start"
|
||||
JustifyContent="Start">
|
||||
<Button Text="Tagesansicht"
|
||||
Style="{StaticResource DayToggleButtonStyle}"
|
||||
Margin="0,0,10,10"
|
||||
Command="{Binding SelectDayViewExportLayoutCommand}">
|
||||
<Button.Triggers>
|
||||
<DataTrigger TargetType="Button"
|
||||
Binding="{Binding IsDayViewExportLayoutSelected}"
|
||||
Value="True">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{DynamicResource ButtonSecondaryBackground}" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{DynamicResource ButtonSecondaryText}" />
|
||||
</DataTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button Text="Wochenblock"
|
||||
Style="{StaticResource DayToggleButtonStyle}"
|
||||
Margin="0,0,10,10"
|
||||
Command="{Binding SelectWeekBlockExportLayoutCommand}">
|
||||
<Button.Triggers>
|
||||
<DataTrigger TargetType="Button"
|
||||
Binding="{Binding IsWeekBlockExportLayoutSelected}"
|
||||
Value="True">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{DynamicResource ButtonSecondaryBackground}" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{DynamicResource ButtonSecondaryText}" />
|
||||
</DataTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button Text="Tageszusammenfassung"
|
||||
Style="{StaticResource DayToggleButtonStyle}"
|
||||
Margin="0,0,10,10"
|
||||
Command="{Binding SelectDaySummaryExportLayoutCommand}">
|
||||
<Button.Triggers>
|
||||
<DataTrigger TargetType="Button"
|
||||
Binding="{Binding IsDaySummaryExportLayoutSelected}"
|
||||
Value="True">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="{DynamicResource ButtonSecondaryBackground}" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{DynamicResource ButtonSecondaryText}" />
|
||||
</DataTrigger>
|
||||
</Button.Triggers>
|
||||
</Button>
|
||||
</FlexLayout>
|
||||
|
||||
<Label Text="{Binding SelectedExportLayoutDescription}"
|
||||
TextColor="{DynamicResource TextMuted}" />
|
||||
|
||||
<Button Text="Export erstellen"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
Command="{Binding ExportSelectedRangeCommand}" />
|
||||
|
||||
<Button Text="Export entleeren"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding ClearExportsCommand}" />
|
||||
</VerticalStackLayout>
|
||||
</Border>
|
||||
</VerticalStackLayout>
|
||||
|
||||
<VerticalStackLayout IsVisible="{Binding IsDataManagementTabSelected}"
|
||||
Spacing="16">
|
||||
<Border Padding="12"
|
||||
@@ -384,17 +506,17 @@
|
||||
ColumnSpacing="8">
|
||||
<Button Text="Speichern"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.SaveActivityCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.SaveActivityCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
<Button Grid.Column="1"
|
||||
Text="Aktiv/Inaktiv"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.ToggleActivityActiveCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.ToggleActivityActiveCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
<Button Grid.Column="2"
|
||||
Text="Entfernen"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.DeleteActivityCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.DeleteActivityCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
@@ -440,17 +562,17 @@
|
||||
ColumnSpacing="8">
|
||||
<Button Text="Speichern"
|
||||
Style="{StaticResource PrimaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.SaveSymptomCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.SaveSymptomCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
<Button Grid.Column="1"
|
||||
Text="Aktiv/Inaktiv"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.ToggleSymptomActiveCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.ToggleSymptomActiveCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
<Button Grid.Column="2"
|
||||
Text="Entfernen"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.DeleteSymptomCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.DeleteSymptomCommand, x:DataType=views:OptionsPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
@@ -512,19 +634,6 @@
|
||||
</VerticalStackLayout>
|
||||
</Border>
|
||||
|
||||
<Border Padding="12"
|
||||
Stroke="{DynamicResource Border}"
|
||||
BackgroundColor="{DynamicResource SurfaceBackground}">
|
||||
<VerticalStackLayout Spacing="10">
|
||||
<Label Text="Export"
|
||||
FontAttributes="Bold"
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
|
||||
<Button Text="Export entleeren"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding ClearExportsCommand}" />
|
||||
</VerticalStackLayout>
|
||||
</Border>
|
||||
</VerticalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
@@ -664,4 +773,4 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</ContentPage>
|
||||
|
||||
@@ -12,6 +12,7 @@ public partial class OptionsPage : ContentPage
|
||||
private static readonly Regex HexColorRegex = new("^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$", RegexOptions.Compiled);
|
||||
|
||||
private readonly OptionsViewModel _viewModel;
|
||||
public OptionsViewModel ViewModel => _viewModel;
|
||||
private bool _isLoading;
|
||||
private bool _appearanceEditorsBuilt;
|
||||
private bool _appearanceEditorsDirty = true;
|
||||
|
||||
@@ -4,40 +4,12 @@
|
||||
x:Name="RootPage"
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:cfs_tracker.Views"
|
||||
xmlns:viewModels="clr-namespace:cfs_tracker.ViewModels"
|
||||
x:DataType="viewModels:QuickEntryViewModel"
|
||||
Title="Eintrag"
|
||||
BackgroundColor="{DynamicResource AppBackground}">
|
||||
|
||||
<ContentPage.Resources>
|
||||
<Style x:Key="SymptomToggleBorderStyle" TargetType="Border">
|
||||
<Setter Property="Padding" Value="12,10" />
|
||||
<Setter Property="StrokeThickness" Value="1" />
|
||||
<Setter Property="Stroke" Value="{DynamicResource Border}" />
|
||||
<Setter Property="StrokeShape" Value="RoundRectangle 12" />
|
||||
<Setter Property="BackgroundColor" Value="{DynamicResource ButtonPrimaryBackground}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger TargetType="Border"
|
||||
Binding="{Binding IsSelected}"
|
||||
Value="True">
|
||||
<Setter Property="BackgroundColor" Value="{DynamicResource ButtonSecondaryBackground}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SymptomToggleLabelStyle" TargetType="Label">
|
||||
<Setter Property="VerticalOptions" Value="Center" />
|
||||
<Setter Property="TextColor" Value="{DynamicResource ButtonPrimaryText}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger TargetType="Label"
|
||||
Binding="{Binding IsSelected}"
|
||||
Value="True">
|
||||
<Setter Property="TextColor" Value="{DynamicResource ButtonSecondaryText}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ContentPage.Resources>
|
||||
|
||||
<ScrollView>
|
||||
<VerticalStackLayout Padding="16" Spacing="16">
|
||||
|
||||
@@ -63,7 +35,7 @@
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
<Picker Title="Tageszeit"
|
||||
ItemsSource="{Binding Parts}"
|
||||
ItemDisplayBinding="{Binding Name, x:DataType={x:Null}}"
|
||||
ItemDisplayBinding="{Binding Name, x:DataType=viewModels:DayPartOptionItemViewModel}"
|
||||
SelectedItem="{Binding SelectedPart}" />
|
||||
</VerticalStackLayout>
|
||||
</Border>
|
||||
@@ -78,7 +50,7 @@
|
||||
TextColor="{DynamicResource TextPrimary}" />
|
||||
<Picker Title="Tätigkeit"
|
||||
ItemsSource="{Binding Activities}"
|
||||
ItemDisplayBinding="{Binding Name, x:DataType={x:Null}}"
|
||||
ItemDisplayBinding="{Binding Name, x:DataType=viewModels:ActivityPickerItemViewModel}"
|
||||
SelectedItem="{Binding SelectedActivity}" />
|
||||
|
||||
<Label Text="Dauer (HH:mm)"
|
||||
@@ -109,7 +81,7 @@
|
||||
BackgroundColor="{DynamicResource ButtonPrimaryBackground}">
|
||||
<Border.GestureRecognizers>
|
||||
<TapGestureRecognizer
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.ToggleSymptomCommand}"
|
||||
Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.ToggleSymptomCommand, x:DataType=views:QuickEntryPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Border.GestureRecognizers>
|
||||
|
||||
@@ -223,4 +195,4 @@
|
||||
HorizontalOptions="Fill" />
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
</ContentPage>
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace cfs_tracker.Views;
|
||||
public partial class QuickEntryPage : ContentPage, IQueryAttributable
|
||||
{
|
||||
private readonly QuickEntryViewModel _vm;
|
||||
public QuickEntryViewModel ViewModel => _vm;
|
||||
|
||||
public QuickEntryPage(QuickEntryViewModel vm)
|
||||
{
|
||||
@@ -31,4 +32,4 @@ public partial class QuickEntryPage : ContentPage, IQueryAttributable
|
||||
statusValue?.ToString(),
|
||||
commitValue?.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@
|
||||
x:Name="RootPage"
|
||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:cfs_tracker.Views"
|
||||
xmlns:viewModels="clr-namespace:cfs_tracker.ViewModels"
|
||||
x:DataType="viewModels:YearViewModel"
|
||||
Title="Jahr"
|
||||
@@ -88,7 +89,7 @@
|
||||
Padding="3"
|
||||
MinimumHeightRequest="30">
|
||||
<Border.GestureRecognizers>
|
||||
<TapGestureRecognizer Command="{Binding Source={x:Reference RootPage}, Path=BindingContext.OpenDayCommand}"
|
||||
<TapGestureRecognizer Command="{Binding Source={x:Reference RootPage}, Path=ViewModel.OpenDayCommand, x:DataType=views:YearPage}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Border.GestureRecognizers>
|
||||
|
||||
@@ -110,4 +111,4 @@
|
||||
</VerticalStackLayout>
|
||||
</ScrollView>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</ContentPage>
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace cfs_tracker.Views;
|
||||
public partial class YearPage : ContentPage
|
||||
{
|
||||
private readonly YearViewModel _viewModel;
|
||||
public YearViewModel ViewModel => _viewModel;
|
||||
|
||||
public YearPage(YearViewModel viewModel)
|
||||
{
|
||||
@@ -28,4 +29,4 @@ public partial class YearPage : ContentPage
|
||||
await DisplayAlertAsync("Fehler", ex.ToString(), "OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user