|
2 | 2 | using System.Globalization; |
3 | 3 | using CommunityToolkit.Maui.Converters; |
4 | 4 | using CommunityToolkit.Maui.Core; |
| 5 | +using CommunityToolkit.Maui.Extensions; |
5 | 6 | using Microsoft.Maui.Controls.PlatformConfiguration; |
6 | 7 | using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific; |
7 | 8 | using Microsoft.Maui.Controls.Shapes; |
@@ -43,11 +44,6 @@ public PopupPage(Popup popup, IPopupOptions popupOptions) |
43 | 44 | // Only set the content if the parent constructor hasn't set the content already; don't override content if it already exists |
44 | 45 | base.Content ??= new PopupPageLayout(popup, popupOptions); |
45 | 46 |
|
46 | | - if (Shell.Current is Shell shell) |
47 | | - { |
48 | | - Shell.SetPresentationMode(shell, PresentationMode.ModalNotAnimated); |
49 | | - } |
50 | | - |
51 | 47 | tapOutsideOfPopupCommand = new Command(async () => |
52 | 48 | { |
53 | 49 | popupOptions.OnTappingOutsideOfPopup?.Invoke(); |
@@ -108,15 +104,16 @@ public async Task CloseAsync(PopupResult result, CancellationToken token = defau |
108 | 104 |
|
109 | 105 | popupClosedEventManager.HandleEvent(this, result, nameof(PopupClosed)); |
110 | 106 | } |
111 | | - |
112 | | - // Prevent the Android Back Button from dismissing the Popup if CanBeDismissedByTappingOutsideOfPopup is true |
| 107 | + |
113 | 108 | protected override bool OnBackButtonPressed() |
114 | 109 | { |
| 110 | + // Only close the Popup if PopupOptions.CanBeDismissedByTappingOutsideOfPopup is true |
115 | 111 | if (popupOptions.CanBeDismissedByTappingOutsideOfPopup) |
116 | 112 | { |
117 | | - return base.OnBackButtonPressed(); |
| 113 | + CloseAsync(new PopupResult(true), CancellationToken.None).SafeFireAndForget(); |
118 | 114 | } |
119 | | - |
| 115 | + |
| 116 | + // Always return true to let the Android Operating System know that we are manually handling the Navigation request from the Android Back Button |
120 | 117 | return true; |
121 | 118 | } |
122 | 119 |
|
|
0 commit comments