Skip to content
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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e905495
Initial musings on showing popups without having to create your own p…
bijington Nov 29, 2023
1df75cd
Remove commented code
bijington Nov 29, 2023
f7847ec
Pass on the BindingContext of a view up to the popup
bijington Dec 4, 2023
e0ac620
Expand IPopupService API to enable the ability to supply the configur…
bijington Feb 11, 2024
b153f60
Name the cancellation token usage
bijington Feb 20, 2024
4fcbf83
Include DynamicallyAccessedMembers
bijington Sep 10, 2024
45a35b3
Popup V2
VladislavAntonyuk Jan 14, 2025
2716adc
Update samples
VladislavAntonyuk Jan 14, 2025
3fce702
Fix tests
VladislavAntonyuk Jan 15, 2025
fbba90d
register all popups
VladislavAntonyuk Jan 15, 2025
ccf952d
fix tizen build
VladislavAntonyuk Jan 15, 2025
6afff1f
await tasks
VladislavAntonyuk Jan 15, 2025
b097df1
fix xaml
VladislavAntonyuk Jan 15, 2025
45ab59d
Fix tests
VladislavAntonyuk Jan 15, 2025
8b535bf
Fix popup Result
VladislavAntonyuk Jan 15, 2025
10cb099
Fix tests, fix samples, rework popup service
VladislavAntonyuk Jan 15, 2025
133b398
fix sample
VladislavAntonyuk Jan 15, 2025
2de506b
Fix back button
VladislavAntonyuk Jan 15, 2025
8ed786c
Fix tests
VladislavAntonyuk Jan 15, 2025
df0b6a3
Add Navigation parameter
VladislavAntonyuk Jan 21, 2025
d5cb5a1
Fix after rebase
VladislavAntonyuk Feb 6, 2025
e9cf804
Remove old page
VladislavAntonyuk Feb 6, 2025
f1d99c0
Merge branch 'main' into feature/sl/remove-popup-constraint-from-popu…
VladislavAntonyuk Feb 10, 2025
6818cb8
Add docs
VladislavAntonyuk Feb 11, 2025
df907ea
Merge branch 'main' into feature/sl/remove-popup-constraint-from-popu…
VladislavAntonyuk Feb 11, 2025
0616afb
Merge branch 'main' into feature/sl/remove-popup-constraint-from-popu…
VladislavAntonyuk Feb 12, 2025
c38a148
Merge branch 'main' into feature/sl/remove-popup-constraint-from-popu…
TheCodeTraveler Feb 13, 2025
1f23950
Use Partial Property
TheCodeTraveler Feb 13, 2025
0c47444
Disable `PushModalAsync` and `PopModalAsync` Animations
TheCodeTraveler Feb 13, 2025
fb3ba37
Remove Circular Reference to PopupContainer
TheCodeTraveler Feb 13, 2025
bd35857
Remove Null Forgiving Operator
TheCodeTraveler Feb 13, 2025
9839e2e
Update Event Name
TheCodeTraveler Feb 13, 2025
d5174bb
Add CancellationToken Parameter
TheCodeTraveler Feb 14, 2025
86247a0
Remove duplicate `()`
TheCodeTraveler Feb 14, 2025
f191127
Add PopupExtension method for `Page`
TheCodeTraveler Feb 14, 2025
eda00b7
Remove `return await`
TheCodeTraveler Feb 14, 2025
7930fc4
Update formatting
TheCodeTraveler Feb 14, 2025
5dc9eb3
Use `WeakEventManager`
TheCodeTraveler Feb 14, 2025
d8f90a4
Merge branch 'main' into feature/sl/remove-popup-constraint-from-popu…
VladislavAntonyuk Feb 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions samples/CommunityToolkit.Maui.Sample/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,34 @@
</ResourceDictionary.MergedDictionaries>

<Style TargetType="{x:Type popups:ImplicitStylePopup}">
<Setter Property="Size" Value="100,100" />
<Setter Property="Color" Value="Red" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="VerticalOptions" Value="Start" />
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
<Setter Property="WidthRequest" Value="100" />
<Setter Property="HeightRequest" Value="100" />
<Setter Property="BackgroundColor" Value="Red" />
</Style>

