Layout fixes and Push fixes
- Layout und Kalender angepasst - Push status meldung angepasst für Android
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user