Skip to content

Commit

Permalink
Merge pull request #2591 from PrismLibrary/issue-2570
Browse files Browse the repository at this point in the history
Added CanShowDialog method to IPageDialogService
  • Loading branch information
brianlagunas authored Oct 15, 2021
2 parents ac99099 + 2138dbf commit 85e7b7b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Forms/Prism.Forms/Common/ApplicationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ApplicationProvider : IApplicationProvider
/// <inheritdoc/>
public Page MainPage
{
get { return Application.Current.MainPage; }
get { return Application.Current?.MainPage; }
set { Application.Current.MainPage = value; }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ namespace Prism.Services
/// </summary>
public interface IPageDialogService
{
/// <summary>
/// Determines if the dialog can be shown.
/// </summary>
/// <returns>True if you can show the dialog; False if the dialog cannot be shown</returns>
bool CanShowDialog();

/// <summary>
/// Presents an alert dialog to the application user with an accept and a cancel button.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,14 @@ public virtual Task<string> DisplayPromptAsync(string title, string message, str
var keyboard = _keyboardMapper.Map(keyboardType);
return _applicationProvider.MainPage.DisplayPromptAsync(title, message, accept, cancel, placeholder, maxLength, keyboard, initialValue);
}

/// <summary>
/// Determines if the dialog can be shown.
/// </summary>
/// <returns>True if you can show the dialog; False if the dialog cannot be shown</returns>
public bool CanShowDialog()
{
return _applicationProvider.MainPage != null;
}
}
}

0 comments on commit 85e7b7b

Please sign in to comment.