diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml
index 39c342ce9e..759e9c6a7d 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 8663322c49..744864eb28 100644
--- a/.github/workflows/dotnet-build.yml
+++ b/.github/workflows/dotnet-build.yml
@@ -22,10 +22,10 @@ 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.306'
- LATEST_NET_VERSION: '9.0.x'
- PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln'
- PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln'
+ TOOLKIT_NET_VERSION: '10.0.x'
+ LATEST_NET_VERSION: '10.0.x'
+ PathToLibrarySolution: 'src/CommunityToolkit.Maui.slnx'
+ PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.slnx'
PathToCommunityToolkitCsproj: 'src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj'
PathToCommunityToolkitCoreCsproj: 'src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj'
PathToCommunityToolkitCameraCsproj: 'src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj'
@@ -71,12 +71,12 @@ 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:
distribution: 'microsoft'
- java-version: '17'
+ java-version: '21'
- name: Install .NET MAUI Workload
run: |
@@ -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:
@@ -203,7 +203,7 @@ jobs:
run: dotnet build ${{ env.PathToCommunityToolkitCoreCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}
- name: 'Build CommunityToolkit.Maui'
- run: dotnet build ${{ env.PathToLibrarySolution }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}
+ run: dotnet build ${{ env.PathToCommunityToolkitCsproj }} -c Release -p:PackageVersion=${{ env.NugetPackageVersion }} -p:Version=${{ env.NugetPackageVersion }}
- name: Run CommunityToolkit Analyzers UnitTests
run: |
@@ -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@v6
@@ -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@v6
@@ -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@v6
diff --git a/Directory.Build.props b/Directory.Build.props
index d5f741ed02..6a4cf974e7 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,10 +16,11 @@
all
- 9.0.120
+ 10.0.0-rc.2.25504.7
true
true
true
+ SourceGen
+ $(BaseIntermediateOutputPath)\GeneratedFiles -->
true
-
- CsWinRT1028
+ IL2026
-
-
-
- true
+ AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
+
+ false
+ true
+ partial
@@ -63,11 +61,11 @@
-
+
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs b/samples/CommunityToolkit.Maui.Sample/MauiProgram.cs
index 1dd763355a..24cc21bcb2 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()
@@ -136,7 +135,6 @@ 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/Base/BasePage.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Base/BasePage.cs
index 50801ecc53..1fa93b7ae2 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Base/BasePage.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Base/BasePage.cs
@@ -13,6 +13,7 @@ public abstract class BasePage(TViewModel viewModel, bool shouldUseS
public abstract class BasePage : ContentPage
{
+ [Obsolete]
protected BasePage(object? viewModel = null, bool shouldUseSafeArea = true)
{
BindingContext = viewModel;
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs
index 5daca3439f..b2bd895841 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/AnimationBehaviorPage.xaml.cs
@@ -15,8 +15,8 @@ partial class SampleScaleAnimation : BaseAnimation
{
public override async Task Animate(VisualElement view, CancellationToken token)
{
- await view.ScaleTo(1.2, Length, Easing).WaitAsync(token);
- await view.ScaleTo(1, Length, Easing).WaitAsync(token);
+ await view.ScaleToAsync(1.2, Length, Easing).WaitAsync(token);
+ await view.ScaleToAsync(1, Length, Easing).WaitAsync(token);
}
}
@@ -25,5 +25,5 @@ partial class SampleScaleToAnimation : BaseAnimation
public double Scale { get; set; }
public override Task Animate(VisualElement view, CancellationToken token)
- => view.ScaleTo(Scale, Length, Easing).WaitAsync(token);
+ => view.ScaleToAsync(Scale, Length, Easing).WaitAsync(token);
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml
index 8babb0296e..7e243672ba 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/CharactersValidationBehaviorPage.xaml
@@ -23,7 +23,7 @@
+ VerticalOptions="Start">
@@ -46,24 +46,24 @@
ItemsSource="{Binding CharacterTypes, Mode=OneTime}" />
+ VerticalOptions="Fill" />
+ VerticalOptions="Fill" />
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/EmailValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/EmailValidationBehaviorPage.xaml
index 0fb470fa4b..dd3703ca5d 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/EmailValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/EmailValidationBehaviorPage.xaml
@@ -20,11 +20,11 @@
+ VerticalOptions="Start">
@@ -182,7 +182,7 @@
Grid.ColumnSpan="3"
Margin="0"
Padding="0"
- FontSize="Micro"
+ FontSize="6"
FontAttributes="Italic"
HorizontalOptions="Center"
VerticalOptions="Start"
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaskedBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaskedBehaviorPage.xaml
index 8c9ffd5a90..c3f68074dc 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaskedBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaskedBehaviorPage.xaml
@@ -18,21 +18,21 @@
-
+
-
+
-
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaxLengthReachedBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaxLengthReachedBehaviorPage.xaml
index 41aadb5467..049c9e6b84 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaxLengthReachedBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MaxLengthReachedBehaviorPage.xaml
@@ -30,7 +30,7 @@
VerticalTextAlignment="Center" />
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MultiValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MultiValidationBehaviorPage.xaml
index f2539b9b33..8b725ac22a 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MultiValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/MultiValidationBehaviorPage.xaml
@@ -22,7 +22,7 @@
+ VerticalOptions="Start">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/NumericValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/NumericValidationBehaviorPage.xaml
index 663cad9d83..bcc231c490 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/NumericValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/NumericValidationBehaviorPage.xaml
@@ -21,7 +21,7 @@
+ VerticalOptions="Start">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/RequiredStringValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/RequiredStringValidationBehaviorPage.xaml
index 1b913462f5..6fbf0c0e9d 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/RequiredStringValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/RequiredStringValidationBehaviorPage.xaml
@@ -20,7 +20,7 @@
+ VerticalOptions="Start">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TextValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TextValidationBehaviorPage.xaml
index dec1a99d8f..10d3db9ca4 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TextValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TextValidationBehaviorPage.xaml
@@ -20,7 +20,7 @@
+ VerticalOptions="Start">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
index 00acf9fdee..17d96cddb2 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorCollectionViewMultipleSelectionPage.cs
@@ -6,7 +6,6 @@
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;
@@ -38,11 +37,8 @@ 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))
{
- [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/Behaviors/TouchBehavior/TouchBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorPage.xaml
index b471af6311..24bbe60062 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/TouchBehavior/TouchBehaviorPage.xaml
@@ -19,7 +19,7 @@
-
+
@@ -29,7 +29,7 @@
@@ -46,7 +46,7 @@
-
+
+ HorizontalOptions="Center">
@@ -106,7 +106,7 @@
+ HorizontalOptions="Center">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/UriValidationBehaviorPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/UriValidationBehaviorPage.xaml
index 658b9621e1..b1e6f9e94b 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/UriValidationBehaviorPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Behaviors/UriValidationBehaviorPage.xaml
@@ -20,7 +20,7 @@
+ VerticalOptions="Start">
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/BoolToObjectConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/BoolToObjectConverterPage.xaml
index 2a4520fe1e..1fc377f255 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/BoolToObjectConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/BoolToObjectConverterPage.xaml
@@ -26,7 +26,7 @@
Grid.Row="0"
Grid.ColumnSpan="3"
VerticalOptions="Start"
- HorizontalOptions="FillAndExpand" />
+ HorizontalOptions="Fill" />
@@ -69,7 +69,7 @@
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ByteArrayToImageSourceConverterPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ByteArrayToImageSourceConverterPage.xaml.cs
index 4be9cf458c..8fb5f8ad80 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ByteArrayToImageSourceConverterPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ByteArrayToImageSourceConverterPage.xaml.cs
@@ -18,6 +18,6 @@ public ByteArrayToImageSourceConverterPage(IDispatcher dispatcher, ByteArrayToIm
async void HandleImageDownloadFailed(object? sender, string e)
{
ArgumentNullException.ThrowIfNull(sender);
- await dispatcher.DispatchAsync(() => DisplayAlert("Image Download Failed", e, "OK"));
+ await dispatcher.DispatchAsync(() => DisplayAlertAsync("Image Download Failed", e, "OK"));
}
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml
index b9bb99ca5d..6b87974840 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml
@@ -29,7 +29,7 @@
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/EnumToBoolConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/EnumToBoolConverterPage.xaml
index 24bd4da939..a3b879ef7b 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/EnumToBoolConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/EnumToBoolConverterPage.xaml
@@ -31,7 +31,7 @@
+ HorizontalOptions="Center" />
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ImageResourceConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ImageResourceConverterPage.xaml
index 3d21bcf7e5..fc6c5db959 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ImageResourceConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/ImageResourceConverterPage.xaml
@@ -18,7 +18,7 @@
+ HorizontalOptions="Center" TextColor="{StaticResource NormalLabelTextColor}"/>
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/InvertedBoolConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/InvertedBoolConverterPage.xaml
index 8bac8c620e..17d12503eb 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/InvertedBoolConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/InvertedBoolConverterPage.xaml
@@ -25,7 +25,7 @@
@@ -35,7 +35,7 @@
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsEqualConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsEqualConverterPage.xaml
index 8bb84d8286..d83082889d 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsEqualConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsEqualConverterPage.xaml
@@ -19,10 +19,10 @@
+ HorizontalOptions="Fill"/>
-
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(Label.StyleProperty,
- static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time,
+ static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time ?? TimeSpan.Zero,
mode: BindingMode.OneWay,
converter: new IsInRangeConverter
{
@@ -255,7 +255,7 @@ public IsInRangeConverterPage(IsInRangeConverterViewModel viewModel) : base(view
.TextCenter()
.Bind(
Label.StyleProperty,
- static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time,
+ static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time ?? TimeSpan.Zero,
mode: BindingMode.OneWay,
converter: new IsInRangeConverter
{
@@ -274,7 +274,7 @@ public IsInRangeConverterPage(IsInRangeConverterViewModel viewModel) : base(view
.TextCenter()
.Bind(
Label.StyleProperty,
- static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time,
+ static (TimePicker timeSpanInputPicker) => timeSpanInputPicker.Time ?? TimeSpan.Zero,
mode: BindingMode.OneWay,
converter: new IsInRangeConverter
{
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsNotEqualConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsNotEqualConverterPage.xaml
index 811faf9121..944e9ad13a 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsNotEqualConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsNotEqualConverterPage.xaml
@@ -25,10 +25,10 @@
+ HorizontalOptions="Fill"/>
-
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrEmptyConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrEmptyConverterPage.xaml
index e458ca390c..6dadd87c3d 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrEmptyConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrEmptyConverterPage.xaml
@@ -36,12 +36,12 @@
HorizontalOptions="Fill"
Text="{Binding Path=LabelText, Mode=OneWayToSource}"
TextColor="{StaticResource NormalLabelTextColor}"
- VerticalOptions="CenterAndExpand" />
+ VerticalOptions="Center" />
+ VerticalOptions="Center" />
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrWhiteSpaceConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrWhiteSpaceConverterPage.xaml
index 89f6743041..5908e0b8b7 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrWhiteSpaceConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNotNullOrWhiteSpaceConverterPage.xaml
@@ -25,9 +25,9 @@
-
+
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrEmptyConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrEmptyConverterPage.xaml
index e627d8ea37..fb72d7f25f 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrEmptyConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrEmptyConverterPage.xaml
@@ -33,14 +33,14 @@
NullableIsVisible="{Binding LabelText, Mode=OneWay, Converter={StaticResource IsStringNullOrEmptyConverter}}" />
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrWhiteSpaceConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrWhiteSpaceConverterPage.xaml
index 3426d6e522..98e42164c6 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrWhiteSpaceConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsStringNullOrWhiteSpaceConverterPage.xaml
@@ -25,9 +25,9 @@
-
+
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/MultiConverterPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/MultiConverterPage.xaml
index 9738feda47..c2e9db1384 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Converters/MultiConverterPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Converters/MultiConverterPage.xaml
@@ -47,9 +47,9 @@
+ HorizontalOptions="Center"/>
+ HorizontalOptions="Center"/>
@@ -28,7 +28,7 @@
ItemsSource="{Binding LabelText, Mode=OneWay, Converter={StaticResource StringToListConverter}}">
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/AppThemePage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/AppThemePage.xaml.cs
index d286836421..ccb4fe5973 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/AppThemePage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Essentials/AppThemePage.xaml.cs
@@ -9,7 +9,7 @@ public AppThemePage(AppThemeViewModel viewModel) : base(viewModel)
InitializeComponent();
}
- void Switch_Toggled(object sender, ToggledEventArgs e)
+ void Switch_Toggled(object? sender, ToggledEventArgs? e)
{
if (Application.Current is not null)
{
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/ColorAnimationExtensionsPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/ColorAnimationExtensionsPage.xaml.cs
index 70b752ebb4..4fd56a8020 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/ColorAnimationExtensionsPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/ColorAnimationExtensionsPage.xaml.cs
@@ -33,7 +33,7 @@ void SetPickersRandomValue()
EasingPicker.SelectedIndex = Random.Shared.Next(EasingPicker.ItemsSource.Count);
}
- async void Button_Clicked(object sender, EventArgs e)
+ async void Button_Clicked(object? sender, EventArgs? e)
{
var color = colors.ElementAtOrDefault(ColorPicker.SelectedIndex).Value ?? Colors.Transparent;
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/KeyboardExtensionsPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/KeyboardExtensionsPage.xaml.cs
index 2aec9e8750..8374193ed3 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/KeyboardExtensionsPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Extensions/KeyboardExtensionsPage.xaml.cs
@@ -10,7 +10,7 @@ public KeyboardExtensionsPage(KeyboardExtensionsViewModel viewModel) :
InitializeComponent();
}
- void OnEntryFocused(System.Object sender, Microsoft.Maui.Controls.FocusEventArgs e)
+ void OnEntryFocused(object? sender, FocusEventArgs e)
{
#if IOS || MACCATALYST
// Currently .NET MAUI will auto close the keyboard on iOS if you click outside of the entry
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml
index 951dc0fc9f..1c4ed6bd8c 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml
@@ -43,7 +43,7 @@
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml.cs
index 3dd356a135..6c927fca0a 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Layouts/StateContainerPage.xaml.cs
@@ -31,8 +31,8 @@ async void ChangeStateWithCustomAnimation(object? sender, EventArgs e)
{
await StateContainer.ChangeStateWithAnimation(GridWithAnimation,
null,
- (element, token) => element.ScaleTo(0, 100, Easing.SpringIn).WaitAsync(token),
- (element, token) => element.ScaleTo(1, 250, Easing.SpringOut).WaitAsync(token),
+ (element, token) => element.ScaleToAsync(0, 100, Easing.SpringIn).WaitAsync(token),
+ (element, token) => element.ScaleToAsync(1, 250, Easing.SpringOut).WaitAsync(token),
CancellationToken.None);
}
@@ -40,8 +40,8 @@ await StateContainer.ChangeStateWithAnimation(GridWithAnimation,
{
await StateContainer.ChangeStateWithAnimation(GridWithAnimation,
"ReplaceGrid",
- (element, token) => element.ScaleTo(0, 100, Easing.SpringIn).WaitAsync(token),
- (element, token) => element.ScaleTo(1, 250, Easing.SpringOut).WaitAsync(token),
+ (element, token) => element.ScaleToAsync(0, 100, Easing.SpringIn).WaitAsync(token),
+ (element, token) => element.ScaleToAsync(1, 250, Easing.SpringOut).WaitAsync(token),
CancellationToken.None);
}
}
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/PlatformSpecific/PlatformSpecificGalleryPage.cs b/samples/CommunityToolkit.Maui.Sample/Pages/PlatformSpecific/PlatformSpecificGalleryPage.cs
index 346f0842f3..2f154c7920 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/PlatformSpecific/PlatformSpecificGalleryPage.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/PlatformSpecific/PlatformSpecificGalleryPage.cs
@@ -2,6 +2,6 @@
namespace CommunityToolkit.Maui.Sample.Pages;
-public class PlatformSpecificGalleryPage(IDeviceInfo deviceInfo, PlatformSpecificGalleryViewModel viewModel) : BaseGalleryPage("Platform Specific", deviceInfo, viewModel)
+public partial class PlatformSpecificGalleryPage(IDeviceInfo deviceInfo, PlatformSpecificGalleryViewModel viewModel) : BaseGalleryPage("Platform Specific", deviceInfo, viewModel)
{
}
\ No newline at end of file
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewDayOfWeekPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewDayOfWeekPage.xaml
index 58df0253ef..0a4cada395 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewDayOfWeekPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewDayOfWeekPage.xaml
@@ -37,7 +37,7 @@
TargetType="mct:AvatarView">
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewGesturesPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewGesturesPage.xaml.cs
index a976125aec..f708c03095 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewGesturesPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewGesturesPage.xaml.cs
@@ -7,31 +7,31 @@ public partial class AvatarViewGesturesPage : BasePage InitializeComponent();
- async void DragGestureRecognizer_DragStarting(object sender, DragStartingEventArgs e)
+ async void DragGestureRecognizer_DragStarting(object? sender, DragStartingEventArgs? e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await ShowToastGestureMessage("AvatarView drag gesture recognizer, drag starting.", cts.Token);
}
- async void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e)
+ async void PanGestureRecognizer_PanUpdated(object? sender, PanUpdatedEventArgs? e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await ShowToastGestureMessage("AvatarView pan gesture recognizer, pan updated.", cts.Token);
}
- async void PinchGestureRecognizer_PinchUpdated(object sender, PinchGestureUpdatedEventArgs e)
+ async void PinchGestureRecognizer_PinchUpdated(object? sender, PinchGestureUpdatedEventArgs? e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await ShowToastGestureMessage("AvatarView pinch gesture recognizer, pinch updated.", cts.Token);
}
- async void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
+ async void SwipeGestureRecognizer_Swiped(object? sender, SwipedEventArgs e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await ShowToastGestureMessage("AvatarView swipe gesture recognizer, swiped.", cts.Token);
}
- async void TapGestureRecognizer_Tapped(object sender, EventArgs e)
+ async void TapGestureRecognizer_Tapped(object? sender, EventArgs? e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await ShowToastGestureMessage("AvatarView Tap Gesture Recognizer, tapped.", cts.Token);
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewImagesPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewImagesPage.xaml
index a9858f2b83..086919313c 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewImagesPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewImagesPage.xaml
@@ -45,7 +45,7 @@
TargetType="mct:AvatarView">
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewSizesPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewSizesPage.xaml
index fd9c805a53..776a2e2886 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewSizesPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/AvatarView/AvatarViewSizesPage.xaml
@@ -45,7 +45,7 @@
TargetType="mct:AvatarView">
-
+
@@ -64,7 +64,7 @@
TargetType="mct:AvatarView">
-
+
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml
index ed5edd3a93..ea13274a15 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml
@@ -29,7 +29,7 @@
@@ -51,8 +51,8 @@
+ Maximum="{Binding SelectedCamera.MaximumZoomFactor, FallbackValue=1, x:DataType={x:Null}}"
+ Minimum="{Binding SelectedCamera.MinimumZoomFactor, FallbackValue=1, x:DataType={x:Null}}"/>
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs
index 38a987a1c5..df3fe14ea3 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs
@@ -63,7 +63,7 @@ void Cleanup()
Camera.Handler?.DisconnectHandler();
}
- void OnUnloaded(object? sender, EventArgs e)
+ void OnUnloaded(object? sender, EventArgs? e)
{
//Cleanup();
}
@@ -87,17 +87,17 @@ void OnMediaCaptured(object? sender, MediaCapturedEventArgs e)
});
}
- void ZoomIn(object? sender, EventArgs e)
+ void ZoomIn(object? sender, EventArgs? e)
{
Camera.ZoomFactor += 1.0f;
}
- void ZoomOut(object? sender, EventArgs e)
+ void ZoomOut(object? sender, EventArgs? e)
{
Camera.ZoomFactor -= 1.0f;
}
- async void SetNightMode(object? sender, EventArgs e)
+ async void SetNightMode(object? sender, EventArgs? e)
{
#if ANDROID
await Camera.SetExtensionMode(AndroidX.Camera.Extensions.ExtensionMode.Night);
@@ -106,21 +106,21 @@ async void SetNightMode(object? sender, EventArgs e)
#endif
}
- async void StartCameraRecording(object? sender, EventArgs e)
+ async void StartCameraRecording(object? sender, EventArgs? e)
{
await Camera.StartVideoRecording(CancellationToken.None);
}
- async void StopCameraRecording(object? sender, EventArgs e)
+ async void StopCameraRecording(object? sender, EventArgs? e)
{
videoRecordingStream = await Camera.StopVideoRecording(CancellationToken.None);
}
- async void SaveVideo(object? sender, EventArgs e)
+ async void SaveVideo(object? sender, EventArgs? e)
{
if (videoRecordingStream == Stream.Null)
{
- await DisplayAlert("Unable to Save Video", "Stream is null", "OK");
+ await DisplayAlertAsync("Unable to Save Video", "Stream is null", "OK");
}
else
{
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml.cs
index ec589562ca..10d1b4b8c8 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/DrawingViewPage.xaml.cs
@@ -19,7 +19,7 @@ public DrawingViewPage(DrawingViewViewModel viewModel) : base(viewModel)
static double GetSide(double value) =>
double.IsNaN(value) || value <= 1 ? 200 : value;
- void LoadPointsButtonClicked(object sender, EventArgs e)
+ void LoadPointsButtonClicked(object? sender, EventArgs? e)
{
DrawingViewControl.Lines.Clear();
foreach (var line in GenerateLines(2))
@@ -28,7 +28,7 @@ void LoadPointsButtonClicked(object sender, EventArgs e)
}
}
- async void GetCurrentDrawingViewImageClicked(object sender, EventArgs e)
+ async void GetCurrentDrawingViewImageClicked(object? sender, EventArgs? e)
{
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
var stream = await DrawingViewControl.GetImageStream(GestureImage.Width, GestureImage.Height, DrawingViewOutputOption.Lines, cts.Token);
@@ -36,7 +36,7 @@ async void GetCurrentDrawingViewImageClicked(object sender, EventArgs e)
GestureImage.Source = ImageSource.FromStream(() => stream);
}
- async void GenerateImageButtonClicked(object sender, EventArgs e)
+ async void GenerateImageButtonClicked(object? sender, EventArgs? e)
{
var lines = GenerateLines(2);
@@ -76,7 +76,7 @@ IEnumerable GenerateLines(int count)
}
}
- async void OnDrawingLineCompleted(object sender, DrawingLineCompletedEventArgs e)
+ async void OnDrawingLineCompleted(object? sender, DrawingLineCompletedEventArgs e)
{
var width = GetSide(GestureImage.Width);
var height = GetSide(GestureImage.Height);
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..9747bdc246 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)
@@ -13,13 +11,13 @@ public ExpanderPage(ExpanderViewModel viewModel) : base(viewModel)
InitializeComponent();
}
- async void Expander_ExpandedChanged(object sender, Core.ExpandedChangedEventArgs e)
+ async void Expander_ExpandedChanged(object? sender, Core.ExpandedChangedEventArgs e)
{
var collapsedText = e.IsExpanded ? "expanded" : "collapsed";
await Toast.Make($"Expander is {collapsedText}").Show(CancellationToken.None);
}
- async void GoToCSharpSampleClicked(object sender, EventArgs e)
+ 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..ea55c5cb14 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/Expander/ExpanderPageCS.cs
@@ -5,8 +5,6 @@
namespace CommunityToolkit.Maui.Sample.Pages.Views;
-[RequiresUnreferencedCode("Expander is not trim safe")]
-[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public partial class ExpanderPageCS : ContentPage
{
public ExpanderPageCS()
diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/LazyView/LazyViewPage.xaml b/samples/CommunityToolkit.Maui.Sample/Pages/Views/LazyView/LazyViewPage.xaml
index b46b76dc2a..49bb010b00 100644
--- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/LazyView/LazyViewPage.xaml
+++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/LazyView/LazyViewPage.xaml
@@ -20,7 +20,7 @@
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/StatusBarBehaviorViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/StatusBarBehaviorViewModel.cs
index 55d3b7347c..8b5a7f560a 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/StatusBarBehaviorViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/StatusBarBehaviorViewModel.cs
@@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace CommunityToolkit.Maui.Sample.ViewModels.Behaviors;
+
public partial class StatusBarBehaviorViewModel : BaseViewModel
{
[ObservableProperty]
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/TouchBehavior/TouchBehaviorViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/TouchBehavior/TouchBehaviorViewModel.cs
index ac76c08067..6e875f3fce 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/TouchBehavior/TouchBehaviorViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Behaviors/TouchBehavior/TouchBehaviorViewModel.cs
@@ -11,27 +11,27 @@ public partial class TouchBehaviorViewModel : BaseViewModel
[ObservableProperty]
public partial int LongPressCount { get; private set; }
- static Task DisplayAlert(string title, CancellationToken token)
- => Shell.Current.DisplayAlert(title, null, "Ok").WaitAsync(token);
+ static Task DisplayAlertAsync(string title, CancellationToken token)
+ => Shell.Current.DisplayAlertAsync(title, null, "Ok").WaitAsync(token);
[RelayCommand]
static Task ParentClicked(CancellationToken token)
- => DisplayAlert("Parent Clicked", token);
+ => DisplayAlertAsync("Parent Clicked", token);
[RelayCommand]
static Task ChildClicked(CancellationToken token)
- => DisplayAlert("Child Clicked", token);
+ => DisplayAlertAsync("Child Clicked", token);
[RelayCommand]
async Task MonkeySelected(string? monkey, CancellationToken token)
{
if (string.IsNullOrEmpty(monkey))
{
- await DisplayAlert("No monkey selected", token);
+ await DisplayAlertAsync("No monkey selected", token);
return;
}
- await DisplayAlert($"Selected monkey: {monkey}", token);
+ await DisplayAlertAsync($"Selected monkey: {monkey}", token);
}
[RelayCommand]
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ConvertersGalleryViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ConvertersGalleryViewModel.cs
index febf791102..0cc3201bcf 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ConvertersGalleryViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ConvertersGalleryViewModel.cs
@@ -3,6 +3,7 @@
namespace CommunityToolkit.Maui.Sample.ViewModels.Converters;
+[Obsolete]
public partial class ConvertersGalleryViewModel() : BaseGalleryViewModel(
[
SectionModel.Create(nameof(BoolToObjectConverter), "A converter that allows users to convert a bool value binding to a specific object."),
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ItemTappedEventArgsConverterViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ItemTappedEventArgsConverterViewModel.cs
index 63f1712d81..391d1eb3f9 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ItemTappedEventArgsConverterViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/ItemTappedEventArgsConverterViewModel.cs
@@ -22,7 +22,7 @@ Task ItemTapped(Person? person, CancellationToken token)
ItemSelected = null;
- return Application.Current?.Windows[0].Page?.DisplayAlert("Item Tapped", person.Name, "Ok").WaitAsync(token) ?? Task.CompletedTask;
+ return Application.Current?.Windows[0].Page?.DisplayAlertAsync("Item Tapped", person.Name, "Ok").WaitAsync(token) ?? Task.CompletedTask;
}
}
diff --git a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/StateToBooleanConverterViewModel.cs b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/StateToBooleanConverterViewModel.cs
index cb2ad30566..4ade46aac0 100644
--- a/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/StateToBooleanConverterViewModel.cs
+++ b/samples/CommunityToolkit.Maui.Sample/ViewModels/Converters/StateToBooleanConverterViewModel.cs
@@ -3,6 +3,7 @@
using CommunityToolkit.Mvvm.Input;
namespace CommunityToolkit.Maui.Sample.ViewModels.Converters;
+
public partial class StateToBooleanConverterViewModel : BaseViewModel
{
[ObservableProperty]
diff --git a/src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj b/src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj
index 4f00d87ebb..f214ec29df 100644
--- a/src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.Benchmarks/CommunityToolkit.Maui.Analyzers.Benchmarks.csproj
@@ -14,8 +14,8 @@
false
-
-
+
+
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 d71c97d2e5..b36b9845c8 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj
@@ -19,17 +19,9 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
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..6745fb6e9f 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
@@ -3,15 +3,18 @@
using Microsoft.CodeAnalysis.Diagnostics;
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
+#if NET9
ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net90;
+#elif NET10
+ ReferenceAssemblies = Microsoft.CodeAnalysis.Testing.ReferenceAssemblies.Net.Net10;
#else
#error ReferenceAssemblies must be updated to current version of .NET
#endif
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs
index 7a43b1ad17..0e560fb2d2 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpAnalyzerVerifier`1.cs
@@ -29,6 +29,6 @@ public static async Task VerifyAnalyzerAsync(string source, Type[] assembliesUnd
};
test.ExpectedDiagnostics.AddRange(expected);
- await test.RunAsync(CancellationToken.None);
+ await test.RunAsync(TestContext.Current.CancellationToken);
}
}
\ No newline at end of file
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..2aa83ee991 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2+Test.cs
@@ -5,15 +5,16 @@
using Microsoft.CodeAnalysis.Testing;
namespace CommunityToolkit.Maui.Analyzers.UnitTests;
+
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)
{
-#if NET9_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.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs
index 999337d6b6..9157044cf7 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpCodeFixVerifier`2.cs
@@ -5,6 +5,7 @@
using Microsoft.CodeAnalysis.Testing;
namespace CommunityToolkit.Maui.Analyzers.UnitTests;
+
public static partial class CSharpCodeFixVerifier
where TAnalyzer : DiagnosticAnalyzer, new()
where TCodeFix : CodeFixProvider, new()
@@ -30,7 +31,7 @@ public static async Task VerifyAnalyzerAsync(string source, Type[] assembliesUnd
};
test.ExpectedDiagnostics.AddRange(expected);
- await test.RunAsync(CancellationToken.None);
+ await test.RunAsync(TestContext.Current.CancellationToken);
}
///
@@ -51,6 +52,6 @@ public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] ex
};
test.ExpectedDiagnostics.AddRange(expected);
- await test.RunAsync(CancellationToken.None);
+ await test.RunAsync(TestContext.Current.CancellationToken);
}
}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpVerifierHelper.cs b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpVerifierHelper.cs
index 57e6c7e34f..e4005dbb3b 100644
--- a/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpVerifierHelper.cs
+++ b/src/CommunityToolkit.Maui.Analyzers.UnitTests/Verifiers/CSharpVerifierHelper.cs
@@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis.CSharp;
namespace CommunityToolkit.Maui.Analyzers.UnitTests;
+
static class CSharpVerifierHelper
{
///
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.Camera/CameraManager.android.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs
index 81213d08f2..5128a3b55c 100644
--- a/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs
+++ b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs
@@ -48,10 +48,10 @@ public async Task SetExtensionMode(int mode, CancellationToken token)
{
extensionMode = mode;
if (cameraView.SelectedCamera is null
- || processCameraProvider is null
- || cameraPreview is null
- || imageCapture is null
- || videoCapture is null)
+ || processCameraProvider is null
+ || cameraPreview is null
+ || imageCapture is null
+ || videoCapture is null)
{
return;
}
@@ -104,7 +104,7 @@ public async partial ValueTask UpdateCaptureResolution(Size resolution, Cancella
if (resolutionFilter is not null)
{
if (Math.Abs(resolutionFilter.TargetSize.Width - resolution.Width) < double.Epsilon &&
- Math.Abs(resolutionFilter.TargetSize.Height - resolution.Height) < double.Epsilon)
+ Math.Abs(resolutionFilter.TargetSize.Height - resolution.Height) < double.Epsilon)
{
return;
}
@@ -127,7 +127,7 @@ public async partial ValueTask UpdateCaptureResolution(Size resolution, Cancella
.SetAllowedResolutionMode(ResolutionSelector.PreferHigherResolutionOverCaptureRate)?
.SetResolutionFilter(resolutionFilter)
?.Build() ?? throw new InvalidOperationException("Unable to Set Resolution Filter");
-
+
// `.SetResolutionFilter()` should never return null
// According to the Android docs, `ResolutionSelector.Builder.setResolutionFilter(ResolutionFilter)` returns a `NonNull` object
// `ResolutionSelector.Builder.SetResolutionFilter(ResolutionFilter)` returning a nullable object in .NET for Android is likely a C# Binding mistake
@@ -240,7 +240,7 @@ protected async Task StartUseCase(CancellationToken token)
.SetCaptureMode(ImageCapture.CaptureModeMaximizeQuality)?
.SetResolutionSelector(resolutionSelector)
?.Build() ?? throw new InvalidOperationException("Unable to set resolution selector");
-
+
// `.SetResolutionFilter()` should never return null
// According to the Android docs, `ResolutionSelector.Builder.SetResolutionFilter(ResolutionFilter)` returns a `NonNull` object
// `ResolutionSelector.Builder.SetResolutionFilter(ResolutionFilter)` returning a nullable object in .NET for Android is likely a C# Binding mistake
@@ -248,7 +248,7 @@ protected async Task StartUseCase(CancellationToken token)
var videoRecorderBuilder = new Recorder.Builder()
.SetExecutor(cameraExecutor) ?? throw new InvalidOperationException("Unable to set video recorder executor");
-
+
// `.SetExecutor()` should never return null
// According to the Android docs, `ResolutionSelector.Builder.setExecutor(ResolutionFilter)` returns a `NonNull` object
// `ResolutionSelector.Builder.SetExecutor(ResolutionFilter)` returning a nullable object in .NET for Android is likely a C# Binding mistake
@@ -320,12 +320,12 @@ protected virtual partial ValueTask PlatformTakePicture(CancellationToken token)
protected virtual async partial Task PlatformStartVideoRecording(Stream stream, CancellationToken token)
{
if (previewView is null
- || processCameraProvider is null
- || cameraPreview is null
- || imageCapture is null
- || videoCapture is null
- || videoRecorder is null
- || videoRecordingFile is not null)
+ || processCameraProvider is null
+ || cameraPreview is null
+ || imageCapture is null
+ || videoCapture is null
+ || videoRecorder is null
+ || videoRecordingFile is not null)
{
return;
}
@@ -360,7 +360,7 @@ protected virtual async partial Task PlatformStartVideoRecording(Stream stream,
.PrepareRecording(context, outputOptions)
?.WithAudioEnabled()
.Start(executor, captureListener) ?? throw new InvalidOperationException("Unable to prepare recording");
-
+
// `.PrepareRecording()` should never return null
// According to the Android docs, `Recorder.prepareRecording(Context, eMediaSoreOutputOptions)` returns a `NonNull` object
// `Recorder.PrepareRecording(Context, eMediaSoreOutputOptions)` returning a nullable object in .NET for Android is likely a C# Binding mistake
@@ -371,9 +371,9 @@ protected virtual async partial Task PlatformStopVideoRecording(Cancella
{
ArgumentNullException.ThrowIfNull(cameraExecutor);
if (videoRecording is null
- || videoRecordingFile is null
- || videoRecordingFinalizeTcs is null
- || videoRecordingStream is null)
+ || videoRecordingFile is null
+ || videoRecordingFinalizeTcs is null
+ || videoRecordingStream is null)
{
return Stream.Null;
}
@@ -392,8 +392,8 @@ protected virtual async partial Task PlatformStopVideoRecording(Cancella
bool IsVideoCaptureAlreadyBound()
{
return processCameraProvider is not null
- && videoCapture is not null
- && processCameraProvider.IsBound(videoCapture);
+ && videoCapture is not null
+ && processCameraProvider.IsBound(videoCapture);
}
void CleanupVideoRecordingResources()
@@ -434,9 +434,9 @@ async Task EnableModes(CameraInfo selectedCamera, CancellationTo
return;
}
- var extensionsManagerFuture = ExtensionsManager.GetInstanceAsync(context, cameraProviderInstance)
- ?? throw new InvalidOperationException("Unable to get listenable future for camera provider");;
-
+ var extensionsManagerFuture = ExtensionsManager.GetInstanceAsync(context, cameraProviderInstance)
+ ?? throw new InvalidOperationException("Unable to get listenable future for camera provider"); ;
+
extensionsManagerFuture.AddListener(new Runnable(() =>
{
var extensionsManager = (ExtensionsManager?)extensionsManagerFuture.Get();
@@ -541,8 +541,8 @@ sealed class ResolutionFilter(Android.Util.Size size) : Object, IResolutionFilte
.Where(size => size.Width <= TargetSize.Width && size.Height <= TargetSize.Height)
.OrderByDescending(size => size.Width * size.Height).ToList();
- return filteredList is null || filteredList.Count is 0
- ? supportedSizes ?? []
+ return filteredList is null || filteredList.Count is 0
+ ? supportedSizes ?? []
: filteredList;
}
}
diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
index a3d91ce63e..01f8756a03 100644
--- a/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
+++ b/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs
@@ -283,12 +283,12 @@ protected virtual async partial Task PlatformStartVideoRecording(Stream stream,
protected virtual async partial Task PlatformStopVideoRecording(CancellationToken token)
{
- if (captureSession is null
- || videoRecordingFileName is null
- || videoInput is null
- || videoOutput is null
- || videoRecordingStream is null
- || videoRecordingFinalizeTcs is null)
+ if (captureSession is null
+ || videoRecordingFileName is null
+ || videoInput is null
+ || videoOutput is null
+ || videoRecordingStream is null
+ || videoRecordingFinalizeTcs is null)
{
return Stream.Null;
}
diff --git a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj
index 8de19b790c..ff2ab31555 100644
--- a/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj
+++ b/src/CommunityToolkit.Maui.Camera/CommunityToolkit.Maui.Camera.csproj
@@ -43,6 +43,7 @@
true
dotnet,maui,toolkit,kit,communitytoolkit,dotnetcommunitytoolkit,cameraview,camera,photo
Debug;Release
+ true
diff --git a/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs b/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs
index 9f4b12f36c..f15859fc04 100644
--- a/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs
+++ b/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs
@@ -6,11 +6,7 @@ namespace CommunityToolkit.Maui.Core.Handlers;
///
/// Handler definition for the implementation on each platform.
///
-#if TIZEN
-public class CameraViewHandler : ViewHandler
-#else
public partial class CameraViewHandler : ViewHandler, IDisposable
-#endif
{
///
/// The currently defined mappings between properties on the and
diff --git a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
index 6ee85d9f6e..7c14c4820d 100644
--- a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
+++ b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj
@@ -7,6 +7,7 @@
true
true
true
+ true
true
@@ -57,4 +58,10 @@
+
+
+
+
+
+
diff --git a/src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.tizen.cs b/src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.tizen.cs
index 5e46057ade..547700854d 100644
--- a/src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Essentials/Badge/BadgeImplementation.tizen.cs
@@ -9,7 +9,7 @@ public class BadgeImplementation : IBadge
///
public void SetCount(uint count)
{
- var appId = Application.Current.ApplicationInfo.ApplicationId;
+ var appId = Tizen.Applications.Application.Current.ApplicationInfo.ApplicationId;
if (count is 0)
{
BadgeControl.Remove(appId);
diff --git a/src/CommunityToolkit.Maui.Core/Essentials/FileFolderDialog.tizen.cs b/src/CommunityToolkit.Maui.Core/Essentials/FileFolderDialog.tizen.cs
index 940906a2fd..54cd1658da 100644
--- a/src/CommunityToolkit.Maui.Core/Essentials/FileFolderDialog.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Essentials/FileFolderDialog.tizen.cs
@@ -15,6 +15,7 @@
using View = Tizen.NUI.BaseComponents.View;
using VerticalAlignment = Tizen.NUI.VerticalAlignment;
using Window = Tizen.NUI.Window;
+using DeviceInfo = Tizen.UIExtensions.Common.DeviceInfo;
namespace CommunityToolkit.Maui.Storage;
@@ -105,16 +106,16 @@ protected override View CreateContent()
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center
};
- BackgroundColor = new TColor(0.1f, 0.1f, 0.1f, 0.5f).ToNative();
+ BackgroundColor = new Tizen.NUI.Color(255.0f * 0.1f, 255.0f * 0.1f, 255.0f * 0.1f, 255.0f * 0.5f);
- var margin1 = (ushort)20d.ToPixel();
- var margin2 = (ushort)10d.ToPixel();
- var radius = 8d.ToPixel();
+ var margin1 = (ushort)(20d * DeviceInfo.DPI / 160.0);
+ var margin2 = (ushort)(10d * DeviceInfo.DPI / 160.0);
+ int radius = (ushort)(8d * DeviceInfo.DPI / 160.0);
content = new View
{
CornerRadius = radius,
- BoxShadow = new Shadow(20d.ToPixel(), TColor.Black.ToNative()),
+ BoxShadow = new Shadow((20f * DeviceInfo.DPI / 160.0f), TColor.Black.ToNative()),
Layout = new LinearLayout
{
VerticalAlignment = VerticalAlignment.Center,
@@ -134,13 +135,13 @@ protected override View CreateContent()
VerticalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Center,
FontAttributes = Tizen.UIExtensions.Common.FontAttributes.Bold,
TextColor = TColor.Black,
- PixelSize = 21d.ToPixel(),
+ PixelSize = 21f * DeviceInfo.DPI / 160.0f,
});
content.Add(new View
{
BackgroundColor = TColor.FromHex("#cccccc").ToNative(),
- SizeHeight = 1.5d.ToPixel(),
+ SizeHeight = 1.5f * DeviceInfo.DPI / 160.0f,
WidthSpecification = LayoutParamPolicies.MatchParent,
});
@@ -161,7 +162,7 @@ protected override View CreateContent()
content.Add(new View
{
BackgroundColor = TColor.FromHex("#cccccc").ToNative(),
- SizeHeight = 1.5d.ToPixel(),
+ SizeHeight = 1.5f * DeviceInfo.DPI / 160.0f,
WidthSpecification = LayoutParamPolicies.MatchParent,
});
@@ -191,7 +192,7 @@ protected override View CreateContent()
var underline = new PropertyMap();
underline.Add("enable", new PropertyValue("True"));
fileNameEntry.Underline = underline;
- fileNameEntry.PixelSize = 15d.ToPixel();
+ fileNameEntry.PixelSize = 15f * DeviceInfo.DPI / 160.0f;
content.Add(fileNameEntry);
}
@@ -216,8 +217,8 @@ protected override View CreateContent()
TextColor = TColor.Black,
BackgroundColor = TColor.Transparent.ToNative(),
};
- cancelButton.TextLabel.PixelSize = 15d.ToPixel();
- cancelButton.SizeWidth = cancelButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
+ cancelButton.TextLabel.PixelSize = 15f * DeviceInfo.DPI / 160.0f;
+ cancelButton.SizeWidth = cancelButton.TextLabel.NaturalSize.Width + 15f * DeviceInfo.DPI / 160.0f * 2;
cancelButton.Clicked += OnCancelButtonClicked;
horizontalLayout.Add(cancelButton);
@@ -228,8 +229,8 @@ protected override View CreateContent()
TextColor = TColor.Black,
BackgroundColor = TColor.Transparent.ToNative(),
};
- okButton.TextLabel.PixelSize = 15d.ToPixel();
- okButton.SizeWidth = okButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
+ okButton.TextLabel.PixelSize = 15f * DeviceInfo.DPI / 160.0f;
+ okButton.SizeWidth = okButton.TextLabel.NaturalSize.Width + 15f * DeviceInfo.DPI / 160.0f * 2;
okButton.Clicked += OnOkButtonClicked;
horizontalLayout.Add(okButton);
@@ -238,7 +239,7 @@ protected override View CreateContent()
return content;
}
- async void OnNewFolderButtonClicked(object? sender, ClickedEventArgs e)
+ async void OnNewFolderButtonClicked(object? sender, Tizen.NUI.Components.ClickedEventArgs e)
{
try
{
@@ -263,12 +264,12 @@ async void OnNewFolderButtonClicked(object? sender, ClickedEventArgs e)
}
}
- void OnCancelButtonClicked(object? sender, ClickedEventArgs e)
+ void OnCancelButtonClicked(object? sender, Tizen.NUI.Components.ClickedEventArgs e)
{
SendCancel();
}
- void OnOkButtonClicked(object? sender, ClickedEventArgs e)
+ void OnOkButtonClicked(object? sender, Tizen.NUI.Components.ClickedEventArgs e)
{
if (isFileSelectionMode)
{
@@ -292,13 +293,13 @@ void OnRelayout(object? sender, EventArgs e)
{
if (content is not null)
{
- content.SizeWidth = Window.Instance.WindowSize.Width * (IsHorizontal() ? 0.5f : 0.8f);
+ content.SizeWidth = Window.Default.WindowSize.Width * (IsHorizontal() ? 0.5f : 0.8f);
}
}
static bool IsHorizontal()
{
- return Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
+ return Window.Default.WindowSize.Width > Window.Default.WindowSize.Height;
}
static bool CreateSubDirectory(string newDirectory)
@@ -368,10 +369,10 @@ void UpdateDirectoryScrollView(string path)
Text = item,
Focusable = true,
HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
- PixelSize = 16d.ToPixel(),
+ PixelSize = 16f * DeviceInfo.DPI / 160.0f,
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.WrapContent,
- Margin = new Extents(0, 0, (ushort)5d.ToPixel(), (ushort)5d.ToPixel()),
+ Margin = new Extents(0, 0, (ushort)(5f * DeviceInfo.DPI / 160.0f), (ushort)(5f * DeviceInfo.DPI / 160.0f)),
};
itemLabel.TouchEvent += (_, e) =>
{
@@ -397,7 +398,7 @@ void UpdateDirectoryScrollView(string path)
directoryScrollView.ContentContainer.Add(itemLabel);
directoryViews.Add(itemLabel);
}
- directoryScrollView.SizeHeight = 30d.ToPixel() * Math.Min(listItems.Count, 5);
+ directoryScrollView.SizeHeight = (30f * DeviceInfo.DPI / 160.0f) * Math.Min(listItems.Count, 5);
}
IReadOnlyList GetDirectories(string path)
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/IDockLayout.shared.cs b/src/CommunityToolkit.Maui.Core/Interfaces/IDockLayout.shared.cs
index 0ecf0ddb8f..409e025df3 100644
--- a/src/CommunityToolkit.Maui.Core/Interfaces/IDockLayout.shared.cs
+++ b/src/CommunityToolkit.Maui.Core/Interfaces/IDockLayout.shared.cs
@@ -3,7 +3,7 @@
///
/// DockLayout is a layout where views can be docked to the sides (top, left, right, bottom) of the layout container.
///
-public interface IDockLayout : ILayout
+public interface IDockLayout : Microsoft.Maui.ILayout
{
///
/// If true, the last child is expanded to fill the remaining space (default: true).
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/Interfaces/IUniformItemsLayout.shared.cs b/src/CommunityToolkit.Maui.Core/Interfaces/IUniformItemsLayout.shared.cs
index 63807f64d6..cbf6decaf2 100644
--- a/src/CommunityToolkit.Maui.Core/Interfaces/IUniformItemsLayout.shared.cs
+++ b/src/CommunityToolkit.Maui.Core/Interfaces/IUniformItemsLayout.shared.cs
@@ -3,7 +3,7 @@
///
/// Uniform Items Layout Control
///
-public interface IUniformItemsLayout : ILayout
+public interface IUniformItemsLayout : Microsoft.Maui.ILayout
{
///
/// Max rows
diff --git a/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.shared.cs b/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.shared.cs
index c667d6631c..1ba15696c9 100644
--- a/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.shared.cs
@@ -9,6 +9,7 @@
using PlatformView = Microsoft.UI.Xaml.FrameworkElement;
#elif TIZEN
using PlatformView = Tizen.NUI.BaseComponents.View;
+using IPlatformViewHandler = Microsoft.Maui.IViewHandler;
#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID && !TIZEN)
using PlatformView = System.Object;
using IPlatformViewHandler = Microsoft.Maui.IViewHandler;
diff --git a/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.tizen.cs b/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.tizen.cs
index e4655dcbd9..4c6c12283e 100644
--- a/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Platform/KeyboardExtensions/KeyboardExtensions.tizen.cs
@@ -4,16 +4,16 @@ namespace CommunityToolkit.Maui.Core.Platform;
public static partial class KeyboardExtensions
{
- static bool HideKeyboard(this View view) => SetKeyInputFocus(view, false);
+ static bool HideKeyboard(this Tizen.NUI.BaseComponents.View view) => SetKeyInputFocus(view, false);
- static bool ShowKeyboard(this View view) => SetKeyInputFocus(view, true);
+ static bool ShowKeyboard(this Tizen.NUI.BaseComponents.View view) => SetKeyInputFocus(view, true);
- static bool IsSoftKeyboardShowing(this View view)
+ static bool IsSoftKeyboardShowing(this Tizen.NUI.BaseComponents.View view)
{
return view.KeyInputFocus;
}
- static bool SetKeyInputFocus(View view, bool isShow)
+ static bool SetKeyInputFocus(Tizen.NUI.BaseComponents.View view, bool isShow)
{
view.KeyInputFocus = isShow;
diff --git a/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.android.cs b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.android.cs
index 86c11bb516..8912091782 100644
--- a/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.android.cs
+++ b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.android.cs
@@ -38,7 +38,16 @@ static void PlatformSetColor(Color color)
if (Activity.Window is not null)
{
var platformColor = color.ToPlatform();
- Activity.Window.SetStatusBarColor(platformColor);
+
+ if (OperatingSystem.IsAndroidVersionAtLeast(35))
+ {
+ var window = Activity.GetCurrentWindow();
+ window.DecorView.SetBackgroundColor(platformColor);
+ }
+ else
+ {
+ Activity.Window.SetStatusBarColor(platformColor);
+ }
bool isColorTransparent = platformColor == PlatformColor.Transparent;
if (isColorTransparent)
@@ -54,7 +63,6 @@ static void PlatformSetColor(Color color)
WindowCompat.SetDecorFitsSystemWindows(Activity.Window, !isColorTransparent);
}
-
}
static void PlatformSetStyle(StatusBarStyle style)
diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs
index 772c45099b..59e34d4e89 100644
--- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs
@@ -1,4 +1,5 @@
using Microsoft.Maui.Platform;
+using Tizen.UIExtensions.Common;
using NPointStateType = Tizen.NUI.PointStateType;
namespace CommunityToolkit.Maui.Core.Views;
@@ -37,7 +38,8 @@ protected override void Dispose(bool disposing)
bool OnTouch(object source, TouchEventArgs e)
{
- var point = new PointF(e.Touch.GetLocalPosition(0).X.ToScaledDP(), e.Touch.GetLocalPosition(0).Y.ToScaledDP());
+ var point = new PointF(e.Touch.GetLocalPosition(0).X / (float)Tizen.UIExtensions.Common.DeviceInfo.ScalingFactor,
+ e.Touch.GetLocalPosition(0).Y / (float)Tizen.UIExtensions.Common.DeviceInfo.ScalingFactor);
var pointStateType = e.Touch.GetState(0);
switch (pointStateType)
diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/PlatformTouchGraphicsView.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/PlatformTouchGraphicsView.tizen.cs
new file mode 100644
index 0000000000..db37258321
--- /dev/null
+++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/PlatformTouchGraphicsView.tizen.cs
@@ -0,0 +1,141 @@
+using Tizen.UIExtensions.NUI.GraphicsView;
+using PointStateType = Tizen.NUI.PointStateType;
+using DeviceInfo = Tizen.UIExtensions.Common.DeviceInfo;
+
+namespace CommunityToolkit.Maui.Core.Views;
+
+///
+/// The Tizen platform-specific view that handles touch input for drawing operations.
+///
+public class PlatformTouchGraphicsView : SkiaGraphicsView
+{
+ IGraphicsView? graphicsView;
+ RectF bounds;
+ bool dragStarted;
+ PointF[] lastMovedViewPoints = Array.Empty();
+ bool pressedContained;
+
+ ///
+ /// Initialize a new instance of the class
+ ///
+ ///
+ public PlatformTouchGraphicsView(IDrawable? drawable = null) : base(drawable)
+ {
+ HoverEvent += OnHoverEvent;
+ TouchEvent += OnTouchEvent;
+ }
+
+ ///
+ /// Handles the view's resize events.
+ ///
+ protected override void OnResized()
+ {
+ base.OnResized();
+ bounds = new RectF(0, 0, (float)(SizeWidth / DeviceInfo.ScalingFactor), (float)(SizeHeight / DeviceInfo.ScalingFactor));
+ }
+
+ ///
+ /// Connects this platform view to the cross-platform IGraphicsView interface.
+ ///
+ ///
+ public void Connect(IGraphicsView graphicsView) => this.graphicsView = graphicsView;
+
+ ///
+ /// Disconnects from the IGraphicsView.
+ ///
+ public void Disconnect() => graphicsView = null;
+
+ bool OnTouchEvent(object source, TouchEventArgs e)
+ {
+ int touchCount = (int)e.Touch.GetPointCount();
+ var touchPoints = new PointF[touchCount];
+ for (uint i = 0; i < touchCount; i++)
+ {
+ touchPoints[i] = new PointF((float)(e.Touch.GetLocalPosition(i).X / DeviceInfo.ScalingFactor), (float)(e.Touch.GetLocalPosition(i).Y / DeviceInfo.ScalingFactor));
+ }
+
+ switch (e.Touch.GetState(0))
+ {
+ case PointStateType.Motion:
+ TouchesMoved(touchPoints);
+ break;
+ case PointStateType.Down:
+ TouchesBegan(touchPoints);
+ break;
+ case PointStateType.Up:
+ TouchesEnded(touchPoints);
+ break;
+ case PointStateType.Interrupted:
+ TouchesCanceled();
+ break;
+ }
+
+ return false;
+ }
+
+ bool OnHoverEvent(object source, HoverEventArgs e)
+ {
+ int touchCount = (int)e.Hover.GetPointCount();
+ var touchPoints = new PointF[touchCount];
+ for (uint i = 0; i < touchCount; i++)
+ {
+ touchPoints[i] = new PointF((float)(e.Hover.GetLocalPosition(i).X / DeviceInfo.ScalingFactor), (float)(e.Hover.GetLocalPosition(i).Y / DeviceInfo.ScalingFactor));
+ }
+
+ switch (e.Hover.GetState(0))
+ {
+ case PointStateType.Motion:
+ graphicsView?.MoveHoverInteraction(touchPoints);
+ break;
+ case PointStateType.Started:
+ graphicsView?.StartHoverInteraction(touchPoints);
+ break;
+ case PointStateType.Finished:
+ graphicsView?.EndHoverInteraction();
+ break;
+ }
+
+ return false;
+ }
+
+ void TouchesBegan(PointF[] points)
+ {
+ dragStarted = false;
+ lastMovedViewPoints = points;
+ graphicsView?.StartInteraction(points);
+ pressedContained = true;
+ }
+
+ void TouchesMoved(PointF[] points)
+ {
+ if (!dragStarted)
+ {
+ if (points.Length == 1)
+ {
+ float deltaX = lastMovedViewPoints[0].X - points[0].X;
+ float deltaY = lastMovedViewPoints[0].Y - points[0].Y;
+
+ if (MathF.Abs(deltaX) <= 3 && MathF.Abs(deltaY) <= 3)
+ {
+ return;
+ }
+ }
+ }
+
+ lastMovedViewPoints = points;
+ dragStarted = true;
+ pressedContained = bounds.ContainsAny(points);
+ graphicsView?.DragInteraction(points);
+ }
+
+ void TouchesEnded(PointF[] points)
+ {
+ graphicsView?.EndInteraction(points, pressedContained);
+ }
+
+ void TouchesCanceled()
+ {
+ pressedContained = false;
+ graphicsView?.CancelInteraction();
+ }
+}
\ 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.Core/Views/SemanticOrderView/ContentViewGroup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/ContentViewGroup.tizen.cs
new file mode 100644
index 0000000000..e434572d8f
--- /dev/null
+++ b/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/ContentViewGroup.tizen.cs
@@ -0,0 +1,107 @@
+using System;
+using Microsoft.Maui.Platform;
+using SkiaSharp;
+using Tizen.UIExtensions.Common;
+using Tizen.UIExtensions.NUI;
+using DeviceInfo = Tizen.UIExtensions.Common.DeviceInfo;
+using Rect = Microsoft.Maui.Graphics.Rect;
+using Size = Microsoft.Maui.Graphics.Size;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace CommunityToolkit.Maui.Core.Views;
+
+///
+/// An Android ViewGroup implementation responible for hosting, measuring, and arranging cross-platform .NET Maui content.
+///
+public class ContentViewGroup : ViewGroup, IMeasurable
+{
+ IView? virtualView;
+ Size measureCache;
+ bool needMeasureUpdate;
+
+ ///
+ /// Initializes a new instance.
+ ///
+ public ContentViewGroup(IView? view)
+ {
+ virtualView = view;
+ LayoutUpdated += OnLayoutUpdated;
+ }
+
+ ///
+ /// Gets or sets the delegate function that invoke the cross-platform measurement logic.
+ ///
+ public Func? CrossPlatformMeasure { get; set; }
+ ///
+ /// /// Gets or sets the delegate function that invoke the cross-platform layout arrange logic.
+ ///
+ public Func? CrossPlatformArrange { get; set; }
+
+ ///
+ /// Marks this view as 'dirty', indicating that it needs to be remeasured.
+ ///
+ public void SetNeedMeasureUpdate()
+ {
+ needMeasureUpdate = true;
+ MarkChanged();
+ }
+
+ ///
+ /// Reset the 'dirty' flayg, indicating that the view's measurement is currently up-to-date.
+ ///
+ public void ClearNeedMeasureUpdate()
+ {
+ needMeasureUpdate = false;
+ }
+
+ ///
+ /// Measures the view and its content using the provided available width and height constraints.
+ ///
+ public TSize Measure(double availableWidth, double availableHeight)
+ {
+ var measuredSize = InvokeCrossPlatformMeasure(availableWidth / DeviceInfo.ScalingFactor, availableHeight / DeviceInfo.ScalingFactor) * DeviceInfo.ScalingFactor;
+ return new TSize(measuredSize.Width, measuredSize.Height);
+ }
+
+ ///
+ /// Executes the cached CrossPlatformMeasure delegate to calculate the desired size of the cross-platform content.
+ ///
+ public Size InvokeCrossPlatformMeasure(double availableWidth, double availableHeight)
+ {
+ if (CrossPlatformMeasure == null)
+ {
+ return Microsoft.Maui.Graphics.Size.Zero;
+ }
+
+ var measured = CrossPlatformMeasure(availableWidth, availableHeight);
+ if (measured != measureCache && virtualView?.Parent is IView parentView)
+ {
+ parentView?.InvalidateMeasure();
+ }
+ measureCache = measured;
+ ClearNeedMeasureUpdate();
+ return measured;
+ }
+
+ void OnLayoutUpdated(object? sender, LayoutEventArgs e)
+ {
+ if (CrossPlatformArrange is null || CrossPlatformMeasure is null)
+ {
+ return;
+ }
+
+ var bounds = this.GetBounds();
+ var platformGeometry = new Rect(bounds.X / DeviceInfo.ScalingFactor, bounds.Y / DeviceInfo.ScalingFactor, bounds.Width / DeviceInfo.ScalingFactor, bounds.Height / DeviceInfo.ScalingFactor);
+ if (needMeasureUpdate || measureCache != platformGeometry.Size)
+ {
+ InvokeCrossPlatformMeasure(platformGeometry.Width, platformGeometry.Height);
+ }
+
+ if (platformGeometry.Width > 0 && platformGeometry.Height > 0)
+ {
+ platformGeometry.X = 0;
+ platformGeometry.Y = 0;
+ CrossPlatformArrange(platformGeometry);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/MauiSemanticOrderView.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/MauiSemanticOrderView.tizen.cs
index a2bbb6d4cc..ab1f3b702d 100644
--- a/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/MauiSemanticOrderView.tizen.cs
+++ b/src/CommunityToolkit.Maui.Core/Views/SemanticOrderView/MauiSemanticOrderView.tizen.cs
@@ -31,27 +31,7 @@ internal void UpdateViewOrder()
{
return;
}
-
- var order = 0;
- foreach (var view in VirtualView.ViewOrder)
- {
- if (view.Handler is IPlatformViewHandler platformViewHandler && platformViewHandler.PlatformView is not null)
- {
- if (platformViewHandler.PlatformView is WrapperView wrapperView)
- {
- if (wrapperView.Content is not null)
- {
- wrapperView.Content.SiblingOrder = order;
- }
- }
- else
- {
- platformViewHandler.PlatformView.SiblingOrder = order;
- }
-
- order++;
- }
- }
+ // Tizen needs to provide IPlatformViewHandler to update view order.
}
}
diff --git a/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj b/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
index c6d5a9df5f..8931d7e343 100644
--- a/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
+++ b/src/CommunityToolkit.Maui.Maps/CommunityToolkit.Maui.Maps.csproj
@@ -7,6 +7,7 @@
true
true
true
+ true
true
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.MediaElement/AppBuilderExtensions.shared.cs b/src/CommunityToolkit.Maui.MediaElement/AppBuilderExtensions.shared.cs
index 3f7eb88638..57a0d3c49f 100644
--- a/src/CommunityToolkit.Maui.MediaElement/AppBuilderExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/AppBuilderExtensions.shared.cs
@@ -2,6 +2,7 @@
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Core.Handlers;
using CommunityToolkit.Maui.Views;
+using Microsoft.Maui.Hosting;
namespace CommunityToolkit.Maui;
diff --git a/src/CommunityToolkit.Maui.MediaElement/AssemblyInfo.shared.cs b/src/CommunityToolkit.Maui.MediaElement/AssemblyInfo.shared.cs
index 5e4f0ffdb0..9bfc65fdd5 100644
--- a/src/CommunityToolkit.Maui.MediaElement/AssemblyInfo.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/AssemblyInfo.shared.cs
@@ -1,8 +1,9 @@
-[assembly: XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Converters))]
-[assembly: XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core))]
-[assembly: XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core.Handlers))]
-[assembly: XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core.Views))]
-[assembly: XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Views))]
+
+[assembly: Microsoft.Maui.Controls.XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Converters))]
+[assembly: Microsoft.Maui.Controls.XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core))]
+[assembly: Microsoft.Maui.Controls.XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core.Handlers))]
+[assembly: Microsoft.Maui.Controls.XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Core.Views))]
+[assembly: Microsoft.Maui.Controls.XmlnsDefinition(Constants.XamlNamespace, Constants.CommunityToolkitNamespacePrefix + nameof(CommunityToolkit.Maui.Views))]
[assembly: Microsoft.Maui.Controls.XmlnsPrefix(Constants.XamlNamespace, "toolkit")]
diff --git a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
index 9ea02c384d..63a476189c 100644
--- a/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
+++ b/src/CommunityToolkit.Maui.MediaElement/CommunityToolkit.Maui.MediaElement.csproj
@@ -8,6 +8,7 @@
true
true
true
+ true
15.0
@@ -59,13 +60,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/CommunityToolkit.Maui.MediaElement/Extensions/ElementExtensions.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Extensions/ElementExtensions.shared.cs
index 8d285d3610..12d37aaa56 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Extensions/ElementExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Extensions/ElementExtensions.shared.cs
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
+using Microsoft.Maui.Controls;
namespace CommunityToolkit.Maui.Extensions;
static class ElementExtensions
diff --git a/src/CommunityToolkit.Maui.MediaElement/Extensions/PageExtensions.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Extensions/PageExtensions.shared.cs
index 80f66de283..0838febf93 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Extensions/PageExtensions.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Extensions/PageExtensions.shared.cs
@@ -1,3 +1,4 @@
+using Microsoft.Maui.Controls;
namespace CommunityToolkit.Maui.Extensions;
// Since MediaElement can't access .NET MAUI internals we have to copy this code here
diff --git a/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.shared.cs
index 62a9d8e8a4..00cc22a626 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.shared.cs
@@ -1,5 +1,6 @@
using CommunityToolkit.Maui.Core.Views;
using CommunityToolkit.Maui.Views;
+using Microsoft.Maui;
namespace CommunityToolkit.Maui.Core.Handlers;
diff --git a/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs
index bbc29f0064..c388b779b0 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Handlers/MediaElementHandler.windows.cs
@@ -1,5 +1,6 @@
using CommunityToolkit.Maui.Core.Views;
using CommunityToolkit.Maui.Views;
+using Microsoft.Maui.Dispatching;
using Microsoft.Maui.Handlers;
namespace CommunityToolkit.Maui.Core.Handlers;
diff --git a/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs
index a8f7ea3ebb..41334f086c 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Interfaces/IMediaElement.shared.cs
@@ -1,4 +1,5 @@
using CommunityToolkit.Maui.Views;
+using Microsoft.Maui;
namespace CommunityToolkit.Maui.Core;
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs
index 6d663135f2..957bdfd78f 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs
@@ -1,6 +1,9 @@
using System.ComponentModel;
using CommunityToolkit.Maui.Converters;
using CommunityToolkit.Maui.Core;
+using Microsoft.Maui;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Dispatching;
namespace CommunityToolkit.Maui.Views;
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaElementOptions.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaElementOptions.shared.cs
index 48ae9649c7..5a1bb58ce0 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaElementOptions.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaElementOptions.shared.cs
@@ -1,4 +1,8 @@
-namespace CommunityToolkit.Maui.Core;
+using CommunityToolkit.Maui.Core.Views;
+using Microsoft.Maui;
+using Microsoft.Maui.Hosting;
+
+namespace CommunityToolkit.Maui.Core;
///
/// Construction options for MediaElement, for example, to create an Android SurfaceView or TextureView
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs
index 8a83771a42..8c803481be 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/FileMediaSource.shared.cs
@@ -1,5 +1,6 @@
using System.ComponentModel;
using CommunityToolkit.Maui.Converters;
+using Microsoft.Maui.Controls;
namespace CommunityToolkit.Maui.Views;
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs
index 9d716e9f87..4542838487 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/MediaSource.shared.cs
@@ -1,5 +1,7 @@
using System.ComponentModel;
using CommunityToolkit.Maui.Converters;
+using Microsoft.Maui;
+using Microsoft.Maui.Controls;
namespace CommunityToolkit.Maui.Views;
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs
index 8314c160b2..69af77baf4 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/ResourceMediaSource.shared.cs
@@ -1,5 +1,6 @@
using System.ComponentModel;
using CommunityToolkit.Maui.Converters;
+using Microsoft.Maui.Controls;
namespace CommunityToolkit.Maui.Views;
diff --git a/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs b/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs
index c05c97df93..a7c4143069 100644
--- a/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/MediaSource/UriMediaSource.shared.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using Microsoft.Maui.Controls;
using UriTypeConverter = Microsoft.Maui.Controls.UriTypeConverter;
namespace CommunityToolkit.Maui.Views;
diff --git a/src/CommunityToolkit.Maui.MediaElement/Primitives/Metadata.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Primitives/Metadata.windows.cs
index 47180da2e7..9b71a68ee9 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Primitives/Metadata.windows.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Primitives/Metadata.windows.cs
@@ -1,4 +1,5 @@
-using Windows.Media;
+using Microsoft.Maui.Dispatching;
+using Windows.Media;
namespace CommunityToolkit.Maui.Core.Primitives;
diff --git a/src/CommunityToolkit.Maui.MediaElement/Services/MediaControlsService.android.cs b/src/CommunityToolkit.Maui.MediaElement/Services/MediaControlsService.android.cs
index db27fa8054..c1b6de91d3 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Services/MediaControlsService.android.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Services/MediaControlsService.android.cs
@@ -111,7 +111,7 @@ public void SetLegacyNotifications(in MediaSession session, in PlatformMediaElem
playerNotificationManager.SetColor(Resource.Color.abc_primary_text_material_dark);
playerNotificationManager.SetUsePreviousActionInCompactView(true);
playerNotificationManager.SetVisibility(NotificationCompat.VisibilityPublic);
- playerNotificationManager.SetMediaSessionToken(session.SessionCompatToken);
+ playerNotificationManager.SetMediaSessionToken(session.PlatformToken);
playerNotificationManager.SetPlayer(mediaElement);
playerNotificationManager.SetColorized(true);
playerNotificationManager.SetShowPlayButtonIfPlaybackIsSuppressed(true);
diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.tizen.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.tizen.cs
index a0495f3c04..4222b5bdc7 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.tizen.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.tizen.cs
@@ -1,13 +1,12 @@
using CommunityToolkit.Maui.Views;
using Tizen.NUI.BaseComponents;
-using Tizen.UIExtensions.NUI;
namespace CommunityToolkit.Maui.Core.Views;
///
/// The user-interface element that represents the on Tizen.
///
-public class MauiMediaElement : ViewGroup
+public class MauiMediaElement : Tizen.NUI.BaseComponents.View
{
VideoView videoView;
@@ -18,7 +17,7 @@ public class MauiMediaElement : ViewGroup
public MauiMediaElement(VideoView videoView)
{
this.videoView = videoView;
- Children.Add(videoView);
+ Add(videoView);
}
///
diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
index 42e706bf00..3ca4b23d6b 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Views/MauiMediaElement.windows.cs
@@ -3,6 +3,8 @@
using CommunityToolkit.Maui.Extensions;
using CommunityToolkit.Maui.Primitives;
using CommunityToolkit.Maui.Views;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Devices;
using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
@@ -150,8 +152,8 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
mediaPlayerElement.MediaPlayer.Pause();
-
- if(mediaPlayerElement.MediaPlayer.Source is Windows.Media.Core.MediaSource mediaSource)
+
+ if (mediaPlayerElement.MediaPlayer.Source is Windows.Media.Core.MediaSource mediaSource)
{
// Dispose the MediaSource to release the resources
// https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/play-audio-and-video-with-mediaplayer Shows how to dispose the MediaSource
diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.shared.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.shared.cs
index 195537fb62..e4beddcf16 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.shared.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.shared.cs
@@ -11,6 +11,11 @@
#endif
using Microsoft.Extensions.Logging;
+using Microsoft.Maui;
+using System;
+using Microsoft.Maui.Dispatching;
+using Microsoft.Maui.Controls;
+using Microsoft.Extensions.DependencyInjection;
namespace CommunityToolkit.Maui.Core.Views;
@@ -25,7 +30,7 @@ public partial class MediaManager
/// This application's .
/// The instance that is managed through this class.
/// The instance that allows propagation to the main thread.
- public MediaManager(IMauiContext context, IMediaElement mediaElement, IDispatcher dispatcher)
+ public MediaManager(Microsoft.Maui.IMauiContext context, IMediaElement mediaElement, IDispatcher dispatcher)
{
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(mediaElement);
@@ -46,12 +51,12 @@ public MediaManager(IMauiContext context, IMediaElement mediaElement, IDispatche
///
/// The used by this class.
///
- protected IMauiContext MauiContext { get; }
+ protected Microsoft.Maui.IMauiContext MauiContext { get; }
///
/// The that allows propagation to the main thread
///
- protected IDispatcher Dispatcher { get; }
+ protected Microsoft.Maui.Dispatching.IDispatcher Dispatcher { get; }
///
/// Gets the instance for logging purposes.
diff --git a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
index 39fe2aebb1..c1761bcc59 100644
--- a/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
+++ b/src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.windows.cs
@@ -4,6 +4,9 @@
using CommunityToolkit.Maui.Extensions;
using CommunityToolkit.Maui.Views;
using Microsoft.Extensions.Logging;
+using Microsoft.Maui;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Dispatching;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using Windows.Media;
diff --git a/src/CommunityToolkit.Maui.SourceGenerators.Internal/BindablePropertyAttributeSourceGenerator.cs b/src/CommunityToolkit.Maui.SourceGenerators.Internal/BindablePropertyAttributeSourceGenerator.cs
index 21cd6b6513..6dfbd8c38d 100644
--- a/src/CommunityToolkit.Maui.SourceGenerators.Internal/BindablePropertyAttributeSourceGenerator.cs
+++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal/BindablePropertyAttributeSourceGenerator.cs
@@ -6,6 +6,7 @@
using CommunityToolkit.Maui.SourceGenerators.Internal.Helpers;
using CommunityToolkit.Maui.SourceGenerators.Internal.Models;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
@@ -23,41 +24,40 @@ public class BindablePropertyAttributeSourceGenerator : IIncrementalGenerator
/* language=C#-test */
//lang=csharp
$$"""
- //
- // See: CommunityToolkit.Maui.SourceGenerators.Internal.BindablePropertyAttributeSourceGenerator
-
- #pragma warning disable
- #nullable enable
- namespace CommunityToolkit.Maui;
-
- [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
- [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
- sealed partial class BindablePropertyAttribute : Attribute
- {
- public string? PropertyName { get; }
- public Type? DeclaringType { get; set; }
- public object? DefaultValue { get; set; }
- public string DefaultBindingMode { get; set; } = string.Empty;
- public string ValidateValueMethodName { get; set; } = string.Empty;
- public string PropertyChangedMethodName { get; set; } = string.Empty;
- public string PropertyChangingMethodName { get; set; } = string.Empty;
- public string CoerceValueMethodName { get; set; } = string.Empty;
- public string DefaultValueCreatorMethodName { get; set; } = string.Empty;
-
- public BindablePropertyAttribute(string propertyName)
- {
- PropertyName = propertyName;
- }
-
- public BindablePropertyAttribute()
- {
- }
- }
- """;
+ //
+ // See: CommunityToolkit.Maui.SourceGenerators.Internal.BindablePropertyAttributeSourceGenerator
+
+ #pragma warning disable
+ #nullable enable
+ namespace CommunityToolkit.Maui;
+
+ [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
+ sealed partial class BindablePropertyAttribute : Attribute
+ {
+ public string? PropertyName { get; }
+ public Type? DeclaringType { get; set; }
+ public object? DefaultValue { get; set; }
+ public string DefaultBindingMode { get; set; } = string.Empty;
+ public string ValidateValueMethodName { get; set; } = string.Empty;
+ public string PropertyChangedMethodName { get; set; } = string.Empty;
+ public string PropertyChangingMethodName { get; set; } = string.Empty;
+ public string CoerceValueMethodName { get; set; } = string.Empty;
+ public string DefaultValueCreatorMethodName { get; set; } = string.Empty;
+
+ public BindablePropertyAttribute(string propertyName)
+ {
+ PropertyName = propertyName;
+ }
+
+ public BindablePropertyAttribute()
+ {
+ }
+ }
+ """;
public void Initialize(IncrementalGeneratorInitializationContext context)
{
-
#if DEBUG
if (!Debugger.IsAttached)
@@ -82,8 +82,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
static void ExecuteAllValues(SourceProductionContext context, ImmutableArray semanticValues)
{
var groupedValues = semanticValues
- .GroupBy(static sv => (sv.ClassInformation.ClassName, sv.ClassInformation.ContainingNamespace))
- .ToDictionary(static d => d.Key, static d => d.ToArray());
+ .GroupBy(static sv => (sv.ClassInformation.ClassName, sv.ClassInformation.ContainingNamespace))
+ .ToDictionary(static d => d.Key, static d => d.ToArray());
foreach (var keyValuePair in groupedValues)
{
@@ -174,8 +174,7 @@ static void GenerateProperty(StringBuilder sb, BindablePropertyModel info)
// set => SetValue(TextProperty, value);
// }
//
-
- sb.AppendLine($"public partial {info.ReturnType} {info.PropertyName}")
+ sb.AppendLine($"public {info.NewKeywordText}partial {info.ReturnType} {info.PropertyName}")
.AppendLine("{")
.Append("get => (")
.Append(info.ReturnType)
@@ -191,7 +190,7 @@ static SemanticValues SemanticTransform(GeneratorAttributeSyntaxContext context,
{
var propertyDeclarationSyntax = Unsafe.As(context.TargetNode);
var semanticModel = context.SemanticModel;
- var propertySymbol = (IPropertySymbol?)semanticModel.GetDeclaredSymbol(propertyDeclarationSyntax, cancellationToken);
+ var propertySymbol = (IPropertySymbol?)ModelExtensions.GetDeclaredSymbol(semanticModel, propertyDeclarationSyntax, cancellationToken);
if (propertySymbol is null)
{
@@ -207,13 +206,15 @@ static SemanticValues SemanticTransform(GeneratorAttributeSyntaxContext context,
var bindablePropertyModels = new List(context.Attributes.Length);
+ var doesContainNewKeyword = propertyDeclarationSyntax.Modifiers.Any(static x => x.IsKind(SyntaxKind.NewKeyword));
+
var attributeData = context.Attributes[0];
- bindablePropertyModels.Add(CreateBindablePropertyModel(attributeData, propertySymbol.Type.ToDisplayString(), propertySymbol.Name, returnType));
+ bindablePropertyModels.Add(CreateBindablePropertyModel(attributeData, propertySymbol.Type.ToDisplayString(), propertySymbol.Name, returnType, doesContainNewKeyword));
return new(propertyInfo, bindablePropertyModels.ToImmutableArray());
}
- static BindablePropertyModel CreateBindablePropertyModel(in AttributeData attributeData, in string declaringTypeString, in string defaultName, in ITypeSymbol returnType)
+ static BindablePropertyModel CreateBindablePropertyModel(in AttributeData attributeData, in string declaringTypeString, in string defaultName, in ITypeSymbol returnType, in bool doesContainNewKeyword)
{
if (attributeData.AttributeClass is null)
{
@@ -229,20 +230,9 @@ static BindablePropertyModel CreateBindablePropertyModel(in AttributeData attrib
var propertyChangingMethodName = attributeData.GetNamedArgumentsAttributeValueByNameAsString(nameof(BindablePropertyModel.PropertyChangingMethodName));
var propertyName = attributeData.GetConstructorArgumentsAttributeValueByNameAsString(defaultName);
var validateValueMethodName = attributeData.GetNamedArgumentsAttributeValueByNameAsString(nameof(BindablePropertyModel.ValidateValueMethodName));
+ var newKeywordText = doesContainNewKeyword ? "new " : string.Empty;
- return new BindablePropertyModel
- {
- CoerceValueMethodName = coerceValueMethodName,
- DefaultBindingMode = defaultBindingMode,
- DefaultValue = defaultValue,
- DefaultValueCreatorMethodName = defaultValueCreatorMethodName,
- DeclaringType = declaringType,
- PropertyChangedMethodName = propertyChangedMethodName,
- PropertyChangingMethodName = propertyChangingMethodName,
- PropertyName = propertyName,
- ReturnType = returnType,
- ValidateValueMethodName = validateValueMethodName
- };
+ return new BindablePropertyModel(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValueMethodName, propertyChangedMethodName, propertyChangingMethodName, coerceValueMethodName, defaultValueCreatorMethodName, newKeywordText);
}
static bool SyntaxPredicate(SyntaxNode node, CancellationToken cancellationToken) =>
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.Internal/Models/Records.cs b/src/CommunityToolkit.Maui.SourceGenerators.Internal/Models/Records.cs
index c17849f8af..fd9cb5133f 100644
--- a/src/CommunityToolkit.Maui.SourceGenerators.Internal/Models/Records.cs
+++ b/src/CommunityToolkit.Maui.SourceGenerators.Internal/Models/Records.cs
@@ -3,19 +3,7 @@
namespace CommunityToolkit.Maui.SourceGenerators.Internal.Models;
-record BindablePropertyModel
-{
- public string PropertyName { get; set; } = string.Empty;
- public ITypeSymbol? ReturnType { get; set; }
- public string DeclaringType { get; set; } = string.Empty;
- public string DefaultValue { get; set; } = string.Empty;
- public string DefaultBindingMode { get; set; } = string.Empty;
- public string ValidateValueMethodName { get; set; } = string.Empty;
- public string PropertyChangedMethodName { get; set; } = string.Empty;
- public string PropertyChangingMethodName { get; set; } = string.Empty;
- public string CoerceValueMethodName { get; set; } = string.Empty;
- public string DefaultValueCreatorMethodName { get; set; } = string.Empty;
-}
+record BindablePropertyModel(string PropertyName, ITypeSymbol? ReturnType, string DeclaringType, string DefaultValue, string DefaultBindingMode, string ValidateValueMethodName, string PropertyChangedMethodName, string PropertyChangingMethodName, string CoerceValueMethodName, string DefaultValueCreatorMethodName, string NewKeywordText);
record SemanticValues(ClassInformation ClassInformation, EquatableArray BindableProperties);
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 @@
-
+
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/AnimationBehaviorTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/AnimationBehaviorTests.cs
index 6a90f1012e..513aa73977 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/AnimationBehaviorTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/AnimationBehaviorTests.cs
@@ -233,7 +233,7 @@ public override async Task Animate(VisualElement element, CancellationToken toke
AnimationStarted?.Invoke(this, EventArgs.Empty);
- await element.RotateTo(70).WaitAsync(token);
+ await element.RotateToAsync(70).WaitAsync(token);
HasAnimated = true;
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorGenericTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorGenericTests.cs
index c2380aac22..c54d8d1176 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorGenericTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorGenericTests.cs
@@ -9,6 +9,7 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;
public class EventToCommandBehaviorGenericTests() : BaseBehaviorTest, VisualElement>(new EventToCommandBehavior(), new View())
{
[Fact]
+ [Obsolete]
public void ArgumentExceptionIfSpecifiedEventDoesNotExist()
{
var listView = new ListView();
@@ -20,6 +21,7 @@ public void ArgumentExceptionIfSpecifiedEventDoesNotExist()
}
[Fact]
+ [Obsolete]
public void NoExceptionIfSpecifiedEventExists()
{
var listView = new ListView();
@@ -42,6 +44,7 @@ public void NoExceptionIfAttachedToPage()
}
[Fact]
+ [Obsolete]
public void NoExceptionWhenTheEventArgsAreNotNull()
{
var vm = new ViewModelCoffee();
@@ -71,6 +74,7 @@ public void NoExceptionWhenTheEventArgsAreNotNull()
}
[Fact]
+ [Obsolete]
public void NoExceptionWhenTheEventArgsAreNotNull_InheritedType()
{
var vm = new ViewModelCoffee();
@@ -100,6 +104,7 @@ public void NoExceptionWhenTheEventArgsAreNotNull_InheritedType()
}
[Fact]
+ [Obsolete]
public void ParameterOfTypeInt()
{
var vm = new ViewModelCoffee();
@@ -119,6 +124,7 @@ public void ParameterOfTypeInt()
}
[Fact]
+ [Obsolete]
public void NoExceptionWhenTheSelectedItemIsNull()
{
var vm = new ViewModelCoffee();
@@ -142,6 +148,7 @@ public void NoExceptionWhenTheSelectedItemIsNull()
}
[Fact]
+ [Obsolete]
public void HappilyUsesIValueConverterImplementation()
{
var vm = new ViewModelCoffee();
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorTests.cs
index c7e895a5db..9039eeec0e 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/EventToCommandBehaviorTests.cs
@@ -6,6 +6,7 @@ namespace CommunityToolkit.Maui.UnitTests.Behaviors;
public class EventToCommandBehaviorTests() : BaseBehaviorTest(new EventToCommandBehavior(), new View())
{
[Fact]
+ [Obsolete]
public void ArgumentExceptionIfSpecifiedEventDoesNotExist()
{
var listView = new ListView();
@@ -17,6 +18,7 @@ public void ArgumentExceptionIfSpecifiedEventDoesNotExist()
}
[Fact]
+ [Obsolete]
public void NoExceptionIfSpecifiedEventExists()
{
var listView = new ListView();
@@ -39,6 +41,7 @@ public void NoExceptionIfAttachedToPage()
}
[Fact]
+ [Obsolete]
public void ListView_ItemSelected_Test()
{
bool didEventToCommandBehaviorFire = false;
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaskedBehaviorTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaskedBehaviorTests.cs
index 2bbb594f59..d8faa8683e 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaskedBehaviorTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaskedBehaviorTests.cs
@@ -58,6 +58,7 @@ public void ValidMaskWithUniqueUnmaskedCharacterTests(string? mask, char unmaske
}
[Fact]
+ [Obsolete]
public void AttachedToInvalidElementTest()
{
IReadOnlyList invalidVisualElements =
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaxLengthReachedBehaviorTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaxLengthReachedBehaviorTests.cs
index 1ec0d31085..cb83357e34 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaxLengthReachedBehaviorTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/MaxLengthReachedBehaviorTests.cs
@@ -140,6 +140,7 @@ public void ShouldNotDismissKeyboardWhenOptionSetToFalse()
Assert.True(entry.IsFocused);
}
+ [Obsolete]
static Entry CreateEntry(int? maxLength = 2,
bool shouldDismissKeyboardAutomatically = false,
ICommand? command = null,
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/SetFocusOnEntryCompletedTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/SetFocusOnEntryCompletedTests.cs
index 53633fb758..e881a9aa19 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/SetFocusOnEntryCompletedTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/SetFocusOnEntryCompletedTests.cs
@@ -35,6 +35,7 @@ public void SetsFocusWhenCompleted()
Assert.True(entry2.IsFocused);
}
+ [Obsolete]
static Entry CreateEntry(VisualElement? nextElement = null)
{
var entry = new Entry();
diff --git a/src/CommunityToolkit.Maui.UnitTests/Behaviors/UserStoppedTypingBehaviorTests.cs b/src/CommunityToolkit.Maui.UnitTests/Behaviors/UserStoppedTypingBehaviorTests.cs
index 783aa095a8..60135a46ad 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Behaviors/UserStoppedTypingBehaviorTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Behaviors/UserStoppedTypingBehaviorTests.cs
@@ -241,6 +241,7 @@ public async Task ShouldExecuteCommandImmediatelyWhenMinimumLengthThresholdHasNo
Assert.True(commandHasBeenExecuted);
}
+ [Obsolete]
static Entry CreateEntryWithBehavior(int stoppedTypingTimeThreshold = 500,
int minimumLengthThreshold = 0,
bool shouldDismissKeyboardAutomatically = false,
diff --git a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
index 35e24717d4..1595de8092 100644
--- a/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
+++ b/src/CommunityToolkit.Maui.UnitTests/CommunityToolkit.Maui.UnitTests.csproj
@@ -10,21 +10,14 @@
-
+
-
+
-
-
-
-
-
-
-
diff --git a/src/CommunityToolkit.Maui.UnitTests/Converters/ItemTappedEventArgsConverterTests.cs b/src/CommunityToolkit.Maui.UnitTests/Converters/ItemTappedEventArgsConverterTests.cs
index 076a27095f..16d4170302 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Converters/ItemTappedEventArgsConverterTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Converters/ItemTappedEventArgsConverterTests.cs
@@ -4,6 +4,7 @@
namespace CommunityToolkit.Maui.UnitTests.Converters;
+[Obsolete]
public class ItemTappedEventArgsConverterTests : BaseOneWayConverterTest
{
public static TheoryData Data { get; } = new()
@@ -24,6 +25,7 @@ public class ItemTappedEventArgsConverterTests : BaseOneWayConverterTest element.RotateTo(0.75, 500).WaitAsync(token);
+ static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateToAsync(0.75, 500).WaitAsync(token);
}
[Fact(Timeout = (int)TestDuration.Long)]
@@ -257,7 +257,7 @@ public async Task StateContainer_FuncAnimation_Timeout()
await Task.Delay(10, TestContext.Current.CancellationToken);
await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Error, null, CustomAnimation, cancelledTokenSource.Token));
- static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateTo(0.75, 1000).WaitAsync(token);
+ static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateToAsync(0.75, 1000).WaitAsync(token);
}
[Fact(Timeout = (int)TestDuration.Long)]
@@ -275,7 +275,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -307,7 +307,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -339,7 +339,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -376,7 +376,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -421,7 +421,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -432,7 +432,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
Assert.True(StateContainer.GetCanStateChange(layout));
- static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateTo(0.75, 500).WaitAsync(token);
+ static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateToAsync(0.75, 500).WaitAsync(token);
}
[Fact(Timeout = (int)TestDuration.Long)]
@@ -450,7 +450,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -461,7 +461,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
Assert.True(StateContainer.GetCanStateChange(layout));
- static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateTo(0.75, 500).WaitAsync(token);
+ static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateToAsync(0.75, 500).WaitAsync(token);
}
[Fact(Timeout = (int)TestDuration.Long)]
@@ -479,7 +479,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
var exception = Assert.Throws(() => StateContainer.SetCurrentState(layout, StateKey.Anything));
var exception2 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, TestContext.Current.CancellationToken));
var exception3 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, [], null, TestContext.Current.CancellationToken));
- var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeTo(1), null, TestContext.Current.CancellationToken));
+ var exception4 = await Assert.ThrowsAsync(() => StateContainer.ChangeStateWithAnimation(layout, StateKey.Anything, (element, _) => element.FadeToAsync(1), null, TestContext.Current.CancellationToken));
await changeStateWithAnimationTask;
@@ -490,7 +490,7 @@ public async Task StateContainer_ChangingStateWhenCanStateChangePropertyIsFalse_
Assert.True(StateContainer.GetCanStateChange(layout));
- static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateTo(0.75, 500).WaitAsync(token);
+ static Task CustomAnimation(VisualElement element, CancellationToken token) => element.RotateToAsync(0.75, 500).WaitAsync(token);
}
[Fact]
diff --git a/src/CommunityToolkit.Maui.UnitTests/Layouts/UniformItemsLayoutTests.cs b/src/CommunityToolkit.Maui.UnitTests/Layouts/UniformItemsLayoutTests.cs
index 7418f7694e..448adfa968 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Layouts/UniformItemsLayoutTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Layouts/UniformItemsLayoutTests.cs
@@ -97,6 +97,7 @@ public void MaxRowsArrangeChildrenUniformItemsLayout()
}
[Fact]
+ [Obsolete]
public void ArrangeChildrenUniformItemsLayout()
{
var childSize = new Size(childWidth, childHeight);
diff --git a/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs b/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
index 8c9e36600e..86ef495d33 100644
--- a/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
+++ b/src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
@@ -90,8 +90,8 @@ public async Task ShowPopupAsync_AwaitingShowPopupAsync_EnsurePreviousPopupClose
var popupService = ServiceProvider.GetRequiredService();
// Act
- await popupService.ShowPopupAsync(navigation, PopupOptions.Empty, CancellationToken.None);
- await popupService.ShowPopupAsync(navigation, PopupOptions.Empty, CancellationToken.None);
+ await popupService.ShowPopupAsync(navigation, PopupOptions.Empty, TestContext.Current.CancellationToken);
+ await popupService.ShowPopupAsync(navigation, PopupOptions.Empty, TestContext.Current.CancellationToken);
// Assert
Assert.Empty(navigation.ModalStack);
@@ -109,8 +109,8 @@ public async Task ShowPopupAsync_UsingPage_AwaitingShowPopupAsync_EnsurePrevious
}
// Act
- await popupService.ShowPopupAsync(page, PopupOptions.Empty, CancellationToken.None);
- await popupService.ShowPopupAsync(page, PopupOptions.Empty, CancellationToken.None);
+ await popupService.ShowPopupAsync(page, PopupOptions.Empty, TestContext.Current.CancellationToken);
+ await popupService.ShowPopupAsync(page, PopupOptions.Empty, TestContext.Current.CancellationToken);
// Assert
Assert.Empty(navigation.ModalStack);
@@ -203,7 +203,7 @@ public async Task ShowPopupAsync_CancellationTokenExpired()
var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(1));
// Act
- await Task.Delay(100, CancellationToken.None);
+ await Task.Delay(100, TestContext.Current.CancellationToken);
if (Application.Current?.Windows[0].Page is not Page page)
{
@@ -262,7 +262,7 @@ public async Task ShowPopupAsyncShouldReturnResultOnceClosed()
}
// Act
- var result = await popupService.ShowPopupAsync(page.Navigation, PopupOptions.Empty, CancellationToken.None);
+ var result = await popupService.ShowPopupAsync(page.Navigation, PopupOptions.Empty, TestContext.Current.CancellationToken);
// Assert
Assert.Same(mockPopup.Result, result.Result);
@@ -281,7 +281,7 @@ public async Task ShowPopupTAsyncShouldReturnResultOnceClosed()
}
// Act
- var result = await popupService.ShowPopupAsync(page.Navigation, PopupOptions.Empty, CancellationToken.None);
+ var result = await popupService.ShowPopupAsync(page.Navigation, PopupOptions.Empty, TestContext.Current.CancellationToken);
// Assert
Assert.False(result.WasDismissedByTappingOutsideOfPopup);
@@ -295,7 +295,7 @@ public async Task ShowPopupAsync_UsingNavigation_ShouldThrowArgumentNullExceptio
// Act // Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
- await Assert.ThrowsAsync(() => popupService.ShowPopupAsync((INavigation?)null, PopupOptions.Empty, CancellationToken.None));
+ await Assert.ThrowsAsync(() => popupService.ShowPopupAsync((INavigation?)null, PopupOptions.Empty, TestContext.Current.CancellationToken));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}
@@ -307,7 +307,7 @@ public async Task ShowPopupAsync_UsingPage_ShouldThrowArgumentNullException_When
// Act // Assert
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
- await Assert.ThrowsAsync(() => popupService.ShowPopupAsync((Page?)null, PopupOptions.Empty, CancellationToken.None));
+ await Assert.ThrowsAsync(() => popupService.ShowPopupAsync((Page?)null, PopupOptions.Empty, TestContext.Current.CancellationToken));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
}
@@ -387,7 +387,7 @@ public async Task ShowPopupAsync_ShouldThrowArgumentNullException_WhenViewModelI
}
// Act // Assert
- await Assert.ThrowsAsync(() => popupService.ShowPopupAsync