<Style x:Key="ExplicitPopupStyle" TargetType="{x:Type popups:ExplicitStylePopup}">
<Setter Property="Size" Value="200,100" />
<Setter Property="Color" Value="Yellow" />
<Setter Property="HorizontalOptions" Value="End" />
<Setter Property="VerticalOptions" Value="Start" />
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
<Setter Property="WidthRequest" Value="200" />
<Setter Property="HeightRequest" Value="100" />
<Setter Property="BackgroundColor" Value="Yellow" />
</Style>

<Style x:Key="BasePopupStyle" TargetType="{x:Type popups:StyleInheritancePopup}">
<Setter Property="Size" Value="200,200" />
<Setter Property="WidthRequest" Value="200" />
<Setter Property="HeightRequest" Value="200" />
</Style>
<Style x:Key="InheritancePopupStyle" TargetType="{x:Type popups:StyleInheritancePopup}" BasedOn="{StaticResource BasePopupStyle}">
<Setter Property="Color" Value="SkyBlue" />
<Setter Property="HorizontalOptions" Value="End" />
<Setter Property="VerticalOptions" Value="End" />
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
<Setter Property="BackgroundColor" Value="SkyBlue" />
</Style>

<Style x:Key="DynamicBasePopupStyle" TargetType="{x:Type popups:DynamicStyleInheritancePopup}">
<Setter Property="Size" Value="150,150" />
<Setter Property="WidthRequest" Value="150" />
<Setter Property="HeightRequest" Value="150" />
</Style>
<Style x:Key="DynamicInheritancePopupStyle1" TargetType="{x:Type popups:DynamicStyleInheritancePopup}" BasedOn="{StaticResource DynamicBasePopupStyle}">
<Setter Property="Color" Value="Purple" />
<Setter Property="VerticalOptions" Value="End" />
<Setter Property="BackgroundColor" Value="Purple" />
</Style>
<Style x:Key="DynamicInheritancePopupStyle2" TargetType="{x:Type popups:DynamicStyleInheritancePopup}" BaseResourceKey="DynamicInheritancePopupStyle1">
<Setter Property="Color" Value="Orange" />
<Setter Property="HorizontalOptions" Value="End" />
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
<Setter Property="BackgroundColor" Value="Orange" />
</Style>

</ResourceDictionary>
Expand Down
8 changes: 4 additions & 4 deletions samples/CommunityToolkit.Maui.Sample/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public partial class AppShell : Shell
CreateViewModelMapping<AvatarViewSizesPage, AvatarViewSizesViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<BasicMapsPage, BasicMapsViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<CameraViewPage, CameraViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<CustomSizeAndPositionPopupPage, CustomSizeAndPositionPopupViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<DrawingViewPage, DrawingViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<ExpanderPage, ExpanderViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<LazyViewPage, LazyViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
Expand All @@ -130,17 +129,18 @@ public partial class AppShell : Shell
CreateViewModelMapping<MediaElementCarouselViewPage, MediaElementCarouselViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<MediaElementCollectionViewPage, MediaElementCollectionViewViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<MediaElementMultipleWindowsPage, MediaElementMultipleWindowsViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<SemanticOrderViewPage, SemanticOrderViewPageViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<MultiplePopupPage, MultiplePopupViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<PopupAnchorPage, PopupAnchorViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<PopupLayoutAlignmentPage, PopupLayoutAlignmentViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<PopupPositionPage, PopupPositionViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<PopupSizingIssuesPage, PopupSizingIssuesViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<RatingViewCsharpPage, RatingViewCsharpViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<ShowPopupInOnAppearingPage, ShowPopupInOnAppearingPageViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<StylePopupPage, StylePopupViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<RatingViewCsharpPage, RatingViewCsharpViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<RatingViewShowcasePage, RatingViewShowcaseViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<RatingViewXamlPage, RatingViewXamlViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<SemanticOrderViewPage, SemanticOrderViewPageViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<ShowPopupInOnAppearingPage, ShowPopupInOnAppearingPageViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),
CreateViewModelMapping<StylePopupPage, StylePopupViewModel, ViewsGalleryPage, ViewsGalleryViewModel>(),

// Add PlatformSpecific View Models
CreateViewModelMapping<NavigationBarPage, NavigationBarAndroidViewModel, PlatformSpecificGalleryPage, PlatformSpecificGalleryViewModel>()
Expand Down
26 changes: 21 additions & 5 deletions samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public static MauiApp CreateMauiApp()
.AddStandardResilienceHandler(static options => options.Retry = new MobileHttpRetryStrategyOptions());

