Skip to content

Commit

Permalink
chore: update PageDialogService to use the new Current Window API
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Feb 29, 2024
1 parent 2cf0ffe commit d5e9967
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Maui/Prism.Maui/Services/PageDialogs/PageDialogService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Prism.AppModel;
using Prism.Common;
using Prism.AppModel;
using Prism.Navigation;
using FlowDirection = Prism.AppModel.FlowDirection;
using MauiFlow = Microsoft.Maui.FlowDirection;
Expand Down Expand Up @@ -181,5 +180,11 @@ public virtual Task<string> DisplayPromptAsync(string title, string message, str
return GetPage().DisplayPromptAsync(title, message, accept, cancel, placeholder, maxLength, keyboard, initialValue);
}

private Page GetPage() => _windowManager.Windows.OfType<PrismWindow>().First().CurrentPage;
private Page GetPage()
{
if (_windowManager.Current is not PrismWindow window)
throw new InvalidOperationException("There is no Prism Window currently displayed.");

return window.CurrentPage;
}
}

0 comments on commit d5e9967

Please sign in to comment.