Layout fixes and Push fixes

- Layout und Kalender angepasst
- Push status meldung angepasst für Android
This commit is contained in:
2026-03-27 11:58:53 +01:00
parent d11f0e46c0
commit 7b824b6f0c
14 changed files with 780 additions and 609 deletions
+32 -5
View File
@@ -5,6 +5,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Maui.ApplicationModel;
using System.Collections.ObjectModel;
using System.Linq;
namespace cfs_tracker.ViewModels;
@@ -66,11 +67,14 @@ public partial class MonthViewModel : ObservableObject
var monthStart = new DateTime(SelectedDate.Year, SelectedDate.Month, 1);
var monthEnd = monthStart.AddMonths(1);
var daysInMonth = DateTime.DaysInMonth(monthStart.Year, monthStart.Month);
var entries = await _healthEntryRepository.GetEntriesBetweenAsync(monthStart, monthEnd);
Cells.Clear();
var daysInMonth = DateTime.DaysInMonth(monthStart.Year, monthStart.Month);
var leadingEmptyCells = GetMondayBasedColumnIndex(monthStart.DayOfWeek);
for (var i = 0; i < leadingEmptyCells; i++)
Cells.Add(CreatePlaceholderCell());
for (var day = 1; day <= daysInMonth; day++)
{
@@ -93,17 +97,19 @@ public partial class MonthViewModel : ObservableObject
: _appearanceService.GetColor(AppearanceKeys.Border, "#2A3E55")
});
}
while (Cells.Count % 7 != 0)
Cells.Add(CreatePlaceholderCell());
}
private void UpdateHeader()
{
var month = new DateTime(SelectedDate.Year, SelectedDate.Month, 1);
HeaderText = DateHelper.ToGermanMonthYear(month);
HeaderText = DateHelper.ToGermanMonthYear(SelectedDate.Date);
}
private async Task OpenDayAsync(MonthCellViewModel? item)
{
if (item is null)
if (item is null || !item.IsCurrentMonth)
return;
SelectedDate = item.Date.Date;
@@ -147,4 +153,25 @@ public partial class MonthViewModel : ObservableObject
await RefreshAsync();
});
}
}
private static int GetMondayBasedColumnIndex(DayOfWeek dayOfWeek)
{
return dayOfWeek == DayOfWeek.Sunday ? 6 : ((int)dayOfWeek - 1);
}
private static MonthCellViewModel CreatePlaceholderCell()
{
return new MonthCellViewModel
{
Date = DateTime.MinValue,
DayNumberText = string.Empty,
IsCurrentMonth = false,
IsToday = false,
HasEntries = false,
AverageStateText = string.Empty,
StateColor = Colors.Transparent,
TextColor = Colors.Transparent,
BorderColor = Colors.Transparent
};
}
}