7b824b6f0c
- Layout und Kalender angepasst - Push status meldung angepasst für Android
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
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 (string.IsNullOrWhiteSpace(_pendingDate))
|
|
return;
|
|
|
|
for (var attempt = 0; attempt < 20; attempt++)
|
|
{
|
|
if (Shell.Current is not null)
|
|
{
|
|
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));
|
|
return;
|
|
}
|
|
|
|
await Task.Delay(150);
|
|
}
|
|
}
|
|
} |