-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Postpone popup show until platform is ready (#934)
* If platform is not enabled defer to OnNavigatedTo event * Sample to prove support for showing Popup in OnAppearing * Unsubscribe event handlers * Make use of ContinueWith to avoid awaiting * Update src/CommunityToolkit.Maui/Views/Popup/PopupExtensions.shared.cs Co-authored-by: Pedro Jesus <[email protected]> * improved the error handling on TCS Co-authored-by: Pedro Jesus <[email protected]>
- Loading branch information
Showing
7 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/ShowPopupInOnAppearingPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<pages:BasePage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="CommunityToolkit.Maui.Sample.Pages.Views.ShowPopupInOnAppearingPage" | ||
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages" | ||
xmlns:viewModels="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Views" | ||
Title="ShowPopupInOnAppearingPage" | ||
x:TypeArguments="viewModels:ShowPopupInOnAppearingPageViewModel" | ||
x:DataType="viewModels:ShowPopupInOnAppearingPageViewModel"> | ||
<VerticalStackLayout> | ||
<Label | ||
Text="Proves that we now support showing a popup before the platform is even ready." | ||
VerticalOptions="Center" | ||
HorizontalOptions="Center" /> | ||
</VerticalStackLayout> | ||
</pages:BasePage> |
26 changes: 26 additions & 0 deletions
26
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/ShowPopupInOnAppearingPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using CommunityToolkit.Maui.Sample.Models; | ||
using CommunityToolkit.Maui.Sample.ViewModels.Views; | ||
using CommunityToolkit.Maui.Views; | ||
|
||
namespace CommunityToolkit.Maui.Sample.Pages.Views; | ||
|
||
public partial class ShowPopupInOnAppearingPage : BasePage<ShowPopupInOnAppearingPageViewModel> | ||
{ | ||
readonly PopupSizeConstants popupSizeConstants; | ||
|
||
public ShowPopupInOnAppearingPage( | ||
PopupSizeConstants popupSizeConstants, | ||
ShowPopupInOnAppearingPageViewModel showPopupInOnAppearingPageViewModel) | ||
: base(showPopupInOnAppearingPageViewModel) | ||
{ | ||
InitializeComponent(); | ||
this.popupSizeConstants = popupSizeConstants; | ||
} | ||
|
||
protected override async void OnAppearing() | ||
{ | ||
|
||
// Proves that we now support showing a popup before the platform is even ready. | ||
var result = await this.ShowPopupAsync(new ReturnResultPopup(popupSizeConstants)); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...ommunityToolkit.Maui.Sample/ViewModels/Views/Popup/ShowPopupInOnAppearingPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace CommunityToolkit.Maui.Sample.ViewModels.Views; | ||
|
||
public class ShowPopupInOnAppearingPageViewModel : BaseViewModel | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters