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
This commit is contained in:
+111
-14
@@ -1,34 +1,131 @@
|
||||
using cfs_tracker.Services;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace cfs_tracker;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly AppBootstrapService _bootstrapService;
|
||||
|
||||
public App(IServiceProvider serviceProvider)
|
||||
private bool _startupTriggered;
|
||||
|
||||
public App(IServiceProvider serviceProvider, AppBootstrapService bootstrapService)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_serviceProvider = serviceProvider;
|
||||
_bootstrapService = bootstrapService;
|
||||
|
||||
UserAppTheme = AppTheme.Dark;
|
||||
}
|
||||
|
||||
protected override Window CreateWindow(IActivationState? activationState)
|
||||
{
|
||||
var shell = _serviceProvider.GetRequiredService<AppShell>();
|
||||
var appearanceService = _serviceProvider.GetRequiredService<AppearanceService>();
|
||||
var window = new Window(CreateLoadingPage());
|
||||
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
if (!_startupTriggered)
|
||||
{
|
||||
try
|
||||
{
|
||||
await appearanceService.InitializeAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex);
|
||||
}
|
||||
});
|
||||
_startupTriggered = true;
|
||||
_ = InitializeAppAsync(window);
|
||||
}
|
||||
|
||||
return new Window(shell);
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user