Details ausgearbeitet
Linked colors to options menu Options extension Aussehen aufgebohrt: - erlaubt text von status zu ändern, - bessere beschriftung von Farben desing änderung und bedienung - heute status felder anklickbar, - Farbpalette verdunkelt und kontrast reduziert - Kalender Tage anklickbar gemacht - Optionen überarbeitet
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<Application
|
<Application
|
||||||
x:Class="cfs_tracker.App"
|
x:Class="cfs_tracker.App"
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
@@ -7,25 +7,46 @@
|
|||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|
||||||
<Color x:Key="StateGreen">#4CAF50</Color>
|
<!-- Grundfarben -->
|
||||||
<Color x:Key="StateYellow">#FBC02D</Color>
|
<Color x:Key="AppBackground">#0B1620</Color>
|
||||||
<Color x:Key="StateRed">#E53935</Color>
|
<Color x:Key="PanelBackground">#162330</Color>
|
||||||
<Color x:Key="StateGray">#757575</Color>
|
<Color x:Key="PanelBackground2">#203041</Color>
|
||||||
|
<Color x:Key="PanelBorder">#2B3E52</Color>
|
||||||
|
<Color x:Key="TextPrimary">#D9E6F2</Color>
|
||||||
|
<Color x:Key="TextMuted">#94A8BC</Color>
|
||||||
|
|
||||||
<Color x:Key="CardBackground">#F2F2F2</Color>
|
<!-- Statusfarben -->
|
||||||
<Color x:Key="CardBorder">#D0D0D0</Color>
|
<Color x:Key="StateGreen">#4D8B68</Color>
|
||||||
|
<Color x:Key="StateYellow">#B89A42</Color>
|
||||||
|
<Color x:Key="StateRed">#A85C5C</Color>
|
||||||
|
<Color x:Key="StateGray">#5C6670</Color>
|
||||||
|
|
||||||
|
<!-- Statustexte -->
|
||||||
|
<x:String x:Key="StatusGreenText">Grün</x:String>
|
||||||
|
<x:String x:Key="StatusYellowText">Gelb</x:String>
|
||||||
|
<x:String x:Key="StatusRedText">Rot</x:String>
|
||||||
|
<x:String x:Key="StatusGrayText">Grau</x:String>
|
||||||
|
|
||||||
<Style TargetType="ContentPage">
|
<Style TargetType="ContentPage">
|
||||||
<Setter Property="BackgroundColor" Value="White" />
|
<Setter Property="BackgroundColor" Value="{DynamicResource AppBackground}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="Label">
|
<Style TargetType="Label">
|
||||||
<Setter Property="TextColor" Value="Black" />
|
<Setter Property="TextColor" Value="{DynamicResource TextPrimary}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="Button">
|
<Style TargetType="Button">
|
||||||
<Setter Property="CornerRadius" Value="12" />
|
<Setter Property="CornerRadius" Value="12" />
|
||||||
<Setter Property="Padding" Value="12,10" />
|
<Setter Property="Padding" Value="12,10" />
|
||||||
|
<Setter Property="BackgroundColor" Value="{DynamicResource PanelBackground2}" />
|
||||||
|
<Setter Property="TextColor" Value="{DynamicResource TextPrimary}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style TargetType="Border">
|
||||||
|
<Setter Property="BackgroundColor" Value="{DynamicResource PanelBackground}" />
|
||||||
|
<Setter Property="Stroke" Value="{DynamicResource PanelBorder}" />
|
||||||
|
<Setter Property="StrokeThickness" Value="1" />
|
||||||
|
<Setter Property="StrokeShape" Value="RoundRectangle 12" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
+22
-5
@@ -1,17 +1,34 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using cfs_tracker.Services;
|
||||||
|
|
||||||
|
namespace cfs_tracker;
|
||||||
|
|
||||||
namespace cfs_tracker
|
|
||||||
{
|
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public App()
|
private readonly IServiceProvider _serviceProvider;
|
||||||
|
|
||||||
|
public App(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Window CreateWindow(IActivationState? activationState)
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
{
|
{
|
||||||
return new Window(new AppShell());
|
var shell = _serviceProvider.GetRequiredService<AppShell>();
|
||||||
|
var appearanceService = _serviceProvider.GetRequiredService<AppearanceService>();
|
||||||
|
|
||||||
|
MainThread.BeginInvokeOnMainThread(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await appearanceService.InitializeAsync();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Window(shell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+11
-2
@@ -3,26 +3,35 @@
|
|||||||
x:Class="cfs_tracker.AppShell"
|
x:Class="cfs_tracker.AppShell"
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:views="clr-namespace:cfs_tracker.Views">
|
xmlns:views="clr-namespace:cfs_tracker.Views"
|
||||||
|
BackgroundColor="{StaticResource AppBackground}">
|
||||||
|
|
||||||
|
<TabBar Route="MainTabs">
|
||||||
|
|
||||||
<TabBar>
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Tag"
|
Title="Tag"
|
||||||
|
Route="DayTab"
|
||||||
ContentTemplate="{DataTemplate views:DayPage}" />
|
ContentTemplate="{DataTemplate views:DayPage}" />
|
||||||
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Woche"
|
Title="Woche"
|
||||||
|
Route="WeekTab"
|
||||||
ContentTemplate="{DataTemplate views:WeekPage}" />
|
ContentTemplate="{DataTemplate views:WeekPage}" />
|
||||||
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Monat"
|
Title="Monat"
|
||||||
|
Route="MonthTab"
|
||||||
ContentTemplate="{DataTemplate views:MonthPage}" />
|
ContentTemplate="{DataTemplate views:MonthPage}" />
|
||||||
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Jahr"
|
Title="Jahr"
|
||||||
|
Route="YearTab"
|
||||||
ContentTemplate="{DataTemplate views:YearPage}" />
|
ContentTemplate="{DataTemplate views:YearPage}" />
|
||||||
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Optionen"
|
Title="Optionen"
|
||||||
|
Route="OptionsTab"
|
||||||
ContentTemplate="{DataTemplate views:OptionsPage}" />
|
ContentTemplate="{DataTemplate views:OptionsPage}" />
|
||||||
|
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</Shell>
|
</Shell>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
using cfs_tracker.Views;
|
using cfs_tracker.Views;
|
||||||
|
|
||||||
namespace cfs_tracker;
|
namespace cfs_tracker;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Converters;
|
||||||
|
|
||||||
|
public class HexToColorConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is string hex && !string.IsNullOrWhiteSpace(hex))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Color.FromArgb(hex);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Color.FromArgb("#203041");
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is Color color)
|
||||||
|
return color.ToArgbHex();
|
||||||
|
|
||||||
|
return "#203041";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ColorExtensions
|
||||||
|
{
|
||||||
|
public static string ToArgbHex(this Color color)
|
||||||
|
{
|
||||||
|
byte a = (byte)(color.Alpha * 255);
|
||||||
|
byte r = (byte)(color.Red * 255);
|
||||||
|
byte g = (byte)(color.Green * 255);
|
||||||
|
byte b = (byte)(color.Blue * 255);
|
||||||
|
|
||||||
|
if (a < 255)
|
||||||
|
return $"#{a:X2}{r:X2}{g:X2}{b:X2}";
|
||||||
|
|
||||||
|
return $"#{r:X2}{g:X2}{b:X2}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
|
public class ActivityRepository
|
||||||
|
{
|
||||||
|
private readonly AppDatabase _database;
|
||||||
|
|
||||||
|
public ActivityRepository(AppDatabase database)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ActivityItem>> GetAllAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<ActivityItem>()
|
||||||
|
.OrderBy(x => x.SortOrder)
|
||||||
|
.ThenBy(x => x.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ActivityItem>> GetActiveAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<ActivityItem>()
|
||||||
|
.Where(x => x.IsActive)
|
||||||
|
.OrderBy(x => x.SortOrder)
|
||||||
|
.ThenBy(x => x.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<int, string>> GetNameMapAsync()
|
||||||
|
{
|
||||||
|
var all = await GetAllAsync();
|
||||||
|
return all.ToDictionary(x => x.Id, x => x.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EnsureDefaultsAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
if ((await _database.Connection.Table<ActivityItem>().CountAsync()) > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var defaults = new List<ActivityItem>
|
||||||
|
{
|
||||||
|
new() { Name = "Lesen", SortOrder = 0, IsActive = true },
|
||||||
|
new() { Name = "Sport", SortOrder = 1, IsActive = true },
|
||||||
|
new() { Name = "Haushalt", SortOrder = 2, IsActive = true },
|
||||||
|
new() { Name = "Einkaufen", SortOrder = 3, IsActive = true },
|
||||||
|
new() { Name = "Ausgehen", SortOrder = 4, IsActive = true },
|
||||||
|
new() { Name = "Verwaltung", SortOrder = 5, IsActive = true },
|
||||||
|
new() { Name = "Gespräch", SortOrder = 6, IsActive = true },
|
||||||
|
new() { Name = "Spazieren gehen", SortOrder = 7, IsActive = true },
|
||||||
|
new() { Name = "Fernsehen", SortOrder = 8, IsActive = true },
|
||||||
|
new() { Name = "Ruhen / Liegen", SortOrder = 9, IsActive = true }
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in defaults)
|
||||||
|
await _database.Connection.InsertAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddAsync(string name)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var maxSort = 0;
|
||||||
|
var all = await _database.Connection.Table<ActivityItem>().ToListAsync();
|
||||||
|
if (all.Count > 0)
|
||||||
|
maxSort = all.Max(x => x.SortOrder) + 1;
|
||||||
|
|
||||||
|
await _database.Connection.InsertAsync(new ActivityItem
|
||||||
|
{
|
||||||
|
Name = name.Trim(),
|
||||||
|
SortOrder = maxSort,
|
||||||
|
IsActive = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RenameAsync(int id, string newName)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<ActivityItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (item is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item.Name = newName.Trim();
|
||||||
|
await _database.Connection.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetActiveAsync(int id, bool isActive)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<ActivityItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (item is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item.IsActive = isActive;
|
||||||
|
await _database.Connection.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> HasUsageAsync(int activityId)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var count = await _database.Connection.Table<HealthEntry>()
|
||||||
|
.Where(x => x.ActivityId == activityId)
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteIfUnusedAsync(int activityId)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
if (await HasUsageAsync(activityId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<ActivityItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == activityId);
|
||||||
|
|
||||||
|
if (item is not null)
|
||||||
|
await _database.Connection.DeleteAsync(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
-6
@@ -1,5 +1,6 @@
|
|||||||
using SQLite;
|
using SQLite;
|
||||||
using cfs_tracker.Models;
|
using cfs_tracker.Models;
|
||||||
|
using Microsoft.Maui.Storage;
|
||||||
|
|
||||||
namespace cfs_tracker.Data;
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
@@ -10,17 +11,20 @@ public class AppDatabase
|
|||||||
|
|
||||||
public async Task InitAsync()
|
public async Task InitAsync()
|
||||||
{
|
{
|
||||||
if (_initialized)
|
if (_initialized) return;
|
||||||
return;
|
|
||||||
|
|
||||||
var dbPath = Path.Combine(FileSystem.Current.AppDataDirectory, "mecfs_tracker.db3");
|
|
||||||
|
|
||||||
|
var dbPath = Path.Combine(FileSystem.Current.AppDataDirectory, "cfs_tracker.db3");
|
||||||
_database = new SQLiteAsyncConnection(dbPath);
|
_database = new SQLiteAsyncConnection(dbPath);
|
||||||
|
|
||||||
|
await _database.CreateTableAsync<ActivityItem>();
|
||||||
|
await _database.CreateTableAsync<SymptomItem>();
|
||||||
await _database.CreateTableAsync<HealthEntry>();
|
await _database.CreateTableAsync<HealthEntry>();
|
||||||
|
await _database.CreateTableAsync<HealthEntrySymptom>();
|
||||||
|
await _database.CreateTableAsync<ThemeSettingItem>();
|
||||||
|
await _database.CreateTableAsync<AppearanceSetting>();
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteAsyncConnection Connection =>
|
public SQLiteAsyncConnection Connection => _database ?? throw new InvalidOperationException("Database not initialized.");
|
||||||
_database ?? throw new InvalidOperationException("Database not initialized.");
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
|
public class AppearanceRepository
|
||||||
|
{
|
||||||
|
private readonly AppDatabase _database;
|
||||||
|
|
||||||
|
public AppearanceRepository(AppDatabase database)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<AppearanceSetting>> GetAllAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<AppearanceSetting>()
|
||||||
|
.OrderBy(x => x.Key)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AppearanceSetting?> GetByKeyAsync(string key)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<AppearanceSetting>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Key == key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpsertAsync(string key, string value)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var existing = await _database.Connection.Table<AppearanceSetting>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Key == key);
|
||||||
|
|
||||||
|
if (existing is null)
|
||||||
|
{
|
||||||
|
await _database.Connection.InsertAsync(new AppearanceSetting
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
existing.Value = value;
|
||||||
|
await _database.Connection.UpdateAsync(existing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EnsureDefaultsAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
await EnsureDefaultAsync("AppBackground", "#0B1620");
|
||||||
|
await EnsureDefaultAsync("PanelBackground", "#162330");
|
||||||
|
await EnsureDefaultAsync("PanelBackground2", "#203041");
|
||||||
|
await EnsureDefaultAsync("PanelBorder", "#2B3E52");
|
||||||
|
await EnsureDefaultAsync("TextPrimary", "#D9E6F2");
|
||||||
|
await EnsureDefaultAsync("TextMuted", "#94A8BC");
|
||||||
|
await EnsureDefaultAsync("StateGreen", "#4D8B68");
|
||||||
|
await EnsureDefaultAsync("StateYellow", "#B89A42");
|
||||||
|
await EnsureDefaultAsync("StateRed", "#A85C5C");
|
||||||
|
await EnsureDefaultAsync("StateGray", "#5C6670");
|
||||||
|
|
||||||
|
await EnsureDefaultAsync("StatusGreenText", "Grün");
|
||||||
|
await EnsureDefaultAsync("StatusYellowText", "Gelb");
|
||||||
|
await EnsureDefaultAsync("StatusRedText", "Rot");
|
||||||
|
await EnsureDefaultAsync("StatusGrayText", "Grau");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ResetToDefaultsAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
await UpsertAsync("AppBackground", "#0B1620");
|
||||||
|
await UpsertAsync("PanelBackground", "#162330");
|
||||||
|
await UpsertAsync("PanelBackground2", "#203041");
|
||||||
|
await UpsertAsync("PanelBorder", "#2B3E52");
|
||||||
|
await UpsertAsync("TextPrimary", "#D9E6F2");
|
||||||
|
await UpsertAsync("TextMuted", "#94A8BC");
|
||||||
|
await UpsertAsync("StateGreen", "#4D8B68");
|
||||||
|
await UpsertAsync("StateYellow", "#B89A42");
|
||||||
|
await UpsertAsync("StateRed", "#A85C5C");
|
||||||
|
await UpsertAsync("StateGray", "#5C6670");
|
||||||
|
|
||||||
|
await UpsertAsync("StatusGreenText", "Grün");
|
||||||
|
await UpsertAsync("StatusYellowText", "Gelb");
|
||||||
|
await UpsertAsync("StatusRedText", "Rot");
|
||||||
|
await UpsertAsync("StatusGrayText", "Grau");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EnsureDefaultAsync(string key, string value)
|
||||||
|
{
|
||||||
|
var existing = await _database.Connection.Table<AppearanceSetting>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Key == key);
|
||||||
|
|
||||||
|
if (existing is null)
|
||||||
|
{
|
||||||
|
await _database.Connection.InsertAsync(new AppearanceSetting
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using cfs_tracker.Models;
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
namespace cfs_tracker.Data;
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
@@ -6,37 +6,40 @@ public class HealthEntryRepository
|
|||||||
{
|
{
|
||||||
private readonly AppDatabase _database;
|
private readonly AppDatabase _database;
|
||||||
|
|
||||||
public HealthEntryRepository(AppDatabase database)
|
public HealthEntryRepository(AppDatabase database) => _database = database;
|
||||||
{
|
|
||||||
_database = database;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task AddEntryAsync(
|
public async Task AddEntryAsync(HealthState state, EntrySource source, DateTime? timestamp = null, int? activityId = null)
|
||||||
HealthState state,
|
|
||||||
EntrySource source,
|
|
||||||
DateTime? timestamp = null)
|
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
|
||||||
var entry = new HealthEntry
|
var entry = new HealthEntry
|
||||||
{
|
{
|
||||||
Timestamp = timestamp ?? DateTime.Now,
|
Timestamp = timestamp ?? DateTime.Now,
|
||||||
State = state,
|
State = state,
|
||||||
Source = source,
|
Source = source,
|
||||||
|
ActivityId = activityId,
|
||||||
UpdatedAt = DateTime.Now
|
UpdatedAt = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
await _database.Connection.InsertAsync(entry);
|
await _database.Connection.InsertAsync(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpsertBackfillAsync(
|
public async Task<int> AddEntryAndReturnIdAsync(HealthState state, EntrySource source, DateTime? timestamp = null, int? activityId = null)
|
||||||
DateTime date,
|
|
||||||
DayPart part,
|
|
||||||
HealthState state,
|
|
||||||
EntrySource source)
|
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
var entry = new HealthEntry
|
||||||
|
{
|
||||||
|
Timestamp = timestamp ?? DateTime.Now,
|
||||||
|
State = state,
|
||||||
|
Source = source,
|
||||||
|
ActivityId = activityId,
|
||||||
|
UpdatedAt = DateTime.Now
|
||||||
|
};
|
||||||
|
await _database.Connection.InsertAsync(entry);
|
||||||
|
return entry.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpsertBackfillAsync(DateTime date, DayPart part, HealthState state, EntrySource source, int? activityId = null)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
var slotTimestamp = BuildSlotTimestamp(date, part);
|
var slotTimestamp = BuildSlotTimestamp(date, part);
|
||||||
|
|
||||||
var existing = await _database.Connection.Table<HealthEntry>()
|
var existing = await _database.Connection.Table<HealthEntry>()
|
||||||
@@ -44,22 +47,21 @@ public class HealthEntryRepository
|
|||||||
|
|
||||||
if (existing is null)
|
if (existing is null)
|
||||||
{
|
{
|
||||||
var entry = new HealthEntry
|
await _database.Connection.InsertAsync(new HealthEntry
|
||||||
{
|
{
|
||||||
Timestamp = slotTimestamp,
|
Timestamp = slotTimestamp,
|
||||||
State = state,
|
State = state,
|
||||||
Source = source,
|
Source = source,
|
||||||
|
ActivityId = activityId,
|
||||||
UpdatedAt = DateTime.Now
|
UpdatedAt = DateTime.Now
|
||||||
};
|
});
|
||||||
|
|
||||||
await _database.Connection.InsertAsync(entry);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
existing.State = state;
|
existing.State = state;
|
||||||
existing.Source = source;
|
existing.Source = source;
|
||||||
|
existing.ActivityId = activityId;
|
||||||
existing.UpdatedAt = DateTime.Now;
|
existing.UpdatedAt = DateTime.Now;
|
||||||
|
|
||||||
await _database.Connection.UpdateAsync(existing);
|
await _database.Connection.UpdateAsync(existing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,9 +69,7 @@ public class HealthEntryRepository
|
|||||||
public async Task<HealthEntry?> GetBackfillEntryAsync(DateTime date, DayPart part)
|
public async Task<HealthEntry?> GetBackfillEntryAsync(DateTime date, DayPart part)
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
|
||||||
var slotTimestamp = BuildSlotTimestamp(date, part);
|
var slotTimestamp = BuildSlotTimestamp(date, part);
|
||||||
|
|
||||||
return await _database.Connection.Table<HealthEntry>()
|
return await _database.Connection.Table<HealthEntry>()
|
||||||
.FirstOrDefaultAsync(x => x.Timestamp == slotTimestamp);
|
.FirstOrDefaultAsync(x => x.Timestamp == slotTimestamp);
|
||||||
}
|
}
|
||||||
@@ -77,71 +77,29 @@ public class HealthEntryRepository
|
|||||||
public async Task<List<HealthEntry>> GetEntriesForDateAsync(DateTime date)
|
public async Task<List<HealthEntry>> GetEntriesForDateAsync(DateTime date)
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
|
||||||
var start = date.Date;
|
var start = date.Date;
|
||||||
var end = start.AddDays(1);
|
var end = start.AddDays(1);
|
||||||
|
|
||||||
var list = await _database.Connection.Table<HealthEntry>()
|
var list = await _database.Connection.Table<HealthEntry>()
|
||||||
.Where(x => x.Timestamp >= start && x.Timestamp < end)
|
.Where(x => x.Timestamp >= start && x.Timestamp < end)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
return list.OrderBy(x => x.Timestamp).ToList();
|
||||||
return list
|
|
||||||
.OrderBy(x => x.Timestamp)
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<HealthEntry>> GetEntriesBetweenAsync(DateTime startDate, DateTime endDate)
|
public async Task<List<HealthEntry>> GetEntriesBetweenAsync(DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
|
||||||
var start = startDate.Date;
|
var start = startDate.Date;
|
||||||
var end = endDate.Date;
|
var end = endDate.Date;
|
||||||
|
|
||||||
var list = await _database.Connection.Table<HealthEntry>()
|
var list = await _database.Connection.Table<HealthEntry>()
|
||||||
.Where(x => x.Timestamp >= start && x.Timestamp < end)
|
.Where(x => x.Timestamp >= start && x.Timestamp < end)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
return list.OrderBy(x => x.Timestamp).ToList();
|
||||||
return list
|
|
||||||
.OrderBy(x => x.Timestamp)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<HealthEntry>> GetMonthEntriesAsync(int year, int month)
|
|
||||||
{
|
|
||||||
var start = new DateTime(year, month, 1);
|
|
||||||
var end = start.AddMonths(1);
|
|
||||||
|
|
||||||
return await GetEntriesBetweenAsync(start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<List<HealthEntry>> GetYearEntriesAsync(int year)
|
|
||||||
{
|
|
||||||
var start = new DateTime(year, 1, 1);
|
|
||||||
var end = start.AddYears(1);
|
|
||||||
|
|
||||||
return await GetEntriesBetweenAsync(start, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteEntryAsync(int id)
|
public async Task DeleteEntryAsync(int id)
|
||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
|
var item = await _database.Connection.Table<HealthEntry>().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
var item = await _database.Connection.Table<HealthEntry>()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == id);
|
|
||||||
|
|
||||||
if (item is not null)
|
|
||||||
await _database.Connection.DeleteAsync(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteBackfillEntryAsync(DateTime date, DayPart part)
|
|
||||||
{
|
|
||||||
await _database.InitAsync();
|
|
||||||
|
|
||||||
var slotTimestamp = BuildSlotTimestamp(date, part);
|
|
||||||
|
|
||||||
var item = await _database.Connection.Table<HealthEntry>()
|
|
||||||
.FirstOrDefaultAsync(x => x.Timestamp == slotTimestamp);
|
|
||||||
|
|
||||||
if (item is not null)
|
if (item is not null)
|
||||||
await _database.Connection.DeleteAsync(item);
|
await _database.Connection.DeleteAsync(item);
|
||||||
}
|
}
|
||||||
@@ -150,32 +108,13 @@ public class HealthEntryRepository
|
|||||||
{
|
{
|
||||||
await _database.InitAsync();
|
await _database.InitAsync();
|
||||||
await _database.Connection.DeleteAllAsync<HealthEntry>();
|
await _database.Connection.DeleteAllAsync<HealthEntry>();
|
||||||
|
await _database.Connection.DeleteAllAsync<HealthEntrySymptom>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<(HealthEntry? Morning, HealthEntry? Afternoon)> GetBackfillSlotsAsync(DateTime date)
|
private static DateTime BuildSlotTimestamp(DateTime date, DayPart part) => part switch
|
||||||
{
|
|
||||||
await _database.InitAsync();
|
|
||||||
|
|
||||||
var morningTimestamp = BuildSlotTimestamp(date, DayPart.Morning);
|
|
||||||
var afternoonTimestamp = BuildSlotTimestamp(date, DayPart.Afternoon);
|
|
||||||
|
|
||||||
var items = await _database.Connection.Table<HealthEntry>()
|
|
||||||
.Where(x => x.Timestamp == morningTimestamp || x.Timestamp == afternoonTimestamp)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
var morning = items.FirstOrDefault(x => x.Timestamp == morningTimestamp);
|
|
||||||
var afternoon = items.FirstOrDefault(x => x.Timestamp == afternoonTimestamp);
|
|
||||||
|
|
||||||
return (morning, afternoon);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static DateTime BuildSlotTimestamp(DateTime date, DayPart part)
|
|
||||||
{
|
|
||||||
return part switch
|
|
||||||
{
|
{
|
||||||
DayPart.Morning => date.Date.AddHours(9),
|
DayPart.Morning => date.Date.AddHours(9),
|
||||||
DayPart.Afternoon => date.Date.AddHours(15),
|
DayPart.Afternoon => date.Date.AddHours(15),
|
||||||
_ => date.Date.AddHours(9)
|
_ => date.Date.AddHours(9)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
|
public class SymptomRepository
|
||||||
|
{
|
||||||
|
private readonly AppDatabase _database;
|
||||||
|
|
||||||
|
public SymptomRepository(AppDatabase database)
|
||||||
|
{
|
||||||
|
_database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<SymptomItem>> GetAllAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<SymptomItem>()
|
||||||
|
.OrderBy(x => x.SortOrder)
|
||||||
|
.ThenBy(x => x.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<SymptomItem>> GetActiveAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
return await _database.Connection.Table<SymptomItem>()
|
||||||
|
.Where(x => x.IsActive)
|
||||||
|
.OrderBy(x => x.SortOrder)
|
||||||
|
.ThenBy(x => x.Name)
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EnsureDefaultsAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
if ((await _database.Connection.Table<SymptomItem>().CountAsync()) > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var defaults = new List<SymptomItem>
|
||||||
|
{
|
||||||
|
new() { Name = "Kopfschmerzen", SortOrder = 0, IsActive = true },
|
||||||
|
new() { Name = "Kopfnebel", SortOrder = 1, IsActive = true },
|
||||||
|
new() { Name = "Tinnitus", SortOrder = 2, IsActive = true },
|
||||||
|
new() { Name = "Schwere / Müdigkeit", SortOrder = 3, IsActive = true },
|
||||||
|
new() { Name = "Überforderung", SortOrder = 4, IsActive = true }
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var item in defaults)
|
||||||
|
await _database.Connection.InsertAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddAsync(string name)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var maxSort = 0;
|
||||||
|
var all = await _database.Connection.Table<SymptomItem>().ToListAsync();
|
||||||
|
if (all.Count > 0)
|
||||||
|
maxSort = all.Max(x => x.SortOrder) + 1;
|
||||||
|
|
||||||
|
await _database.Connection.InsertAsync(new SymptomItem
|
||||||
|
{
|
||||||
|
Name = name.Trim(),
|
||||||
|
SortOrder = maxSort,
|
||||||
|
IsActive = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RenameAsync(int id, string newName)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<SymptomItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (item is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item.Name = newName.Trim();
|
||||||
|
await _database.Connection.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetActiveAsync(int id, bool isActive)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<SymptomItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (item is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
item.IsActive = isActive;
|
||||||
|
await _database.Connection.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> HasUsageAsync(int symptomId)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var count = await _database.Connection.Table<HealthEntrySymptom>()
|
||||||
|
.Where(x => x.SymptomItemId == symptomId)
|
||||||
|
.CountAsync();
|
||||||
|
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteIfUnusedAsync(int symptomId)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
if (await HasUsageAsync(symptomId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var item = await _database.Connection.Table<SymptomItem>()
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == symptomId);
|
||||||
|
|
||||||
|
if (item is not null)
|
||||||
|
await _database.Connection.DeleteAsync(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<int>> GetSymptomIdsForEntryAsync(int entryId)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var links = await _database.Connection.Table<HealthEntrySymptom>()
|
||||||
|
.Where(x => x.HealthEntryId == entryId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return links.Select(x => x.SymptomItemId).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetSymptomsForEntryAsync(int entryId, IEnumerable<int> symptomIds)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var existing = await _database.Connection.Table<HealthEntrySymptom>()
|
||||||
|
.Where(x => x.HealthEntryId == entryId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var item in existing)
|
||||||
|
await _database.Connection.DeleteAsync(item);
|
||||||
|
|
||||||
|
foreach (var symptomId in symptomIds.Distinct())
|
||||||
|
{
|
||||||
|
await _database.Connection.InsertAsync(new HealthEntrySymptom
|
||||||
|
{
|
||||||
|
HealthEntryId = entryId,
|
||||||
|
SymptomItemId = symptomId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<int, List<string>>> GetSymptomsByEntryIdsAsync(IEnumerable<int> entryIds)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
|
||||||
|
var ids = entryIds.Distinct().ToHashSet();
|
||||||
|
var result = new Dictionary<int, List<string>>();
|
||||||
|
|
||||||
|
if (ids.Count == 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
var allLinks = await _database.Connection.Table<HealthEntrySymptom>().ToListAsync();
|
||||||
|
var relevantLinks = allLinks.Where(x => ids.Contains(x.HealthEntryId)).ToList();
|
||||||
|
|
||||||
|
if (relevantLinks.Count == 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
var allSymptoms = await _database.Connection.Table<SymptomItem>().ToListAsync();
|
||||||
|
var symptomMap = allSymptoms.ToDictionary(x => x.Id, x => x.Name);
|
||||||
|
|
||||||
|
foreach (var group in relevantLinks.GroupBy(x => x.HealthEntryId))
|
||||||
|
{
|
||||||
|
result[group.Key] = group
|
||||||
|
.Where(x => symptomMap.ContainsKey(x.SymptomItemId))
|
||||||
|
.Select(x => symptomMap[x.SymptomItemId])
|
||||||
|
.Distinct()
|
||||||
|
.OrderBy(x => x)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Data;
|
||||||
|
|
||||||
|
public class ThemeSettingsRepository
|
||||||
|
{
|
||||||
|
private readonly AppDatabase _database;
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, string> DefaultValues = new()
|
||||||
|
{
|
||||||
|
["AppBackground"] = "#0B1620",
|
||||||
|
["PanelBackground"] = "#162330",
|
||||||
|
["PanelBackground2"] = "#203041",
|
||||||
|
["PanelBorder"] = "#2B3E52",
|
||||||
|
["TextPrimary"] = "#D9E6F2",
|
||||||
|
["TextMuted"] = "#94A8BC",
|
||||||
|
["StateGreen"] = "#4D8B68",
|
||||||
|
["StateYellow"] = "#B89A42",
|
||||||
|
["StateRed"] = "#A85C5C",
|
||||||
|
["StateGray"] = "#5C6670",
|
||||||
|
};
|
||||||
|
|
||||||
|
public ThemeSettingsRepository(AppDatabase database) => _database = database;
|
||||||
|
|
||||||
|
public async Task EnsureDefaultsAsync()
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
foreach (var pair in DefaultValues)
|
||||||
|
{
|
||||||
|
var existing = await _database.Connection.Table<ThemeSettingItem>().FirstOrDefaultAsync(x => x.Key == pair.Key);
|
||||||
|
if (existing is null)
|
||||||
|
await _database.Connection.InsertAsync(new ThemeSettingItem { Key = pair.Key, Value = pair.Value });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<ThemeSettingItem>> GetAllAsync()
|
||||||
|
{
|
||||||
|
await EnsureDefaultsAsync();
|
||||||
|
return await _database.Connection.Table<ThemeSettingItem>().OrderBy(x => x.Key).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveAsync(ThemeSettingItem item)
|
||||||
|
{
|
||||||
|
await _database.InitAsync();
|
||||||
|
await _database.Connection.InsertOrReplaceAsync(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace cfs_tracker.Helpers;
|
||||||
|
|
||||||
|
public static class ThemeKeys
|
||||||
|
{
|
||||||
|
public const string AppBackground = "AppBackground";
|
||||||
|
public const string PanelBackground = "PanelBackground";
|
||||||
|
public const string PanelBackground2 = "PanelBackground2";
|
||||||
|
public const string PanelBorder = "PanelBorder";
|
||||||
|
public const string TextPrimary = "TextPrimary";
|
||||||
|
public const string TextMuted = "TextMuted";
|
||||||
|
|
||||||
|
public const string StateGreen = "StateGreen";
|
||||||
|
public const string StateYellow = "StateYellow";
|
||||||
|
public const string StateRed = "StateRed";
|
||||||
|
public const string StateGray = "StateGray";
|
||||||
|
|
||||||
|
public const string StatusGreenText = "StatusGreenText";
|
||||||
|
public const string StatusYellowText = "StatusYellowText";
|
||||||
|
public const string StatusRedText = "StatusRedText";
|
||||||
|
public const string StatusGrayText = "StatusGrayText";
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Helpers;
|
||||||
|
|
||||||
|
public static class ThemeResourceHelper
|
||||||
|
{
|
||||||
|
public static Color GetColor(string key, string fallbackHex = "#FFFFFF")
|
||||||
|
{
|
||||||
|
if (Application.Current?.Resources.TryGetValue(key, out var value) == true && value is Color color)
|
||||||
|
return color;
|
||||||
|
|
||||||
|
return Color.FromArgb(fallbackHex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetString(string key, string fallback = "")
|
||||||
|
{
|
||||||
|
if (Application.Current?.Resources.TryGetValue(key, out var value) == true && value is string text)
|
||||||
|
return text;
|
||||||
|
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
x:Class="cfs_tracker.MainPage">
|
|
||||||
|
|
||||||
<ScrollView>
|
|
||||||
<VerticalStackLayout
|
|
||||||
Padding="30,0"
|
|
||||||
Spacing="25">
|
|
||||||
<Image
|
|
||||||
Source="dotnet_bot.png"
|
|
||||||
HeightRequest="185"
|
|
||||||
Aspect="AspectFit"
|
|
||||||
SemanticProperties.Description="dot net bot in a submarine number ten" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Hello, World!"
|
|
||||||
Style="{StaticResource Headline}"
|
|
||||||
SemanticProperties.HeadingLevel="Level1" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Welcome to .NET Multi-platform App UI"
|
|
||||||
Style="{StaticResource SubHeadline}"
|
|
||||||
SemanticProperties.HeadingLevel="Level2"
|
|
||||||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
x:Name="CounterBtn"
|
|
||||||
Text="Click me"
|
|
||||||
SemanticProperties.Hint="Counts the number of times you click"
|
|
||||||
Clicked="OnCounterClicked"
|
|
||||||
HorizontalOptions="Fill" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</ContentPage>
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace cfs_tracker
|
|
||||||
{
|
|
||||||
public partial class MainPage : ContentPage
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
public MainPage()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnCounterClicked(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (count == 1)
|
|
||||||
CounterBtn.Text = $"Clicked {count} time";
|
|
||||||
else
|
|
||||||
CounterBtn.Text = $"Clicked {count} times";
|
|
||||||
|
|
||||||
SemanticScreenReader.Announce(CounterBtn.Text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+16
-9
@@ -1,7 +1,8 @@
|
|||||||
using cfs_tracker.Data;
|
using cfs_tracker.Data;
|
||||||
using cfs_tracker.Services;
|
using cfs_tracker.Services;
|
||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
using cfs_tracker.Views;
|
using cfs_tracker.Views;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace cfs_tracker;
|
namespace cfs_tracker;
|
||||||
|
|
||||||
@@ -13,31 +14,37 @@ public static class MauiProgram
|
|||||||
|
|
||||||
builder
|
builder
|
||||||
.UseMauiApp<App>()
|
.UseMauiApp<App>()
|
||||||
.ConfigureFonts(fonts =>
|
.ConfigureFonts(fonts => { });
|
||||||
{
|
|
||||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
|
||||||
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
|
|
||||||
});
|
|
||||||
|
|
||||||
builder.Services.AddSingleton<AppDatabase>();
|
builder.Services.AddSingleton<AppDatabase>();
|
||||||
builder.Services.AddSingleton<HealthEntryRepository>();
|
builder.Services.AddSingleton<HealthEntryRepository>();
|
||||||
|
builder.Services.AddSingleton<ActivityRepository>();
|
||||||
|
builder.Services.AddSingleton<SymptomRepository>();
|
||||||
|
builder.Services.AddSingleton<ThemeSettingsRepository>();
|
||||||
builder.Services.AddSingleton<AggregationService>();
|
builder.Services.AddSingleton<AggregationService>();
|
||||||
builder.Services.AddSingleton<PdfExportService>();
|
builder.Services.AddSingleton<CalendarStateService>();
|
||||||
|
builder.Services.AddSingleton<AppearanceService>();
|
||||||
|
|
||||||
builder.Services.AddTransient<DayViewModel>();
|
builder.Services.AddTransient<DayViewModel>();
|
||||||
builder.Services.AddTransient<WeekViewModel>();
|
builder.Services.AddTransient<WeekViewModel>();
|
||||||
builder.Services.AddTransient<MonthViewModel>();
|
builder.Services.AddTransient<MonthViewModel>();
|
||||||
builder.Services.AddTransient<YearViewModel>();
|
builder.Services.AddTransient<YearViewModel>();
|
||||||
builder.Services.AddTransient<QuickEntryViewModel>();
|
builder.Services.AddTransient<QuickEntryViewModel>();
|
||||||
|
builder.Services.AddTransient<OptionsViewModel>();
|
||||||
|
|
||||||
builder.Services.AddTransient<DayPage>();
|
builder.Services.AddTransient<DayPage>();
|
||||||
builder.Services.AddTransient<WeekPage>();
|
builder.Services.AddTransient<WeekPage>();
|
||||||
builder.Services.AddTransient<MonthPage>();
|
builder.Services.AddTransient<MonthPage>();
|
||||||
builder.Services.AddTransient<YearPage>();
|
builder.Services.AddTransient<YearPage>();
|
||||||
builder.Services.AddTransient<QuickEntryPage>();
|
builder.Services.AddTransient<QuickEntryPage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<OptionsViewModel>();
|
|
||||||
builder.Services.AddTransient<OptionsPage>();
|
builder.Services.AddTransient<OptionsPage>();
|
||||||
|
builder.Services.AddSingleton<AppShell>();
|
||||||
|
builder.Services.AddSingleton<AppearanceRepository>();
|
||||||
|
builder.Services.AddSingleton<AppearanceService>();
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
builder.Logging.AddDebug();
|
||||||
|
#endif
|
||||||
|
|
||||||
return builder.Build();
|
return builder.Build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using SQLite;
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
public class ActivityItem
|
||||||
|
{
|
||||||
|
[PrimaryKey, AutoIncrement] public int Id { get; set; }
|
||||||
|
[Unique] public string Name { get; set; } = string.Empty;
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
public int SortOrder { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using SQLite;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
|
||||||
|
public class AppearanceSetting
|
||||||
|
{
|
||||||
|
[PrimaryKey]
|
||||||
|
public string Key { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
namespace cfs_tracker.Models
|
namespace cfs_tracker.Models;
|
||||||
{
|
|
||||||
public class CalendarDaySummary
|
public class CalendarDaySummary
|
||||||
{
|
{
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public double? Average { get; set; }
|
||||||
public double? Average { get; set; } // null = kein Eintrag
|
|
||||||
public int EntryCount { get; set; }
|
public int EntryCount { get; set; }
|
||||||
|
|
||||||
public HealthState? DisplayState { get; set; }
|
public HealthState? DisplayState { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
namespace cfs_tracker.Models
|
namespace cfs_tracker.Models;
|
||||||
{
|
|
||||||
public class DayDetailSummary
|
public class DayDetailSummary
|
||||||
{
|
{
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
public int GreenCount { get; set; }
|
public int GreenCount { get; set; }
|
||||||
public int YellowCount { get; set; }
|
public int YellowCount { get; set; }
|
||||||
public int RedCount { get; set; }
|
public int RedCount { get; set; }
|
||||||
public int GrayCount { get; set; }
|
public int GrayCount { get; set; }
|
||||||
|
|
||||||
public List<HealthEntry> Entries { get; set; } = new();
|
public List<HealthEntry> Entries { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
+2
-7
@@ -1,7 +1,2 @@
|
|||||||
namespace cfs_tracker.Models;
|
namespace cfs_tracker.Models;
|
||||||
|
public enum DayPart { Morning=0, Afternoon=1 }
|
||||||
public enum DayPart
|
|
||||||
{
|
|
||||||
Morning = 0,
|
|
||||||
Afternoon = 1
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,2 @@
|
|||||||
namespace cfs_tracker.Models
|
namespace cfs_tracker.Models;
|
||||||
{
|
public enum EntrySource { App=0, Notification=1 }
|
||||||
public enum EntrySource
|
|
||||||
{
|
|
||||||
App = 0,
|
|
||||||
Notification = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
using cfs_tracker.Models;
|
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
public class HealthEntry
|
public class HealthEntry
|
||||||
{
|
{
|
||||||
[PrimaryKey, AutoIncrement]
|
[PrimaryKey, AutoIncrement] public int Id { get; set; }
|
||||||
public int Id { get; set; }
|
[Indexed] public DateTime Timestamp { get; set; }
|
||||||
|
|
||||||
public DateTime Timestamp { get; set; }
|
|
||||||
|
|
||||||
public HealthState State { get; set; }
|
public HealthState State { get; set; }
|
||||||
|
|
||||||
public EntrySource Source { get; set; }
|
public EntrySource Source { get; set; }
|
||||||
|
[Indexed] public int? ActivityId { get; set; }
|
||||||
public DateTime UpdatedAt { get; set; }
|
public DateTime UpdatedAt { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using SQLite;
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
public class HealthEntrySymptom
|
||||||
|
{
|
||||||
|
[PrimaryKey, AutoIncrement] public int Id { get; set; }
|
||||||
|
[Indexed] public int HealthEntryId { get; set; }
|
||||||
|
[Indexed] public int SymptomItemId { get; set; }
|
||||||
|
}
|
||||||
+2
-10
@@ -1,10 +1,2 @@
|
|||||||
namespace cfs_tracker.Models
|
namespace cfs_tracker.Models;
|
||||||
{
|
public enum HealthState { Gray=0, Red=1, Yellow=2, Green=3 }
|
||||||
public enum HealthState
|
|
||||||
{
|
|
||||||
Gray = 0, // Totalausfall
|
|
||||||
Red = 1, // schlecht
|
|
||||||
Yellow = 2, // so lala
|
|
||||||
Green = 3 // gut
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,27 +1,41 @@
|
|||||||
namespace cfs_tracker.Models;
|
using cfs_tracker.Helpers;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
|
||||||
public static class HealthStateExtensions
|
public static class HealthStateExtensions
|
||||||
{
|
{
|
||||||
public static Color ToColor(this HealthState state)
|
public static string ToColorKey(this HealthState state)
|
||||||
{
|
{
|
||||||
return state switch
|
return state switch
|
||||||
{
|
{
|
||||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
HealthState.Green => ThemeKeys.StateGreen,
|
||||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
HealthState.Yellow => ThemeKeys.StateYellow,
|
||||||
HealthState.Red => Color.FromArgb("#E53935"),
|
HealthState.Red => ThemeKeys.StateRed,
|
||||||
HealthState.Gray => Color.FromArgb("#757575"),
|
HealthState.Gray => ThemeKeys.StateGray,
|
||||||
_ => Colors.Transparent
|
_ => ThemeKeys.PanelBackground2
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToLabel(this HealthState state)
|
public static string ToTextKey(this HealthState state)
|
||||||
{
|
{
|
||||||
return state switch
|
return state switch
|
||||||
{
|
{
|
||||||
HealthState.Green => "Gut",
|
HealthState.Green => ThemeKeys.StatusGreenText,
|
||||||
HealthState.Yellow => "So lala",
|
HealthState.Yellow => ThemeKeys.StatusYellowText,
|
||||||
HealthState.Red => "Schlecht",
|
HealthState.Red => ThemeKeys.StatusRedText,
|
||||||
HealthState.Gray => "Totalausfall",
|
HealthState.Gray => ThemeKeys.StatusGrayText,
|
||||||
|
_ => ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToFallbackText(this HealthState state)
|
||||||
|
{
|
||||||
|
return state switch
|
||||||
|
{
|
||||||
|
HealthState.Green => "Grün",
|
||||||
|
HealthState.Yellow => "Gelb",
|
||||||
|
HealthState.Red => "Rot",
|
||||||
|
HealthState.Gray => "Grau",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
namespace cfs_tracker.Models;
|
||||||
|
public enum OptionsTab { Database, Activities, Symptoms, Appearance }
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using SQLite;
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
public class SymptomItem
|
||||||
|
{
|
||||||
|
[PrimaryKey, AutoIncrement] public int Id { get; set; }
|
||||||
|
[Unique] public string Name { get; set; } = string.Empty;
|
||||||
|
public bool IsActive { get; set; } = true;
|
||||||
|
public int SortOrder { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using SQLite;
|
||||||
|
namespace cfs_tracker.Models;
|
||||||
|
public class ThemeSettingItem
|
||||||
|
{
|
||||||
|
[PrimaryKey] public string Key { get; set; } = string.Empty;
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
namespace cfs_tracker.Models
|
namespace cfs_tracker.Models;
|
||||||
{
|
|
||||||
public class WeekDaySummary
|
public class WeekDaySummary
|
||||||
{
|
{
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
public double? MorningAverage { get; set; }
|
||||||
public double? MorningAverage { get; set; } // vor 12 Uhr
|
public double? AfternoonAverage { get; set; }
|
||||||
public double? AfternoonAverage { get; set; } // ab 12 Uhr
|
|
||||||
|
|
||||||
public int MorningCount { get; set; }
|
public int MorningCount { get; set; }
|
||||||
public int AfternoonCount { get; set; }
|
public int AfternoonCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
@@ -1,22 +1,9 @@
|
|||||||
using Android.App;
|
using Android.App;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
using Android.OS;
|
using Android.OS;
|
||||||
|
|
||||||
namespace cfs_tracker;
|
namespace cfs_tracker;
|
||||||
|
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
|
||||||
[Activity(
|
|
||||||
Theme = "@style/Maui.SplashTheme",
|
|
||||||
MainLauncher = true,
|
|
||||||
ConfigurationChanges = ConfigChanges.ScreenSize
|
|
||||||
| ConfigChanges.Orientation
|
|
||||||
| ConfigChanges.UiMode
|
|
||||||
| ConfigChanges.ScreenLayout
|
|
||||||
| ConfigChanges.SmallestScreenSize
|
|
||||||
| ConfigChanges.Density)]
|
|
||||||
public class MainActivity : MauiAppCompatActivity
|
public class MainActivity : MauiAppCompatActivity
|
||||||
{
|
{
|
||||||
protected override void OnCreate(Bundle? savedInstanceState)
|
protected override void OnCreate(Bundle? savedInstanceState){ base.OnCreate(savedInstanceState); }
|
||||||
{
|
|
||||||
base.OnCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Der Debug-Log mit Exit-Code 0xffffffff zeigt keinen verwertbaren Managed-Stacktrace.
|
||||||
|
Das ist meist ein nativer UI-Absturz oder ein fehlerhafter XAML-/WinUI-Pfad.
|
||||||
|
|
||||||
|
Wichtige Hinweise:
|
||||||
|
- Nur die Views in diesem ZIP verwenden.
|
||||||
|
- Keine doppelte OptionsPage im Projekt-Root behalten.
|
||||||
|
- Keine speziellen MauiXaml Update-Einträge in der csproj verwenden.
|
||||||
|
- Vor dem Test alte DB löschen sowie bin/obj leeren.
|
||||||
@@ -1,4 +1 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256"><rect width="256" height="256" fill="#0B1620"/><text x="50%" y="55%" dominant-baseline="middle" text-anchor="middle" font-size="96" fill="#D9E6F2">C</text></svg>
|
||||||
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<rect x="0" y="0" width="456" height="456" fill="#512BD4" />
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 228 B After Width: | Height: | Size: 226 B |
@@ -1,8 +1 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256"><rect width="256" height="256" fill="#0B1620"/><circle cx="128" cy="128" r="64" fill="#203041"/></svg>
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
||||||
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
|
|
||||||
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
|
|
||||||
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
|
|
||||||
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 167 B |
@@ -1,39 +1,18 @@
|
|||||||
using cfs_tracker.Models;
|
using cfs_tracker.Models;
|
||||||
|
|
||||||
namespace cfs_tracker.Services;
|
namespace cfs_tracker.Services;
|
||||||
|
|
||||||
public class AggregationService
|
public class AggregationService
|
||||||
{
|
{
|
||||||
public DayDetailSummary BuildDaySummary(DateTime date, IEnumerable<HealthEntry> entries)
|
|
||||||
{
|
|
||||||
var list = entries
|
|
||||||
.Where(x => x.Timestamp.Date == date.Date)
|
|
||||||
.OrderBy(x => x.Timestamp)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
return new DayDetailSummary
|
|
||||||
{
|
|
||||||
Date = date.Date,
|
|
||||||
GreenCount = list.Count(x => x.State == HealthState.Green),
|
|
||||||
YellowCount = list.Count(x => x.State == HealthState.Yellow),
|
|
||||||
RedCount = list.Count(x => x.State == HealthState.Red),
|
|
||||||
GrayCount = list.Count(x => x.State == HealthState.Gray),
|
|
||||||
Entries = list
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WeekDaySummary> BuildWeekSummary(DateTime weekStart, IEnumerable<HealthEntry> entries)
|
public List<WeekDaySummary> BuildWeekSummary(DateTime weekStart, IEnumerable<HealthEntry> entries)
|
||||||
{
|
{
|
||||||
var result = new List<WeekDaySummary>();
|
var result = new List<WeekDaySummary>();
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
{
|
{
|
||||||
var date = weekStart.Date.AddDays(i);
|
var date = weekStart.Date.AddDays(i);
|
||||||
var dayEntries = entries.Where(x => x.Timestamp.Date == date).ToList();
|
var dayEntries = entries.Where(x => x.Timestamp.Date == date).ToList();
|
||||||
|
|
||||||
var morning = dayEntries.Where(x => x.Timestamp.Hour < 12).ToList();
|
var morning = dayEntries.Where(x => x.Timestamp.Hour < 12).ToList();
|
||||||
var afternoon = dayEntries.Where(x => x.Timestamp.Hour >= 12).ToList();
|
var afternoon = dayEntries.Where(x => x.Timestamp.Hour >= 12).ToList();
|
||||||
|
|
||||||
result.Add(new WeekDaySummary
|
result.Add(new WeekDaySummary
|
||||||
{
|
{
|
||||||
Date = date,
|
Date = date,
|
||||||
@@ -43,81 +22,53 @@ public class AggregationService
|
|||||||
AfternoonCount = afternoon.Count
|
AfternoonCount = afternoon.Count
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CalendarDaySummary> BuildMonthSummary(DateTime month, IEnumerable<HealthEntry> entries)
|
public List<CalendarDaySummary> BuildMonthSummary(DateTime month, IEnumerable<HealthEntry> entries)
|
||||||
{
|
{
|
||||||
var first = new DateTime(month.Year, month.Month, 1);
|
var first = new DateTime(month.Year, month.Month, 1);
|
||||||
var days = DateTime.DaysInMonth(month.Year, month.Month);
|
int days = DateTime.DaysInMonth(month.Year, month.Month);
|
||||||
|
|
||||||
var result = new List<CalendarDaySummary>();
|
var result = new List<CalendarDaySummary>();
|
||||||
|
|
||||||
for (int i = 0; i < days; i++)
|
for (int i = 0; i < days; i++)
|
||||||
{
|
{
|
||||||
var date = first.AddDays(i);
|
var date = first.AddDays(i);
|
||||||
var dayEntries = entries.Where(x => x.Timestamp.Date == date.Date).ToList();
|
var dayEntries = entries.Where(x => x.Timestamp.Date == date.Date).ToList();
|
||||||
|
|
||||||
var avg = AverageOrNull(dayEntries);
|
var avg = AverageOrNull(dayEntries);
|
||||||
|
result.Add(new CalendarDaySummary { Date = date, Average = avg, EntryCount = dayEntries.Count, DisplayState = ToDisplayState(avg) });
|
||||||
result.Add(new CalendarDaySummary
|
|
||||||
{
|
|
||||||
Date = date,
|
|
||||||
Average = avg,
|
|
||||||
EntryCount = dayEntries.Count,
|
|
||||||
DisplayState = ToDisplayState(avg)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CalendarDaySummary> BuildYearSummary(int year, IEnumerable<HealthEntry> entries)
|
public List<CalendarDaySummary> BuildYearSummary(int year, IEnumerable<HealthEntry> entries)
|
||||||
{
|
{
|
||||||
var result = new List<CalendarDaySummary>();
|
var result = new List<CalendarDaySummary>();
|
||||||
|
|
||||||
for (int month = 1; month <= 12; month++)
|
for (int month = 1; month <= 12; month++)
|
||||||
{
|
{
|
||||||
var days = DateTime.DaysInMonth(year, month);
|
int days = DateTime.DaysInMonth(year, month);
|
||||||
|
|
||||||
for (int day = 1; day <= days; day++)
|
for (int day = 1; day <= days; day++)
|
||||||
{
|
{
|
||||||
var date = new DateTime(year, month, day);
|
var date = new DateTime(year, month, day);
|
||||||
var dayEntries = entries.Where(x => x.Timestamp.Date == date.Date).ToList();
|
var dayEntries = entries.Where(x => x.Timestamp.Date == date.Date).ToList();
|
||||||
|
|
||||||
var avg = AverageOrNull(dayEntries);
|
var avg = AverageOrNull(dayEntries);
|
||||||
|
result.Add(new CalendarDaySummary { Date = date, Average = avg, EntryCount = dayEntries.Count, DisplayState = ToDisplayState(avg) });
|
||||||
result.Add(new CalendarDaySummary
|
|
||||||
{
|
|
||||||
Date = date,
|
|
||||||
Average = avg,
|
|
||||||
EntryCount = dayEntries.Count,
|
|
||||||
DisplayState = ToDisplayState(avg)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HealthState? ToDisplayState(double? average)
|
public HealthState? ToDisplayState(double? average)
|
||||||
{
|
{
|
||||||
if (average is null)
|
if (average is null) return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
if (average >= 2.5) return HealthState.Green;
|
if (average >= 2.5) return HealthState.Green;
|
||||||
if (average >= 1.5) return HealthState.Yellow;
|
if (average >= 1.5) return HealthState.Yellow;
|
||||||
if (average >= 0.5) return HealthState.Red;
|
if (average >= 0.5) return HealthState.Red;
|
||||||
return HealthState.Gray;
|
return HealthState.Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double? AverageOrNull(IEnumerable<HealthEntry> entries)
|
private static double? AverageOrNull(IEnumerable<HealthEntry> entries)
|
||||||
{
|
{
|
||||||
var list = entries.ToList();
|
var list = entries.ToList();
|
||||||
if (list.Count == 0)
|
return list.Count == 0 ? null : list.Average(x => (int)x.State);
|
||||||
return null;
|
|
||||||
|
|
||||||
return list.Average(x => (int)x.State);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Helpers;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Services;
|
||||||
|
|
||||||
|
public class AppearanceService
|
||||||
|
{
|
||||||
|
private readonly AppearanceRepository _repository;
|
||||||
|
|
||||||
|
public event Action? AppearanceChanged;
|
||||||
|
|
||||||
|
public AppearanceService(AppearanceRepository repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task InitializeAsync()
|
||||||
|
{
|
||||||
|
await _repository.EnsureDefaultsAsync();
|
||||||
|
await ApplyAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ApplyAsync()
|
||||||
|
{
|
||||||
|
var items = await _repository.GetAllAsync();
|
||||||
|
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
if (item.Key.StartsWith("Status", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
Application.Current!.Resources[item.Key] = item.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Application.Current!.Resources[item.Key] = Color.FromArgb(item.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AppearanceChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveColorAsync(string key, string value)
|
||||||
|
{
|
||||||
|
await _repository.UpsertAsync(key, value);
|
||||||
|
await ApplyAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SaveTextAsync(string key, string value)
|
||||||
|
{
|
||||||
|
await _repository.UpsertAsync(key, value);
|
||||||
|
await ApplyAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ResetAsync()
|
||||||
|
{
|
||||||
|
await _repository.ResetToDefaultsAsync();
|
||||||
|
await ApplyAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
namespace cfs_tracker.Services;
|
||||||
|
|
||||||
|
public class CalendarStateService
|
||||||
|
{
|
||||||
|
private DateTime _selectedDate = DateTime.Today;
|
||||||
|
|
||||||
|
public DateTime SelectedDate
|
||||||
|
{
|
||||||
|
get => _selectedDate;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var newValue = value.Date;
|
||||||
|
if (_selectedDate != newValue)
|
||||||
|
{
|
||||||
|
_selectedDate = newValue;
|
||||||
|
SelectedDateChanged?.Invoke(_selectedDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<DateTime>? SelectedDateChanged;
|
||||||
|
|
||||||
|
public async Task ShowDayTabAsync(DateTime date)
|
||||||
|
{
|
||||||
|
SelectedDate = date.Date;
|
||||||
|
|
||||||
|
if (Shell.Current is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await Shell.Current.GoToAsync("//MainTabs/DayTab");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
namespace cfs_tracker.Services;
|
|
||||||
|
|
||||||
public interface INotificationService
|
|
||||||
{
|
|
||||||
Task RequestPermissionAsync();
|
|
||||||
Task ScheduleDailyAsync(TimeSpan time, string title, string message);
|
|
||||||
Task CancelAllAsync();
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
namespace cfs_tracker.Services;
|
|
||||||
|
|
||||||
public class PdfExportService
|
|
||||||
{
|
|
||||||
public Task<string> ExportMonthAsync(DateTime month)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<string> ExportYearAsync(int year)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<string> ExportWeekAsync(DateTime weekStart)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task<string> ExportDayAsync(DateTime day)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
|
public partial class AppearanceColorItemViewModel : ObservableObject
|
||||||
|
{
|
||||||
|
public string Key { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string title = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string value = string.Empty;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
|
public partial class AppearanceTextItemViewModel : ObservableObject
|
||||||
|
{
|
||||||
|
public string Key { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string title = string.Empty;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string value = string.Empty;
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
|
||||||
|
|
||||||
public enum CalendarMode
|
|
||||||
{
|
|
||||||
Day,
|
|
||||||
Week,
|
|
||||||
Month,
|
|
||||||
Year
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class CalendarViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
[ObservableProperty]
|
|
||||||
private CalendarMode currentMode = CalendarMode.Month;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private DateTime selectedDate = DateTime.Today;
|
|
||||||
|
|
||||||
public IRelayCommand ShowDayCommand { get; }
|
|
||||||
public IRelayCommand ShowWeekCommand { get; }
|
|
||||||
public IRelayCommand ShowMonthCommand { get; }
|
|
||||||
public IRelayCommand ShowYearCommand { get; }
|
|
||||||
public IRelayCommand TodayCommand { get; }
|
|
||||||
|
|
||||||
public CalendarViewModel()
|
|
||||||
{
|
|
||||||
ShowDayCommand = new RelayCommand(() => CurrentMode = CalendarMode.Day);
|
|
||||||
ShowWeekCommand = new RelayCommand(() => CurrentMode = CalendarMode.Week);
|
|
||||||
ShowMonthCommand = new RelayCommand(() => CurrentMode = CalendarMode.Month);
|
|
||||||
ShowYearCommand = new RelayCommand(() => CurrentMode = CalendarMode.Year);
|
|
||||||
TodayCommand = new RelayCommand(() => SelectedDate = DateTime.Today);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +1,44 @@
|
|||||||
using cfs_tracker.Models;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
public class DayEntryItemViewModel
|
public partial class DayEntryItemViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
public DateTime Timestamp { get; init; }
|
|
||||||
|
|
||||||
public string TimeText { get; init; } = "";
|
public string TimeText { get; init; } = string.Empty;
|
||||||
public string StateText { get; init; } = "";
|
public string StateText { get; init; } = string.Empty;
|
||||||
public string SourceText { get; init; } = "";
|
|
||||||
|
public string ActivityText { get; init; } = string.Empty;
|
||||||
|
public string SymptomsText { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
public bool HasActivity => !string.IsNullOrWhiteSpace(ActivityText);
|
||||||
|
public bool HasSymptoms => !string.IsNullOrWhiteSpace(SymptomsText);
|
||||||
|
public bool HasDetails => HasActivity || HasSymptoms;
|
||||||
|
|
||||||
|
public string FoldoutText => IsExpanded ? "Details ausblenden" : "Details anzeigen";
|
||||||
|
|
||||||
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
||||||
public Color TextColor { get; init; } = Colors.Black;
|
public Color TextColor { get; init; } = Colors.White;
|
||||||
|
|
||||||
public static DayEntryItemViewModel FromEntry(HealthEntry entry)
|
[ObservableProperty]
|
||||||
{
|
private bool isExpanded;
|
||||||
var state = entry.State;
|
|
||||||
var background = state switch
|
|
||||||
{
|
|
||||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
|
||||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
|
||||||
HealthState.Red => Color.FromArgb("#E53935"),
|
|
||||||
HealthState.Gray => Color.FromArgb("#757575"),
|
|
||||||
_ => Colors.Transparent
|
|
||||||
};
|
|
||||||
|
|
||||||
var textColor = state switch
|
public IRelayCommand ToggleExpandedCommand { get; }
|
||||||
{
|
|
||||||
HealthState.Gray => Colors.White,
|
|
||||||
HealthState.Green => Colors.White,
|
|
||||||
_ => Colors.Black
|
|
||||||
};
|
|
||||||
|
|
||||||
return new DayEntryItemViewModel
|
public DayEntryItemViewModel()
|
||||||
{
|
{
|
||||||
Id = entry.Id,
|
ToggleExpandedCommand = new RelayCommand(ToggleExpanded);
|
||||||
Timestamp = entry.Timestamp,
|
}
|
||||||
TimeText = entry.Timestamp.ToString("HH:mm"),
|
|
||||||
StateText = state switch
|
private void ToggleExpanded()
|
||||||
{
|
{
|
||||||
HealthState.Green => "Gut",
|
if (!HasDetails)
|
||||||
HealthState.Yellow => "So lala",
|
return;
|
||||||
HealthState.Red => "Schlecht",
|
|
||||||
HealthState.Gray => "Totalausfall",
|
IsExpanded = !IsExpanded;
|
||||||
_ => ""
|
OnPropertyChanged(nameof(FoldoutText));
|
||||||
},
|
|
||||||
SourceText = entry.Source switch
|
|
||||||
{
|
|
||||||
EntrySource.App => "App",
|
|
||||||
EntrySource.Notification => "Push",
|
|
||||||
_ => ""
|
|
||||||
},
|
|
||||||
BackgroundColor = background,
|
|
||||||
TextColor = textColor
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+110
-11
@@ -1,22 +1,27 @@
|
|||||||
using cfs_tracker.Data;
|
|
||||||
using cfs_tracker.Models;
|
|
||||||
using cfs_tracker.Views;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Helpers;
|
||||||
|
using cfs_tracker.Models;
|
||||||
|
using cfs_tracker.Services;
|
||||||
|
using cfs_tracker.Views;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
public partial class DayViewModel : ObservableObject
|
public partial class DayViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _repository;
|
||||||
|
private readonly ActivityRepository _activityRepository;
|
||||||
|
private readonly SymptomRepository _symptomRepository;
|
||||||
|
private readonly CalendarStateService _calendarState;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private DateTime selectedDate = DateTime.Today;
|
private DateTime selectedDate = DateTime.Today;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string selectedDateText = "";
|
private string selectedDateText = string.Empty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int greenCount;
|
private int greenCount;
|
||||||
@@ -30,6 +35,18 @@ public partial class DayViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int grayCount;
|
private int grayCount;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string greenStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGreenText, "Grün");
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string yellowStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusYellowText, "Gelb");
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string redStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusRedText, "Rot");
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string grayStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGrayText, "Grau");
|
||||||
|
|
||||||
public ObservableCollection<DayEntryItemViewModel> Entries { get; } = new();
|
public ObservableCollection<DayEntryItemViewModel> Entries { get; } = new();
|
||||||
|
|
||||||
public IAsyncRelayCommand PreviousDayCommand { get; }
|
public IAsyncRelayCommand PreviousDayCommand { get; }
|
||||||
@@ -38,9 +55,24 @@ public partial class DayViewModel : ObservableObject
|
|||||||
public IAsyncRelayCommand AddEntryCommand { get; }
|
public IAsyncRelayCommand AddEntryCommand { get; }
|
||||||
public IAsyncRelayCommand<DayEntryItemViewModel> DeleteEntryCommand { get; }
|
public IAsyncRelayCommand<DayEntryItemViewModel> DeleteEntryCommand { get; }
|
||||||
|
|
||||||
public DayViewModel(HealthEntryRepository repository)
|
public IAsyncRelayCommand SaveGreenQuickCommand { get; }
|
||||||
|
public IAsyncRelayCommand SaveYellowQuickCommand { get; }
|
||||||
|
public IAsyncRelayCommand SaveRedQuickCommand { get; }
|
||||||
|
public IAsyncRelayCommand SaveGrayQuickCommand { get; }
|
||||||
|
|
||||||
|
public DayViewModel(
|
||||||
|
HealthEntryRepository repository,
|
||||||
|
ActivityRepository activityRepository,
|
||||||
|
SymptomRepository symptomRepository,
|
||||||
|
CalendarStateService calendarState)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
|
_activityRepository = activityRepository;
|
||||||
|
_symptomRepository = symptomRepository;
|
||||||
|
_calendarState = calendarState;
|
||||||
|
|
||||||
|
SelectedDate = _calendarState.SelectedDate;
|
||||||
|
_calendarState.SelectedDateChanged += OnSharedSelectedDateChanged;
|
||||||
|
|
||||||
PreviousDayCommand = new AsyncRelayCommand(PreviousDayAsync);
|
PreviousDayCommand = new AsyncRelayCommand(PreviousDayAsync);
|
||||||
NextDayCommand = new AsyncRelayCommand(NextDayAsync);
|
NextDayCommand = new AsyncRelayCommand(NextDayAsync);
|
||||||
@@ -48,7 +80,13 @@ public partial class DayViewModel : ObservableObject
|
|||||||
AddEntryCommand = new AsyncRelayCommand(OpenQuickEntryAsync);
|
AddEntryCommand = new AsyncRelayCommand(OpenQuickEntryAsync);
|
||||||
DeleteEntryCommand = new AsyncRelayCommand<DayEntryItemViewModel>(DeleteEntryAsync);
|
DeleteEntryCommand = new AsyncRelayCommand<DayEntryItemViewModel>(DeleteEntryAsync);
|
||||||
|
|
||||||
|
SaveGreenQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Green));
|
||||||
|
SaveYellowQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Yellow));
|
||||||
|
SaveRedQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Red));
|
||||||
|
SaveGrayQuickCommand = new AsyncRelayCommand(() => QuickSaveAsync(HealthState.Gray));
|
||||||
|
|
||||||
UpdateDateText();
|
UpdateDateText();
|
||||||
|
RefreshStatusTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnSelectedDateChanged(DateTime value)
|
partial void OnSelectedDateChanged(DateTime value)
|
||||||
@@ -56,8 +94,17 @@ public partial class DayViewModel : ObservableObject
|
|||||||
UpdateDateText();
|
UpdateDateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void OnSharedSelectedDateChanged(DateTime date)
|
||||||
|
{
|
||||||
|
SelectedDate = date;
|
||||||
|
await RefreshAsync();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task RefreshAsync()
|
public async Task RefreshAsync()
|
||||||
{
|
{
|
||||||
|
SelectedDate = _calendarState.SelectedDate;
|
||||||
|
RefreshStatusTexts();
|
||||||
|
|
||||||
var entries = await _repository.GetEntriesForDateAsync(SelectedDate);
|
var entries = await _repository.GetEntriesForDateAsync(SelectedDate);
|
||||||
|
|
||||||
GreenCount = entries.Count(x => x.State == HealthState.Green);
|
GreenCount = entries.Count(x => x.State == HealthState.Green);
|
||||||
@@ -67,25 +114,69 @@ public partial class DayViewModel : ObservableObject
|
|||||||
|
|
||||||
Entries.Clear();
|
Entries.Clear();
|
||||||
|
|
||||||
|
var activityMap = await _activityRepository.GetNameMapAsync();
|
||||||
|
var symptomMapByEntry = await _symptomRepository.GetSymptomsByEntryIdsAsync(entries.Select(x => x.Id));
|
||||||
|
|
||||||
foreach (var entry in entries.OrderBy(x => x.Timestamp))
|
foreach (var entry in entries.OrderBy(x => x.Timestamp))
|
||||||
Entries.Add(DayEntryItemViewModel.FromEntry(entry));
|
{
|
||||||
|
string activityText = string.Empty;
|
||||||
|
if (entry.ActivityId.HasValue && activityMap.TryGetValue(entry.ActivityId.Value, out var activityName))
|
||||||
|
activityText = activityName;
|
||||||
|
|
||||||
|
symptomMapByEntry.TryGetValue(entry.Id, out var symptoms);
|
||||||
|
string symptomsText = symptoms is { Count: > 0 }
|
||||||
|
? string.Join(", ", symptoms)
|
||||||
|
: string.Empty;
|
||||||
|
|
||||||
|
Entries.Add(new DayEntryItemViewModel
|
||||||
|
{
|
||||||
|
Id = entry.Id,
|
||||||
|
TimeText = entry.Timestamp.ToString("HH:mm"),
|
||||||
|
StateText = ThemeResourceHelper.GetString(
|
||||||
|
entry.State.ToTextKey(),
|
||||||
|
entry.State.ToFallbackText()),
|
||||||
|
ActivityText = activityText,
|
||||||
|
SymptomsText = symptomsText,
|
||||||
|
BackgroundColor = ThemeResourceHelper.GetColor(entry.State.ToColorKey(), "#203041"),
|
||||||
|
TextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task QuickSaveAsync(HealthState state)
|
||||||
|
{
|
||||||
|
if (SelectedDate.Date == DateTime.Today)
|
||||||
|
{
|
||||||
|
await _repository.AddEntryAsync(
|
||||||
|
state,
|
||||||
|
EntrySource.App,
|
||||||
|
DateTime.Now);
|
||||||
|
|
||||||
|
await RefreshAsync();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await OpenQuickEntryAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task PreviousDayAsync()
|
private async Task PreviousDayAsync()
|
||||||
{
|
{
|
||||||
SelectedDate = SelectedDate.AddDays(-1);
|
_calendarState.SelectedDate = SelectedDate.AddDays(-1);
|
||||||
|
SelectedDate = _calendarState.SelectedDate;
|
||||||
await RefreshAsync();
|
await RefreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task NextDayAsync()
|
private async Task NextDayAsync()
|
||||||
{
|
{
|
||||||
SelectedDate = SelectedDate.AddDays(1);
|
_calendarState.SelectedDate = SelectedDate.AddDays(1);
|
||||||
|
SelectedDate = _calendarState.SelectedDate;
|
||||||
await RefreshAsync();
|
await RefreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetTodayAsync()
|
private async Task SetTodayAsync()
|
||||||
{
|
{
|
||||||
SelectedDate = DateTime.Today;
|
_calendarState.SelectedDate = DateTime.Today;
|
||||||
|
SelectedDate = _calendarState.SelectedDate;
|
||||||
await RefreshAsync();
|
await RefreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,4 +199,12 @@ public partial class DayViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RefreshStatusTexts()
|
||||||
|
{
|
||||||
|
GreenStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGreenText, "Grün");
|
||||||
|
YellowStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusYellowText, "Gelb");
|
||||||
|
RedStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusRedText, "Rot");
|
||||||
|
GrayStatusText = ThemeResourceHelper.GetString(ThemeKeys.StatusGrayText, "Grau");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,26 +1,13 @@
|
|||||||
using Microsoft.Maui.Graphics;
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
public class MonthCellViewModel
|
public class MonthCellViewModel
|
||||||
{
|
{
|
||||||
public bool IsRealDay { get; init; }
|
public bool IsRealDay { get; init; }
|
||||||
public DateTime Date { get; init; }
|
public DateTime Date { get; init; }
|
||||||
|
|
||||||
public string DayNumberText { get; init; } = "";
|
public string DayNumberText { get; init; } = "";
|
||||||
public string CountText { get; init; } = "";
|
public string CountText { get; init; } = "";
|
||||||
|
|
||||||
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
public Color BackgroundColor { get; init; } = Colors.Transparent;
|
||||||
public Color BorderColor { get; init; } = Colors.Transparent;
|
public Color BorderColor { get; init; } = Colors.Transparent;
|
||||||
public Color TextColor { get; init; } = Colors.Black;
|
public Color TextColor { get; init; } = Colors.Black;
|
||||||
|
public static MonthCellViewModel Placeholder() => new() { IsRealDay = false };
|
||||||
public static MonthCellViewModel Placeholder() => new()
|
|
||||||
{
|
|
||||||
IsRealDay = false,
|
|
||||||
BackgroundColor = Colors.Transparent,
|
|
||||||
BorderColor = Colors.Transparent,
|
|
||||||
TextColor = Colors.Transparent,
|
|
||||||
DayNumberText = "",
|
|
||||||
CountText = ""
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using cfs_tracker.Data;
|
|
||||||
using cfs_tracker.Models;
|
|
||||||
using cfs_tracker.Services;
|
|
||||||
using cfs_tracker.ViewModels;
|
|
||||||
using cfs_tracker.Views;
|
|
||||||
using Microsoft.Maui.Graphics;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Helpers;
|
||||||
|
using cfs_tracker.Models;
|
||||||
|
using cfs_tracker.Services;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
@@ -15,12 +13,13 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _repository;
|
||||||
private readonly AggregationService _aggregationService;
|
private readonly AggregationService _aggregationService;
|
||||||
|
private readonly CalendarStateService _calendarState;
|
||||||
private readonly CultureInfo _culture = new("de-DE");
|
private readonly CultureInfo _culture = new("de-DE");
|
||||||
|
|
||||||
private DateTime _currentMonth = new(DateTime.Today.Year, DateTime.Today.Month, 1);
|
private DateTime _currentMonth = new(DateTime.Today.Year, DateTime.Today.Month, 1);
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string selectedMonthText = "";
|
private string selectedMonthText = string.Empty;
|
||||||
|
|
||||||
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
||||||
|
|
||||||
@@ -31,10 +30,12 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
|
|
||||||
public MonthViewModel(
|
public MonthViewModel(
|
||||||
HealthEntryRepository repository,
|
HealthEntryRepository repository,
|
||||||
AggregationService aggregationService)
|
AggregationService aggregationService,
|
||||||
|
CalendarStateService calendarState)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_aggregationService = aggregationService;
|
_aggregationService = aggregationService;
|
||||||
|
_calendarState = calendarState;
|
||||||
|
|
||||||
PreviousMonthCommand = new AsyncRelayCommand(PreviousMonthAsync);
|
PreviousMonthCommand = new AsyncRelayCommand(PreviousMonthAsync);
|
||||||
NextMonthCommand = new AsyncRelayCommand(NextMonthAsync);
|
NextMonthCommand = new AsyncRelayCommand(NextMonthAsync);
|
||||||
@@ -69,15 +70,7 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
|
|
||||||
private MonthCellViewModel BuildCell(CalendarDaySummary summary)
|
private MonthCellViewModel BuildCell(CalendarDaySummary summary)
|
||||||
{
|
{
|
||||||
Color background = summary.DisplayState switch
|
var colorKey = summary.DisplayState?.ToColorKey() ?? ThemeKeys.PanelBackground2;
|
||||||
{
|
|
||||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
|
||||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
|
||||||
HealthState.Red => Color.FromArgb("#E53935"),
|
|
||||||
HealthState.Gray => Color.FromArgb("#757575"),
|
|
||||||
_ => Color.FromArgb("#F2F2F2")
|
|
||||||
};
|
|
||||||
|
|
||||||
bool isToday = summary.Date.Date == DateTime.Today.Date;
|
bool isToday = summary.Date.Date == DateTime.Today.Date;
|
||||||
|
|
||||||
return new MonthCellViewModel
|
return new MonthCellViewModel
|
||||||
@@ -85,10 +78,12 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
IsRealDay = true,
|
IsRealDay = true,
|
||||||
Date = summary.Date,
|
Date = summary.Date,
|
||||||
DayNumberText = summary.Date.Day.ToString(),
|
DayNumberText = summary.Date.Day.ToString(),
|
||||||
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : "",
|
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : string.Empty,
|
||||||
BackgroundColor = background,
|
BackgroundColor = ThemeResourceHelper.GetColor(colorKey, "#203041"),
|
||||||
BorderColor = isToday ? Colors.Black : Color.FromArgb("#D0D0D0"),
|
BorderColor = isToday
|
||||||
TextColor = summary.DisplayState == HealthState.Gray ? Colors.White : Colors.Black
|
? ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||||
|
: ThemeResourceHelper.GetColor(ThemeKeys.PanelBorder, "#2B3E52"),
|
||||||
|
TextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +101,7 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
|
|
||||||
private async Task SetTodayAsync()
|
private async Task SetTodayAsync()
|
||||||
{
|
{
|
||||||
_currentMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
|
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||||
await RefreshAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
||||||
@@ -115,7 +109,6 @@ public partial class MonthViewModel : ObservableObject
|
|||||||
if (cell is null || !cell.IsRealDay)
|
if (cell is null || !cell.IsRealDay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string date = cell.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
await _calendarState.ShowDayTabAsync(cell.Date);
|
||||||
await Shell.Current.GoToAsync($"{nameof(QuickEntryPage)}?date={date}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,16 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using cfs_tracker.Data;
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Services;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
public partial class OptionsViewModel : ObservableObject
|
public partial class OptionsViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _healthRepository;
|
||||||
|
private readonly AppearanceRepository _appearanceRepository;
|
||||||
|
private readonly AppearanceService _appearanceService;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string deleteConfirmationText = string.Empty;
|
private string deleteConfirmationText = string.Empty;
|
||||||
@@ -14,12 +18,25 @@ public partial class OptionsViewModel : ObservableObject
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string statusText = string.Empty;
|
private string statusText = string.Empty;
|
||||||
|
|
||||||
public IAsyncRelayCommand DeleteAllDataCommand { get; }
|
public ObservableCollection<AppearanceColorItemViewModel> AppearanceColors { get; } = new();
|
||||||
|
public ObservableCollection<AppearanceTextItemViewModel> StatusTexts { get; } = new();
|
||||||
|
|
||||||
public OptionsViewModel(HealthEntryRepository repository)
|
public IAsyncRelayCommand DeleteAllDataCommand { get; }
|
||||||
|
public IAsyncRelayCommand SaveAppearanceCommand { get; }
|
||||||
|
public IAsyncRelayCommand ResetAppearanceCommand { get; }
|
||||||
|
|
||||||
|
public OptionsViewModel(
|
||||||
|
HealthEntryRepository healthRepository,
|
||||||
|
AppearanceRepository appearanceRepository,
|
||||||
|
AppearanceService appearanceService)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_healthRepository = healthRepository;
|
||||||
|
_appearanceRepository = appearanceRepository;
|
||||||
|
_appearanceService = appearanceService;
|
||||||
|
|
||||||
DeleteAllDataCommand = new AsyncRelayCommand(DeleteAllDataAsync, CanDeleteAllData);
|
DeleteAllDataCommand = new AsyncRelayCommand(DeleteAllDataAsync, CanDeleteAllData);
|
||||||
|
SaveAppearanceCommand = new AsyncRelayCommand(SaveAppearanceAsync);
|
||||||
|
ResetAppearanceCommand = new AsyncRelayCommand(ResetAppearanceAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnDeleteConfirmationTextChanged(string value)
|
partial void OnDeleteConfirmationTextChanged(string value)
|
||||||
@@ -27,19 +44,86 @@ public partial class OptionsViewModel : ObservableObject
|
|||||||
DeleteAllDataCommand.NotifyCanExecuteChanged();
|
DeleteAllDataCommand.NotifyCanExecuteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task LoadAsync()
|
||||||
|
{
|
||||||
|
await LoadAppearanceAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private bool CanDeleteAllData()
|
private bool CanDeleteAllData()
|
||||||
{
|
{
|
||||||
return string.Equals(
|
return string.Equals(DeleteConfirmationText?.Trim(), "löschen", StringComparison.OrdinalIgnoreCase);
|
||||||
DeleteConfirmationText?.Trim(),
|
|
||||||
"löschen",
|
|
||||||
StringComparison.OrdinalIgnoreCase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteAllDataAsync()
|
private async Task DeleteAllDataAsync()
|
||||||
{
|
{
|
||||||
await _repository.DeleteAllAsync();
|
await _healthRepository.DeleteAllAsync();
|
||||||
|
|
||||||
DeleteConfirmationText = string.Empty;
|
DeleteConfirmationText = string.Empty;
|
||||||
StatusText = "Alle gespeicherten Einträge wurden gelöscht.";
|
StatusText = "Alle gespeicherten Einträge wurden gelöscht.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadAppearanceAsync()
|
||||||
|
{
|
||||||
|
AppearanceColors.Clear();
|
||||||
|
StatusTexts.Clear();
|
||||||
|
|
||||||
|
var all = await _appearanceRepository.GetAllAsync();
|
||||||
|
|
||||||
|
AddColor(all, "AppBackground", "App-Hintergrund");
|
||||||
|
AddColor(all, "PanelBackground", "Panel-Hintergrund");
|
||||||
|
AddColor(all, "PanelBackground2", "Sekundäre Fläche");
|
||||||
|
AddColor(all, "PanelBorder", "Panel-Rand");
|
||||||
|
AddColor(all, "TextPrimary", "Haupttext");
|
||||||
|
AddColor(all, "TextMuted", "Gedimmter Text");
|
||||||
|
AddColor(all, "StateGreen", "Statusfarbe Grün");
|
||||||
|
AddColor(all, "StateYellow", "Statusfarbe Gelb");
|
||||||
|
AddColor(all, "StateRed", "Statusfarbe Rot");
|
||||||
|
AddColor(all, "StateGray", "Statusfarbe Grau");
|
||||||
|
|
||||||
|
AddText(all, "StatusGreenText", "Text für Grün");
|
||||||
|
AddText(all, "StatusYellowText", "Text für Gelb");
|
||||||
|
AddText(all, "StatusRedText", "Text für Rot");
|
||||||
|
AddText(all, "StatusGrayText", "Text für Grau");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddColor(List<Models.AppearanceSetting> all, string key, string title)
|
||||||
|
{
|
||||||
|
var value = all.FirstOrDefault(x => x.Key == key)?.Value ?? string.Empty;
|
||||||
|
|
||||||
|
AppearanceColors.Add(new AppearanceColorItemViewModel
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Title = title,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddText(List<Models.AppearanceSetting> all, string key, string title)
|
||||||
|
{
|
||||||
|
var value = all.FirstOrDefault(x => x.Key == key)?.Value ?? string.Empty;
|
||||||
|
|
||||||
|
StatusTexts.Add(new AppearanceTextItemViewModel
|
||||||
|
{
|
||||||
|
Key = key,
|
||||||
|
Title = title,
|
||||||
|
Value = value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SaveAppearanceAsync()
|
||||||
|
{
|
||||||
|
foreach (var item in AppearanceColors)
|
||||||
|
await _appearanceService.SaveColorAsync(item.Key, item.Value);
|
||||||
|
|
||||||
|
foreach (var item in StatusTexts)
|
||||||
|
await _appearanceService.SaveTextAsync(item.Key, item.Value);
|
||||||
|
|
||||||
|
StatusText = "Aussehen wurde gespeichert.";
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ResetAppearanceAsync()
|
||||||
|
{
|
||||||
|
await _appearanceService.ResetAsync();
|
||||||
|
await LoadAppearanceAsync();
|
||||||
|
StatusText = "Aussehen wurde auf Standard zurückgesetzt.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
@@ -9,112 +9,84 @@ namespace cfs_tracker.ViewModels;
|
|||||||
|
|
||||||
public partial class QuickEntryViewModel : ObservableObject
|
public partial class QuickEntryViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _repo;
|
||||||
|
private readonly ActivityRepository _activityRepo;
|
||||||
|
private readonly SymptomRepository _symptomRepo;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty] private DateTime selectedDate = DateTime.Today;
|
||||||
private DateTime selectedDate = DateTime.Today;
|
[ObservableProperty] private string selectedDateText = "";
|
||||||
|
[ObservableProperty] private bool isPastDate;
|
||||||
|
[ObservableProperty] private bool isFutureDate;
|
||||||
|
[ObservableProperty] private string selectedPartText = "Vormittag";
|
||||||
|
[ObservableProperty] private SelectableItemViewModel? selectedActivity;
|
||||||
|
|
||||||
[ObservableProperty]
|
public ObservableCollection<string> AvailableParts { get; } = new() { "Vormittag", "Nachmittag" };
|
||||||
private string selectedDateText = "";
|
public ObservableCollection<SelectableItemViewModel> Activities { get; } = new();
|
||||||
|
public ObservableCollection<SelectableItemViewModel> Symptoms { get; } = new();
|
||||||
[ObservableProperty]
|
|
||||||
private bool isPastDate;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private bool isFutureDate;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private string selectedPartText = "Vormittag";
|
|
||||||
|
|
||||||
public ObservableCollection<string> AvailableParts { get; } = new()
|
|
||||||
{
|
|
||||||
"Vormittag",
|
|
||||||
"Nachmittag"
|
|
||||||
};
|
|
||||||
|
|
||||||
public IAsyncRelayCommand SaveGreenCommand { get; }
|
public IAsyncRelayCommand SaveGreenCommand { get; }
|
||||||
public IAsyncRelayCommand SaveYellowCommand { get; }
|
public IAsyncRelayCommand SaveYellowCommand { get; }
|
||||||
public IAsyncRelayCommand SaveRedCommand { get; }
|
public IAsyncRelayCommand SaveRedCommand { get; }
|
||||||
public IAsyncRelayCommand SaveGrayCommand { get; }
|
public IAsyncRelayCommand SaveGrayCommand { get; }
|
||||||
|
|
||||||
public QuickEntryViewModel(HealthEntryRepository repository)
|
public QuickEntryViewModel(HealthEntryRepository repo, ActivityRepository activityRepo, SymptomRepository symptomRepo)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repo=repo; _activityRepo=activityRepo; _symptomRepo=symptomRepo;
|
||||||
|
|
||||||
SaveGreenCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Green));
|
SaveGreenCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Green));
|
||||||
SaveYellowCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Yellow));
|
SaveYellowCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Yellow));
|
||||||
SaveRedCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Red));
|
SaveRedCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Red));
|
||||||
SaveGrayCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Gray));
|
SaveGrayCommand = new AsyncRelayCommand(()=>SaveAsync(HealthState.Gray));
|
||||||
|
}
|
||||||
|
|
||||||
UpdateState();
|
public async Task LoadLookupsAsync()
|
||||||
|
{
|
||||||
|
Activities.Clear();
|
||||||
|
Symptoms.Clear();
|
||||||
|
Activities.Add(new SelectableItemViewModel { Id = 0, Name = "Keine Angabe" });
|
||||||
|
foreach (var a in await _activityRepo.GetActiveAsync()) Activities.Add(new SelectableItemViewModel { Id = a.Id, Name = a.Name });
|
||||||
|
foreach (var s in await _symptomRepo.GetActiveAsync()) Symptoms.Add(new SelectableItemViewModel { Id = s.Id, Name = s.Name });
|
||||||
|
SelectedActivity ??= Activities.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDateFromQuery(string? dateText)
|
public void SetDateFromQuery(string? dateText)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(dateText) &&
|
if (!string.IsNullOrWhiteSpace(dateText) && DateTime.TryParseExact(dateText, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var parsed))
|
||||||
DateTime.TryParseExact(
|
|
||||||
dateText,
|
|
||||||
"yyyy-MM-dd",
|
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
DateTimeStyles.None,
|
|
||||||
out var parsed))
|
|
||||||
{
|
|
||||||
SelectedDate = parsed.Date;
|
SelectedDate = parsed.Date;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
SelectedDate = DateTime.Today;
|
SelectedDate = DateTime.Today;
|
||||||
}
|
|
||||||
|
|
||||||
UpdateState();
|
UpdateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnSelectedDateChanged(DateTime value)
|
partial void OnSelectedDateChanged(DateTime value) => UpdateState();
|
||||||
{
|
|
||||||
UpdateState();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task SaveAsync(HealthState state)
|
private async Task SaveAsync(HealthState state)
|
||||||
{
|
{
|
||||||
if (IsFutureDate)
|
if (IsFutureDate) return;
|
||||||
return;
|
int? activityId = SelectedActivity is not null && SelectedActivity.Id > 0 ? SelectedActivity.Id : null;
|
||||||
|
int entryId;
|
||||||
if (IsPastDate)
|
if (IsPastDate)
|
||||||
{
|
{
|
||||||
await _repository.UpsertBackfillAsync(
|
await _repo.UpsertBackfillAsync(SelectedDate, SelectedPartText == "Nachmittag" ? DayPart.Afternoon : DayPart.Morning, state, EntrySource.App, activityId);
|
||||||
SelectedDate,
|
var saved = await _repo.GetBackfillEntryAsync(SelectedDate, SelectedPartText == "Nachmittag" ? DayPart.Afternoon : DayPart.Morning);
|
||||||
GetSelectedPart(),
|
entryId = saved?.Id ?? 0;
|
||||||
state,
|
|
||||||
EntrySource.App);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _repository.AddEntryAsync(
|
entryId = await _repo.AddEntryAndReturnIdAsync(state, EntrySource.App, DateTime.Now, activityId);
|
||||||
state,
|
|
||||||
EntrySource.App,
|
|
||||||
DateTime.Now);
|
|
||||||
}
|
}
|
||||||
|
if (entryId > 0)
|
||||||
await Shell.Current.GoToAsync("..");
|
|
||||||
}
|
|
||||||
|
|
||||||
private DayPart GetSelectedPart()
|
|
||||||
{
|
{
|
||||||
return SelectedPartText == "Nachmittag"
|
await _symptomRepo.SetSymptomsForEntryAsync(entryId, Symptoms.Where(x=>x.IsSelected).Select(x=>x.Id));
|
||||||
? DayPart.Afternoon
|
}
|
||||||
: DayPart.Morning;
|
await Shell.Current.GoToAsync("..");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateState()
|
private void UpdateState()
|
||||||
{
|
{
|
||||||
var today = DateTime.Today;
|
var today = DateTime.Today;
|
||||||
|
|
||||||
IsPastDate = SelectedDate.Date < today;
|
IsPastDate = SelectedDate.Date < today;
|
||||||
IsFutureDate = SelectedDate.Date > today;
|
IsFutureDate = SelectedDate.Date > today;
|
||||||
|
|
||||||
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
SelectedDateText = SelectedDate.ToString("dddd, dd. MMMM yyyy", new CultureInfo("de-DE"));
|
||||||
|
if (!IsPastDate) SelectedPartText = "Vormittag";
|
||||||
if (!IsPastDate)
|
|
||||||
SelectedPartText = "Vormittag";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
namespace cfs_tracker.ViewModels;
|
||||||
|
public partial class SelectableItemViewModel : ObservableObject
|
||||||
|
{
|
||||||
|
public int Id { get; init; }
|
||||||
|
public string Name { get; init; } = "";
|
||||||
|
[ObservableProperty] private bool isSelected;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.Maui.Graphics;
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
@@ -6,20 +6,20 @@ public class WeekCellViewModel
|
|||||||
{
|
{
|
||||||
public DateTime Date { get; init; }
|
public DateTime Date { get; init; }
|
||||||
|
|
||||||
public string DayText { get; init; } = "";
|
public string DayText { get; init; } = string.Empty;
|
||||||
public string DateText { get; init; } = "";
|
public string DateText { get; init; } = string.Empty;
|
||||||
|
|
||||||
public string MorningText { get; init; } = "";
|
public string MorningText { get; init; } = string.Empty;
|
||||||
public string AfternoonText { get; init; } = "";
|
public string AfternoonText { get; init; } = string.Empty;
|
||||||
|
|
||||||
public string MorningCountText { get; init; } = "";
|
public string MorningCountText { get; init; } = string.Empty;
|
||||||
public string AfternoonCountText { get; init; } = "";
|
public string AfternoonCountText { get; init; } = string.Empty;
|
||||||
|
|
||||||
public Color MorningBackgroundColor { get; init; } = Colors.Transparent;
|
public Color MorningBackgroundColor { get; init; } = Colors.Transparent;
|
||||||
public Color AfternoonBackgroundColor { get; init; } = Colors.Transparent;
|
public Color AfternoonBackgroundColor { get; init; } = Colors.Transparent;
|
||||||
|
|
||||||
public Color MorningTextColor { get; init; } = Colors.Black;
|
public Color MorningTextColor { get; init; } = Colors.White;
|
||||||
public Color AfternoonTextColor { get; init; } = Colors.Black;
|
public Color AfternoonTextColor { get; init; } = Colors.White;
|
||||||
|
|
||||||
public bool IsToday { get; init; }
|
public bool IsToday { get; init; }
|
||||||
}
|
}
|
||||||
+31
-40
@@ -1,13 +1,12 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using cfs_tracker.Data;
|
|
||||||
using cfs_tracker.Models;
|
|
||||||
using cfs_tracker.Services;
|
|
||||||
using cfs_tracker.ViewModels;
|
|
||||||
using cfs_tracker.Views;
|
|
||||||
using Microsoft.Maui.Graphics;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Helpers;
|
||||||
|
using cfs_tracker.Models;
|
||||||
|
using cfs_tracker.Services;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
@@ -15,12 +14,13 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _repository;
|
||||||
private readonly AggregationService _aggregationService;
|
private readonly AggregationService _aggregationService;
|
||||||
|
private readonly CalendarStateService _calendarState;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private DateTime anchorDate = DateTime.Today;
|
private DateTime anchorDate = DateTime.Today;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string weekText = "";
|
private string weekText = string.Empty;
|
||||||
|
|
||||||
public ObservableCollection<WeekCellViewModel> Days { get; } = new();
|
public ObservableCollection<WeekCellViewModel> Days { get; } = new();
|
||||||
|
|
||||||
@@ -31,10 +31,12 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
|
|
||||||
public WeekViewModel(
|
public WeekViewModel(
|
||||||
HealthEntryRepository repository,
|
HealthEntryRepository repository,
|
||||||
AggregationService aggregationService)
|
AggregationService aggregationService,
|
||||||
|
CalendarStateService calendarState)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_aggregationService = aggregationService;
|
_aggregationService = aggregationService;
|
||||||
|
_calendarState = calendarState;
|
||||||
|
|
||||||
PreviousWeekCommand = new AsyncRelayCommand(PreviousWeekAsync);
|
PreviousWeekCommand = new AsyncRelayCommand(PreviousWeekAsync);
|
||||||
NextWeekCommand = new AsyncRelayCommand(NextWeekAsync);
|
NextWeekCommand = new AsyncRelayCommand(NextWeekAsync);
|
||||||
@@ -68,14 +70,14 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
Date = summary.Date,
|
Date = summary.Date,
|
||||||
DayText = summary.Date.ToString("ddd", new CultureInfo("de-DE")),
|
DayText = summary.Date.ToString("ddd", new CultureInfo("de-DE")),
|
||||||
DateText = summary.Date.ToString("dd.MM"),
|
DateText = summary.Date.ToString("dd.MM"),
|
||||||
MorningText = summary.MorningAverage.HasValue ? StateLabel(morningState) : "—",
|
MorningText = StateLabel(morningState),
|
||||||
AfternoonText = summary.AfternoonAverage.HasValue ? StateLabel(afternoonState) : "—",
|
AfternoonText = StateLabel(afternoonState),
|
||||||
MorningCountText = summary.MorningCount > 0 ? $"{summary.MorningCount}x" : "",
|
MorningCountText = summary.MorningCount > 0 ? $"{summary.MorningCount}x" : string.Empty,
|
||||||
AfternoonCountText = summary.AfternoonCount > 0 ? $"{summary.AfternoonCount}x" : "",
|
AfternoonCountText = summary.AfternoonCount > 0 ? $"{summary.AfternoonCount}x" : string.Empty,
|
||||||
MorningBackgroundColor = StateColor(morningState),
|
MorningBackgroundColor = StateColor(morningState),
|
||||||
AfternoonBackgroundColor = StateColor(afternoonState),
|
AfternoonBackgroundColor = StateColor(afternoonState),
|
||||||
MorningTextColor = StateTextColor(morningState),
|
MorningTextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2"),
|
||||||
AfternoonTextColor = StateTextColor(afternoonState),
|
AfternoonTextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2"),
|
||||||
IsToday = summary.Date.Date == DateTime.Today.Date
|
IsToday = summary.Date.Date == DateTime.Today.Date
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -94,8 +96,7 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
|
|
||||||
private async Task SetTodayAsync()
|
private async Task SetTodayAsync()
|
||||||
{
|
{
|
||||||
AnchorDate = DateTime.Today;
|
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||||
await RefreshAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OpenDayAsync(WeekCellViewModel? cell)
|
private async Task OpenDayAsync(WeekCellViewModel? cell)
|
||||||
@@ -103,8 +104,7 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
if (cell is null)
|
if (cell is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string date = cell.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
await _calendarState.ShowDayTabAsync(cell.Date);
|
||||||
await Shell.Current.GoToAsync($"{nameof(QuickEntryPage)}?date={date}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DateTime StartOfWeek(DateTime date)
|
private static DateTime StartOfWeek(DateTime date)
|
||||||
@@ -113,28 +113,19 @@ public partial class WeekViewModel : ObservableObject
|
|||||||
return date.Date.AddDays(-diff);
|
return date.Date.AddDays(-diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string StateLabel(HealthState? state) => state switch
|
private static string StateLabel(HealthState? state)
|
||||||
{
|
{
|
||||||
HealthState.Green => "Gut",
|
if (state is null)
|
||||||
HealthState.Yellow => "So lala",
|
return "—";
|
||||||
HealthState.Red => "Schlecht",
|
|
||||||
HealthState.Gray => "Ausfall",
|
|
||||||
_ => "—"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Color StateColor(HealthState? state) => state switch
|
return ThemeResourceHelper.GetString(
|
||||||
{
|
state.Value.ToTextKey(),
|
||||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
state.Value.ToFallbackText());
|
||||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
}
|
||||||
HealthState.Red => Color.FromArgb("#E53935"),
|
|
||||||
HealthState.Gray => Color.FromArgb("#757575"),
|
|
||||||
_ => Color.FromArgb("#F2F2F2")
|
|
||||||
};
|
|
||||||
|
|
||||||
private static Color StateTextColor(HealthState? state) => state switch
|
private static Color StateColor(HealthState? state)
|
||||||
{
|
{
|
||||||
HealthState.Green => Colors.White,
|
var key = state?.ToColorKey() ?? ThemeKeys.PanelBackground2;
|
||||||
HealthState.Gray => Colors.White,
|
return ThemeResourceHelper.GetColor(key, "#203041");
|
||||||
_ => Colors.Black
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
public class YearMonthViewModel
|
public class YearMonthViewModel
|
||||||
{
|
{
|
||||||
public int MonthNumber { get; init; }
|
public int MonthNumber { get; init; }
|
||||||
public string MonthText { get; init; } = "";
|
public string MonthText { get; init; } = "";
|
||||||
|
|
||||||
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
public ObservableCollection<MonthCellViewModel> Days { get; } = new();
|
||||||
}
|
}
|
||||||
+20
-25
@@ -1,11 +1,11 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using cfs_tracker.Data;
|
|
||||||
using cfs_tracker.Models;
|
|
||||||
using cfs_tracker.Services;
|
|
||||||
using cfs_tracker.Views;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using cfs_tracker.Data;
|
||||||
|
using cfs_tracker.Helpers;
|
||||||
|
using cfs_tracker.Models;
|
||||||
|
using cfs_tracker.Services;
|
||||||
|
|
||||||
namespace cfs_tracker.ViewModels;
|
namespace cfs_tracker.ViewModels;
|
||||||
|
|
||||||
@@ -13,12 +13,13 @@ public partial class YearViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
private readonly HealthEntryRepository _repository;
|
private readonly HealthEntryRepository _repository;
|
||||||
private readonly AggregationService _aggregationService;
|
private readonly AggregationService _aggregationService;
|
||||||
|
private readonly CalendarStateService _calendarState;
|
||||||
private readonly CultureInfo _culture = new("de-DE");
|
private readonly CultureInfo _culture = new("de-DE");
|
||||||
|
|
||||||
private int _currentYear = DateTime.Today.Year;
|
private int _currentYear = DateTime.Today.Year;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string selectedYearText = "";
|
private string selectedYearText = string.Empty;
|
||||||
|
|
||||||
public ObservableCollection<YearMonthViewModel> Months { get; } = new();
|
public ObservableCollection<YearMonthViewModel> Months { get; } = new();
|
||||||
|
|
||||||
@@ -29,10 +30,12 @@ public partial class YearViewModel : ObservableObject
|
|||||||
|
|
||||||
public YearViewModel(
|
public YearViewModel(
|
||||||
HealthEntryRepository repository,
|
HealthEntryRepository repository,
|
||||||
AggregationService aggregationService)
|
AggregationService aggregationService,
|
||||||
|
CalendarStateService calendarState)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_aggregationService = aggregationService;
|
_aggregationService = aggregationService;
|
||||||
|
_calendarState = calendarState;
|
||||||
|
|
||||||
PreviousYearCommand = new AsyncRelayCommand(PreviousYearAsync);
|
PreviousYearCommand = new AsyncRelayCommand(PreviousYearAsync);
|
||||||
NextYearCommand = new AsyncRelayCommand(NextYearAsync);
|
NextYearCommand = new AsyncRelayCommand(NextYearAsync);
|
||||||
@@ -78,15 +81,7 @@ public partial class YearViewModel : ObservableObject
|
|||||||
|
|
||||||
private MonthCellViewModel BuildCell(CalendarDaySummary summary)
|
private MonthCellViewModel BuildCell(CalendarDaySummary summary)
|
||||||
{
|
{
|
||||||
Color background = summary.DisplayState switch
|
var colorKey = summary.DisplayState?.ToColorKey() ?? ThemeKeys.PanelBackground2;
|
||||||
{
|
|
||||||
HealthState.Green => Color.FromArgb("#4CAF50"),
|
|
||||||
HealthState.Yellow => Color.FromArgb("#FBC02D"),
|
|
||||||
HealthState.Red => Color.FromArgb("#E53935"),
|
|
||||||
HealthState.Gray => Color.FromArgb("#757575"),
|
|
||||||
_ => Color.FromArgb("#F2F2F2")
|
|
||||||
};
|
|
||||||
|
|
||||||
bool isToday = summary.Date.Date == DateTime.Today.Date;
|
bool isToday = summary.Date.Date == DateTime.Today.Date;
|
||||||
|
|
||||||
return new MonthCellViewModel
|
return new MonthCellViewModel
|
||||||
@@ -94,10 +89,12 @@ public partial class YearViewModel : ObservableObject
|
|||||||
IsRealDay = true,
|
IsRealDay = true,
|
||||||
Date = summary.Date,
|
Date = summary.Date,
|
||||||
DayNumberText = summary.Date.Day.ToString(),
|
DayNumberText = summary.Date.Day.ToString(),
|
||||||
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : "",
|
CountText = summary.EntryCount > 0 ? $"{summary.EntryCount}x" : string.Empty,
|
||||||
BackgroundColor = background,
|
BackgroundColor = ThemeResourceHelper.GetColor(colorKey, "#203041"),
|
||||||
BorderColor = isToday ? Colors.Black : Color.FromArgb("#D0D0D0"),
|
BorderColor = isToday
|
||||||
TextColor = summary.DisplayState == HealthState.Gray ? Colors.White : Colors.Black
|
? ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||||
|
: ThemeResourceHelper.GetColor(ThemeKeys.PanelBorder, "#2B3E52"),
|
||||||
|
TextColor = ThemeResourceHelper.GetColor(ThemeKeys.TextPrimary, "#D9E6F2")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,8 +112,7 @@ public partial class YearViewModel : ObservableObject
|
|||||||
|
|
||||||
private async Task SetTodayAsync()
|
private async Task SetTodayAsync()
|
||||||
{
|
{
|
||||||
_currentYear = DateTime.Today.Year;
|
await _calendarState.ShowDayTabAsync(DateTime.Today);
|
||||||
await RefreshAsync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
private async Task OpenDayAsync(MonthCellViewModel? cell)
|
||||||
@@ -124,7 +120,6 @@ public partial class YearViewModel : ObservableObject
|
|||||||
if (cell is null || !cell.IsRealDay)
|
if (cell is null || !cell.IsRealDay)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string date = cell.Date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
|
await _calendarState.ShowDayTabAsync(cell.Date);
|
||||||
await Shell.Current.GoToAsync($"{nameof(QuickEntryPage)}?date={date}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+109
-12
@@ -42,37 +42,85 @@
|
|||||||
|
|
||||||
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" ColumnSpacing="10" RowSpacing="10">
|
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" ColumnSpacing="10" RowSpacing="10">
|
||||||
|
|
||||||
<Border Grid.Row="0" Grid.Column="0" BackgroundColor="#4CAF50" StrokeThickness="0" StrokeShape="RoundRectangle 12" Padding="12">
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
BackgroundColor="{DynamicResource StateGreen}"
|
||||||
|
StrokeThickness="0"
|
||||||
|
StrokeShape="RoundRectangle 12"
|
||||||
|
Padding="12">
|
||||||
|
<Border.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Command="{Binding SaveGreenQuickCommand}" />
|
||||||
|
</Border.GestureRecognizers>
|
||||||
|
|
||||||
<VerticalStackLayout>
|
<VerticalStackLayout>
|
||||||
<Label Text="Grün" TextColor="White" FontAttributes="Bold" />
|
<Label Text="{Binding GreenStatusText}" TextColor="White" FontAttributes="Bold" />
|
||||||
<Label Text="{Binding GreenCount}" TextColor="White" FontSize="22" />
|
<Label Text="{Binding GreenCount}" TextColor="White" FontSize="22" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border Grid.Row="0" Grid.Column="1" BackgroundColor="#FBC02D" StrokeThickness="0" StrokeShape="RoundRectangle 12" Padding="12">
|
<Border
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
BackgroundColor="{DynamicResource StateYellow}"
|
||||||
|
StrokeThickness="0"
|
||||||
|
StrokeShape="RoundRectangle 12"
|
||||||
|
Padding="12">
|
||||||
|
<Border.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Command="{Binding SaveYellowQuickCommand}" />
|
||||||
|
</Border.GestureRecognizers>
|
||||||
|
|
||||||
<VerticalStackLayout>
|
<VerticalStackLayout>
|
||||||
<Label Text="Gelb" FontAttributes="Bold" />
|
<Label Text="{Binding YellowStatusText}" TextColor="White" FontAttributes="Bold" />
|
||||||
<Label Text="{Binding YellowCount}" FontSize="22" />
|
<Label Text="{Binding YellowCount}" TextColor="White" FontSize="22" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border Grid.Row="1" Grid.Column="0" BackgroundColor="#E53935" StrokeThickness="0" StrokeShape="RoundRectangle 12" Padding="12">
|
<Border
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
BackgroundColor="{DynamicResource StateRed}"
|
||||||
|
StrokeThickness="0"
|
||||||
|
StrokeShape="RoundRectangle 12"
|
||||||
|
Padding="12">
|
||||||
|
<Border.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Command="{Binding SaveRedQuickCommand}" />
|
||||||
|
</Border.GestureRecognizers>
|
||||||
|
|
||||||
<VerticalStackLayout>
|
<VerticalStackLayout>
|
||||||
<Label Text="Rot" TextColor="White" FontAttributes="Bold" />
|
<Label Text="{Binding RedStatusText}" TextColor="White" FontAttributes="Bold" />
|
||||||
<Label Text="{Binding RedCount}" TextColor="White" FontSize="22" />
|
<Label Text="{Binding RedCount}" TextColor="White" FontSize="22" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Border Grid.Row="1" Grid.Column="1" BackgroundColor="#757575" StrokeThickness="0" StrokeShape="RoundRectangle 12" Padding="12">
|
<Border
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
BackgroundColor="{DynamicResource StateGray}"
|
||||||
|
StrokeThickness="0"
|
||||||
|
StrokeShape="RoundRectangle 12"
|
||||||
|
Padding="12">
|
||||||
|
<Border.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Command="{Binding SaveGrayQuickCommand}" />
|
||||||
|
</Border.GestureRecognizers>
|
||||||
|
|
||||||
<VerticalStackLayout>
|
<VerticalStackLayout>
|
||||||
<Label Text="Grau" TextColor="White" FontAttributes="Bold" />
|
<Label Text="{Binding GrayStatusText}" TextColor="White" FontAttributes="Bold" />
|
||||||
<Label Text="{Binding GrayCount}" TextColor="White" FontSize="22" />
|
<Label Text="{Binding GrayCount}" TextColor="White" FontSize="22" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CollectionView ItemsSource="{Binding Entries}" SelectionMode="None">
|
<Label
|
||||||
|
Text="Einträge"
|
||||||
|
FontSize="20"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
TextColor="{DynamicResource TextPrimary}" />
|
||||||
|
|
||||||
|
<CollectionView
|
||||||
|
ItemsSource="{Binding Entries}"
|
||||||
|
SelectionMode="None">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Border
|
<Border
|
||||||
@@ -82,6 +130,8 @@
|
|||||||
StrokeThickness="0"
|
StrokeThickness="0"
|
||||||
StrokeShape="RoundRectangle 12">
|
StrokeShape="RoundRectangle 12">
|
||||||
|
|
||||||
|
<VerticalStackLayout Spacing="8">
|
||||||
|
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="12">
|
<Grid ColumnDefinitions="Auto,*,Auto" ColumnSpacing="12">
|
||||||
<Label
|
<Label
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
@@ -91,8 +141,20 @@
|
|||||||
VerticalOptions="Center" />
|
VerticalOptions="Center" />
|
||||||
|
|
||||||
<VerticalStackLayout Grid.Column="1" Spacing="2">
|
<VerticalStackLayout Grid.Column="1" Spacing="2">
|
||||||
<Label Text="{Binding StateText}" TextColor="{Binding TextColor}" FontAttributes="Bold" />
|
<Label
|
||||||
<Label Text="{Binding SourceText}" TextColor="{Binding TextColor}" FontSize="12" />
|
Text="{Binding StateText}"
|
||||||
|
TextColor="{Binding TextColor}"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Text="{Binding FoldoutText}"
|
||||||
|
Command="{Binding ToggleExpandedCommand}"
|
||||||
|
IsVisible="{Binding HasDetails}"
|
||||||
|
Padding="0"
|
||||||
|
FontSize="12"
|
||||||
|
BackgroundColor="Transparent"
|
||||||
|
TextColor="{Binding TextColor}"
|
||||||
|
HorizontalOptions="Start" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -103,6 +165,41 @@
|
|||||||
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.DeleteEntryCommand}"
|
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.DeleteEntryCommand}"
|
||||||
CommandParameter="{Binding .}" />
|
CommandParameter="{Binding .}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Border
|
||||||
|
IsVisible="{Binding IsExpanded}"
|
||||||
|
Padding="10"
|
||||||
|
BackgroundColor="{DynamicResource PanelBackground2}"
|
||||||
|
Stroke="{DynamicResource PanelBorder}"
|
||||||
|
StrokeThickness="1"
|
||||||
|
StrokeShape="RoundRectangle 10">
|
||||||
|
|
||||||
|
<VerticalStackLayout Spacing="6">
|
||||||
|
|
||||||
|
<VerticalStackLayout IsVisible="{Binding HasActivity}" Spacing="2">
|
||||||
|
<Label
|
||||||
|
Text="Tätigkeit"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
TextColor="{DynamicResource TextPrimary}" />
|
||||||
|
<Label
|
||||||
|
Text="{Binding ActivityText}"
|
||||||
|
TextColor="{DynamicResource TextMuted}" />
|
||||||
|
</VerticalStackLayout>
|
||||||
|
|
||||||
|
<VerticalStackLayout IsVisible="{Binding HasSymptoms}" Spacing="2">
|
||||||
|
<Label
|
||||||
|
Text="Symptome"
|
||||||
|
FontAttributes="Bold"
|
||||||
|
TextColor="{DynamicResource TextPrimary}" />
|
||||||
|
<Label
|
||||||
|
Text="{Binding SymptomsText}"
|
||||||
|
TextColor="{DynamicResource TextMuted}" />
|
||||||
|
</VerticalStackLayout>
|
||||||
|
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
</CollectionView.ItemTemplate>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
|
|||||||
+8
-79
@@ -1,45 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage x:Class="cfs_tracker.Views.MonthPage"
|
||||||
x:Class="cfs_tracker.Views.MonthPage"
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Name="ThisPage"
|
x:Name="ThisPage"
|
||||||
Title="Monat">
|
Title="Monat">
|
||||||
|
<ScrollView><VerticalStackLayout Padding="16" Spacing="14">
|
||||||
<ScrollView>
|
|
||||||
<VerticalStackLayout Padding="16" Spacing="14">
|
|
||||||
|
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
||||||
<Button
|
<Button Grid.Column="0" Text="◀" WidthRequest="52" HeightRequest="44" Command="{Binding PreviousMonthCommand}" />
|
||||||
Grid.Column="0"
|
<Label Grid.Column="1" Text="{Binding SelectedMonthText}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" />
|
||||||
Text="◀"
|
<Button Grid.Column="2" Text="Heute" Margin="8,0,0,0" Command="{Binding TodayCommand}" />
|
||||||
WidthRequest="52"
|
<Button Grid.Column="3" Text="▶" WidthRequest="52" HeightRequest="44" Margin="8,0,0,0" Command="{Binding NextMonthCommand}" />
|
||||||
HeightRequest="44"
|
|
||||||
Command="{Binding PreviousMonthCommand}" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Grid.Column="1"
|
|
||||||
Text="{Binding SelectedMonthText}"
|
|
||||||
HorizontalTextAlignment="Center"
|
|
||||||
VerticalTextAlignment="Center"
|
|
||||||
FontSize="24"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="2"
|
|
||||||
Text="Heute"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding TodayCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="3"
|
|
||||||
Text="▶"
|
|
||||||
WidthRequest="52"
|
|
||||||
HeightRequest="44"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding NextMonthCommand}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*,*,*,*,*,*,*">
|
<Grid ColumnDefinitions="*,*,*,*,*,*,*">
|
||||||
<Label Grid.Column="0" Text="Mo" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
<Label Grid.Column="0" Text="Mo" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
||||||
<Label Grid.Column="1" Text="Di" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
<Label Grid.Column="1" Text="Di" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
||||||
@@ -49,48 +20,6 @@
|
|||||||
<Label Grid.Column="5" Text="Sa" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
<Label Grid.Column="5" Text="Sa" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
||||||
<Label Grid.Column="6" Text="So" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
<Label Grid.Column="6" Text="So" HorizontalTextAlignment="Center" FontAttributes="Bold" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<CollectionView ItemsSource="{Binding Days}" SelectionMode="None"><CollectionView.ItemsLayout><GridItemsLayout Orientation="Vertical" Span="7" /></CollectionView.ItemsLayout><CollectionView.ItemTemplate><DataTemplate><Grid Padding="3"><Border HeightRequest="74" BackgroundColor="{Binding BackgroundColor}" Stroke="{Binding BorderColor}"><Grid Padding="6"><Grid.GestureRecognizers><TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}" CommandParameter="{Binding .}" /></Grid.GestureRecognizers><VerticalStackLayout IsVisible="{Binding IsRealDay}" Spacing="4"><Label Text="{Binding DayNumberText}" TextColor="{Binding TextColor}" FontAttributes="Bold" FontSize="16" /><Label Text="{Binding CountText}" TextColor="{Binding TextColor}" FontSize="12" /></VerticalStackLayout></Grid></Border></Grid></DataTemplate></CollectionView.ItemTemplate></CollectionView>
|
||||||
<CollectionView ItemsSource="{Binding Days}" SelectionMode="None">
|
</VerticalStackLayout></ScrollView>
|
||||||
<CollectionView.ItemsLayout>
|
|
||||||
<GridItemsLayout Orientation="Vertical" Span="7" />
|
|
||||||
</CollectionView.ItemsLayout>
|
|
||||||
|
|
||||||
<CollectionView.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Grid Padding="3">
|
|
||||||
<Border
|
|
||||||
HeightRequest="74"
|
|
||||||
BackgroundColor="{Binding BackgroundColor}"
|
|
||||||
Stroke="{Binding BorderColor}"
|
|
||||||
StrokeThickness="1"
|
|
||||||
StrokeShape="RoundRectangle 10">
|
|
||||||
|
|
||||||
<Grid Padding="6">
|
|
||||||
<Grid.GestureRecognizers>
|
|
||||||
<TapGestureRecognizer
|
|
||||||
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
</Grid.GestureRecognizers>
|
|
||||||
|
|
||||||
<VerticalStackLayout IsVisible="{Binding IsRealDay}" Spacing="4">
|
|
||||||
<Label
|
|
||||||
Text="{Binding DayNumberText}"
|
|
||||||
TextColor="{Binding TextColor}"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
FontSize="16" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="{Binding CountText}"
|
|
||||||
TextColor="{Binding TextColor}"
|
|
||||||
FontSize="12" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
</DataTemplate>
|
|
||||||
</CollectionView.ItemTemplate>
|
|
||||||
</CollectionView>
|
|
||||||
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
+4
-16
@@ -1,20 +1,8 @@
|
|||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
public partial class MonthPage : ContentPage
|
public partial class MonthPage : ContentPage
|
||||||
{
|
{
|
||||||
private readonly MonthViewModel _viewModel;
|
private readonly MonthViewModel _vm;
|
||||||
|
public MonthPage(MonthViewModel vm){ InitializeComponent(); BindingContext = _vm = vm; }
|
||||||
public MonthPage(MonthViewModel viewModel)
|
protected override async void OnAppearing(){ base.OnAppearing(); await _vm.RefreshAsync(); }
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = _viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
|
||||||
{
|
|
||||||
base.OnAppearing();
|
|
||||||
await _viewModel.RefreshAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage
|
|
||||||
x:Class="cfs_tracker.Views.OptionsPage"
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
Title="Optionen">
|
|
||||||
|
|
||||||
<ScrollView>
|
|
||||||
<VerticalStackLayout Padding="16" Spacing="16">
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Optionen"
|
|
||||||
FontSize="26"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Border
|
|
||||||
Padding="14"
|
|
||||||
BackgroundColor="#FFF4F4"
|
|
||||||
Stroke="#D88"
|
|
||||||
StrokeThickness="1"
|
|
||||||
StrokeShape="RoundRectangle 12">
|
|
||||||
|
|
||||||
<VerticalStackLayout Spacing="12">
|
|
||||||
<Label
|
|
||||||
Text="Datenbank löschen"
|
|
||||||
FontSize="20"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Dadurch werden alle gespeicherten Einträge unwiderruflich entfernt."
|
|
||||||
FontSize="14" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="Zur Bestätigung bitte das Wort 'löschen' eingeben."
|
|
||||||
FontSize="14"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Entry
|
|
||||||
Placeholder="löschen"
|
|
||||||
Text="{Binding DeleteConfirmationText}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Text="Alle Daten löschen"
|
|
||||||
BackgroundColor="#B00020"
|
|
||||||
TextColor="White"
|
|
||||||
Command="{Binding DeleteAllDataCommand}" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="{Binding StatusText}"
|
|
||||||
FontSize="13" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</ContentPage>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using cfs_tracker.ViewModels;
|
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
|
||||||
|
|
||||||
public partial class OptionsPage : ContentPage
|
|
||||||
{
|
|
||||||
public OptionsPage(OptionsViewModel viewModel)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = viewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage
|
||||||
|
x:Class="cfs_tracker.Views.OptionsPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:conv="clr-namespace:cfs_tracker.Converters"
|
||||||
|
Title="Optionen">
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<conv:HexToColorConverter x:Key="HexToColorConverter" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
|
<ScrollView>
|
||||||
|
<VerticalStackLayout Padding="16" Spacing="16">
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Optionen"
|
||||||
|
FontSize="26"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Aussehen"
|
||||||
|
FontSize="22"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Farben"
|
||||||
|
FontSize="18"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<CollectionView ItemsSource="{Binding AppearanceColors}" SelectionMode="None">
|
||||||
|
<CollectionView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border Padding="12" Margin="0,0,0,8">
|
||||||
|
<VerticalStackLayout Spacing="8">
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="{Binding Title}"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Grid ColumnDefinitions="*,60" ColumnSpacing="10">
|
||||||
|
<Entry
|
||||||
|
Grid.Column="0"
|
||||||
|
Text="{Binding Value}"
|
||||||
|
Placeholder="#RRGGBB" />
|
||||||
|
|
||||||
|
<Border
|
||||||
|
Grid.Column="1"
|
||||||
|
HeightRequest="42"
|
||||||
|
WidthRequest="42"
|
||||||
|
Padding="0"
|
||||||
|
Stroke="{DynamicResource PanelBorder}"
|
||||||
|
StrokeThickness="1"
|
||||||
|
StrokeShape="RoundRectangle 8"
|
||||||
|
BackgroundColor="{Binding Value, Converter={StaticResource HexToColorConverter}}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</CollectionView.ItemTemplate>
|
||||||
|
</CollectionView>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Status-Texte"
|
||||||
|
FontSize="18"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<CollectionView ItemsSource="{Binding StatusTexts}" SelectionMode="None">
|
||||||
|
<CollectionView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border Padding="12" Margin="0,0,0,8">
|
||||||
|
<VerticalStackLayout Spacing="6">
|
||||||
|
<Label
|
||||||
|
Text="{Binding Title}"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
<Entry
|
||||||
|
Text="{Binding Value}" />
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</CollectionView.ItemTemplate>
|
||||||
|
</CollectionView>
|
||||||
|
|
||||||
|
<HorizontalStackLayout Spacing="10">
|
||||||
|
<Button
|
||||||
|
Text="Aussehen speichern"
|
||||||
|
Command="{Binding SaveAppearanceCommand}" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Text="Standard wiederherstellen"
|
||||||
|
Command="{Binding ResetAppearanceCommand}" />
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Datenbank"
|
||||||
|
FontSize="22"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Border Padding="14">
|
||||||
|
<VerticalStackLayout Spacing="12">
|
||||||
|
<Label
|
||||||
|
Text="Alle Einträge löschen"
|
||||||
|
FontSize="18"
|
||||||
|
FontAttributes="Bold" />
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="Zur Bestätigung das Wort 'löschen' eingeben." />
|
||||||
|
|
||||||
|
<Entry
|
||||||
|
Placeholder="löschen"
|
||||||
|
Text="{Binding DeleteConfirmationText}" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Text="Alle Daten löschen"
|
||||||
|
BackgroundColor="#A85C5C"
|
||||||
|
Command="{Binding DeleteAllDataCommand}" />
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Text="{Binding StatusText}"
|
||||||
|
FontSize="13" />
|
||||||
|
|
||||||
|
</VerticalStackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</ContentPage>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
|
public partial class OptionsPage : ContentPage
|
||||||
|
{
|
||||||
|
private readonly OptionsViewModel _viewModel;
|
||||||
|
|
||||||
|
public OptionsPage(OptionsViewModel viewModel)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BindingContext = _viewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
await _viewModel.LoadAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-88
@@ -1,95 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage x:Class="cfs_tracker.Views.QuickEntryPage"
|
||||||
x:Class="cfs_tracker.Views.QuickEntryPage"
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
Title="Eintrag">
|
Title="Eintrag">
|
||||||
|
<ScrollView><VerticalStackLayout Padding="20" Spacing="18">
|
||||||
<ScrollView>
|
<Label Text="Wie geht es dir?" FontSize="28" FontAttributes="Bold" HorizontalTextAlignment="Center" />
|
||||||
<VerticalStackLayout Padding="20" Spacing="18">
|
<Label Text="{Binding SelectedDateText}" FontSize="16" HorizontalTextAlignment="Center" />
|
||||||
|
<VerticalStackLayout IsVisible="{Binding IsPastDate}" Spacing="8">
|
||||||
<Label
|
<Label Text="Tageszeit" FontAttributes="Bold" HorizontalTextAlignment="Center" />
|
||||||
Text="Wie geht es dir?"
|
<Picker Title="Tageszeit" ItemsSource="{Binding AvailableParts}" SelectedItem="{Binding SelectedPartText}" />
|
||||||
FontSize="28"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HorizontalTextAlignment="Center" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="{Binding SelectedDateText}"
|
|
||||||
FontSize="16"
|
|
||||||
HorizontalTextAlignment="Center" />
|
|
||||||
|
|
||||||
<VerticalStackLayout
|
|
||||||
IsVisible="{Binding IsPastDate}"
|
|
||||||
Spacing="8">
|
|
||||||
<Label
|
|
||||||
Text="Tageszeit"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HorizontalTextAlignment="Center" />
|
|
||||||
|
|
||||||
<Picker
|
|
||||||
Title="Tageszeit"
|
|
||||||
ItemsSource="{Binding AvailableParts}"
|
|
||||||
SelectedItem="{Binding SelectedPartText}" />
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
<Border Padding="12"><VerticalStackLayout Spacing="8"><Label Text="Tätigkeit" FontAttributes="Bold" /><Picker Title="Tätigkeit" ItemsSource="{Binding Activities}" ItemDisplayBinding="{Binding Name}" SelectedItem="{Binding SelectedActivity}" /></VerticalStackLayout></Border>
|
||||||
<Label
|
<Border Padding="12"><VerticalStackLayout Spacing="8"><Label Text="Symptome" FontAttributes="Bold" /><CollectionView ItemsSource="{Binding Symptoms}" SelectionMode="None"><CollectionView.ItemTemplate><DataTemplate><Grid ColumnDefinitions="Auto,*" Padding="0,4"><CheckBox IsChecked="{Binding IsSelected}" /><Label Grid.Column="1" Text="{Binding Name}" VerticalOptions="Center" /></Grid></DataTemplate></CollectionView.ItemTemplate></CollectionView></VerticalStackLayout></Border>
|
||||||
IsVisible="{Binding IsFutureDate}"
|
<Label IsVisible="{Binding IsFutureDate}" Text="Für zukünftige Tage können keine Einträge gesetzt werden." TextColor="{StaticResource StateRed}" HorizontalTextAlignment="Center" />
|
||||||
Text="Für zukünftige Tage können keine Einträge gesetzt werden."
|
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" ColumnSpacing="12" RowSpacing="12">
|
||||||
TextColor="Red"
|
<Button Grid.Row="0" Grid.Column="0" Text="Grün Gut" FontSize="22" FontAttributes="Bold" HeightRequest="120" BackgroundColor="{StaticResource StateGreen}" TextColor="White" Command="{Binding SaveGreenCommand}" />
|
||||||
HorizontalTextAlignment="Center" />
|
<Button Grid.Row="0" Grid.Column="1" Text="Gelb So lala" FontSize="22" FontAttributes="Bold" HeightRequest="120" BackgroundColor="{StaticResource StateYellow}" TextColor="Black" Command="{Binding SaveYellowCommand}" />
|
||||||
|
<Button Grid.Row="1" Grid.Column="0" Text="Rot Schlecht" FontSize="22" FontAttributes="Bold" HeightRequest="120" BackgroundColor="{StaticResource StateRed}" TextColor="White" Command="{Binding SaveRedCommand}" />
|
||||||
<Grid
|
<Button Grid.Row="1" Grid.Column="1" Text="Grau Totalausfall" FontSize="22" FontAttributes="Bold" HeightRequest="120" BackgroundColor="{StaticResource StateGray}" TextColor="White" Command="{Binding SaveGrayCommand}" />
|
||||||
ColumnDefinitions="*,*"
|
|
||||||
RowDefinitions="Auto,Auto"
|
|
||||||
ColumnSpacing="12"
|
|
||||||
RowSpacing="12">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.Column="0"
|
|
||||||
Text="Grün Gut"
|
|
||||||
FontSize="22"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HeightRequest="120"
|
|
||||||
BackgroundColor="#4CAF50"
|
|
||||||
TextColor="White"
|
|
||||||
Command="{Binding SaveGreenCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Row="0"
|
|
||||||
Grid.Column="1"
|
|
||||||
Text="Gelb So lala"
|
|
||||||
FontSize="22"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HeightRequest="120"
|
|
||||||
BackgroundColor="#FBC02D"
|
|
||||||
TextColor="Black"
|
|
||||||
Command="{Binding SaveYellowCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
|
||||||
Text="Rot Schlecht"
|
|
||||||
FontSize="22"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HeightRequest="120"
|
|
||||||
BackgroundColor="#E53935"
|
|
||||||
TextColor="White"
|
|
||||||
Command="{Binding SaveRedCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="1"
|
|
||||||
Text="Grau Totalausfall"
|
|
||||||
FontSize="22"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HeightRequest="120"
|
|
||||||
BackgroundColor="#757575"
|
|
||||||
TextColor="White"
|
|
||||||
Command="{Binding SaveGrayCommand}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</VerticalStackLayout></ScrollView>
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
@@ -1,21 +1,10 @@
|
|||||||
using Microsoft.Maui.Controls;
|
using Microsoft.Maui.Controls;
|
||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
public partial class QuickEntryPage : ContentPage, IQueryAttributable
|
public partial class QuickEntryPage : ContentPage, IQueryAttributable
|
||||||
{
|
{
|
||||||
private readonly QuickEntryViewModel _viewModel;
|
private readonly QuickEntryViewModel _vm;
|
||||||
|
public QuickEntryPage(QuickEntryViewModel vm){ InitializeComponent(); BindingContext = _vm = vm; }
|
||||||
public QuickEntryPage(QuickEntryViewModel viewModel)
|
protected override async void OnAppearing(){ base.OnAppearing(); await _vm.LoadLookupsAsync(); }
|
||||||
{
|
public void ApplyQueryAttributes(IDictionary<string, object> query){ query.TryGetValue("date", out var value); _vm.SetDateFromQuery(value?.ToString()); }
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = _viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplyQueryAttributes(IDictionary<string, object> query)
|
|
||||||
{
|
|
||||||
query.TryGetValue("date", out var value);
|
|
||||||
_viewModel.SetDateFromQuery(value?.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+13
-89
@@ -1,107 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage x:Class="cfs_tracker.Views.WeekPage"
|
||||||
x:Class="cfs_tracker.Views.WeekPage"
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Name="ThisPage"
|
x:Name="ThisPage"
|
||||||
Title="Woche">
|
Title="Woche">
|
||||||
|
<ScrollView><VerticalStackLayout Padding="16" Spacing="14">
|
||||||
<ScrollView>
|
|
||||||
<VerticalStackLayout Padding="16" Spacing="14">
|
|
||||||
|
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto,Auto">
|
||||||
<Button
|
<Button Grid.Column="0" Text="◀" WidthRequest="52" HeightRequest="44" Command="{Binding PreviousWeekCommand}" />
|
||||||
Grid.Column="0"
|
<Label Grid.Column="1" Text="{Binding WeekText}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="22" FontAttributes="Bold" />
|
||||||
Text="◀"
|
<Button Grid.Column="2" Text="Heute" Margin="8,0,0,0" Command="{Binding TodayCommand}" />
|
||||||
WidthRequest="52"
|
<Button Grid.Column="3" Text="▶" WidthRequest="52" HeightRequest="44" Margin="8,0,0,0" Command="{Binding NextWeekCommand}" />
|
||||||
HeightRequest="44"
|
|
||||||
Command="{Binding PreviousWeekCommand}" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Grid.Column="1"
|
|
||||||
Text="{Binding WeekText}"
|
|
||||||
HorizontalTextAlignment="Center"
|
|
||||||
VerticalTextAlignment="Center"
|
|
||||||
FontSize="22"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="2"
|
|
||||||
Text="Heute"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding TodayCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="3"
|
|
||||||
Text="▶"
|
|
||||||
WidthRequest="52"
|
|
||||||
HeightRequest="44"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding NextWeekCommand}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CollectionView ItemsSource="{Binding Days}" SelectionMode="None">
|
<CollectionView ItemsSource="{Binding Days}" SelectionMode="None">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate><DataTemplate>
|
||||||
<DataTemplate>
|
<Border Margin="0,0,0,10" Padding="12">
|
||||||
<Border
|
|
||||||
Margin="0,0,0,10"
|
|
||||||
Padding="12"
|
|
||||||
BackgroundColor="White"
|
|
||||||
Stroke="#D0D0D0"
|
|
||||||
StrokeThickness="1"
|
|
||||||
StrokeShape="RoundRectangle 12">
|
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,Auto" ColumnDefinitions="*" RowSpacing="10">
|
<Grid RowDefinitions="Auto,Auto" ColumnDefinitions="*" RowSpacing="10">
|
||||||
<VerticalStackLayout Grid.Row="0">
|
<VerticalStackLayout Grid.Row="0">
|
||||||
<Label Text="{Binding DayText}" FontAttributes="Bold" FontSize="18" />
|
<Label Text="{Binding DayText}" FontAttributes="Bold" FontSize="18" />
|
||||||
<Label Text="{Binding DateText}" FontSize="13" Opacity="0.7" />
|
<Label Text="{Binding DateText}" FontSize="13" TextColor="{StaticResource TextMuted}" />
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
<Grid Grid.Row="1" ColumnDefinitions="*,*" ColumnSpacing="10">
|
<Grid Grid.Row="1" ColumnDefinitions="*,*" ColumnSpacing="10">
|
||||||
<Border
|
<Border Grid.Column="0" BackgroundColor="{Binding MorningBackgroundColor}" Padding="10"><Border.GestureRecognizers><TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}" CommandParameter="{Binding .}" /></Border.GestureRecognizers><VerticalStackLayout><Label Text="Vormittag" FontAttributes="Bold" TextColor="{Binding MorningTextColor}" /><Label Text="{Binding MorningText}" FontSize="18" TextColor="{Binding MorningTextColor}" /><Label Text="{Binding MorningCountText}" FontSize="12" TextColor="{Binding MorningTextColor}" /></VerticalStackLayout></Border>
|
||||||
Grid.Column="0"
|
<Border Grid.Column="1" BackgroundColor="{Binding AfternoonBackgroundColor}" Padding="10"><Border.GestureRecognizers><TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}" CommandParameter="{Binding .}" /></Border.GestureRecognizers><VerticalStackLayout><Label Text="Nachmittag" FontAttributes="Bold" TextColor="{Binding AfternoonTextColor}" /><Label Text="{Binding AfternoonText}" FontSize="18" TextColor="{Binding AfternoonTextColor}" /><Label Text="{Binding AfternoonCountText}" FontSize="12" TextColor="{Binding AfternoonTextColor}" /></VerticalStackLayout></Border>
|
||||||
BackgroundColor="{Binding MorningBackgroundColor}"
|
|
||||||
StrokeThickness="0"
|
|
||||||
StrokeShape="RoundRectangle 10"
|
|
||||||
Padding="10">
|
|
||||||
<Border.GestureRecognizers>
|
|
||||||
<TapGestureRecognizer
|
|
||||||
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
</Border.GestureRecognizers>
|
|
||||||
|
|
||||||
<VerticalStackLayout>
|
|
||||||
<Label Text="Vormittag" FontAttributes="Bold" TextColor="{Binding MorningTextColor}" />
|
|
||||||
<Label Text="{Binding MorningText}" FontSize="18" TextColor="{Binding MorningTextColor}" />
|
|
||||||
<Label Text="{Binding MorningCountText}" FontSize="12" TextColor="{Binding MorningTextColor}" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<Border
|
|
||||||
Grid.Column="1"
|
|
||||||
BackgroundColor="{Binding AfternoonBackgroundColor}"
|
|
||||||
StrokeThickness="0"
|
|
||||||
StrokeShape="RoundRectangle 10"
|
|
||||||
Padding="10">
|
|
||||||
<Border.GestureRecognizers>
|
|
||||||
<TapGestureRecognizer
|
|
||||||
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
</Border.GestureRecognizers>
|
|
||||||
|
|
||||||
<VerticalStackLayout>
|
|
||||||
<Label Text="Nachmittag" FontAttributes="Bold" TextColor="{Binding AfternoonTextColor}" />
|
|
||||||
<Label Text="{Binding AfternoonText}" FontSize="18" TextColor="{Binding AfternoonTextColor}" />
|
|
||||||
<Label Text="{Binding AfternoonCountText}" FontSize="12" TextColor="{Binding AfternoonTextColor}" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate></CollectionView.ItemTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
|
||||||
</CollectionView>
|
</CollectionView>
|
||||||
|
</VerticalStackLayout></ScrollView>
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
+4
-16
@@ -1,20 +1,8 @@
|
|||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
public partial class WeekPage : ContentPage
|
public partial class WeekPage : ContentPage
|
||||||
{
|
{
|
||||||
private readonly WeekViewModel _viewModel;
|
private readonly WeekViewModel _vm;
|
||||||
|
public WeekPage(WeekViewModel vm){ InitializeComponent(); BindingContext = _vm = vm; }
|
||||||
public WeekPage(WeekViewModel viewModel)
|
protected override async void OnAppearing(){ base.OnAppearing(); await _vm.RefreshAsync(); }
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = _viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
|
||||||
{
|
|
||||||
base.OnAppearing();
|
|
||||||
await _viewModel.RefreshAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+6
-117
@@ -1,127 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage x:Class="cfs_tracker.Views.YearPage"
|
||||||
x:Class="cfs_tracker.Views.YearPage"
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Name="ThisPage"
|
x:Name="ThisPage"
|
||||||
Title="Jahr">
|
Title="Jahr">
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*" Padding="16">
|
<Grid RowDefinitions="Auto,*" Padding="16">
|
||||||
|
|
||||||
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto" Margin="0,0,0,12">
|
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto" Margin="0,0,0,12">
|
||||||
<Button
|
<Button Grid.Column="0" Text="◀" WidthRequest="52" HeightRequest="44" Command="{Binding PreviousYearCommand}" />
|
||||||
Grid.Column="0"
|
<Label Grid.Column="1" Text="{Binding SelectedYearText}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="24" FontAttributes="Bold" />
|
||||||
Text="◀"
|
<Button Grid.Column="2" Text="Heute" Margin="8,0,0,0" Command="{Binding TodayCommand}" />
|
||||||
WidthRequest="52"
|
<Button Grid.Column="3" Text="▶" WidthRequest="52" HeightRequest="44" Margin="8,0,0,0" Command="{Binding NextYearCommand}" />
|
||||||
HeightRequest="44"
|
|
||||||
Command="{Binding PreviousYearCommand}" />
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Grid.Column="1"
|
|
||||||
Text="{Binding SelectedYearText}"
|
|
||||||
HorizontalTextAlignment="Center"
|
|
||||||
VerticalTextAlignment="Center"
|
|
||||||
FontSize="24"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="2"
|
|
||||||
Text="Heute"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding TodayCommand}" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Grid.Column="3"
|
|
||||||
Text="▶"
|
|
||||||
WidthRequest="52"
|
|
||||||
HeightRequest="44"
|
|
||||||
Margin="8,0,0,0"
|
|
||||||
Command="{Binding NextYearCommand}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<ScrollView Grid.Row="1"><VerticalStackLayout Spacing="12" BindableLayout.ItemsSource="{Binding Months}"><BindableLayout.ItemTemplate><DataTemplate><Border Padding="12"><VerticalStackLayout Spacing="10"><Label Text="{Binding MonthText}" FontSize="20" FontAttributes="Bold" /><HorizontalStackLayout Spacing="4"><Label Text="Mo" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="Di" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="Mi" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="Do" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="Fr" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="Sa" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /><Label Text="So" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" /></HorizontalStackLayout><FlexLayout Direction="Row" Wrap="Wrap" JustifyContent="Start" AlignItems="Start" BindableLayout.ItemsSource="{Binding Days}"><BindableLayout.ItemTemplate><DataTemplate><Border WidthRequest="44" HeightRequest="44" Margin="2" BackgroundColor="{Binding BackgroundColor}" Stroke="{Binding BorderColor}"><Grid Padding="4"><Grid.GestureRecognizers><TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}" CommandParameter="{Binding .}" /></Grid.GestureRecognizers><VerticalStackLayout IsVisible="{Binding IsRealDay}" Spacing="1"><Label Text="{Binding DayNumberText}" TextColor="{Binding TextColor}" FontSize="11" FontAttributes="Bold" HorizontalTextAlignment="Center" /><Label Text="{Binding CountText}" TextColor="{Binding TextColor}" FontSize="9" HorizontalTextAlignment="Center" /></VerticalStackLayout></Grid></Border></DataTemplate></BindableLayout.ItemTemplate></FlexLayout></VerticalStackLayout></Border></DataTemplate></BindableLayout.ItemTemplate></VerticalStackLayout></ScrollView>
|
||||||
<ScrollView Grid.Row="1">
|
|
||||||
<VerticalStackLayout
|
|
||||||
Spacing="12"
|
|
||||||
BindableLayout.ItemsSource="{Binding Months}">
|
|
||||||
|
|
||||||
<BindableLayout.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Border
|
|
||||||
Padding="12"
|
|
||||||
BackgroundColor="White"
|
|
||||||
Stroke="#D0D0D0"
|
|
||||||
StrokeThickness="1"
|
|
||||||
StrokeShape="RoundRectangle 12">
|
|
||||||
|
|
||||||
<VerticalStackLayout Spacing="10">
|
|
||||||
|
|
||||||
<Label
|
|
||||||
Text="{Binding MonthText}"
|
|
||||||
FontSize="20"
|
|
||||||
FontAttributes="Bold" />
|
|
||||||
|
|
||||||
<HorizontalStackLayout Spacing="4">
|
|
||||||
<Label Text="Mo" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="Di" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="Mi" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="Do" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="Fr" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="Sa" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
<Label Text="So" WidthRequest="44" HorizontalTextAlignment="Center" FontSize="12" />
|
|
||||||
</HorizontalStackLayout>
|
|
||||||
|
|
||||||
<FlexLayout
|
|
||||||
Direction="Row"
|
|
||||||
Wrap="Wrap"
|
|
||||||
JustifyContent="Start"
|
|
||||||
AlignItems="Start"
|
|
||||||
BindableLayout.ItemsSource="{Binding Days}">
|
|
||||||
|
|
||||||
<BindableLayout.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<Border
|
|
||||||
WidthRequest="44"
|
|
||||||
HeightRequest="44"
|
|
||||||
Margin="2"
|
|
||||||
BackgroundColor="{Binding BackgroundColor}"
|
|
||||||
Stroke="{Binding BorderColor}"
|
|
||||||
StrokeThickness="1"
|
|
||||||
StrokeShape="RoundRectangle 8">
|
|
||||||
|
|
||||||
<Grid Padding="4">
|
|
||||||
<Grid.GestureRecognizers>
|
|
||||||
<TapGestureRecognizer
|
|
||||||
Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.OpenDayCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
</Grid.GestureRecognizers>
|
|
||||||
|
|
||||||
<VerticalStackLayout
|
|
||||||
IsVisible="{Binding IsRealDay}"
|
|
||||||
Spacing="1">
|
|
||||||
<Label
|
|
||||||
Text="{Binding DayNumberText}"
|
|
||||||
TextColor="{Binding TextColor}"
|
|
||||||
FontSize="11"
|
|
||||||
FontAttributes="Bold"
|
|
||||||
HorizontalTextAlignment="Center" />
|
|
||||||
<Label
|
|
||||||
Text="{Binding CountText}"
|
|
||||||
TextColor="{Binding TextColor}"
|
|
||||||
FontSize="9"
|
|
||||||
HorizontalTextAlignment="Center" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</BindableLayout.ItemTemplate>
|
|
||||||
</FlexLayout>
|
|
||||||
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</BindableLayout.ItemTemplate>
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
+4
-16
@@ -1,20 +1,8 @@
|
|||||||
using cfs_tracker.ViewModels;
|
using cfs_tracker.ViewModels;
|
||||||
|
|
||||||
namespace cfs_tracker.Views;
|
namespace cfs_tracker.Views;
|
||||||
|
|
||||||
public partial class YearPage : ContentPage
|
public partial class YearPage : ContentPage
|
||||||
{
|
{
|
||||||
private readonly YearViewModel _viewModel;
|
private readonly YearViewModel _vm;
|
||||||
|
public YearPage(YearViewModel vm){ InitializeComponent(); BindingContext = _vm = vm; }
|
||||||
public YearPage(YearViewModel viewModel)
|
protected override async void OnAppearing(){ base.OnAppearing(); await _vm.RefreshAsync(); }
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = _viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async void OnAppearing()
|
|
||||||
{
|
|
||||||
base.OnAppearing();
|
|
||||||
await _viewModel.RefreshAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+2
-39
@@ -1,73 +1,36 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net10.0-android;net10.0-windows10.0.19041.0</TargetFrameworks>
|
<TargetFrameworks>net10.0-android;net10.0-windows10.0.19041.0</TargetFrameworks>
|
||||||
|
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>cfs_tracker</RootNamespace>
|
<RootNamespace>cfs_tracker</RootNamespace>
|
||||||
|
|
||||||
<UseMaui>true</UseMaui>
|
<UseMaui>true</UseMaui>
|
||||||
<SingleProject>true</SingleProject>
|
<SingleProject>true</SingleProject>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<MauiXamlInflator>SourceGen</MauiXamlInflator>
|
|
||||||
|
|
||||||
<ApplicationTitle>cfs-tracker</ApplicationTitle>
|
<ApplicationTitle>cfs-tracker</ApplicationTitle>
|
||||||
<ApplicationId>com.companyname.cfstracker</ApplicationId>
|
<ApplicationId>com.companyname.cfstracker</ApplicationId>
|
||||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||||
<ApplicationVersion>1</ApplicationVersion>
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
|
|
||||||
<WindowsPackageType>None</WindowsPackageType>
|
<WindowsPackageType>None</WindowsPackageType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
|
||||||
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
|
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
|
||||||
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
|
||||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
|
<MauiIcon Include="Resources\AppIcon\appicon.svg" Color="#0B1620" />
|
||||||
|
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#0B1620" BaseSize="128,128" />
|
||||||
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
|
|
||||||
|
|
||||||
<MauiImage Include="Resources\Images\*" />
|
<MauiImage Include="Resources\Images\*" />
|
||||||
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
|
|
||||||
|
|
||||||
<MauiFont Include="Resources\Fonts\*" />
|
<MauiFont Include="Resources\Fonts\*" />
|
||||||
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
|
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.1" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.1" />
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.50" />
|
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.50" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.5" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.5" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<MauiXaml Update="Views\DayPage.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\MonthPage.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\Options.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\QuickEntryPage.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\WeekPage.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\YearPage.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user