Files
cfs-Tracker/App.xaml.cs
T
Djagor d85f2e0fb3 Farbpalette vorladen lassen
Bootstraper läd jetzt die farbeinstellung sofort und nicht nachträglich

cleanup and rework

PDF switch to HTML

export fix

Colorsystem

Farben für knöpfe hinzugefügt als anpassung

button color

button color primary and secondary change
2026-03-24 21:59:59 +01:00

131 lines
3.8 KiB
C#

using cfs_tracker.Services;
using System.Diagnostics;
namespace cfs_tracker;
public partial class App : Application
{
private readonly IServiceProvider _serviceProvider;
private readonly AppBootstrapService _bootstrapService;
private bool _startupTriggered;
public App(IServiceProvider serviceProvider, AppBootstrapService bootstrapService)
{
InitializeComponent();
_serviceProvider = serviceProvider;
_bootstrapService = bootstrapService;
UserAppTheme = AppTheme.Dark;
}
protected override Window CreateWindow(IActivationState? activationState)
{
var window = new Window(CreateLoadingPage());
if (!_startupTriggered)
{
_startupTriggered = true;
_ = InitializeAppAsync(window);
}
return window;
}
private async Task InitializeAppAsync(Window window)
{
try
{
await _bootstrapService.InitializeAsync();
var shell = _serviceProvider.GetRequiredService<AppShell>();
await MainThread.InvokeOnMainThreadAsync(() =>
{
window.Page = shell;
});
}
catch (Exception ex)
{
Debug.WriteLine($"App bootstrap failed: {ex}");
await MainThread.InvokeOnMainThreadAsync(() =>
{
window.Page = CreateErrorPage(ex);
});
}
}
private static Page CreateLoadingPage()
{
return new ContentPage
{
Title = "Laden",
BackgroundColor = Color.FromArgb("#0B1A2A"),
Content = new Grid
{
Padding = 24,
Children =
{
new VerticalStackLayout
{
Spacing = 16,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Children =
{
new ActivityIndicator
{
IsRunning = true,
WidthRequest = 48,
HeightRequest = 48,
Color = Color.FromArgb("#DCE7F3")
},
new Label
{
Text = "App wird geladen ...",
FontSize = 20,
HorizontalTextAlignment = TextAlignment.Center,
TextColor = Color.FromArgb("#DCE7F3")
}
}
}
}
}
};
}
private static Page CreateErrorPage(Exception ex)
{
return new ContentPage
{
Title = "Startfehler",
BackgroundColor = Color.FromArgb("#0B1A2A"),
Content = new ScrollView
{
Content = new VerticalStackLayout
{
Padding = 24,
Spacing = 16,
Children =
{
new Label
{
Text = "Fehler beim Starten der App",
FontSize = 24,
FontAttributes = FontAttributes.Bold,
TextColor = Color.FromArgb("#FFB4B4")
},
new Label
{
Text = ex.ToString(),
FontSize = 14,
TextColor = Color.FromArgb("#DCE7F3")
}
}
}
}
};
}
}