From 4696d3d4f546a2b1535a76ec5f4bf56f105539c1 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 09:52:58 -0700
Subject: [PATCH 01/41] Update to .NET 10
---
.github/workflows/benchmarks.yml | 4 +-
.github/workflows/dotnet-build.yml | 16 +-
Directory.Build.props | 8 +-
global.json | 4 +-
.../CommunityToolkit.Maui.Sample.csproj | 2 +-
...ityToolkit.Maui.Analyzers.UnitTests.csproj | 4 +-
.../Handlers/Popup/PopUpHandler.android.cs | 151 ------
.../Handlers/Popup/PopUpHandler.windows.cs | 171 -------
.../Handlers/Popup/PopupHandler.macios.cs | 108 -----
.../Handlers/Popup/PopupHandler.net.cs | 80 ----
.../Handlers/Popup/PopupHandler.shared.cs | 56 ---
.../Handlers/Popup/PopupHandler.tizen.cs | 104 ----
.../Interfaces/IPopup.shared.cs | 66 ---
.../Views/Popup/MauiPopup.android.cs | 136 ------
.../Views/Popup/MauiPopup.macios.cs | 241 ----------
.../Views/Popup/MauiPopup.tizen.cs | 143 ------
.../Views/Popup/PopupExtensions.android.cs | 444 ------------------
.../Views/Popup/PopupExtensions.macios.cs | 255 ----------
.../Views/Popup/PopupExtensions.windows.cs | 270 -----------
.../Views/Popup/PopupOverlay.windows.cs | 57 ---
.../Views/MediaManager.macios.cs | 4 +-
src/CommunityToolkit.Maui/Options.cs | 10 +-
.../Views/AvatarView.shared.cs | 1 +
23 files changed, 27 insertions(+), 2308 deletions(-)
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.android.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.windows.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.macios.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.net.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
delete mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml
index ea695717ac..a3d2798aa2 100644
--- a/.github/workflows/benchmarks.yml
+++ b/.github/workflows/benchmarks.yml
@@ -13,7 +13,7 @@ on:
- '*'
env:
- LATEST_NET_VERSION: '9.0.x'
+ LATEST_NET_VERSION: '10.0.x'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
concurrency:
@@ -42,7 +42,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.LATEST_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- name: Install .NET MAUI Workload
run: |
diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml
index 423a4e6d1f..139a350a19 100644
--- a/.github/workflows/dotnet-build.yml
+++ b/.github/workflows/dotnet-build.yml
@@ -22,8 +22,8 @@ env:
NugetPackageVersionCamera: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersionMediaElement: '99.0.0-preview${{ github.run_number }}'
NugetPackageVersionMaps: '99.0.0-preview${{ github.run_number }}'
- TOOLKIT_NET_VERSION: '9.0.300'
- LATEST_NET_VERSION: '9.0.x'
+ TOOLKIT_NET_VERSION: '10.0.x'
+ LATEST_NET_VERSION: '10.0.x'
PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
@@ -43,7 +43,7 @@ env:
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestProjectDirectory: 'src/CommunityToolkit.Maui.Analyzers.UnitTests'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
- CommunityToolkitLibrary_Xcode_Version: '16.2'
+ CommunityToolkitLibrary_Xcode_Version: '16.4'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -71,7 +71,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.LATEST_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- uses: actions/setup-java@v5
with:
@@ -145,7 +145,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- uses: actions/setup-java@v5
with:
@@ -273,7 +273,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- name: Download NuGet List
uses: actions/download-artifact@v5
@@ -345,7 +345,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- name: Download signed packages
uses: actions/download-artifact@v5
@@ -373,7 +373,7 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.TOOLKIT_NET_VERSION }}
- dotnet-quality: 'ga'
+ dotnet-quality: 'preview'
- name: Download signed packages
uses: actions/download-artifact@v5
diff --git a/Directory.Build.props b/Directory.Build.props
index 4c20b96c8e..7837d99bc1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,8 +2,8 @@
enable
- NETSDK1023
- net9.0
+ NETSDK1023;XCODE_26_0_PREVIEW
+ net10.0
preview
enable
true
@@ -16,8 +16,8 @@
all
- 9.0.110
- 10.0.0
+ 10.0.0-rc.1.25452.6
+ 11.0.0
true
true
true
diff --git a/global.json b/global.json
index a5d75d8411..55e0e2cf3a 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"sdk": {
- "version": "9.0.300",
+ "version": "10.0.100-rc.1.25451.107",
"rollForward": "latestFeature",
- "allowPrerelease": false
+ "allowPrerelease": true
}
}
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index 9a810778d0..df5c7eb324 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -67,7 +67,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
index 9af74b1843..7c505604c4 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
@@ -20,13 +20,13 @@
-
+
-
+
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.android.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.android.cs
deleted file mode 100644
index 23c8cc63b5..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.android.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using CommunityToolkit.Maui.Core.Views;
-using Microsoft.Maui.Handlers;
-using Microsoft.Maui.Platform;
-using AView = Android.Views.View;
-
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-public partial class PopupHandler : ElementHandler
-{
- internal AView? Container { get; set; }
- internal int LastPopupWidth { get; set; }
- internal int LastPopupHeight { get; set; }
- internal double LastWindowWidth { get; set; }
- internal double LastWindowHeight { get; set; }
-
- ///
- /// Action that's triggered when the Popup is closed
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnClosed(PopupHandler handler, IPopup view, object? result)
- {
- var popup = handler.PlatformView;
-
- if (!popup.Context.GetActivity().IsDestroyed())
- {
- if (popup.IsShowing)
- {
- popup.Dismiss();
- }
- }
-
- view.HandlerCompleteTCS.TrySetResult();
-
- handler.DisconnectHandler(popup);
- }
-
- ///
- /// Action that's triggered when the Popup is Opened.
- ///
- /// An instance of .
- /// An instance of .
- /// We don't need to provide the result parameter here.
- public static void MapOnOpened(PopupHandler handler, IPopup view, object? result)
- {
- handler.PlatformView.Show();
- }
-
- ///
- /// Action that's triggered when the Popup is dismissed by tapping outside of the popup.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
- {
- if (view.CanBeDismissedByTappingOutsideOfPopup)
- {
- view.OnDismissedByTappingOutsideOfPopup();
- }
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapAnchor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetAnchor(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetCanBeDismissedByTappingOutsideOfPopup(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapColor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetColor(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapSize(PopupHandler handler, IPopup view)
- {
- ArgumentNullException.ThrowIfNull(handler.Container);
-
- handler.PlatformView.SetSize(view, handler.Container, handler);
- }
-
- ///
- protected override MauiPopup CreatePlatformElement()
- {
- _ = MauiContext ?? throw new InvalidOperationException("MauiContext is null, please check your MauiApplication.");
- _ = MauiContext.Context ?? throw new InvalidOperationException("Android Context is null, please check your MauiApplication.");
-
- return new MauiPopup(MauiContext.Context, MauiContext);
- }
-
- ///
- protected override void ConnectHandler(MauiPopup platformView)
- {
- Container = platformView.SetElement(VirtualView);
-
- if (Container is not null)
- {
- Container.LayoutChange += OnLayoutChange;
- }
- }
-
- ///
- protected override void DisconnectHandler(MauiPopup platformView)
- {
- platformView.Dispose();
-
- if (Container is not null)
- {
- Container.LayoutChange -= OnLayoutChange;
- }
- }
-
- void OnShowed(object? sender, EventArgs args)
- {
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
-
- VirtualView.OnOpened();
- }
-
- void OnLayoutChange(object? sender, EventArgs e)
- {
- if (VirtualView?.Handler?.PlatformView is Dialog dialog && Container is not null)
- {
- PopupExtensions.SetSize(dialog, VirtualView, Container, this);
- }
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.windows.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.windows.cs
deleted file mode 100644
index 0ea2845638..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopUpHandler.windows.cs
+++ /dev/null
@@ -1,171 +0,0 @@
-using CommunityToolkit.Maui.Core.Extensions;
-using CommunityToolkit.Maui.Core.Views;
-using Microsoft.Maui.Handlers;
-using Microsoft.Maui.Platform;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Controls.Primitives;
-using Windows.UI.ViewManagement;
-
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-public partial class PopupHandler : ElementHandler
-{
- ///
- /// Action that's triggered when the Popup is Dismissed.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnClosed(PopupHandler handler, IPopup view, object? result)
- {
- var window = view.GetWindow();
- if (window.Overlays.FirstOrDefault() is IWindowOverlay popupOverlay)
- {
- window.RemoveOverlay(popupOverlay);
- }
-
- view.HandlerCompleteTCS.TrySetResult();
- handler.DisconnectHandler(handler.PlatformView);
- }
-
- ///
- /// Action that's triggered when the Popup is Opened.
- ///
- /// An instance of .
- /// An instance of .
- /// We don't need to provide the result parameter here.
- public static void MapOnOpened(PopupHandler handler, IPopup view, object? result)
- {
- ArgumentNullException.ThrowIfNull(view.Parent);
- ArgumentNullException.ThrowIfNull(handler.MauiContext);
-
- var parent = view.Parent.ToPlatform(handler.MauiContext);
- parent.IsHitTestVisible = false;
- handler.PlatformView.XamlRoot = view.GetWindow().Content?.Handler?.MauiContext?.GetPlatformWindow().Content.XamlRoot ?? throw new InvalidOperationException("Window Content cannot be null");
- handler.PlatformView.IsHitTestVisible = true;
- handler.PlatformView.IsOpen = true;
-
- AddOverlayToWindow(view.GetWindow());
-
- view.OnOpened();
- }
-
-
- ///
- /// Action that's triggered when the Popup is dismissed by tapping outside of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
- {
- view.OnDismissedByTappingOutsideOfPopup();
- handler.DisconnectHandler(handler.PlatformView);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapAnchor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetAnchor(view, handler.MauiContext);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.IsLightDismissEnabled = view.CanBeDismissedByTappingOutsideOfPopup;
- handler.PlatformView.LightDismissOverlayMode = LightDismissOverlayMode.Off;
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapColor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetColor(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapSize(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetSize(view, handler.MauiContext);
- }
-
- ///
- protected override void DisconnectHandler(Popup platformView)
- {
- if (VirtualView.Parent is null)
- {
- return;
- }
-
- ArgumentNullException.ThrowIfNull(VirtualView.Handler?.MauiContext);
- var parent = VirtualView.Parent.ToPlatform(VirtualView.Handler.MauiContext);
- parent.IsHitTestVisible = true;
- platformView.IsOpen = false;
- platformView.Closed -= OnClosed;
- if (MauiContext is not null)
- {
- MauiContext.GetPlatformWindow().SizeChanged -= OnSizeChanged;
- }
- }
-
- ///
- protected override Popup CreatePlatformElement()
- {
- var popup = new Popup();
- return popup;
- }
-
- ///
- protected override void ConnectHandler(Popup platformView)
- {
- platformView.Closed += OnClosed;
- platformView.ConfigureControl(VirtualView, MauiContext);
- if (MauiContext is not null)
- {
- MauiContext.GetPlatformWindow().SizeChanged += OnSizeChanged;
- }
- base.ConnectHandler(platformView);
- }
-
- static void AddOverlayToWindow(IWindow window)
- {
- var uiSetting = new UISettings();
- var backgroundColor = uiSetting.GetColorValue(UIColorType.Background).ToColor();
- window.AddOverlay(new PopupOverlay(window, backgroundColor.IsDark()
- ? Color.FromRgba(0, 0, 0, 153)
- : Color.FromRgba(255, 255, 255, 153))); // 60% Opacity
- }
-
- void OnClosed(object? sender, object e)
- {
- if (!PlatformView.IsOpen && VirtualView.CanBeDismissedByTappingOutsideOfPopup)
- {
- VirtualView.Handler?.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup));
- }
- }
-
- void OnSizeChanged(object? sender, WindowSizeChangedEventArgs e)
- {
- if (VirtualView is not null)
- {
- PopupExtensions.SetSize(PlatformView, VirtualView, MauiContext);
- PopupExtensions.SetLayout(PlatformView, VirtualView, MauiContext);
- }
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.macios.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.macios.cs
deleted file mode 100644
index 809f8a3ecd..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.macios.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using CommunityToolkit.Maui.Core.Views;
-using Microsoft.Maui.Handlers;
-
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-public partial class PopupHandler : ElementHandler
-{
- ///
- /// Action that's triggered when the Popup is Dismissed.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static async void MapOnClosed(PopupHandler handler, IPopup view, object? result)
- {
- var presentationController = handler.PlatformView.PresentationController;
- if (presentationController?.PresentedViewController is UIViewController presentationViewController)
- {
- await presentationViewController.DismissViewControllerAsync(true);
- }
-
- view.HandlerCompleteTCS.TrySetResult();
-
- handler.DisconnectHandler(handler.PlatformView);
- }
-
- ///
- /// Action that's triggered when the Popup is dismissed by tapping outside of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
- {
- if (handler.PlatformView is not MauiPopup popupRenderer)
- {
- throw new InvalidOperationException($"{nameof(handler.PlatformView)} must be of type {typeof(PopupHandler)}.");
- }
-
- if (popupRenderer.IsViewLoaded && view.CanBeDismissedByTappingOutsideOfPopup)
- {
- view.OnDismissedByTappingOutsideOfPopup();
- }
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
-
- public static void MapAnchor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetSize(view);
- handler.PlatformView.SetLayout(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetCanBeDismissedByTappingOutsideOfPopup(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapColor(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetBackgroundColor(view);
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapSize(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.SetSize(view);
- handler.PlatformView.SetLayout(view);
- }
-
- ///
- protected override void ConnectHandler(MauiPopup platformView)
- {
- base.ConnectHandler(platformView);
- platformView.SetElement(VirtualView);
- }
-
- ///
- protected override MauiPopup CreatePlatformElement()
- {
- return new MauiPopup(MauiContext ?? throw new NullReferenceException(nameof(MauiContext)));
- }
-
- ///
- protected override void DisconnectHandler(MauiPopup platformView)
- {
- base.DisconnectHandler(platformView);
- platformView.CleanUp();
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.net.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.net.cs
deleted file mode 100644
index 5c307f03e0..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.net.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-public partial class PopupHandler : Microsoft.Maui.Handlers.ElementHandler
-{
- ///
- protected override object CreatePlatformElement() => throw new NotSupportedException();
-
- ///
- /// Action that's triggered when the Popup is closed.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnClosed(PopupHandler handler, IPopup view, object? result)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup is Opened.
- ///
- /// An instance of .
- /// An instance of .
- /// We don't need to provide the result parameter here.
- public static void MapOnOpened(PopupHandler handler, IPopup view, object? result)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup is dismissed by tapping outside of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapAnchor(PopupHandler handler, IPopup view)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapColor(PopupHandler handler, IPopup view)
- {
- throw new NotSupportedException();
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapSize(PopupHandler handler, IPopup view)
- {
- throw new NotSupportedException();
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
deleted file mode 100644
index 29cf972747..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.shared.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System.ComponentModel;
-
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-///
-/// Handler Popup control
-///
-#if NET10_0_OR_GREATER
-#error Remove PopupHandler
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(PopupHandler)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public partial class PopupHandler
-{
- ///
- /// PropertyMapper for Popup Control
- ///
- public static IPropertyMapper PopUpMapper = new PropertyMapper(ElementMapper)
- {
- [nameof(IPopup.Anchor)] = MapAnchor,
- [nameof(IPopup.Color)] = MapColor,
- [nameof(IPopup.Size)] = MapSize,
- [nameof(IPopup.VerticalOptions)] = MapSize,
- [nameof(IPopup.HorizontalOptions)] = MapSize,
- [nameof(IPopup.CanBeDismissedByTappingOutsideOfPopup)] = MapCanBeDismissedByTappingOutsideOfPopup
- };
-
- ///
- /// for Popup Control.
- ///
- public static CommandMapper PopUpCommandMapper = new(ElementCommandMapper)
- {
-#if !(IOS || MACCATALYST)
- [nameof(IPopup.OnOpened)] = MapOnOpened,
- [nameof(IPopup.OnClosed)] = MapOnClosed,
-#endif
- [nameof(IPopup.OnDismissedByTappingOutsideOfPopup)] = MapOnDismissedByTappingOutsideOfPopup
- };
-
- ///
- /// Constructor for .
- ///
- /// Custom instance of , if it's null the will be used
- /// Custom instance of , if it's null the will be used
- public PopupHandler(IPropertyMapper? mapper, CommandMapper? commandMapper)
- : base(mapper ?? PopUpMapper, commandMapper ?? PopUpCommandMapper)
- {
- }
-
- ///
- /// Default Constructor for .
- ///
- public PopupHandler()
- : base(PopUpMapper, PopUpCommandMapper)
- {
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs
deleted file mode 100644
index e8755cfa18..0000000000
--- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using CommunityToolkit.Maui.Core.Views;
-using Tizen.UIExtensions.NUI;
-
-namespace CommunityToolkit.Maui.Core.Handlers;
-
-public partial class PopupHandler : Microsoft.Maui.Handlers.ElementHandler
-{
- ///
- /// Action that's triggered when the Popup is closed.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnClosed(PopupHandler handler, IPopup view, object? result)
- {
- var popup = handler.PlatformView;
-
- if (popup.IsOpen)
- {
- popup.Close();
- }
- view.HandlerCompleteTCS.TrySetResult();
-
- handler.DisconnectHandler(popup);
- }
-
- ///
- /// Action that's triggered when the Popup is Opened.
- ///
- /// An instance of .
- /// An instance of .
- /// We don't need to provide the result parameter here.
- public static void MapOnOpened(PopupHandler handler, IPopup view, object? result)
- {
- handler.PlatformView.ShowPopup();
- }
-
- ///
- /// Action that's triggered when the Popup is dismissed by tapping outside of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- /// The result that should return from this Popup.
- public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view, object? result)
- {
- if (view.CanBeDismissedByTappingOutsideOfPopup)
- {
- view.OnDismissedByTappingOutsideOfPopup();
- }
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapAnchor(PopupHandler handler, IPopup view)
- {
- // On Tizen, Anchor only update when popup is opened
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view)
- {
- // this property directly access on platform view
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapColor(PopupHandler handler, IPopup view)
- {
- // this property directly access on platform view
- }
-
- ///
- /// Action that's triggered when the Popup property changes.
- ///
- /// An instance of .
- /// An instance of .
- public static void MapSize(PopupHandler handler, IPopup view)
- {
- handler.PlatformView.UpdateContentSize();
- }
-
- ///
- protected override void ConnectHandler(MauiPopup platformView)
- {
- platformView.SetElement(VirtualView);
- }
-
- ///
- protected override MauiPopup CreatePlatformElement()
- {
- var mauiContext = MauiContext ?? throw new InvalidOperationException("${nameof(MauiContext)} cannot be null");
- return new MauiPopup(mauiContext);
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs b/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
deleted file mode 100644
index 3ae3d056ea..0000000000
--- a/src/CommunityToolkit.Maui.Core/Interfaces/IPopup.shared.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System.ComponentModel;
-using IElement = Microsoft.Maui.IElement;
-using LayoutAlignment = Microsoft.Maui.Primitives.LayoutAlignment;
-
-namespace CommunityToolkit.Maui.Core;
-
-///
-/// Represents a small View that pops up at front the Page.
-///
-#if NET10_0_OR_GREATER
-#error Remove IPopup
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(IPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public interface IPopup : IElement, IVisualTreeElement, IAsynchronousHandler
-{
- ///
- /// Gets the View that Popup will be anchored.
- ///
- IView? Anchor { get; }
-
- ///
- /// Gets the Popup's color.
- ///
- Color? Color { get; }
-
- ///
- /// Gets the Popup's Content.
- ///
- IView? Content { get; }
-
- ///
- /// Gets the horizontal aspect of this element's arrangement in a container.
- ///
- LayoutAlignment HorizontalOptions { get; }
-
- ///
- /// Gets the CanBeDismissedByTappingOutsideOfPopup property.
- ///
- bool CanBeDismissedByTappingOutsideOfPopup { get; }
-
- ///
- /// Gets the Popup's size.
- ///
- Size Size { get; }
-
- ///
- /// Gets the vertical aspect of this element's arrangement in a container.
- ///
- LayoutAlignment VerticalOptions { get; }
-
- ///
- /// Occurs when the Popup is closed.
- ///
- /// Return value from the Popup.
- void OnClosed(object? result = null);
-
- ///
- /// Occurs when the Popup is opened.
- ///
- void OnOpened();
-
- ///
- /// Occurs when the Popup is dismissed by a user tapping outside the Popup.
- ///
- void OnDismissedByTappingOutsideOfPopup();
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
deleted file mode 100644
index a89ed9e250..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.android.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using Android.Content;
-using Android.Views;
-using Microsoft.Maui.Platform;
-using AView = Android.Views.View;
-
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// The native implementation of Popup control.
-///
-#if NET10_0_OR_GREATER
-#error Remove MauiPopup
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public class MauiPopup : Dialog, IDialogInterfaceOnCancelListener
-{
- readonly IMauiContext mauiContext;
-
- ///
- /// Constructor of .
- ///
- /// An instance of .
- /// An instance of .
- /// If is null an exception will be thrown.
- public MauiPopup(Context context, IMauiContext mauiContext)
- : base(context)
- {
- this.mauiContext = mauiContext ?? throw new ArgumentNullException(nameof(mauiContext));
- }
-
- ///
- /// An instance of the .
- ///
- public IPopup? VirtualView { get; private set; }
-
- ///
- /// Method to initialize the native implementation.
- ///
- /// An instance of .
- public AView? SetElement(IPopup? element)
- {
- ArgumentNullException.ThrowIfNull(element);
-
- VirtualView = element;
-
- if (TryCreateContainer(VirtualView, out var container))
- {
- SubscribeEvents();
- }
-
- return container;
- }
-
- ///
- /// Method to show the Popup.
- ///
- public override void Show()
- {
- base.Show();
-
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
-
- VirtualView.OnOpened();
- }
-
- ///
- /// Method triggered when the Popup is dismissed by tapping outside of the Popup.
- ///
- /// An instance of the .
- public void OnDismissedByTappingOutsideOfPopup(IDialogInterface dialog)
- {
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
- _ = VirtualView.Handler ?? throw new InvalidOperationException($"{nameof(VirtualView.Handler)} cannot be null");
-
- VirtualView.Handler?.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup));
- }
-
- ///
- /// Method to clean up the resources of the .
- ///
- public void CleanUp()
- {
- VirtualView = null;
- }
-
- ///
- public override bool OnTouchEvent(MotionEvent e)
- {
- if (VirtualView is not null)
- {
- if (VirtualView.CanBeDismissedByTappingOutsideOfPopup &&
- e.Action == MotionEventActions.Up)
- {
- if (Window?.DecorView is AView decorView)
- {
- float x = e.GetX();
- float y = e.GetY();
-
- if (!(x >= 0 && x <= decorView.Width && y >= 0 && y <= decorView.Height))
- {
- if (IsShowing)
- {
- OnDismissedByTappingOutsideOfPopup(this);
- }
- }
- }
- }
- }
-
- return !this.IsDisposed() && base.OnTouchEvent(e);
- }
-
- bool TryCreateContainer(in IPopup popup, [NotNullWhen(true)] out AView? container)
- {
- container = null;
-
- if (popup.Content is null)
- {
- return false;
- }
-
- container = popup.Content.ToPlatform(mauiContext);
- SetContentView(container);
-
- return true;
- }
-
- void SubscribeEvents()
- {
- SetOnCancelListener(this);
- }
-
- void IDialogInterfaceOnCancelListener.OnCancel(IDialogInterface? dialog) => OnDismissedByTappingOutsideOfPopup(this);
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
deleted file mode 100644
index 4860b76ff7..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.macios.cs
+++ /dev/null
@@ -1,241 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using CommunityToolkit.Maui.Core.Extensions;
-using Microsoft.Maui.ApplicationModel;
-using Microsoft.Maui.Handlers;
-
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// The native implementation of Popup control.
-///
-///
-/// Constructor of .
-///
-/// An instance of .
-/// If is null an exception will be thrown.
-#if NET10_0_OR_GREATER
-#error Remove MauiPopup
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public class MauiPopup(IMauiContext mauiContext) : UIViewController
-{
- readonly IMauiContext mauiContext = mauiContext ?? throw new ArgumentNullException(nameof(mauiContext));
-
- ///
- /// An instance of the that holds the .
- ///
- public PageHandler? Control { get; private set; }
-
- ///
- /// An instance of the .
- ///
- public IPopup? VirtualView { get; private set; }
-
- internal UIViewController? ViewController { get; private set; }
-
- ///
- /// Method to update the Popup's size.
- ///
- ///
- public void SetElementSize(Size size) =>
- Control?.ContainerView?.SizeThatFits(size);
-
- ///
- public override void ViewDidLayoutSubviews()
- {
- base.ViewDidLayoutSubviews();
-
- _ = View ?? throw new InvalidOperationException($"{nameof(View)} cannot be null.");
- _ = View.Superview ?? throw new InvalidOperationException($"{nameof(View.Superview)} cannot be null.");
-
- View.Superview.Layer.CornerRadius = 0.0f;
- View.Superview.Layer.MasksToBounds = false;
-
- if (PresentationController is not null)
- {
- SetShadowView(PresentationController.ContainerView);
- }
-
- SetElementSize(new Size(View.Bounds.Width, View.Bounds.Height));
-
- if (VirtualView is not null)
- {
- this.SetSize(VirtualView);
- this.SetLayout(VirtualView);
- }
- }
-
- ///
- public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
- {
- coordinator.AnimateAlongsideTransition(_ =>
- {
- // Before screen rotate
- }, _ =>
- {
- // After screen rotate
- if (VirtualView is not null)
- {
- this.SetSize(VirtualView);
- this.SetLayout(VirtualView);
- }
- });
-
- if (View is not null)
- {
- View.Bounds = new CGRect(0, 0, PreferredContentSize.Width, PreferredContentSize.Height);
- }
-
- base.ViewWillTransitionToSize(toSize, coordinator);
- }
-
- ///
- /// Method to initialize the native implementation.
- ///
- /// An instance of .
- [MemberNotNull(nameof(VirtualView), nameof(ViewController))]
- public void SetElement(IPopup element)
- {
-#if MACCATALYST
- if (element.Parent?.Handler is not PageHandler)
- {
- throw new InvalidOperationException($"The {nameof(element.Parent)} must be of type {typeof(PageHandler)}.");
- }
-#endif
-
- VirtualView = element;
- ModalPresentationStyle = UIModalPresentationStyle.Popover;
-
- _ = View ?? throw new InvalidOperationException($"{nameof(View)} cannot be null.");
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null.");
-
-#if MACCATALYST
- var pageHandler = VirtualView.Parent.Handler as PageHandler;
- var rootViewController = pageHandler?.ViewController ?? WindowStateManager.Default.GetCurrentUIViewController() ?? throw new InvalidOperationException($"{nameof(PageHandler.ViewController)} cannot be null.");
-#else
- var rootViewController = WindowStateManager.Default.GetCurrentUIViewController() ?? throw new InvalidOperationException($"{nameof(PageHandler.ViewController)} cannot be null.");
-#endif
-
- ViewController ??= rootViewController;
- }
-
- ///
- /// Method to clean up the resources of the .
- ///
- public void CleanUp()
- {
- if (VirtualView is null)
- {
- return;
- }
-
- VirtualView = null;
-
- if (PresentationController is UIPopoverPresentationController presentationController)
- {
- presentationController.Delegate = null;
- }
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- [MemberNotNull(nameof(Control), nameof(ViewController))]
- public void CreateControl(Func func, in IPopup virtualView)
- {
- Control = func(virtualView);
-
- SetPresentationController();
-
- _ = View ?? throw new InvalidOperationException($"{nameof(View)} cannot be null.");
- SetView(View, Control);
-
- _ = ViewController ?? throw new InvalidOperationException($"{nameof(ViewController)} cannot be null.");
- AddToCurrentPageViewController(ViewController);
-
- this.SetSize(virtualView);
- this.SetLayout(virtualView);
- }
-
- static void SetShadowView(in UIView target)
- {
- if (target.Class.Name is "_UICutoutShadowView")
- {
- target.RemoveFromSuperview();
- }
-
- if (target.Class.Name is "_UIPopoverDimmingView")
- {
- target.BackgroundColor = UIColor.Black.ColorWithAlpha(0.4f);
- }
-
- foreach (var view in target.Subviews)
- {
- SetShadowView(view);
- }
- }
-
- void SetView(UIView view, IPlatformViewHandler control)
- {
- view.AddSubview(control.ViewController?.View ?? throw new InvalidOperationException($"{nameof(control.ViewController.View)} cannot be null."));
- view.Bounds = new CGRect(0, 0, PreferredContentSize.Width, PreferredContentSize.Height);
- AddChildViewController(control.ViewController);
-
- view.SafeTopAnchor().ConstraintEqualTo(control.ViewController.View.SafeTopAnchor()).Active = true;
- view.SafeBottomAnchor().ConstraintEqualTo(control.ViewController.View.SafeBottomAnchor()).Active = true;
- view.SafeLeadingAnchor().ConstraintEqualTo(control.ViewController.View.SafeLeadingAnchor()).Active = true;
- view.SafeTrailingAnchor().ConstraintEqualTo(control.ViewController.View.SafeTrailingAnchor()).Active = true;
-
- if (VirtualView is not null)
- {
- this.SetBackgroundColor(VirtualView);
- }
- }
-
- void SetPresentationController()
- {
- var popOverDelegate = new PopoverDelegate();
- popOverDelegate.PopoverDismissedEvent += HandlePopoverDelegateDismissed;
-
- var presentationController = (UIPopoverPresentationController)(PresentationController ?? throw new InvalidOperationException($"{nameof(PresentationController)} cannot be null."));
- presentationController.SourceView = ViewController?.View ?? throw new InvalidOperationException($"{nameof(ViewController.View)} cannot be null.");
-
- presentationController.Delegate = popOverDelegate;
- }
-
- [MemberNotNull(nameof(VirtualView))]
- void HandlePopoverDelegateDismissed(object? sender, UIPresentationController e)
- {
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null.");
- VirtualView.Handler?.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup));
- }
-
- void AddToCurrentPageViewController(UIViewController viewController)
- {
- viewController.PresentViewController(this, true, null);
- }
-
- sealed class PopoverDelegate : UIPopoverPresentationControllerDelegate
- {
- readonly WeakEventManager popoverDismissedEventManager = new();
-
- public event EventHandler PopoverDismissedEvent
- {
- add => popoverDismissedEventManager.AddEventHandler(value);
- remove => popoverDismissedEventManager.RemoveEventHandler(value);
- }
-
- public override UIModalPresentationStyle GetAdaptivePresentationStyle(UIPresentationController forPresentationController) =>
- UIModalPresentationStyle.None;
-
- public override UIModalPresentationStyle GetAdaptivePresentationStyle(UIPresentationController controller, UITraitCollection traitCollection) =>
- UIModalPresentationStyle.None;
-
- public override void DidDismiss(UIPresentationController presentationController) =>
- popoverDismissedEventManager.HandleEvent(this, presentationController, nameof(PopoverDismissedEvent));
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
deleted file mode 100644
index 6c6b0129d9..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-using System.ComponentModel;
-using Microsoft.Maui.Platform;
-using Microsoft.Maui.Primitives;
-using Tizen.NUI;
-using Tizen.UIExtensions.NUI;
-using NHorizontalAlignment = Tizen.NUI.HorizontalAlignment;
-using NVerticalAlignment = Tizen.NUI.VerticalAlignment;
-
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// The native implementation of Popup control.
-///
-#if NET10_0_OR_GREATER
-#error Remove MauiPopup
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(MauiPopup)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public class MauiPopup : Popup
-{
- readonly IMauiContext mauiContext;
-
- ///
- /// Constructor of .
- ///
- /// An instance of .
- /// If is null an exception will be thrown.
- public MauiPopup(IMauiContext mauiContext)
- {
- this.mauiContext = mauiContext ?? throw new ArgumentNullException(nameof(mauiContext));
- OutsideClicked += OnOutsideClicked;
- }
-
- ///
- /// An instance of the .
- ///
- public IPopup? VirtualView { get; private set; }
-
- ///
- protected override void Dispose(bool isDisposing)
- {
- if (isDisposing)
- {
- OutsideClicked -= OnOutsideClicked;
- }
-
- base.Dispose(isDisposing);
- }
-
- ///
- /// Method to initialize the native implementation.
- ///
- /// An instance of .
- public void SetElement(IPopup? element)
- {
- VirtualView = element;
- }
-
- ///
- /// Method to show the Popup
- ///
- public void ShowPopup()
- {
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
- Content = VirtualView.Content?.ToPlatform(mauiContext) ?? throw new InvalidOperationException($"{nameof(VirtualView.Content)} cannot be null");
-
- BackgroundColor = new Tizen.NUI.Color(0.1f, 0.1f, 0.1f, 0.5f);
- Content.BackgroundColor = (VirtualView.Color ?? Colors.Transparent).ToNUIColor();
-
- if (VirtualView.Anchor is not null)
- {
- var anchorView = VirtualView.Anchor.ToPlatform();
- var anchorPosition = anchorView.ScreenPosition;
- Layout = new AbsoluteLayout();
- Content.UpdatePosition(new Tizen.UIExtensions.Common.Point(anchorPosition.X, anchorPosition.Y));
- }
- else
- {
- Layout = new LinearLayout
- {
- LinearOrientation = LinearLayout.Orientation.Vertical,
- VerticalAlignment = ToVerticalAlignment(VirtualView.VerticalOptions),
- HorizontalAlignment = ToHorizontalAlignment(VirtualView.Content.FlowDirection, VirtualView.HorizontalOptions),
- };
- Content.UpdatePosition(new Tizen.UIExtensions.Common.Point(0, 0));
- }
-
- UpdateContentSize();
-
- Open();
- VirtualView.OnOpened();
- }
-
- ///
- /// Method to update size of Content
- ///
- ///
- public void UpdateContentSize()
- {
- _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
- if (Content is null)
- {
- return;
- }
-
- if (VirtualView.Size.Width > 0 && VirtualView.Size.Height > 0)
- {
- Content.UpdateSize(VirtualView.Size.ToPixel());
- }
- else
- {
- var measured = VirtualView.Content?.Measure(double.PositiveInfinity, double.PositiveInfinity).ToPixel() ?? new Tizen.UIExtensions.Common.Size(0, 0);
- Content.UpdateSize(measured);
- }
- }
-
- static NVerticalAlignment ToVerticalAlignment(LayoutAlignment align) => align switch
- {
- LayoutAlignment.Start => NVerticalAlignment.Top,
- LayoutAlignment.End => NVerticalAlignment.Bottom,
- _ => NVerticalAlignment.Center
- };
-
- static NHorizontalAlignment ToHorizontalAlignment(FlowDirection direction, LayoutAlignment align) => align switch
- {
- LayoutAlignment.Start => direction == FlowDirection.RightToLeft ? NHorizontalAlignment.End : NHorizontalAlignment.Begin,
- LayoutAlignment.End => direction == FlowDirection.RightToLeft ? NHorizontalAlignment.Begin : NHorizontalAlignment.End,
- _ => NHorizontalAlignment.Center
- };
-
- void OnOutsideClicked(object? sender, EventArgs e)
- {
- if (VirtualView?.Handler is null)
- {
- return;
- }
-
- if (VirtualView.CanBeDismissedByTappingOutsideOfPopup)
- {
- Close();
- VirtualView.Handler?.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup));
- }
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
deleted file mode 100644
index 64d6d462d1..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.android.cs
+++ /dev/null
@@ -1,444 +0,0 @@
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using Android.Graphics.Drawables;
-using Android.Views;
-using CommunityToolkit.Maui.Core.Handlers;
-using Microsoft.Maui.Platform;
-using static Android.Views.ViewGroup;
-using AColorRes = Android.Resource.Color;
-using APoint = Android.Graphics.Point;
-using AView = Android.Views.View;
-using LayoutAlignment = Microsoft.Maui.Primitives.LayoutAlignment;
-
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// Extension class where Helper methods for Popup lives.
-///
-#if NET10_0_OR_GREATER
-#error Remove MauiPopup
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public static class PopupExtensions
-{
- ///
- /// Method to update the view.
- ///
- /// An instance of .
- /// An instance of .
- /// Width of Popup
- /// Height of Popup
- /// if the is null an exception will be thrown.
- public static void SetAnchor(this Dialog dialog, in IPopup popup, int? popupWidth = null, int? popupHeight = null)
- {
- var window = GetWindow(dialog);
-
- var windowManager = window.WindowManager;
- var statusBarHeight = GetStatusBarHeight(windowManager);
- var navigationBarHeight = GetNavigationBarHeight(windowManager);
- var windowSize = GetWindowSize(windowManager);
- var rotation = windowManager.DefaultDisplay?.Rotation ?? throw new InvalidOperationException("DefaultDisplay cannot be null");
- navigationBarHeight = windowSize.Height < windowSize.Width ? (rotation == SurfaceOrientation.Rotation270 ? navigationBarHeight : 0) : 0;
-
- if (popup.Handler?.MauiContext is null)
- {
- return;
- }
-
- if (popup.Anchor is not null)
- {
- var anchorView = popup.Anchor.ToPlatform();
-
- var locationOnScreen = new int[2];
- anchorView.GetLocationOnScreen(locationOnScreen);
- if (popupWidth is null && popupHeight is null)
- {
- window.DecorView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);
- }
-
- // This logic is tricky, please read these notes if you need to modify
- // Android window coordinate starts (0,0) at the top left and (max,max) at the bottom right. All of the positions
- // that are being handled in this operation assume the point is at the top left of the rectangle. This means the
- // calculation operates in this order:
- // 1. Calculate top-left position of Anchor
- // 2. Calculate the Actual Center of the Anchor by adding the width /2 and height / 2
- // 3. Calculate the top-left point of where the dialog should be positioned by subtracting the Width / 2 and height / 2
- // of the dialog that is about to be drawn.
- var attribute = window.Attributes ?? throw new InvalidOperationException($"{nameof(window.Attributes)} cannot be null");
-
- var newX = locationOnScreen[0] - navigationBarHeight + (anchorView.Width / 2) - (popupWidth == null ? (window.DecorView.Width / 2) : (int)(popupWidth / 2));
- var newY = locationOnScreen[1] - statusBarHeight + (anchorView.Height / 2) - (popupHeight == null ? (window.DecorView.Height / 2) : (int)(popupHeight / 2));
-
- if (!(newX == attribute.X &&
- newY == attribute.Y))
- {
- window.SetGravity(GravityFlags.Top | GravityFlags.Left);
- attribute.X = newX;
- attribute.Y = newY;
- window.Attributes = attribute;
- }
- }
- else
- {
- SetDialogPosition(popup, window);
- }
- }
-
- ///
- /// Method to update the property.
- ///
- /// An instance of .
- /// An instance of .
- public static void SetColor(this Dialog dialog, in IPopup popup)
- {
- if (popup.Color is null)
- {
- return;
- }
-
- var window = GetWindow(dialog);
- window.SetBackgroundDrawable(new ColorDrawable(popup.Color.ToPlatform(AColorRes.BackgroundLight, dialog.Context)));
- }
-
- ///
- /// Method to update the property.
- ///
- /// An instance of .
- /// An instance of .
- public static void SetCanBeDismissedByTappingOutsideOfPopup(this Dialog dialog, in IPopup popup)
- {
- dialog.SetCancelable(popup.CanBeDismissedByTappingOutsideOfPopup);
- dialog.SetCanceledOnTouchOutside(popup.CanBeDismissedByTappingOutsideOfPopup);
- }
-
- ///
- /// Method to update the property.
- ///
- /// An instance of .
- /// An instance of .
- /// The native representation of .
- /// An instance of .
- /// if the is null an exception will be thrown. If the is null an exception will be thrown.
- public static void SetSize(this Dialog dialog, in IPopup popup, in AView container, PopupHandler handler)
- {
- ArgumentNullException.ThrowIfNull(dialog);
- ArgumentNullException.ThrowIfNull(container);
- ArgumentNullException.ThrowIfNull(popup.Content);
- ArgumentNullException.ThrowIfNull(handler);
-
- var window = GetWindow(dialog);
- var context = dialog.Context;
- var windowManager = window.WindowManager;
-
- var decorView = (ViewGroup)window.DecorView;
-
- var windowSize = GetWindowSize(windowManager);
- int width = LayoutParams.WrapContent;
- int height = LayoutParams.WrapContent;
-
- if (popup.Size.IsZero)
- {
- if (double.IsNaN(popup.Content.Width) || double.IsNaN(popup.Content.Height))
- {
- if ((handler.LastPopupWidth == decorView.MeasuredWidth
- && handler.LastPopupHeight == decorView.MeasuredHeight)
- && Math.Abs(handler.LastWindowWidth - windowSize.Width) < 0.01 // Allow for floating point variation
- && Math.Abs(handler.LastWindowHeight - windowSize.Height) < 0.01) // Allow for floating point variation
- {
- SetAnchor(dialog, popup, handler.LastPopupWidth, handler.LastPopupHeight);
- return;
- }
-
- decorView.Measure(
- MeasureSpecMode.AtMost.MakeMeasureSpec((int)windowSize.Width),
- MeasureSpecMode.AtMost.MakeMeasureSpec((int)windowSize.Height)
- );
-
- if (double.IsNaN(popup.Content.Width))
- {
- if (popup.HorizontalOptions == LayoutAlignment.Fill)
- {
- width = (int)windowSize.Width;
- }
- else
- {
- if (decorView.MeasuredWidth >= windowSize.Width)
- {
- width = (int)windowSize.Width;
- }
- }
- }
- else
- {
- if (context.ToPixels(popup.Content.Width) >= windowSize.Width)
- {
- width = (int)windowSize.Width;
- }
- else
- {
- width = (int)context.ToPixels(popup.Content.Width);
- }
- }
-
- if (double.IsNaN(popup.Content.Height))
- {
- if (popup.VerticalOptions == LayoutAlignment.Fill)
- {
- height = (int)windowSize.Height;
- }
- else
- {
- if (decorView.MeasuredHeight >= windowSize.Height)
- {
- height = (int)windowSize.Height;
- }
- }
- }
- else
- {
- if (context.ToPixels(popup.Content.Height) >= windowSize.Height)
- {
- height = (int)windowSize.Height;
- }
- else
- {
- height = (int)context.ToPixels(popup.Content.Height);
- }
- }
-
- window.SetLayout(width, height);
-
- width = width == LayoutParams.WrapContent ? decorView.MeasuredWidth : width;
- height = height == LayoutParams.WrapContent ? decorView.MeasuredHeight : height;
- }
- else
- {
- width = (int)context.ToPixels(popup.Content.Width);
- height = (int)context.ToPixels(popup.Content.Height);
- width = width > windowSize.Width ? (int)windowSize.Width : width;
- height = height > windowSize.Height ? (int)windowSize.Height : height;
-
- if (handler.LastPopupWidth == width
- && handler.LastPopupHeight == height
- && Math.Abs(handler.LastWindowWidth - windowSize.Width) < 0.01 // Allow for floating point variation
- && Math.Abs(handler.LastWindowHeight - windowSize.Height) < 0.01)// Allow for floating point variation
- {
- SetAnchor(dialog, popup, handler.LastPopupWidth, handler.LastPopupHeight);
- return;
- }
-
- window.SetLayout(width, height);
-
- }
- }
- else
- {
- width = (int)context.ToPixels(popup.Size.Width);
- height = (int)context.ToPixels(popup.Size.Height);
- width = width > windowSize.Width ? (int)windowSize.Width : width;
- height = height > windowSize.Height ? (int)windowSize.Height : height;
-
- if (handler.LastPopupWidth == width
- && handler.LastPopupHeight == height
- && Math.Abs(handler.LastWindowWidth - windowSize.Width) < 0.01 // Allow for floating point variation
- && Math.Abs(handler.LastWindowHeight - windowSize.Height) < 0.01) // Allow for floating point variation
- {
- SetAnchor(dialog, popup, handler.LastPopupWidth, handler.LastPopupHeight);
- return;
- }
-
- window.SetLayout(width, height);
-
- }
-
- handler.LastPopupWidth = decorView.Width;
- handler.LastPopupHeight = decorView.Height;
- handler.LastWindowWidth = windowSize.Width;
- handler.LastWindowHeight = windowSize.Height;
-
- SetAnchor(dialog, popup, width, height);
- }
-
- static void SetDialogPosition(in IPopup popup, Window window)
- {
- var isFlowDirectionRightToLeft = popup.Content?.FlowDirection == FlowDirection.RightToLeft;
-
- var gravityFlags = popup.VerticalOptions switch
- {
- LayoutAlignment.Start => GravityFlags.Top,
- LayoutAlignment.End => GravityFlags.Bottom,
- LayoutAlignment.Center or LayoutAlignment.Fill => GravityFlags.CenterVertical,
- _ => throw new NotSupportedException($"{nameof(IPopup.VerticalOptions)}: {popup.VerticalOptions} is not yet supported")
- };
-
- gravityFlags |= popup.HorizontalOptions switch
- {
- LayoutAlignment.Start => isFlowDirectionRightToLeft ? GravityFlags.Right : GravityFlags.Left,
- LayoutAlignment.End => isFlowDirectionRightToLeft ? GravityFlags.Left : GravityFlags.Right,
- LayoutAlignment.Center or LayoutAlignment.Fill => GravityFlags.CenterHorizontal,
- _ => throw new NotSupportedException($"{nameof(IPopup.HorizontalOptions)}: {popup.HorizontalOptions} is not yet supported")
- };
-
- window.SetGravity(gravityFlags);
- }
-
- static Window GetWindow(in Dialog dialog) =>
- dialog.Window ?? throw new InvalidOperationException($"{nameof(Dialog)}.{nameof(Dialog.Window)} cannot be null");
-
- static Size GetWindowSize([NotNull] IWindowManager? windowManager)
- {
- ArgumentNullException.ThrowIfNull(windowManager);
-
- int windowWidth;
- int windowHeight;
- int statusBarHeight;
- int navigationBarHeight;
-
- if (OperatingSystem.IsAndroidVersionAtLeast(30))
- {
- var windowMetrics = windowManager.CurrentWindowMetrics;
- var windowInsets = windowMetrics.WindowInsets.GetInsetsIgnoringVisibility(WindowInsets.Type.SystemBars());
- windowWidth = windowMetrics.Bounds.Width();
- windowHeight = windowMetrics.Bounds.Height();
- statusBarHeight = windowInsets.Top;
- navigationBarHeight = windowHeight < windowWidth ? windowInsets.Left + windowInsets.Right : windowInsets.Bottom;
- }
- else if (windowManager.DefaultDisplay is null)
- {
- throw new InvalidOperationException($"{nameof(IWindowManager)}.{nameof(IWindowManager.DefaultDisplay)} cannot be null");
- }
- else
- {
- APoint realSize = new();
- APoint displaySize = new();
- APoint displaySmallSize = new();
- APoint displayLargeSize = new();
-
- windowManager.DefaultDisplay.GetRealSize(realSize);
- ArgumentNullException.ThrowIfNull(realSize);
-
- windowManager.DefaultDisplay.GetSize(displaySize);
- ArgumentNullException.ThrowIfNull(displaySize);
-
- windowManager.DefaultDisplay.GetCurrentSizeRange(displaySmallSize, displayLargeSize);
- ArgumentNullException.ThrowIfNull(displaySmallSize);
- ArgumentNullException.ThrowIfNull(displayLargeSize);
-
- windowWidth = realSize.X;
- windowHeight = realSize.Y;
-
- if (displaySize.X > displaySize.Y)
- {
- statusBarHeight = displaySize.Y - displaySmallSize.Y;
- }
- else
- {
- statusBarHeight = displaySize.Y - displayLargeSize.Y;
- }
-
- navigationBarHeight = realSize.Y < realSize.X
- ? (realSize.X - displaySize.X)
- : (realSize.Y - displaySize.Y);
- }
-
- windowWidth -= windowHeight < windowWidth
- ? navigationBarHeight
- : 0;
-
- windowHeight -= (windowHeight < windowWidth
- ? 0
- : navigationBarHeight)
- + statusBarHeight;
-
- return new Size(windowWidth, windowHeight);
- }
-
- static int GetNavigationBarHeight(IWindowManager? windowManager)
- {
- ArgumentNullException.ThrowIfNull(windowManager);
-
- int navigationBarHeight;
-
- if (OperatingSystem.IsAndroidVersionAtLeast(30))
- {
- var windowMetrics = windowManager.CurrentWindowMetrics;
- var windowInsets = windowMetrics.WindowInsets.GetInsetsIgnoringVisibility(WindowInsets.Type.SystemBars());
- var windowWidth = windowMetrics.Bounds.Width();
- var windowHeight = windowMetrics.Bounds.Height();
- navigationBarHeight = windowHeight < windowWidth ? windowInsets.Left + windowInsets.Right : windowInsets.Bottom;
- }
- else if (windowManager.DefaultDisplay is null)
- {
- throw new InvalidOperationException($"{nameof(IWindowManager)}.{nameof(IWindowManager.DefaultDisplay)} cannot be null");
- }
- else
- {
- APoint realSize = new();
- APoint displaySize = new();
- APoint displaySmallSize = new();
- APoint displayLargeSize = new();
-
- windowManager.DefaultDisplay.GetRealSize(realSize);
- ArgumentNullException.ThrowIfNull(realSize);
-
- windowManager.DefaultDisplay.GetSize(displaySize);
- ArgumentNullException.ThrowIfNull(displaySize);
-
- windowManager.DefaultDisplay.GetCurrentSizeRange(displaySmallSize, displayLargeSize);
- ArgumentNullException.ThrowIfNull(displaySmallSize);
- ArgumentNullException.ThrowIfNull(displayLargeSize);
-
- navigationBarHeight = realSize.Y < realSize.X
- ? (realSize.X - displaySize.X)
- : (realSize.Y - displaySize.Y);
- }
-
- return navigationBarHeight;
- }
-
- static int GetStatusBarHeight(IWindowManager? windowManager)
- {
- ArgumentNullException.ThrowIfNull(windowManager);
-
- int statusBarHeight;
-
- if (OperatingSystem.IsAndroidVersionAtLeast(30))
- {
- var windowMetrics = windowManager.CurrentWindowMetrics;
- var windowInsets = windowMetrics.WindowInsets.GetInsetsIgnoringVisibility(WindowInsets.Type.SystemBars());
- statusBarHeight = windowInsets.Top;
- }
- else if (windowManager.DefaultDisplay is null)
- {
- throw new InvalidOperationException($"{nameof(IWindowManager)}.{nameof(IWindowManager.DefaultDisplay)} cannot be null");
- }
- else
- {
- APoint realSize = new();
- APoint displaySize = new();
- APoint displaySmallSize = new();
- APoint displayLargeSize = new();
-
- windowManager.DefaultDisplay.GetRealSize(realSize);
- ArgumentNullException.ThrowIfNull(realSize);
-
- windowManager.DefaultDisplay.GetSize(displaySize);
- ArgumentNullException.ThrowIfNull(displaySize);
-
- windowManager.DefaultDisplay.GetCurrentSizeRange(displaySmallSize, displayLargeSize);
- ArgumentNullException.ThrowIfNull(displaySmallSize);
- ArgumentNullException.ThrowIfNull(displayLargeSize);
-
- if (displaySize.X > displaySize.Y)
- {
- statusBarHeight = displaySize.Y - displaySmallSize.Y;
- }
- else
- {
- statusBarHeight = displaySize.Y - displayLargeSize.Y;
- }
- }
-
- return statusBarHeight;
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
deleted file mode 100644
index dd14e0d74c..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.macios.cs
+++ /dev/null
@@ -1,255 +0,0 @@
-using System.ComponentModel;
-using Microsoft.Maui.Platform;
-using ObjCRuntime;
-
-namespace CommunityToolkit.Maui.Core.Views;
-///
-/// Extension class where Helper methods for Popup lives.
-///
-#if NET10_0_OR_GREATER
-#error Remove PopupExtensions
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public static class PopupExtensions
-{
- static readonly nfloat defaultPopoverLayoutMargin = 0.0001f;
-
-#if MACCATALYST
- // https://github.com/CommunityToolkit/Maui/pull/1361#issuecomment-1736487174
- static nfloat popupMargin = 18f;
-#endif
-
-
- ///
- /// Method to update the of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- public static void SetSize(this MauiPopup mauiPopup, in IPopup popup)
- {
- ArgumentNullException.ThrowIfNull(popup.Content);
-
- CGRect frame;
-
- if (mauiPopup.ViewController?.View?.Window is UIWindow window)
- {
- frame = window.Frame;
- }
- else
- {
- frame = UIScreen.MainScreen.Bounds;
- }
-
- CGSize currentSize;
-
- if (popup.Size.IsZero)
- {
- if (double.IsNaN(popup.Content.Width) || double.IsNaN(popup.Content.Height))
- {
- var content = popup.Content.ToPlatform(popup.Handler?.MauiContext ?? throw new InvalidOperationException($"{nameof(popup.Handler.MauiContext)} Cannot Be Null"));
- var contentSize = content.SizeThatFits(new CGSize(double.IsNaN(popup.Content.Width) ? frame.Width : popup.Content.Width, double.IsNaN(popup.Content.Height) ? frame.Height : popup.Content.Height));
- var width = contentSize.Width;
- var height = contentSize.Height;
-
- if (double.IsNaN(popup.Content.Width))
- {
- width = popup.HorizontalOptions == Microsoft.Maui.Primitives.LayoutAlignment.Fill ? frame.Size.Width : width;
- }
- if (double.IsNaN(popup.Content.Height))
- {
- height = popup.VerticalOptions == Microsoft.Maui.Primitives.LayoutAlignment.Fill ? frame.Size.Height : height;
- }
-
- currentSize = new CGSize(width, height);
- }
- else
- {
- currentSize = new CGSize(popup.Content.Width, popup.Content.Height);
- }
- }
- else
- {
- currentSize = new CGSize(popup.Size.Width, popup.Size.Height);
- }
-
-#if MACCATALYST
- currentSize.Width = NMath.Min(currentSize.Width, frame.Size.Width - defaultPopoverLayoutMargin * 2 - popupMargin * 2);
- currentSize.Height = NMath.Min(currentSize.Height, frame.Size.Height - defaultPopoverLayoutMargin * 2 - popupMargin * 2);
-#else
- currentSize.Width = NMath.Min(currentSize.Width, frame.Size.Width);
- currentSize.Height = NMath.Min(currentSize.Height, frame.Size.Height);
-#endif
- mauiPopup.PreferredContentSize = currentSize;
- }
-
- ///
- /// Method to update the of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- public static void SetBackgroundColor(this MauiPopup mauiPopup, in IPopup popup)
- {
- if (mauiPopup.PopoverPresentationController is not null && Equals(popup.Color, Colors.Transparent))
- {
- mauiPopup.PopoverPresentationController.PopoverBackgroundViewType = typeof(TransparentPopoverBackgroundView);
- }
-
- if (mauiPopup.Control is null)
- {
- return;
- }
-
- var color = popup.Color?.ToPlatform();
- mauiPopup.Control.PlatformView.BackgroundColor = color;
-
- if (mauiPopup.Control.ViewController?.View is UIView view)
- {
- view.BackgroundColor = color;
- }
- }
-
- ///
- /// Method to update the property of the Popup.
- ///
- /// An instance of .
- /// An instance of .
- public static void SetCanBeDismissedByTappingOutsideOfPopup(this MauiPopup mauiPopup, in IPopup popup)
- {
- if (OperatingSystem.IsIOSVersionAtLeast(13))
- {
- mauiPopup.ModalInPresentation = !popup.CanBeDismissedByTappingOutsideOfPopup;
- }
- }
-
- ///
- /// Method to update the layout of the Popup and .
- ///
- /// An instance of .
- /// An instance of .
- public static void SetLayout(this MauiPopup mauiPopup, in IPopup popup)
- {
- if (mauiPopup.View is null)
- {
- return;
- }
-
- CGRect frame;
-
- if (mauiPopup.ViewController?.View?.Window is UIWindow window)
- {
- frame = window.Frame;
- }
- else
- {
- frame = UIScreen.MainScreen.Bounds;
- }
-
- if (mauiPopup.PopoverPresentationController is null)
- {
- throw new InvalidOperationException("PopoverPresentationController cannot be null");
- }
-
-#if MACCATALYST
- var titleBarHeight = mauiPopup.ViewController?.NavigationController?.NavigationBar.Frame.Y ?? 0;
- var navigationBarHeight = mauiPopup.ViewController?.NavigationController?.NavigationBar.Frame.Size.Height ?? 0;
-#endif
-
- if (popup.Anchor is null)
- {
- var isFlowDirectionRightToLeft = popup.Content?.FlowDirection == FlowDirection.RightToLeft;
- var horizontalOptionsPositiveNegativeMultiplier = isFlowDirectionRightToLeft ? (nfloat)(-1) : (nfloat)1;
-
- nfloat originY;
- if (mauiPopup.PreferredContentSize.Height < frame.Height)
- {
- originY = popup.VerticalOptions switch
- {
-#if MACCATALYST
- Microsoft.Maui.Primitives.LayoutAlignment.Start => mauiPopup.PreferredContentSize.Height / 2 - (titleBarHeight + navigationBarHeight - popupMargin),
- Microsoft.Maui.Primitives.LayoutAlignment.End => frame.Height - mauiPopup.PreferredContentSize.Height / 2 - (titleBarHeight + navigationBarHeight + popupMargin),
- Microsoft.Maui.Primitives.LayoutAlignment.Center or Microsoft.Maui.Primitives.LayoutAlignment.Fill => frame.GetMidY() - (titleBarHeight + navigationBarHeight),
-#else
- Microsoft.Maui.Primitives.LayoutAlignment.Start => mauiPopup.PreferredContentSize.Height / 2,
- Microsoft.Maui.Primitives.LayoutAlignment.End => frame.Height - (mauiPopup.PreferredContentSize.Height / 2),
- Microsoft.Maui.Primitives.LayoutAlignment.Center or Microsoft.Maui.Primitives.LayoutAlignment.Fill => frame.GetMidY(),
-#endif
- _ => throw new NotSupportedException($"{nameof(Microsoft.Maui.Primitives.LayoutAlignment)} {popup.VerticalOptions} is not yet supported")
- };
- }
- else
- {
- originY = -frame.GetMidY();
- }
-
- nfloat originX;
- if (mauiPopup.PreferredContentSize.Width < frame.Width)
- {
- originX = popup.HorizontalOptions switch
- {
-#if MACCATALYST
- Microsoft.Maui.Primitives.LayoutAlignment.Start => (frame.Width - frame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (mauiPopup.PreferredContentSize.Width - mauiPopup.PreferredContentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (popupMargin - popupMargin * horizontalOptionsPositiveNegativeMultiplier),
- Microsoft.Maui.Primitives.LayoutAlignment.End => (frame.Width + frame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (mauiPopup.PreferredContentSize.Width + mauiPopup.PreferredContentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (popupMargin + popupMargin * horizontalOptionsPositiveNegativeMultiplier),
- Microsoft.Maui.Primitives.LayoutAlignment.Center or Microsoft.Maui.Primitives.LayoutAlignment.Fill => frame.GetMidX() - mauiPopup.PreferredContentSize.Width / 2 - popupMargin,
-#else
- Microsoft.Maui.Primitives.LayoutAlignment.Start => (frame.Width - frame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (mauiPopup.PreferredContentSize.Width / 2 - mauiPopup.PreferredContentSize.Width / 2 * horizontalOptionsPositiveNegativeMultiplier) / 2,
- Microsoft.Maui.Primitives.LayoutAlignment.End => (frame.Width + frame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - (mauiPopup.PreferredContentSize.Width / 2 + mauiPopup.PreferredContentSize.Width / 2 * horizontalOptionsPositiveNegativeMultiplier) / 2,
- Microsoft.Maui.Primitives.LayoutAlignment.Center or Microsoft.Maui.Primitives.LayoutAlignment.Fill => frame.GetMidX(),
-#endif
- _ => throw new NotSupportedException($"{nameof(Microsoft.Maui.Primitives.LayoutAlignment)} {popup.VerticalOptions} is not yet supported")
- };
- }
- else
- {
- originX = -frame.GetMidX();
- }
-
- if (mauiPopup.ViewController?.PopoverPresentationController is UIPopoverPresentationController popoverPresentationController)
- {
- mauiPopup.PopoverPresentationController.SourceView = popoverPresentationController.SourceView;
- }
- mauiPopup.PopoverPresentationController.SourceRect = new CGRect(originX, originY, 0, 0);
- mauiPopup.PopoverPresentationController.PermittedArrowDirections = 0;
- // From the point of view of usability, the top, bottom, left, and right values of UIEdgeInsets cannot all be 0.
- // If you specify 0 for the top, bottom, left, and right of UIEdgeInsets, the default margins will be added, so
- // specify a value as close to 0 here as possible.
- mauiPopup.PopoverPresentationController.PopoverLayoutMargins = new UIEdgeInsets(defaultPopoverLayoutMargin, defaultPopoverLayoutMargin, defaultPopoverLayoutMargin, defaultPopoverLayoutMargin);
- }
- else
- {
- var view = popup.Anchor.ToPlatform(popup.Handler?.MauiContext ?? throw new InvalidOperationException($"{nameof(popup.Handler.MauiContext)} Cannot Be Null"));
- mauiPopup.PopoverPresentationController.SourceView = view;
- mauiPopup.PopoverPresentationController.SourceRect = view.Bounds;
- }
- }
-
- sealed class TransparentPopoverBackgroundView : UIPopoverBackgroundView
- {
- public TransparentPopoverBackgroundView(IntPtr handle) : base(handle)
- {
- BackgroundColor = Colors.Transparent.ToPlatform();
- Alpha = 0.0f;
- }
-
- public override nfloat ArrowOffset { get; set; }
-
- public override UIPopoverArrowDirection ArrowDirection { get; set; }
-
- [Export("arrowHeight")]
- static new float GetArrowHeight()
- {
- return 0f;
- }
-
- [Export("arrowBase")]
- static new float GetArrowBase()
- {
- return 0f;
- }
-
- [Export("contentViewInsets")]
- static new UIEdgeInsets GetContentViewInsets()
- {
- return UIEdgeInsets.Zero;
- }
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
deleted file mode 100644
index 1bf50b9f24..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupExtensions.windows.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-using System.ComponentModel;
-using CommunityToolkit.Maui.Core.Handlers;
-using Microsoft.Maui.Platform;
-using Microsoft.Maui.Primitives;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Controls.Primitives;
-
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// Extension class where Helper methods for Popup lives.
-///
-#if NET10_0_OR_GREATER
-#error Remove PopupExtensions
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(PopupExtensions)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-public static class PopupExtensions
-{
- ///
- /// Method to update the based on the .
- ///
- /// An instance of .
- /// An instance of .
- public static void SetColor(this Popup mauiPopup, IPopup popup)
- {
- ArgumentNullException.ThrowIfNull(popup.Content);
-
- var color = popup.Color ?? Colors.Transparent;
- if (mauiPopup.Child is Panel panel)
- {
- panel.Background = color.ToPlatform();
- }
- }
-
- ///
- /// Method to update the popup anchor based on the .
- ///
- /// An instance of .
- /// An instance of .
- /// An instance of .
- public static void SetAnchor(this Popup mauiPopup, IPopup popup, IMauiContext? mauiContext)
- {
- ArgumentNullException.ThrowIfNull(mauiContext);
- mauiPopup.PlacementTarget = popup.Anchor?.ToPlatform(mauiContext);
- }
-
- ///
- /// Method to prepare control.
- ///
- /// An instance of .
- /// An instance of .
- /// An instance of .
- public static void ConfigureControl(this Popup mauiPopup, IPopup popup, IMauiContext? mauiContext)
- {
- ArgumentNullException.ThrowIfNull(mauiContext);
- if (popup.Content is not null && popup.Handler is PopupHandler handler)
- {
- mauiPopup.Child = handler.VirtualView.Content?.ToPlatform(mauiContext);
- }
-
- mauiPopup.SetSize(popup, mauiContext);
- mauiPopup.SetLayout(popup, mauiContext);
- }
-
- ///
- /// Method to update the popup size based on the .
- ///
- /// An instance of .
- /// An instance of .
- /// An instance of .
- public static void SetSize(this Popup mauiPopup, IPopup popup, IMauiContext? mauiContext)
- {
- ArgumentNullException.ThrowIfNull(mauiContext);
- ArgumentNullException.ThrowIfNull(popup.Content);
-
- const double defaultBorderThickness = 0;
- const double defaultSize = 600;
-
- var popupParent = mauiContext.GetPlatformWindow();
- var currentSize = new Size { Width = defaultSize, Height = defaultSize / 2 };
-
- if (popup.Size.IsZero)
- {
- if (double.IsNaN(popup.Content.Width) || (double.IsNaN(popup.Content.Height)))
- {
- currentSize = popup.Content.Measure(double.IsNaN(popup.Content.Width) ? popupParent.Bounds.Width : popup.Content.Width, double.IsNaN(popup.Content.Height) ? popupParent.Bounds.Height : popup.Content.Height);
-
- if (double.IsNaN(popup.Content.Width))
- {
- currentSize.Width = popup.HorizontalOptions == LayoutAlignment.Fill ? popupParent.Bounds.Width : currentSize.Width;
- }
- if (double.IsNaN(popup.Content.Height))
- {
- currentSize.Height = popup.VerticalOptions == LayoutAlignment.Fill ? popupParent.Bounds.Height : currentSize.Height;
- }
- }
- else
- {
- currentSize.Width = popup.Content.Width;
- currentSize.Height = popup.Content.Height;
- }
- }
- else
- {
- currentSize.Width = popup.Size.Width;
- currentSize.Height = popup.Size.Height;
- }
-
- currentSize.Width = Math.Min(currentSize.Width, popupParent.Bounds.Width);
- currentSize.Height = Math.Min(currentSize.Height, popupParent.Bounds.Height);
-
- mauiPopup.Width = currentSize.Width;
- mauiPopup.Height = currentSize.Height;
- mauiPopup.MinWidth = mauiPopup.MaxWidth = currentSize.Width + (defaultBorderThickness * 2);
- mauiPopup.MinHeight = mauiPopup.MaxHeight = currentSize.Height + (defaultBorderThickness * 2);
-
- if (mauiPopup.Child is FrameworkElement control)
- {
- control.Width = mauiPopup.Width;
- control.Height = mauiPopup.Height;
- }
- }
-
- ///
- /// Method to update the popup layout.
- ///
- /// An instance of .
- /// An instance of .
- /// An instance of .
- public static void SetLayout(this Popup mauiPopup, IPopup popup, IMauiContext? mauiContext)
- {
- ArgumentNullException.ThrowIfNull(mauiContext);
- ArgumentNullException.ThrowIfNull(popup.Content);
-
- var popupParent = mauiContext.GetPlatformWindow();
- popup.Content.Measure(double.PositiveInfinity, double.PositiveInfinity);
- var contentSize = popup.Content.ToPlatform(mauiContext).DesiredSize;
- var popupParentFrame = popupParent.Bounds;
-
- var isFlowDirectionRightToLeft = popup.Content?.FlowDirection == Microsoft.Maui.FlowDirection.RightToLeft;
- var horizontalOptionsPositiveNegativeMultiplier = isFlowDirectionRightToLeft ? -1 : 1;
-
- var verticalOptions = popup.VerticalOptions;
- var horizontalOptions = popup.HorizontalOptions;
- if (popup.Anchor is not null)
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Top;
- }
- else if (IsTopLeft(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.TopEdgeAlignedLeft;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = 0;
- }
- else if (IsTop(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Top;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = 0;
- }
- else if (IsTopRight(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.TopEdgeAlignedRight;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width + popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier;
- mauiPopup.VerticalOffset = 0;
- }
- else if (IsRight(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Right;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width + popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsBottomRight(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.BottomEdgeAlignedRight;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width + popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier;
- mauiPopup.VerticalOffset = popupParentFrame.Height - contentSize.Height;
- }
- else if (IsBottom(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Bottom;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = popupParentFrame.Height - contentSize.Height;
- }
- else if (IsBottomLeft(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.BottomEdgeAlignedLeft;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = popupParentFrame.Height - contentSize.Height;
- }
- else if (IsLeft(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Left;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsCenter(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsFillLeft(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsFillCenter(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsFillRight(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width + popupParentFrame.Width * horizontalOptionsPositiveNegativeMultiplier) / 2 - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsTopFill(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = 0;
- }
- else if (IsCenterFill(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else if (IsBottomFill(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = popupParentFrame.Height - contentSize.Height;
- }
- else if (IsFill(verticalOptions, horizontalOptions))
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
- else
- {
- mauiPopup.DesiredPlacement = PopupPlacementMode.Auto;
- mauiPopup.HorizontalOffset = (popupParentFrame.Width - contentSize.Width * horizontalOptionsPositiveNegativeMultiplier) / 2;
- mauiPopup.VerticalOffset = (popupParentFrame.Height - contentSize.Height) / 2;
- }
-
- static bool IsTopLeft(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Start && horizontalOptions == LayoutAlignment.Start;
- static bool IsTop(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Start && horizontalOptions == LayoutAlignment.Center;
- static bool IsTopRight(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Start && horizontalOptions == LayoutAlignment.End;
- static bool IsRight(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Center && horizontalOptions == LayoutAlignment.End;
- static bool IsBottomRight(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.End && horizontalOptions == LayoutAlignment.End;
- static bool IsBottom(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.End && horizontalOptions == LayoutAlignment.Center;
- static bool IsBottomLeft(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.End && horizontalOptions == LayoutAlignment.Start;
- static bool IsLeft(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Center && horizontalOptions == LayoutAlignment.Start;
- static bool IsCenter(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Center && horizontalOptions == LayoutAlignment.Center;
- static bool IsFillLeft(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Fill && horizontalOptions == LayoutAlignment.Start;
- static bool IsFillCenter(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Fill && horizontalOptions == LayoutAlignment.Center;
- static bool IsFillRight(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Fill && horizontalOptions == LayoutAlignment.End;
- static bool IsTopFill(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Start && horizontalOptions == LayoutAlignment.Fill;
- static bool IsCenterFill(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Center && horizontalOptions == LayoutAlignment.Fill;
- static bool IsBottomFill(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.End && horizontalOptions == LayoutAlignment.Fill;
- static bool IsFill(LayoutAlignment verticalOptions, LayoutAlignment horizontalOptions) => verticalOptions == LayoutAlignment.Fill && horizontalOptions == LayoutAlignment.Fill;
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
deleted file mode 100644
index a72d4896d5..0000000000
--- a/src/CommunityToolkit.Maui.Core/Views/Popup/PopupOverlay.windows.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System.ComponentModel;
-namespace CommunityToolkit.Maui.Core.Views;
-
-///
-/// Displays Overlay in the Popup background.
-///
-#if NET10_0_OR_GREATER
-#error Remove PopupOverlay
-#endif
-[EditorBrowsable(EditorBrowsableState.Never), Obsolete($"{nameof(PopupOverlay)} is no longer used by {nameof(CommunityToolkit)}.{nameof(Maui)} and will be removed in .NET 10")]
-class PopupOverlay : WindowOverlay
-{
- readonly IWindowOverlayElement popupOverlayElement;
-
- ///
- /// Instantiates a new instance of .
- ///
- /// An instance of .
- /// Popup overlay color
- public PopupOverlay(IWindow window, Color? overlayColor = null) : base(window)
- {
- popupOverlayElement = new PopupOverlayElement(this, overlayColor);
-
- AddWindowElement(popupOverlayElement);
-
- EnableDrawableTouchHandling = true;
- }
-
- class PopupOverlayElement : IWindowOverlayElement
- {
- readonly IWindowOverlay overlay;
- readonly Color overlayColor = Color.FromRgba(255, 255, 255, 153); // 60% Opacity
-
- RectF overlayRect = new();
-
- public PopupOverlayElement(IWindowOverlay overlay, Color? overlayColor = null)
- {
- this.overlay = overlay;
- if (overlayColor is not null)
- {
- this.overlayColor = overlayColor;
- }
- }
-
- public bool Contains(Point point)
- {
- return overlayRect.Contains(new Point(point.X / overlay.Density, point.Y / overlay.Density));
- }
-
- public void Draw(ICanvas canvas, RectF dirtyRect)
- {
- overlayRect = dirtyRect;
- canvas.FillColor = overlayColor;
- canvas.FillRectangle(dirtyRect.X, dirtyRect.Y, dirtyRect.Width, dirtyRect.Height);
- }
- }
-}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
index 352e8fdee0..1ff46e819c 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.macios.cs
@@ -317,7 +317,7 @@ void SetPoster()
return;
}
- var videoTrack = PlayerItem.Asset.TracksWithMediaType(AVMediaTypes.Video.GetConstant()).FirstOrDefault();
+ var videoTrack = PlayerItem.Asset.TracksWithMediaType(AVMediaTypes.Video.GetConstant() ?? new NSString("0")).FirstOrDefault();
if (videoTrack is not null)
{
return;
@@ -512,7 +512,7 @@ protected virtual void Dispose(bool disposing)
var asset = avPlayerItem.Asset;
// Retrieve the video track
- var videoTrack = asset.TracksWithMediaType(AVMediaTypes.Video.GetConstant()).FirstOrDefault();
+ var videoTrack = asset.TracksWithMediaType(AVMediaTypes.Video.GetConstant() ?? new NSString("0")).FirstOrDefault();
if (videoTrack is not null)
{
diff --git a/src/CommunityToolkit.Maui/Options.cs b/src/CommunityToolkit.Maui/Options.cs
index 2d8d319694..879d9d48cd 100644
--- a/src/CommunityToolkit.Maui/Options.cs
+++ b/src/CommunityToolkit.Maui/Options.cs
@@ -11,12 +11,7 @@ namespace CommunityToolkit.Maui;
///
/// .NET MAUI Community Toolkit Options.
///
-#if NET9_0
-public class Options() : Core.Options
-#elif NET10_OR_GREATER
-#error Remove .NET 9 code now that we're upgrading to .NET 10; Options should not have a public constructor, only public methods. Having a public constructor allows developers to override the values set when using AppBuilderExtensions
public class Options : Core.Options
-#endif
{
readonly MauiAppBuilder? builder;
@@ -25,6 +20,11 @@ internal Options(in MauiAppBuilder builder) : this()
this.builder = builder;
}
+ internal Options()
+ {
+
+ }
+
internal static bool ShouldSuppressExceptionsInAnimations { get; private set; }
internal static bool ShouldSuppressExceptionsInConverters { get; private set; }
internal static bool ShouldSuppressExceptionsInBehaviors { get; private set; }
diff --git a/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs b/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs
index 674d53350e..9b4899a3a9 100644
--- a/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs
+++ b/src/CommunityToolkit.Maui/Views/AvatarView.shared.cs
@@ -2,6 +2,7 @@
using CommunityToolkit.Maui.Core;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Shapes;
+using ILineHeightElement = Microsoft.Maui.Controls.ILineHeightElement;
namespace CommunityToolkit.Maui.Views;
From d438f9c91490b9e4a0e637ae1bb522b51e2d70b7 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 10:09:06 -0700
Subject: [PATCH 02/41] Update CSharpCodeFixVerifier`2+Test.cs
---
.../Verifiers/CSharpCodeFixVerifier`2+Test.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
index 81797f7ab1..51083757d6 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
@@ -13,8 +13,8 @@ protected class Test : CSharpCodeFixTest
{
public Test(params ReadOnlySpan assembliesUnderTest)
{
-#if NET9_0
- ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
+#if NET10_0
+ ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
From fcf2e952ff902faba2f7a60a9f4bca47efe93a62 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 10:13:59 -0700
Subject: [PATCH 03/41] Fix Unit Test
---
.../Views/AvatarView/AvatarViewInterfaceTests.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CommunityToolkit.Maui.UnitTests/Views/AvatarView/AvatarViewInterfaceTests.cs b/src/CommunityToolkit.Maui.UnitTests/Views/AvatarView/AvatarViewInterfaceTests.cs
index 72575d466a..1223da88ff 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Views/AvatarView/AvatarViewInterfaceTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Views/AvatarView/AvatarViewInterfaceTests.cs
@@ -296,7 +296,7 @@ public void ILineHeightElementOnLineHeightChanged()
{
// For code coverage
var avatarView = new Maui.Views.AvatarView();
- ((Microsoft.Maui.Controls.Internals.ILineHeightElement)avatarView).OnLineHeightChanged(0.0, 3.7);
+ ((ILineHeightElement)avatarView).OnLineHeightChanged(0.0, 3.7);
avatarView.Text.Should().Be("?");
}
}
\ No newline at end of file
From bfefeb268ed6180024dfd601588a1f8d99b47298 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 10:19:55 -0700
Subject: [PATCH 04/41] Update Verifiers
---
.../Verifiers/CSharpAnalyzerVerifier`1+Test.cs | 6 +++---
.../Verifiers/CSharpCodeFixVerifier`2+Test.cs | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
index c0936edd28..f6a2f0eca2 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
@@ -6,12 +6,12 @@ namespace CommunityToolkit.Maui.Analyzers.UnitTests;
public static partial class CSharpAnalyzerVerifier
where TAnalyzer : DiagnosticAnalyzer, new()
{
- public class Test : CSharpAnalyzerTest
+ class Test : CSharpAnalyzerTest
{
public Test(params ReadOnlySpan assembliesUnderTest)
{
-#if NET9_0
- ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
+#if NET10_0
+ ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
index 51083757d6..4a509c8928 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
@@ -9,7 +9,7 @@ public static partial class CSharpCodeFixVerifier
where TAnalyzer : DiagnosticAnalyzer, new()
where TCodeFix : CodeFixProvider, new()
{
- protected class Test : CSharpCodeFixTest
+ class Test : CSharpCodeFixTest
{
public Test(params ReadOnlySpan assembliesUnderTest)
{
From 7fe076c0d760066fb086f49b36fb6760cc5ce21f Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 10:26:00 -0700
Subject: [PATCH 05/41] Downgrade
`Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net`
---
.../Verifiers/CSharpAnalyzerVerifier`1+Test.cs | 2 +-
.../Verifiers/CSharpCodeFixVerifier`2+Test.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
index f6a2f0eca2..087bc878ce 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
@@ -11,7 +11,7 @@ class Test : CSharpAnalyzerTest assembliesUnderTest)
{
#if NET10_0
- ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100;
+ ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
index 4a509c8928..20fc05eb01 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
@@ -14,7 +14,7 @@ class Test : CSharpCodeFixTest
public Test(params ReadOnlySpan assembliesUnderTest)
{
#if NET10_0
- ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net100;
+ ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
From fbbcf5d6a390a4b3f358f7aa2c15263b61f999e9 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 11:38:31 -0700
Subject: [PATCH 06/41] Keep Compiler Error for
`Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net`
---
.../Verifiers/CSharpAnalyzerVerifier`1+Test.cs | 2 +-
.../Verifiers/CSharpCodeFixVerifier`2+Test.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
index 087bc878ce..cd137fb848 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
@@ -10,7 +10,7 @@ class Test : CSharpAnalyzerTest assembliesUnderTest)
{
-#if NET10_0
+#if NET9
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
index 20fc05eb01..4751c06c52 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
@@ -13,7 +13,7 @@ class Test : CSharpCodeFixTest
{
public Test(params ReadOnlySpan assembliesUnderTest)
{
-#if NET10_0
+#if NET9
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
#else
#error ReferenceAssemblies must be updated to current version of .NET
From 60ccda67e8573c6c287f7371694bda476f2c9d06 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 7 Oct 2025 11:53:22 -0700
Subject: [PATCH 07/41] Update Directory.Build.props
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 7837d99bc1..23f2b2083b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -203,7 +203,7 @@
IL2090,IL2091,IL2092,IL2093,IL2094,IL2095,IL2096,IL2097,IL2098,IL2099,
IL2100,IL2101,IL2102,IL2103,IL2104,IL2105,IL2106,IL2107,IL2108,IL2109,
IL2110,IL2111,IL2112,IL2113,IL2114,IL2115,IL2116,IL2117,IL2118,IL2119,
- IL2120,IL2121,IL2122,
+ IL2120,IL2121,IL2122,IL2123,
IL3050,IL3051,IL3052,IL3053,IL3054,IL3055,IL3056,
RS1038,RS2007
From e271c71ed7b139a347d5c6b3c6e8cf6a99c6ce0b Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Thu, 9 Oct 2025 14:54:23 -0700
Subject: [PATCH 08/41] Remove AOT
---
.../CommunityToolkit.Maui.Sample.csproj | 12 +++++-------
samples/CommunityToolkit.Maui.Sample/MauiProgram.cs | 4 +---
...uchBehaviorCollectionViewMultipleSelectionPage.cs | 5 ++---
.../Pages/Views/Expander/ExpanderPage.xaml.cs | 3 +--
.../Pages/Views/Expander/ExpanderPageCS.cs | 3 +--
.../Platforms/MacCatalyst/AppDelegate.cs | 4 ----
.../Platforms/iOS/AppDelegate.cs | 4 ----
.../Views/Expander/Expander.shared.cs | 1 -
8 files changed, 10 insertions(+), 26 deletions(-)
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index df5c7eb324..e2da400ff6 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -36,13 +36,11 @@
-
-
-
- true
+ AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
+
+ false
+ true
+ partial
diff --git a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
index 1dd763355a..a8231b0d62 100644
--- a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
+++ b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
@@ -47,7 +47,6 @@ namespace CommunityToolkit.Maui.Sample;
public static class MauiProgram
{
- [RequiresUnreferencedCode($"{nameof(CommunityToolkit.Maui.Views.Expander)} and {nameof(TouchBehaviorCollectionViewMultipleSelectionPage)} are not type safe")]
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder()
@@ -135,8 +134,7 @@ public static MauiApp CreateMauiApp()
return builder.Build();
}
-
- [RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Sample.MauiProgram.AddTransientWithShellRoute()")]
+
static void RegisterViewsAndViewModels(in IServiceCollection services)
{
// Add Gallery Pages + ViewModels
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
index 00acf9fdee..250a690f3f 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
@@ -6,11 +6,11 @@
namespace CommunityToolkit.Maui.Sample.Pages.Behaviors;
-[RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Markup.BindableObjectExtensions.Bind(BindableProperty, String, BindingMode, IValueConverter, Object, String, Object, Object, Object)")]
public partial class TouchBehaviorCollectionViewMultipleSelectionPage : BasePage
{
readonly CollectionView collectionView;
+ [RequiresUnreferencedCode("")]
public TouchBehaviorCollectionViewMultipleSelectionPage(TouchBehaviorCollectionViewMultipleSelectionViewModel viewModel) : base(viewModel)
{
Content = new VerticalStackLayout
@@ -37,8 +37,7 @@ async void HandleSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
await Toast.Make($"Number of Creators Selected: {collectionView.SelectedItems?.Count ?? 0}").Show();
}
-
-
+
[RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Markup.BindableObjectExtensions.Bind(BindableProperty, String, BindingMode, IValueConverter, Object, String, Object, Object, Object)")]
sealed class CreatorsDataTemplate(TouchBehaviorCollectionViewMultipleSelectionViewModel viewModel) : DataTemplate(() => CreateLayout(viewModel))
{
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
index 9239102530..4079dc7b68 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
@@ -4,8 +4,6 @@
namespace CommunityToolkit.Maui.Sample.Pages.Views;
-[RequiresUnreferencedCode("Expander is not trim safe")]
-[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public partial class ExpanderPage : BasePage
{
public ExpanderPage(ExpanderViewModel viewModel) : base(viewModel)
@@ -19,6 +17,7 @@ async void Expander_ExpandedChanged(object sender, Core.ExpandedChangedEventArgs
await Toast.Make($"Expander is {collapsedText}").Show(CancellationToken.None);
}
+ [RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Sample.Pages.Views.ExpanderPageCS.ExpanderPageCS()")]
async void GoToCSharpSampleClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new ExpanderPageCS());
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
index 4725207cd2..c9ede7bf65 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
@@ -5,10 +5,9 @@
namespace CommunityToolkit.Maui.Sample.Pages.Views;
-[RequiresUnreferencedCode("Expander is not trim safe")]
-[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public partial class ExpanderPageCS : ContentPage
{
+ [RequiresUnreferencedCode("Expander is not Trimmer safe")]
public ExpanderPageCS()
{
const string dotnetBotUrl = "https://avatars.githubusercontent.com/u/9011267?v=4";
diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/AppDelegate.cs b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/AppDelegate.cs
index b843e80959..f7b67ff8ef 100644
--- a/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/AppDelegate.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Platforms/MacCatalyst/AppDelegate.cs
@@ -4,11 +4,7 @@
namespace CommunityToolkit.Maui.Sample;
[Register(nameof(AppDelegate))]
-[RequiresUnreferencedCode($"{nameof(MauiProgram.CreateMauiApp)} requires unreferenced code")]
public class AppDelegate : MauiUIApplicationDelegate
{
-#pragma warning disable IL2046
- [RequiresUnreferencedCode($"{nameof(MauiProgram.CreateMauiApp)} requires unreferenced code")]
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
-#pragma warning restore IL2046
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/iOS/AppDelegate.cs b/samples/CommunityToolkit.Maui.Sample/Platforms/iOS/AppDelegate.cs
index b843e80959..f7b67ff8ef 100644
--- a/samples/CommunityToolkit.Maui.Sample/Platforms/iOS/AppDelegate.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Platforms/iOS/AppDelegate.cs
@@ -4,11 +4,7 @@
namespace CommunityToolkit.Maui.Sample;
[Register(nameof(AppDelegate))]
-[RequiresUnreferencedCode($"{nameof(MauiProgram.CreateMauiApp)} requires unreferenced code")]
public class AppDelegate : MauiUIApplicationDelegate
{
-#pragma warning disable IL2046
- [RequiresUnreferencedCode($"{nameof(MauiProgram.CreateMauiApp)} requires unreferenced code")]
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
-#pragma warning restore IL2046
}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs b/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
index d9221b1e95..8fbb55c2b9 100644
--- a/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
+++ b/src/CommunityToolkit.Maui/Views/Expander/Expander.shared.cs
@@ -7,7 +7,6 @@ namespace CommunityToolkit.Maui.Views;
///
[ContentProperty(nameof(Content))]
-[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
[RequiresUnreferencedCode("Calls Microsoft.Maui.Controls.Binding.Binding(String, BindingMode, IValueConverter, Object, String, Object)")]
public partial class Expander : ContentView, IExpander
{
From c4cc7d7cb44b850adb2372ce0a1acef045b13c7e Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 14 Oct 2025 13:57:56 -0700
Subject: [PATCH 09/41] Update to .NET 10 RC 2
---
Directory.Build.props | 2 +-
global.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Directory.Build.props b/Directory.Build.props
index 23f2b2083b..79fb9d0b3b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,7 +16,7 @@
all
- 10.0.0-rc.1.25452.6
+ 10.0.0-rc.2.25504.7
11.0.0
true
true
diff --git a/global.json b/global.json
index 55e0e2cf3a..33b94ff507 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "10.0.100-rc.1.25451.107",
+ "version": "10.0.100-rc.2.25502.107",
"rollForward": "latestFeature",
"allowPrerelease": true
}
From 7ad399083b8d6fc06bcc0b748eaea9ae9c21e72d Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 14 Oct 2025 14:02:54 -0700
Subject: [PATCH 10/41] Update NuGet Packages
---
.github/workflows/dotnet-build.yml | 2 +-
.../CommunityToolkit.Maui.Sample.csproj | 2 +-
.../CommunityToolkit.Maui.Analyzers.CodeFixes.csproj | 2 +-
.../CommunityToolkit.Maui.Analyzers.UnitTests.csproj | 4 ++--
.../CommunityToolkit.Maui.Analyzers.csproj | 2 +-
.../CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj | 2 +-
.../CommunityToolkit.Maui.Camera.Analyzers.csproj | 2 +-
...munityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj | 2 +-
.../CommunityToolkit.Maui.MediaElement.Analyzers.csproj | 2 +-
.../CommunityToolkit.Maui.SourceGenerators.Internal.csproj | 2 +-
.../CommunityToolkit.Maui.SourceGenerators.csproj | 2 +-
11 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml
index 35ac640734..3c851f4d75 100644
--- a/.github/workflows/dotnet-build.yml
+++ b/.github/workflows/dotnet-build.yml
@@ -43,7 +43,7 @@ env:
PathToCommunityToolkitMediaElementAnalyzersCodeFixCsproj: 'src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj'
PathToCommunityToolkitAnalyzersUnitTestProjectDirectory: 'src/CommunityToolkit.Maui.Analyzers.UnitTests'
PathToCommunityToolkitAnalyzersBenchmarkCsproj: 'src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj'
- CommunityToolkitLibrary_Xcode_Version: '16.4'
+ CommunityToolkitLibrary_Xcode_Version: '26.0.1'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index e2da400ff6..23a8f2647e 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -65,7 +65,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj b/src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj
index df416dbbc1..8bda7bedbe 100644
--- a/src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.CodeFixes/CommunityToolkit.Maui.Analyzers.CodeFixes.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
index 7c505604c4..6297499ea7 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
@@ -21,12 +21,12 @@
-
+
-
+
diff --git a/src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj b/src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj
index c7ffd9094a..1342ad2678 100644
--- a/src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers/CommunityToolkit.Maui.Analyzers.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj b/src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj
index 5e9d7cfa21..2ab2e8f7fb 100644
--- a/src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj
+++ b/src/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes/CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj b/src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj
index 4fcf2ceac9..ff376830b7 100644
--- a/src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj
+++ b/src/CommunityToolkit.Maui.Camera.Analyzers/CommunityToolkit.Maui.Camera.Analyzers.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj b/src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj
index 26f3593580..5670a169e0 100644
--- a/src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj
+++ b/src/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes/CommunityToolkit.Maui.MediaElement.Analyzers.CodeFixes.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj b/src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj
index d7c2282f54..dc2f509b05 100644
--- a/src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj
+++ b/src/CommunityToolkit.Maui.MediaElement.Analyzers/CommunityToolkit.Maui.MediaElement.Analyzers.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj b/src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj
index 0db4d21732..b1d5d63347 100644
--- a/src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj
+++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal/CommunityToolkit.Maui.SourceGenerators.Internal.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj b/src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj
index ff45c781e1..b6648742e9 100644
--- a/src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj
+++ b/src/CommunityToolkit.Maui.SourceGenerators/CommunityToolkit.Maui.SourceGenerators.csproj
@@ -10,7 +10,7 @@
-
+
From 6db0619938678ef7f5e2effb8a1e432a657868e0 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 14 Oct 2025 14:13:44 -0700
Subject: [PATCH 11/41] Update NuGet packages
---
.../CommunityToolkit.Maui.Analyzers.UnitTests.csproj | 2 +-
.../CommunityToolkit.Maui.UnitTests.csproj | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
index 6297499ea7..341c82b65c 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
index 35e24717d4..4cfbe78130 100644
--- a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
@@ -15,7 +15,7 @@
-
+
From 05a0a11959218cd14d913c6431da4954b3c9ef95 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 14 Oct 2025 14:57:09 -0700
Subject: [PATCH 12/41] Remove `[RequiresUnreferencedCode]`
---
.../CommunityToolkit.Maui.Sample.csproj | 4 ++--
.../TouchBehaviorCollectionViewMultipleSelectionPage.cs | 5 +----
.../Pages/Views/Expander/ExpanderPage.xaml.cs | 3 +--
.../Pages/Views/Expander/ExpanderPageCS.cs | 1 -
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index dfd6975b56..d4a24702da 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -31,8 +31,8 @@
true
-
- CsWinRT1028
+
+ CsWinRT1028;IL2026
(BindableProperty, String, BindingMode, IValueConverter, Object, String, Object, Object, Object)")]
sealed class CreatorsDataTemplate(TouchBehaviorCollectionViewMultipleSelectionViewModel viewModel) : DataTemplate(() => CreateLayout(viewModel))
{
- [RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Markup.BindableObjectExtensions.Bind(BindableProperty, String, BindingMode, IValueConverter, Object, String, Object, Object, Object)")]
static VerticalStackLayout CreateLayout(TouchBehaviorCollectionViewMultipleSelectionViewModel viewModel) => new VerticalStackLayout
{
Children =
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
index 4079dc7b68..663a5830cc 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPage.xaml.cs
@@ -16,8 +16,7 @@ async void Expander_ExpandedChanged(object sender, Core.ExpandedChangedEventArgs
var collapsedText = e.IsExpanded ? "expanded" : "collapsed";
await Toast.Make($"Expander is {collapsedText}").Show(CancellationToken.None);
}
-
- [RequiresUnreferencedCode("Calls CommunityToolkit.Maui.Sample.Pages.Views.ExpanderPageCS.ExpanderPageCS()")]
+
async void GoToCSharpSampleClicked(object sender, EventArgs e)
{
await Navigation.PushAsync(new ExpanderPageCS());
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
index c9ede7bf65..ea55c5cb14 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
@@ -7,7 +7,6 @@ namespace CommunityToolkit.Maui.Sample.Pages.Views;
public partial class ExpanderPageCS : ContentPage
{
- [RequiresUnreferencedCode("Expander is not Trimmer safe")]
public ExpanderPageCS()
{
const string dotnetBotUrl = "https://avatars.githubusercontent.com/u/9011267?v=4";
From 5f38f13c684866b397b8cde85c18d0ecb5f7e803 Mon Sep 17 00:00:00 2001
From: Brandon Minnick <13558917+TheCodeTraveler@users.noreply.github.com>
Date: Tue, 14 Oct 2025 15:21:28 -0700
Subject: [PATCH 13/41] Remove `CsWinRT1028`
---
.../CommunityToolkit.Maui.Sample.csproj | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index d4a24702da..fc1ab5a9e9 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -31,8 +31,7 @@
true
-
- CsWinRT1028;IL2026
+ IL2026
+
diff --git a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
index 5cbed9631a..6ee85d9f6e 100644
--- a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
+++ b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
@@ -51,8 +51,8 @@
-
-
+
+
diff --git a/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj b/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
index 3049d75301..c6d5a9df5f 100644
--- a/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
+++ b/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
@@ -50,8 +50,8 @@
-
-
+
+
diff --git a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
index 3967c221ad..9ea02c384d 100644
--- a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
+++ b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
@@ -73,7 +73,7 @@
-
+
diff --git a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj
index 3b43020049..1329cb0a7b 100644
--- a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj
+++ b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj
@@ -69,7 +69,7 @@
-
+
From c029aa35c122c8eadbac85797ee7f5293401bd58 Mon Sep 17 00:00:00 2001
From: James Crutchley
Date: Fri, 24 Oct 2025 22:38:05 -0700
Subject: [PATCH 16/41] sample apps builds
---
.../CommunityToolkit.Maui.Sample.csproj | 2 +-
.../Pages/Converters/IsInRangeConverterPage.cs | 6 +++---
.../Pages/PlatformSpecific/PlatformSpecificGalleryPage.cs | 2 +-
.../Pages/Views/Popup/PopupOnDisappearingPage.cs | 2 +-
.../Pages/Views/RatingView/RatingViewCsharpPage.cs | 6 +++---
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
index fc1ab5a9e9..20ae79cdd2 100644
--- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
+++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj
@@ -60,7 +60,7 @@
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsInRangeConverterPage.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsInRangeConverterPage.cs
index 71b812cd7f..4f4c17f49d 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsInRangeConverterPage.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsInRangeConverterPage.cs
@@ -235,7 +235,7 @@ public IsInRangeConverterPage(IsInRangeConverterViewModel viewModel) : base(view
.Row(Row.TimeSpanExample1).Column(Column.Result)
.TextCenter()
.Bind