diff --git a/SpeedrunTracker/App.xaml.cs b/SpeedrunTracker/App.xaml.cs index 6e674a1..b317374 100644 --- a/SpeedrunTracker/App.xaml.cs +++ b/SpeedrunTracker/App.xaml.cs @@ -1,4 +1,5 @@ -namespace SpeedrunTracker; + +namespace SpeedrunTracker; public partial class App : Application { @@ -8,6 +9,10 @@ public App(ILocalSettingsService settingsService) { InitializeComponent(); UserAppTheme = settingsService.UserSettings.Theme; - MainPage = new AppShell(); + } + + protected override Window CreateWindow(IActivationState activationState) + { + return new Window(new AppShell()); } } diff --git a/SpeedrunTracker/Services/DialogService.cs b/SpeedrunTracker/Services/DialogService.cs index 6d3937f..9d40e59 100644 --- a/SpeedrunTracker/Services/DialogService.cs +++ b/SpeedrunTracker/Services/DialogService.cs @@ -1,14 +1,18 @@ -namespace SpeedrunTracker.Services; +using Microsoft.Maui.Controls.PlatformConfiguration; + +namespace SpeedrunTracker.Services; public class DialogService : IDialogService { public Task ShowAlertAsync(string title, string message, string cancel = "OK") { - return Application.Current.MainPage.DisplayAlert(title, message, cancel); + return GetMainPage()?.DisplayAlert(title, message, cancel); } public Task ShowConfirmationAsync(string title, string message, string accept = "Yes", string cancel = "No") { - return Application.Current.MainPage.DisplayAlert(title, message, accept, cancel); + return GetMainPage()?.DisplayAlert(title, message, accept, cancel); } + + private Page GetMainPage() => Application.Current.Windows[0].Page; }