builder.Services.AddSingleton<AppShell>();
builder.Services.AddSingleton<PopupSizeConstants>();

RegisterViewsAndViewModels(builder.Services);
RegisterEssentials(builder.Services);
Expand Down Expand Up @@ -246,7 +245,6 @@ static void RegisterViewsAndViewModels(in IServiceCollection services)
// Add Views Pages + ViewModels
services.AddTransientWithShellRoute<BasicMapsPage, BasicMapsViewModel>();
services.AddTransientWithShellRoute<CameraViewPage, CameraViewViewModel>();
services.AddTransientWithShellRoute<CustomSizeAndPositionPopupPage, CustomSizeAndPositionPopupViewModel>();
services.AddTransientWithShellRoute<DrawingViewPage, DrawingViewViewModel>();
services.AddTransientWithShellRoute<ExpanderPage, ExpanderViewModel>();
services.AddTransientWithShellRoute<LazyViewPage, LazyViewViewModel>();
Expand All @@ -268,9 +266,27 @@ static void RegisterViewsAndViewModels(in IServiceCollection services)
services.AddTransientWithShellRoute<PopupSizingIssuesPage, PopupSizingIssuesViewModel>();

// Add Popups
services.AddTransientPopup<CsharpBindingPopup, CsharpBindingPopupViewModel>();
services.AddTransientPopup<UpdatingPopup, UpdatingPopupViewModel>();
services.AddTransientPopup<XamlBindingPopup, XamlBindingPopupViewModel>();
services.AddPopup<ApplyToDerivedTypesPopup>();
services.AddPopup<ButtonPopup>();
services.AddPopup<CsharpBindingPopup, CsharpBindingPopupViewModel>();
services.AddPopup<DynamicStyleInheritancePopup>();
services.AddPopup<DynamicStylePopup>();
services.AddPopup<ExplicitStylePopup>();
services.AddPopup<ImplicitStylePopup>();
services.AddPopup<MultipleButtonPopup>();
services.AddPopup<NoOutsideTapDismissPopup>();
services.AddPopup<OpenedEventSimplePopup>();
services.AddPopup<RedBlueBoxPopup>();
services.AddPopup<ReturnResultPopup>();
services.AddPopup<SimplePopup>();
services.AddPopup<StyleClassPopup>();
services.AddPopup<StyleInheritancePopup>();
services.AddPopup<ToggleSizePopup>();
services.AddPopup<TransparentPopup>();
services.AddPopup<UpdatingPopup, UpdatingPopupViewModel>();
services.AddPopup<XamlBindingPopup, XamlBindingPopupViewModel>();

services.AddPopup<PopupContentView, PopupContentViewModel>();
}

static void RegisterEssentials(in IServiceCollection services)
Expand Down
22 changes: 0 additions & 22 deletions samples/CommunityToolkit.Maui.Sample/Models/PopupSize.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Core.Primitives;
using CommunityToolkit.Maui.Sample.ViewModels.Views;
using CommunityToolkit.Maui.Views;
Expand Down Expand Up @@ -243,7 +244,7 @@ async void ChangeAspectClicked(object? sender, EventArgs e)
MediaElement.Aspect = (Aspect)aspectEnum;
}

void DisplayPopup(object sender, EventArgs e)
async void DisplayPopup(object sender, EventArgs e)
{
MediaElement.Pause();
var popupMediaElement = new MediaElement
Expand All @@ -256,8 +257,6 @@ void DisplayPopup(object sender, EventArgs e)
};
var popup = new Popup
{
VerticalOptions = LayoutAlignment.Center,
HorizontalOptions = LayoutAlignment.Center,
Content = new StackLayout
{
Children =
Expand All @@ -267,11 +266,8 @@ void DisplayPopup(object sender, EventArgs e)
}
};

this.ShowPopup(popup);
popup.Closed += (s, e) =>
{
popupMediaElement.Stop();
popupMediaElement.Handler?.DisconnectHandler();
};
await this.ShowPopup(popup, new PopupOptions());
popupMediaElement.Stop();
popupMediaElement.Handler?.DisconnectHandler();
}
}
Loading
Loading