feat(ui): constrain decimal input and add stacked timed toasts with uniform actions

This commit is contained in:
2026-11-02 19:19:07 +01:00
parent 22e509d982
commit 86a73b862a
24 changed files with 315 additions and 103 deletions
@@ -8,7 +8,7 @@ namespace Duempelkas.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString, string? settingsDirectory = null)
{
services.AddSingleton(new DatabaseLocation(connectionString));
// The factory also registers FinanceDbContext as scoped. Registering
@@ -23,8 +23,9 @@ public static class DependencyInjection
services.AddSingleton<IFileDialogService, FileDialogService>();
services.AddScoped<IFileSaveService, FileSaveService>();
services.AddSingleton<IBackupService, BackupService>();
services.AddSingleton<ISettingsService, SettingsService>();
services.AddSingleton<ISettingsService>(new SettingsService(settingsDirectory));
services.AddSingleton<ReportingPeriod>();
services.AddSingleton<ToastService>();
return services;
}
@@ -5,9 +5,10 @@ namespace Duempelkas.Infrastructure.Services;
public class SettingsService : ISettingsService
{
private static readonly string SettingsPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Duempelkas", "settings.json");
private readonly string SettingsPath;
public SettingsService(string? directory = null) => SettingsPath = Path.Combine(directory ?? Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Duempelkas"), "settings.json");
private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true };
@@ -24,7 +25,7 @@ public class SettingsService : ISettingsService
await SaveAsync(settings);
}
private static async Task<AppSettings> LoadAsync()
private async Task<AppSettings> LoadAsync()
{
if (!File.Exists(SettingsPath))
return new AppSettings();
@@ -40,7 +41,7 @@ public class SettingsService : ISettingsService
}
}
private static async Task SaveAsync(AppSettings settings)
private async Task SaveAsync(AppSettings settings)
{
var dir = Path.GetDirectoryName(SettingsPath)!;
Directory.CreateDirectory(dir);