-
Notifications
You must be signed in to change notification settings - Fork 440
Popup V2 #1581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Popup V2 #1581
Conversation
I have ended up rewriting at least 3 or 4 samples submitted as bugs using standard DI pattern because the code would crash in IOS 17.x. I wanted to verify the issues that were being reported. If I see a bunch of different reports I put extra effort in. Simplifying implementation would be great. I am all for that. |
There are currently a couple of breaking changes to the await popupService.ShowPopupAsync<MockPageViewModel>(CancellationToken.None); becomes await popupService.ShowPopupAsync<MockPageViewModel>(token: CancellationToken.None); await Assert.ThrowsAsync<TaskCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(viewModel => viewModel.HasLoaded = true, cts.Token)); becomes await Assert.ThrowsAsync<TaskCanceledException>(() => popupService.ShowPopupAsync<MockPageViewModel>(viewModel => viewModel.HasLoaded = true, token: cts.Token)); It also involves removing the ability to supply a |
@bijington FYI - we now have a few merge conflicts on this PR after merging a bunch of Popup PRs today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 11 changed files in this pull request and generated no suggestions.
Files not reviewed (6)
- samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/MultiplePopupPage.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/Views/Popups/PopupContentView.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/MauiProgram.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/MultiplePopupViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/PopupContentViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/Views/Popups/PopupContentView.xaml.cs: Evaluated as low risk
c1488d0
to
ebc39f2
Compare
aeb9020
to
94bee57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! I didn't run locally yet, just reviewed the code.
I saw that you removed the old popups reference, and I think we should mark them as obsolete and let them live for a while before removing everything. At least is what I remember from the last standup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 81 out of 96 changed files in this pull request and generated no comments.
Files not reviewed (15)
- samples/CommunityToolkit.Maui.Sample/App.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/MultiplePopupPage.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/Resources/Styles/Styles.xaml: Language not supported
- samples/CommunityToolkit.Maui.Sample/Models/PopupSize.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/PopupSizingIssuesViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/StylePopupViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/PopupPositionViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/CustomSizeAndPositionPopupViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/UpdatingPopupViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/Pages/Views/MediaElement/MediaElementPage.xaml.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupLayoutAlignmentPage.xaml.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/ShowPopupInOnAppearingPage.xaml.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/ViewsGalleryViewModel.cs: Evaluated as low risk
- samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/PopupAnchorViewModel.cs: Evaluated as low risk
Comments suppressed due to low confidence (1)
samples/CommunityToolkit.Maui.Sample/ViewModels/Views/Popup/PopupContentViewModel.cs:8
- The property name 'message' should be renamed to 'Message' to follow PascalCase convention.
string message = "";
This PR is also extremely close to merging. I'm working on the docs this week which is the final hurdle |
Handlers re-added with [Obsolete]
. We will remove them in the .NET 10 PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the popup samples to use the new IPopupService
API (Popup V2), removes legacy popup pages, and updates popup configuration property names, service registrations, and styles for compatibility with MAUI Toolkit Popup V2.
- Replace direct
ShowPopupAsync
extension andPopupSizeConstants
usage withIPopupService
injection across sample pages. - Remove obsolete sample pages (PopupAnchorPage, MultiplePopupPage, CustomSizeAndPositionPopupPage) and update navigation routes to the consolidated
PopupsPage
. - Update
PopupOptions
property names (e.g.,WidthRequest
,HeightRequest
,BackgroundColor
), bump package and MAUI versions, and refresh service registrations for new popups.
Reviewed Changes
Copilot reviewed 137 out of 137 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/ShowPopupInOnAppearingPage.xaml.cs | Inject IPopupService , track single display with flag |
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupsPage.xaml.cs | Inject IPopupService , consolidate handlers into PopupsPage |
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupSizingIssuesPage.xaml | Rename title, remove obsolete CommandParameter binding |
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupLayoutAlignmentPage.xaml.cs | Update layout option logic; switch to ShowPopup call |
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupOnDisappearingPage.cs | Switch to inline ShowPopupAsync on disappearing |
samples/CommunityToolkit.Maui.Sample/MauiProgram.cs | Remove PopupSizeConstants , overhaul popup registrations |
samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj | Bump toolkit and resilience package versions |
samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs | Update shell route mappings for new popup pages |
samples/CommunityToolkit.Maui.Sample/App.xaml | Migrate popup style setters to new property names |
Directory.Build.props | Bump MAUI package version and suppress new analyzer ID |
Comments suppressed due to low confidence (3)
samples/CommunityToolkit.Maui.Sample/MauiProgram.cs:125
IPopupService
is injected into several pages but not registered in the DI container. Add a registration likebuilder.Services.AddSingleton<IPopupService, PopupService>();
before consuming it.
builder.Services.AddSingleton<AppShell>();
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/ShowPopupInOnAppearingPage.xaml.cs:9
- [nitpick] Private fields should follow .NET conventions by being prefixed with an underscore. Consider renaming
hasPopupBeenShown
to_hasPopupBeenShown
.
bool hasPopupBeenShown;
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupSizingIssuesPage.xaml:25
- The
CommandParameter
binding was removed butShowPopupCommand
likely needs the page reference for anchoring the popup. If the view model still depends on a parameter, either restore theCommandParameter="{Binding Source={x:Reference Self}}"
or update the command implementation to no longer require an argument.
<Button Text="Show Popup" Command="{Binding ShowPopupCommand}"/>
samples/CommunityToolkit.Maui.Sample/Pages/Views/Popup/PopupLayoutAlignmentPage.xaml.cs
Show resolved
Hide resolved
This ensures we do not forget to remove the Obsolete Popup classes in our .NET 10 release
* Add `Close()` * Update PopupExtensions.shared.cs * Add CancellationToken * Add Unit Tests * Add Support for Shell * Add .NET 10 Compiler Error This ensures we do not forget to remove the Obsolete Popup classes in our .NET 10 release * Rename `Close()` -> `CloseAsync()` * Add `[EditorBrowsable(EditorBrowsableState.Never)]` to Obsolete classes * Update Samples * Fix XML
Here are the updated Requirements we'll add to the next Release Notes: Breaking Changes
RequirementsThe following tools are now required for CommunityToolkit.Maui:
global.json
|
Description of Change
Popup v2 completely redesigns Popup from the ground up. Instead of using custom handlers to create a Popup, instead of using janky workarounds to display the popup, and instead of using janky workarounds to size + position the Popup,
Popup
now inherits fromContentView
and is displayed using a Transparent Modal Page.Under the hood, we've created
internal class PopupPage : Content
, a transparentContentPage
that is used to display content. WhenShowPopupAsync()
is called, we now use the MAUI's INavigation to display the Popup on aPopupPage
usingawait Navigation.PushModalAsync(popupPage, shouldAnimate: false)
.There are also now 2 ways user can create popup:
View
directly toShowPopup
Shell.Current.ShowPopup(new Label { Text = "This is a Popup" })
For MVVM users there is a PopupService. Pay attention all popups must be registered. Also you can close popup from PopupService only if you opened it using PopupService. DO NOT combine extension method and PopupService.
Now all configurations live in PopupOptions. You can configure PageOverlayColor, Shadow, Border, BorderThickness, BorderStrokeThickness and CanBeClosedByTappingOutsidePopup.
The BindingContext is set automatically to PopupContainer, Popup and View.
As the new Popup uses only MAUI Controls, we expect you get all benefits of HotReload. All Controls including Popup in Popup and MediaElement should work without issues.
Features removed: AnchorView.
Linked Issues
FlyoutBehaviour.Locked
on macOS #2566OnLoaded
Popup Workaround #1490FlyoutBehaviour.Locked
on macOS #2566PR Checklist
approved
(bug) orChampioned
(feature/proposal)main
at time of PRMigration Guide
Popup XAML/CS
You can now use any View as Popup Content without inheriting it from Popup. But if you need to return a result from the popup, you have to inherit from Popup.
Popup Service