Options fix

clean up and fixes

- Heute gefixt
- Code Cleanup

NotificationScheduleItemViewModel

-fixed NotificationScheduleItemViewModel for Windows compat

push implementation

Push fixes

Push benachrichtungen eingebaut
- Status bei push
- Push auch in background
- Toggle für symtome angepasst

push system change

exporter update

Optionen fix

- Optionen aufgeteilt auf 3 tabs
- Anpassungen haben jetzt Farbslider

Optimierung fix
This commit is contained in:
2026-03-24 23:35:01 +01:00
parent d85f2e0fb3
commit d11f0e46c0
46 changed files with 2362 additions and 517 deletions
-2
View File
@@ -1,7 +1,5 @@
using cfs_tracker.Data;
using cfs_tracker.Helpers;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
namespace cfs_tracker.Services;
-2
View File
@@ -1,5 +1,3 @@
using Microsoft.Maui.Storage;
namespace cfs_tracker.Services;
public class DatabaseLocationService
+1 -3
View File
@@ -1,6 +1,4 @@
using Microsoft.Maui.ApplicationModel;
namespace cfs_tracker.Services;
namespace cfs_tracker.Services;
public static class ExportUiHelper
{
+2 -1
View File
@@ -2,5 +2,6 @@ namespace cfs_tracker.Services;
public interface INotificationScheduler
{
Task SyncAsync(CancellationToken cancellationToken = default);
Task<bool> EnsurePermissionAsync();
Task SyncAsync();
}
+2 -4
View File
@@ -2,8 +2,6 @@ namespace cfs_tracker.Services;
public sealed class NoOpNotificationScheduler : INotificationScheduler
{
public Task SyncAsync(CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
public Task<bool> EnsurePermissionAsync() => Task.FromResult(true);
public Task SyncAsync() => Task.CompletedTask;
}
+41
View File
@@ -0,0 +1,41 @@
using cfs_tracker.Views;
namespace cfs_tracker.Services;
public sealed class NotificationNavigationService
{
private string? _pendingDate;
private string? _pendingStatus;
private bool _pendingCommit;
public void QueueQuickEntry(DateTime date, string? status = null, bool commit = false)
{
_pendingDate = date.ToString("yyyy-MM-dd");
_pendingStatus = status;
_pendingCommit = commit;
}
public async Task FlushAsync()
{
if (Shell.Current is null || string.IsNullOrWhiteSpace(_pendingDate))
return;
var date = _pendingDate;
var status = _pendingStatus;
var commit = _pendingCommit;
_pendingDate = null;
_pendingStatus = null;
_pendingCommit = false;
var route = $"{nameof(QuickEntryPage)}?date={Uri.EscapeDataString(date)}";
if (!string.IsNullOrWhiteSpace(status))
route += $"&status={Uri.EscapeDataString(status)}";
if (commit)
route += "&commit=true";
await MainThread.InvokeOnMainThreadAsync(() => Shell.Current.GoToAsync(route));
}
}
+108 -11
View File
@@ -1,8 +1,6 @@
using cfs_tracker.Data;
using cfs_tracker.Helpers;
using cfs_tracker.Models;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Storage;
using System.Net;
using System.Text;
@@ -47,16 +45,21 @@ public sealed class PdfExportService : IPdfExportService
var entries = await _healthEntryRepository.GetEntriesForDateAsync(date);
var activityNames = await GetActivityNamesAsync();
var symptomNamesByEntry = await GetSymptomNamesByEntryAsync(entries.Select(x => x.Id));
var conflicts = DetectDayExportConflicts(entries);
var sb = new StringBuilder();
sb.AppendLine($"<h1>Tagesübersicht – {Encode(date.ToString("dd.MM.yyyy"))}</h1>");
if (conflicts.Count > 0)
sb.AppendLine(BuildConflictHtml(conflicts));
sb.AppendLine("<table>");
sb.AppendLine("<thead><tr><th>Uhrzeit</th><th>Status</th><th>Tätigkeit</th><th>Symptome</th></tr></thead>");
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.OrderBy(x => x.Timestamp).ThenBy(x => x.Id))
{
var symptoms = symptomNamesByEntry.TryGetValue(entry.Id, out var symptomList)
var symptoms = symptomNamesByEntry.TryGetValue(entry.Id, out var symptomList) && symptomList.Count > 0
? string.Join(", ", symptomList)
: "—";
@@ -65,15 +68,16 @@ public sealed class PdfExportService : IPdfExportService
: "—";
sb.AppendLine("<tr>");
sb.AppendLine($"<td>{Encode(entry.Timestamp.ToString("HH:mm"))}</td>");
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=\"4\">Keine Einträge vorhanden.</td></tr>");
sb.AppendLine("<tr><td colspan=\"5\">Keine Einträge vorhanden.</td></tr>");
sb.AppendLine("</tbody></table>");
@@ -310,6 +314,7 @@ public sealed class PdfExportService : IPdfExportService
.Distinct()
.ToList());
}
private async Task<ExportResult> SaveHtmlAsync(
string fileName,
string title,
@@ -319,17 +324,20 @@ public sealed class PdfExportService : IPdfExportService
var folder = GetExportFolderPath();
Directory.CreateDirectory(folder);
var path = Path.Combine(folder, fileName);
var html = WrapHtml(title, bodyHtml, compactA4);
var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
var extension = Path.GetExtension(fileName);
var path = GetUniqueFilePath(folder, fileNameWithoutExtension, extension);
var html = WrapHtml(title, bodyHtml, compactA4);
await File.WriteAllTextAsync(path, html, Encoding.UTF8);
return new ExportResult
{
FilePath = path,
FileName = fileName
FileName = Path.GetFileName(path)
};
}
private string StateCell(HealthState state, string text)
{
var background = GetStateBackgroundCss(state);
@@ -436,8 +444,6 @@ public sealed class PdfExportService : IPdfExportService
}
catch
{
// absichtlich ignorieren, damit eine einzelne blockierte Datei
// nicht den ganzen Vorgang abbricht
}
}
@@ -514,6 +520,18 @@ public sealed class PdfExportService : IPdfExportService
.compact-symptoms {
width: 32%;
}
.conflict-box {
border: 1px solid #000000;
background: #fff8e1;
padding: {{(compactA4 ? "6px" : "10px")}};
margin-bottom: {{(compactA4 ? "8px" : "14px")}};
}
.conflict-box ul {
margin: 6px 0 0 18px;
padding: 0;
}
</style>
</head>
<body>
@@ -521,4 +539,83 @@ public sealed class PdfExportService : IPdfExportService
</body>
</html>
""";
private static string GetUniqueFilePath(string directory, string fileNameWithoutExtension, string extension)
{
Directory.CreateDirectory(directory);
var safeExtension = string.IsNullOrWhiteSpace(extension)
? ".html"
: (extension.StartsWith('.') ? extension : "." + extension);
var basePath = Path.Combine(directory, fileNameWithoutExtension + safeExtension);
if (!File.Exists(basePath))
return basePath;
var counter = 1;
while (true)
{
var candidate = Path.Combine(directory, $"{fileNameWithoutExtension} ({counter}){safeExtension}");
if (!File.Exists(candidate))
return candidate;
counter++;
}
}
private static string GetDayTimeLabel(HealthEntry entry)
{
if (entry.DayPart == DayPart.Morning)
return "Vormittag";
if (entry.DayPart == DayPart.Afternoon)
return "Nachmittag";
return entry.Timestamp.ToString("HH:mm");
}
private static string FormatDuration(int? durationMinutes)
{
if (!durationMinutes.HasValue || durationMinutes.Value <= 0)
return "—";
var duration = TimeSpan.FromMinutes(durationMinutes.Value);
return duration.ToString(@"hh\:mm");
}
private static List<string> DetectDayExportConflicts(IEnumerable<HealthEntry> entries)
{
var result = new List<string>();
var morningCount = entries.Count(x => x.DayPart == DayPart.Morning);
var afternoonCount = entries.Count(x => x.DayPart == DayPart.Afternoon);
if (morningCount > 1)
result.Add("Mehrere Vormittag-Einträge gefunden.");
if (afternoonCount > 1)
result.Add("Mehrere Nachmittag-Einträge gefunden.");
return result;
}
private static string BuildConflictHtml(IEnumerable<string> conflicts)
{
var list = conflicts.ToList();
if (list.Count == 0)
return string.Empty;
var sb = new StringBuilder();
sb.AppendLine("<div class=\"conflict-box\">");
sb.AppendLine("<strong>Hinweis auf mögliche Konflikte:</strong>");
sb.AppendLine("<ul>");
foreach (var item in list)
sb.AppendLine($"<li>{Encode(item)}</li>");
sb.AppendLine("</ul>");
sb.AppendLine("</div>");
return sb.ToString();
}
}