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
+4
View File
@@ -13,4 +13,8 @@ public partial class MonthCellViewModel : ObservableObject
public Color StateColor { get; init; } = Colors.Transparent;
public Color TextColor { get; init; } = Colors.White;
public Color BorderColor { get; init; } = Colors.Transparent;
public bool IsPlaceholder => !IsCurrentMonth;
public bool ShowDayNumber => IsCurrentMonth;
public bool ShowAverage => IsCurrentMonth && HasEntries;
}
+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
};
}
}
-3
View File
@@ -4,10 +4,7 @@ using cfs_tracker.Models;
using cfs_tracker.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
namespace cfs_tracker.ViewModels;
+32 -2
View File
@@ -3,7 +3,9 @@ using cfs_tracker.Helpers;
using cfs_tracker.Services;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Maui.ApplicationModel;
using System.Collections.ObjectModel;
using System.Linq;
namespace cfs_tracker.ViewModels;
@@ -79,6 +81,10 @@ public partial class YearViewModel : ObservableObject
Title = DateHelper.ToGermanMonthYear(monthStart)
};
var leadingEmptyCells = GetMondayBasedColumnIndex(monthStart.DayOfWeek);
for (var i = 0; i < leadingEmptyCells; i++)
section.Cells.Add(CreatePlaceholderCell());
for (var day = 1; day <= daysInMonth; day++)
{
var date = new DateTime(monthStart.Year, monthStart.Month, day);
@@ -101,6 +107,9 @@ public partial class YearViewModel : ObservableObject
});
}
while (section.Cells.Count % 7 != 0)
section.Cells.Add(CreatePlaceholderCell());
Months.Add(section);
}
}
@@ -112,7 +121,7 @@ public partial class YearViewModel : ObservableObject
private async Task OpenDayAsync(MonthCellViewModel? item)
{
if (item is null)
if (item is null || !item.IsCurrentMonth)
return;
SelectedDate = item.Date.Date;
@@ -156,4 +165,25 @@ public partial class YearViewModel : 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
};
}
}