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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user