Code cleanup and preparation for the next release (breaking changes) (#1324)
* Code cleanup and preparation for .net 8 * Update CompareConverter.shared.cs * Revert global.json * More CleanUps * Remove redundant TrySetCanceled and rely on speech recognition result * Update Formatting --------- Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com>
This commit is contained in:
Родитель
272bb46c58
Коммит
930b4684b6
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<NetVersion>net7.0</NetVersion>
|
||||
<!-- Fixes https://github.com/dotnet/maui/pull/12114 -->
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<LangVersion>latest</LangVersion>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net7.0-ios')) != true">
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('$(NetVersion)-ios')) != true">
|
||||
<Compile Remove="**\**\*.ios.cs" />
|
||||
<None Include="**\**\*.ios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
<Compile Remove="**\ios\**\*.cs" />
|
||||
<None Include="**\ios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('net7.0-maccatalyst')) != true">
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('$(NetVersion)-maccatalyst')) != true">
|
||||
<Compile Remove="**\*.macos.cs" />
|
||||
<None Include="**\*.macos.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
<Compile Remove="**\macos\**\*.cs" />
|
||||
<None Include="**\macos\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('net7.0-ios')) != true AND $(TargetFramework.StartsWith('net7.0-maccatalyst')) != true">
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('Xamarin.Mac')) != true AND $(TargetFramework.StartsWith('Xamarin.iOS')) != true AND $(TargetFramework.StartsWith('$(NetVersion)-ios')) != true AND $(TargetFramework.StartsWith('$(NetVersion)-maccatalyst')) != true">
|
||||
<Compile Remove="**\*.macios.cs" />
|
||||
<None Include="**\*.macios.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
<Compile Remove="**\macios\**\*.cs" />
|
||||
<None Include="**\macios\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('net7.0-android')) != true ">
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith('MonoAndroid')) != true AND $(TargetFramework.StartsWith('$(NetVersion)-android')) != true ">
|
||||
<Compile Remove="**\**\*.android.cs" />
|
||||
<None Include="**\**\*.android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
|
||||
<Compile Remove="**\android\**\*.cs" />
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0-ios;net7.0-android;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
|
||||
<TargetFrameworks>$(NetVersion)-ios;$(NetVersion)-android;$(NetVersion)-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<Picker
|
||||
Grid.Row="2"
|
||||
ItemsSource="{Binding Locales}"
|
||||
SelectedItem="{Binding Locale}"
|
||||
SelectedItem="{Binding CurrentLocale}"
|
||||
ItemDisplayBinding="{Binding ., Converter={StaticResource PickerLocaleDisplayConverter}}"
|
||||
Margin="0,0,0,20">
|
||||
</Picker>
|
||||
|
|
|
@ -20,8 +20,7 @@ public partial class ShowPopupInOnAppearingPage : BasePage<ShowPopupInOnAppearin
|
|||
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
|
||||
// Proves that we now support showing a popup before the platform is even ready.
|
||||
var result = await this.ShowPopupAsync(new ReturnResultPopup(popupSizeConstants));
|
||||
await this.ShowPopupAsync(new ReturnResultPopup(popupSizeConstants));
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Maui.Dispatching;
|
||||
|
||||
|
@ -58,7 +59,7 @@ public sealed partial class ByteArrayToImageSourceConverterViewModel : BaseViewM
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
Trace.WriteLine(e);
|
||||
OnImageDownloadFailed(e.Message);
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -18,7 +18,7 @@ public partial class SpeechToTextViewModel : BaseViewModel
|
|||
readonly ISpeechToText speechToText;
|
||||
|
||||
[ObservableProperty]
|
||||
Locale? locale;
|
||||
Locale? currentLocale;
|
||||
|
||||
[ObservableProperty]
|
||||
string? recognitionText = "Welcome to .NET MAUI Community Toolkit!";
|
||||
|
@ -45,7 +45,7 @@ public partial class SpeechToTextViewModel : BaseViewModel
|
|||
Locales.Add(locale);
|
||||
}
|
||||
|
||||
Locale = Locales.FirstOrDefault(x => x.Language is defaultLanguage or defaultLanguage_android or defaultLanguage_tizen) ?? Locales.FirstOrDefault();
|
||||
CurrentLocale = Locales.FirstOrDefault(x => x.Language is defaultLanguage or defaultLanguage_android or defaultLanguage_tizen) ?? Locales.FirstOrDefault();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
@ -53,7 +53,7 @@ public partial class SpeechToTextViewModel : BaseViewModel
|
|||
{
|
||||
await textToSpeech.SpeakAsync(RecognitionText ?? "Welcome to .NET MAUI Community Toolkit!", new()
|
||||
{
|
||||
Locale = Locale,
|
||||
Locale = CurrentLocale,
|
||||
Pitch = 2,
|
||||
Volume = 1
|
||||
}, cancellationToken);
|
||||
|
@ -74,7 +74,7 @@ public partial class SpeechToTextViewModel : BaseViewModel
|
|||
RecognitionText = beginSpeakingPrompt;
|
||||
|
||||
var recognitionResult = await speechToText.ListenAsync(
|
||||
CultureInfo.GetCultureInfo(Locale?.Language ?? defaultLanguage),
|
||||
CultureInfo.GetCultureInfo(CurrentLocale?.Language ?? defaultLanguage),
|
||||
new Progress<string>(partialText =>
|
||||
{
|
||||
if (RecognitionText is beginSpeakingPrompt)
|
||||
|
@ -102,6 +102,6 @@ public partial class SpeechToTextViewModel : BaseViewModel
|
|||
|
||||
void HandleLocalesCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged(nameof(Locale));
|
||||
OnPropertyChanged(nameof(CurrentLocale));
|
||||
}
|
||||
}
|
|
@ -11,24 +11,10 @@ public sealed partial class PopupAnchorViewModel : BaseViewModel
|
|||
[RelayCommand]
|
||||
static void ShowPopup(View anchor)
|
||||
{
|
||||
|
||||
// Using the C# version of Popup until this get fixed
|
||||
// https://github.com/dotnet/maui/issues/4300
|
||||
|
||||
// This works
|
||||
|
||||
var popup = new TransparentPopupCSharp()
|
||||
{
|
||||
Anchor = anchor
|
||||
};
|
||||
|
||||
// This doesn't work
|
||||
|
||||
//var popup = new TransparentPopup
|
||||
//{
|
||||
// Anchor = anchor
|
||||
//};
|
||||
|
||||
Page.ShowPopup(popup);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>$(NetVersion)</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<UseMaui>true</UseMaui>
|
||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
|
||||
<TargetFrameworks>$(NetVersion);$(NetVersion)-android;$(NetVersion)-ios;$(NetVersion)-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
|
||||
<UseMauiCore>true</UseMauiCore>
|
||||
<UseMauiEssentials>true</UseMauiEssentials>
|
||||
<SingleProject>true</SingleProject>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<Authors>Microsoft</Authors>
|
||||
<Owners>Microsoft</Owners>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
<Product>CommunityToolkit.Maui (net7.0)</Product>
|
||||
<Product>CommunityToolkit.Maui ($(NetVersion))</Product>
|
||||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/CommunityToolkit/Maui</PackageProjectUrl>
|
||||
|
@ -56,7 +56,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
<PackageReference Include="System.Speech" Version="7.0.0" Condition="'$(TargetFramework)' == 'net7.0-windows10.0.19041.0'" />
|
||||
<PackageReference Include="System.Speech" Version="7.0.0" Condition="'$(TargetFramework)' == '$(NetVersion)-windows10.0.19041.0'" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -25,7 +25,7 @@ public sealed partial class FileSaverImplementation : IFileSaver, IDisposable
|
|||
var isDirectoryCreated = fileManager.CreateDirectory(tempDirectoryPath, true, null, out var error);
|
||||
if (!isDirectoryCreated)
|
||||
{
|
||||
throw new Exception(error?.LocalizedDescription ?? "Unable to create temp directory.");
|
||||
throw new FileSaveException(error?.LocalizedDescription ?? "Unable to create temp directory.");
|
||||
}
|
||||
|
||||
var fileUrl = tempDirectoryPath.Append(fileName, false);
|
||||
|
|
|
@ -86,7 +86,6 @@ public sealed partial class SpeechToTextImplementation
|
|||
await using (cancellationToken.Register(async () =>
|
||||
{
|
||||
await StopRecording();
|
||||
speechRecognitionTaskCompletionSource.SetCanceled();
|
||||
}))
|
||||
{
|
||||
return await speechRecognitionTaskCompletionSource.Task;
|
||||
|
@ -119,7 +118,10 @@ public sealed partial class SpeechToTextImplementation
|
|||
{
|
||||
try
|
||||
{
|
||||
await speechRecognizer?.ContinuousRecognitionSession.StopAsync();
|
||||
if (speechRecognizer is not null)
|
||||
{
|
||||
await speechRecognizer.ContinuousRecognitionSession.StopAsync();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ namespace CommunityToolkit.Maui.Core.Platform;
|
|||
|
||||
static partial class StatusBar
|
||||
{
|
||||
static void PlatformSetColor(Color color) => throw new NotSupportedException($"{nameof(PlatformSetColor)} is only supported on net6.0-ios and net6.0-android and later");
|
||||
static void PlatformSetColor(Color color) => throw new NotSupportedException($"{nameof(PlatformSetColor)} is only supported on iOS and Android 23 and later");
|
||||
|
||||
static void PlatformSetStyle(StatusBarStyle statusBarStyle) => throw new NotSupportedException($"{nameof(PlatformSetStyle)} is only supported on net6.0-ios and net6.0-android and later");
|
||||
static void PlatformSetStyle(StatusBarStyle statusBarStyle) => throw new NotSupportedException($"{nameof(PlatformSetStyle)} is only supported on iOS and Android 23 and later");
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using Android.Content;
|
||||
using Android.Views;
|
||||
using CommunityToolkit.Maui.Core.Extensions;
|
||||
using Microsoft.Maui.Platform;
|
||||
using AColor = Android.Graphics.Color;
|
||||
using APaint = Android.Graphics.Paint;
|
||||
|
@ -85,4 +87,17 @@ public partial class MauiDrawingView : PlatformTouchGraphicsView
|
|||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
static ObservableCollection<PointF> CreateCollectionWithNormalizedPoints(in ObservableCollection<PointF> points, in int drawingViewWidth, in int drawingViewHeight, in float canvasScale)
|
||||
{
|
||||
var newPoints = new List<PointF>();
|
||||
foreach (var point in points)
|
||||
{
|
||||
var pointX = Math.Clamp(point.X, 0, drawingViewWidth / canvasScale);
|
||||
var pointY = Math.Clamp(point.Y, 0, drawingViewHeight / canvasScale);
|
||||
newPoints.Add(new PointF(pointX, pointY));
|
||||
}
|
||||
|
||||
return newPoints.ToObservableCollection();
|
||||
}
|
||||
}
|
|
@ -192,8 +192,8 @@ public partial class MauiDrawingView
|
|||
canvas.StrokeColor = lineColor;
|
||||
canvas.StrokeSize = lineWidth;
|
||||
canvas.StrokeDashOffset = 0;
|
||||
canvas.StrokeLineCap = LineCap.Butt;
|
||||
canvas.StrokeLineJoin = LineJoin.Miter;
|
||||
canvas.StrokeLineCap = LineCap.Round;
|
||||
canvas.StrokeLineJoin = LineJoin.Round;
|
||||
canvas.StrokeDashPattern = Array.Empty<float>();
|
||||
}
|
||||
|
||||
|
@ -221,20 +221,5 @@ public partial class MauiDrawingView
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
static ObservableCollection<PointF> CreateCollectionWithNormalizedPoints(in ObservableCollection<PointF> points, in int drawingViewWidth, in int drawingViewHeight, in float canvasScale)
|
||||
{
|
||||
var newPoints = new List<PointF>();
|
||||
foreach (var point in points)
|
||||
{
|
||||
var pointX = Math.Clamp(point.X, 0, drawingViewWidth / canvasScale);
|
||||
var pointY = Math.Clamp(point.Y, 0, drawingViewHeight / canvasScale);
|
||||
newPoints.Add(new PointF(pointX, pointY));
|
||||
}
|
||||
|
||||
return newPoints.ToObservableCollection();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using CoreAnimation;
|
||||
|
||||
namespace CommunityToolkit.Maui.Core.Views;
|
||||
|
||||
/// <summary>
|
||||
/// A rounded <see cref="UIStackView"/>
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public class RoundedStackView : UIStackView
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize <see cref="RoundedStackView"/>
|
||||
/// </summary>
|
||||
public RoundedStackView(NFloat leftPadding, NFloat topPadding, NFloat rightPadding, NFloat bottomPadding)
|
||||
{
|
||||
LeftPadding = leftPadding;
|
||||
TopPadding = topPadding;
|
||||
RightPadding = rightPadding;
|
||||
BottomPadding = bottomPadding;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Left Padding
|
||||
/// </summary>
|
||||
public NFloat LeftPadding { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Top Padding
|
||||
/// </summary>
|
||||
public NFloat TopPadding { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Right Padding
|
||||
/// </summary>
|
||||
public NFloat RightPadding { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Bottom Padding
|
||||
/// </summary>
|
||||
public NFloat BottomPadding { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Draw(CGRect rect)
|
||||
{
|
||||
ClipsToBounds = true;
|
||||
|
||||
var path = GetRoundedPath(rect, LeftPadding, TopPadding, RightPadding, BottomPadding);
|
||||
var maskLayer = new CAShapeLayer
|
||||
{
|
||||
Frame = rect,
|
||||
Path = path
|
||||
};
|
||||
|
||||
Layer.Mask = maskLayer;
|
||||
Layer.MasksToBounds = true;
|
||||
}
|
||||
|
||||
static CGPath? GetRoundedPath(CGRect rect, NFloat left, NFloat top, NFloat right, NFloat bottom)
|
||||
{
|
||||
var path = new UIBezierPath();
|
||||
path.MoveTo(new CGPoint(rect.Width - right, rect.Y));
|
||||
|
||||
path.AddArc(new CGPoint(rect.X + rect.Width - right, rect.Y + right), right, (NFloat)(Math.PI * 1.5), (NFloat)Math.PI * 2, true);
|
||||
path.AddLineTo(new CGPoint(rect.Width, rect.Height - bottom));
|
||||
|
||||
path.AddArc(new CGPoint(rect.X + rect.Width - bottom, rect.Y + rect.Height - bottom), bottom, 0, (NFloat)(Math.PI * .5), true);
|
||||
path.AddLineTo(new CGPoint(left, rect.Height));
|
||||
|
||||
path.AddArc(new CGPoint(rect.X + left, rect.Y + rect.Height - left), left, (NFloat)(Math.PI * .5), (NFloat)Math.PI, true);
|
||||
path.AddLineTo(new CGPoint(rect.X, top));
|
||||
|
||||
path.AddArc(new CGPoint(rect.X + top, rect.Y + top), top, (NFloat)Math.PI, (NFloat)(Math.PI * 1.5), true);
|
||||
|
||||
path.ClosePath();
|
||||
|
||||
return path.CGPath;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
|
||||
<TargetFrameworks>$(NetVersion);$(NetVersion)-android;$(NetVersion)-ios;$(NetVersion)-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<Authors>Microsoft</Authors>
|
||||
<Owners>Microsoft</Owners>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
<Product>CommunityToolkit.Maui (net7.0)</Product>
|
||||
<Product>CommunityToolkit.Maui ($(NetVersion))</Product>
|
||||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/CommunityToolkit/Maui</PackageProjectUrl>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
|
||||
<TargetFrameworks>$(NetVersion);$(NetVersion)-android;$(NetVersion)-ios;$(NetVersion)-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<Authors>Microsoft</Authors>
|
||||
<Owners>Microsoft</Owners>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
<Product>CommunityToolkit.Maui (net7.0)</Product>
|
||||
<Product>CommunityToolkit.Maui ($(NetVersion))</Product>
|
||||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/CommunityToolkit/Maui</PackageProjectUrl>
|
||||
|
|
|
@ -44,13 +44,10 @@ public class MauiMediaElement : CoordinatorLayout
|
|||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (playerView is not null)
|
||||
{
|
||||
// https://github.com/google/ExoPlayer/issues/1855#issuecomment-251041500
|
||||
playerView.Player?.Release();
|
||||
playerView.Player?.Dispose();
|
||||
playerView.Dispose();
|
||||
}
|
||||
// https://github.com/google/ExoPlayer/issues/1855#issuecomment-251041500
|
||||
playerView.Player?.Release();
|
||||
playerView.Player?.Dispose();
|
||||
playerView.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace CommunityToolkit.Maui.Core.Views;
|
|||
/// <summary>
|
||||
/// The user-interface element that represents the <see cref="MediaElement"/> on Windows.
|
||||
/// </summary>
|
||||
public class MauiMediaElement : Grid
|
||||
public class MauiMediaElement : Grid, IDisposable
|
||||
{
|
||||
readonly MediaPlayerElement mediaElement;
|
||||
|
||||
|
@ -26,6 +26,18 @@ public class MauiMediaElement : Grid
|
|||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaElement?.MediaPlayer.Dispose();
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the managed and unmanaged resources used by the <see cref="MauiMediaElement"/>.
|
||||
/// </summary>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
mediaElement.MediaPlayer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -208,7 +208,7 @@ public partial class MediaManager : Java.Lang.Object, IPlayer.IListener
|
|||
/// </remarks>
|
||||
public void OnVolumeChanged(float volume)
|
||||
{
|
||||
if (Player is null || MediaElement is null)
|
||||
if (Player is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -252,8 +252,7 @@ public partial class MediaManager : Java.Lang.Object, IPlayer.IListener
|
|||
|
||||
protected virtual partial void PlatformStop()
|
||||
{
|
||||
if (Player is null || MediaElement is null
|
||||
|| MediaElement.Source is null)
|
||||
if (Player is null || MediaElement.Source is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -315,7 +314,7 @@ public partial class MediaManager : Java.Lang.Object, IPlayer.IListener
|
|||
var path = resourceMediaSource.Path;
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
string assetFilePath = "asset://" + package + "/" + path;
|
||||
var assetFilePath = $"asset://{package}{Path.PathSeparator}{path}";
|
||||
|
||||
Player.SetMediaItem(MediaItem.FromUri(assetFilePath));
|
||||
Player.Prepare();
|
||||
|
|
|
@ -44,7 +44,7 @@ public class StatusBarBehaviorTests : BaseTest
|
|||
{
|
||||
var statusBarBehavior = new StatusBarBehavior();
|
||||
var exception = Assert.Throws<NotSupportedException>(() => statusBarBehavior.StatusBarColor = Colors.Red);
|
||||
exception.Message.Should().Be("PlatformSetColor is only supported on net6.0-ios and net6.0-android and later");
|
||||
exception.Message.Should().Be("PlatformSetColor is only supported on iOS and Android 23 and later");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -52,6 +52,6 @@ public class StatusBarBehaviorTests : BaseTest
|
|||
{
|
||||
var statusBarBehavior = new StatusBarBehavior();
|
||||
var exception = Assert.Throws<NotSupportedException>(() => statusBarBehavior.StatusBarStyle = StatusBarStyle.DarkContent);
|
||||
exception.Message.Should().Be("PlatformSetStyle is only supported on net6.0-ios and net6.0-android and later");
|
||||
exception.Message.Should().Be("PlatformSetStyle is only supported on iOS and Android 23 and later");
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>$(NetVersion)</TargetFramework>
|
||||
<UseMaui>true</UseMaui>
|
||||
<IsPackable>false</IsPackable>
|
||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||
|
|
|
@ -53,7 +53,7 @@ public class IntToBoolConverterTests : BaseConverterTest<IntToBoolConverter>
|
|||
{
|
||||
var intToBoolConverter = new IntToBoolConverter();
|
||||
Assert.Throws<ArgumentNullException>(() => ((ICommunityToolkitValueConverter)intToBoolConverter).Convert(null, typeof(bool), null, CultureInfo.CurrentCulture));
|
||||
Assert.Throws<ArgumentNullException>(() => ((ICommunityToolkitValueConverter)intToBoolConverter).ConvertBack(null, typeof(bool), null, CultureInfo.CurrentCulture)); ;
|
||||
Assert.Throws<ArgumentNullException>(() => ((ICommunityToolkitValueConverter)intToBoolConverter).ConvertBack(null, typeof(bool), null, CultureInfo.CurrentCulture));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -66,14 +66,14 @@ public class StateContainerTests : BaseTest
|
|||
[Fact]
|
||||
public void StateView_HasStateKey()
|
||||
{
|
||||
var view = StateContainer.GetStateViews(layout).First();
|
||||
var view = StateContainer.GetStateViews(layout)[0];
|
||||
Assert.Equal(StateKey.Loading, StateView.GetStateKey(view));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StateView_SetsStateKey()
|
||||
{
|
||||
var view = (View)layout.Children.First();
|
||||
var view = (View)layout.Children[0];
|
||||
StateView.SetStateKey(view, StateKey.Anything);
|
||||
Assert.Equal(StateKey.Anything, StateView.GetStateKey(view));
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ public class StateContainerTests : BaseTest
|
|||
public void Controller_SwitchesToStateFromContentSuccess()
|
||||
{
|
||||
controller.SwitchToState(StateKey.Loading);
|
||||
var state = controller.GetLayout().Children.First();
|
||||
var state = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(state);
|
||||
Assert.Equal("Loading", ((Label)state).Text);
|
||||
|
@ -494,13 +494,13 @@ public class StateContainerTests : BaseTest
|
|||
public void Controller_SwitchesToContentFromStateSuccess()
|
||||
{
|
||||
controller.SwitchToState(StateKey.Loading);
|
||||
var label = controller.GetLayout().Children.First();
|
||||
var label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Loading", ((Label)label).Text);
|
||||
|
||||
controller.SwitchToContent();
|
||||
label = controller.GetLayout().Children.First();
|
||||
label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Default", ((Label)label).Text);
|
||||
|
@ -510,13 +510,13 @@ public class StateContainerTests : BaseTest
|
|||
public void Controller_SwitchesToStateFromStateSuccess()
|
||||
{
|
||||
controller.SwitchToState(StateKey.Anything);
|
||||
var label = controller.GetLayout().Children.First();
|
||||
var label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Anything", ((Label)label).Text);
|
||||
|
||||
controller.SwitchToState(StateKey.Loading);
|
||||
label = controller.GetLayout().Children.First();
|
||||
label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Loading", ((Label)label).Text);
|
||||
|
@ -526,13 +526,13 @@ public class StateContainerTests : BaseTest
|
|||
public void Controller_SwitchesToStateFromSameStateSuccess()
|
||||
{
|
||||
controller.SwitchToState(StateKey.Loading);
|
||||
var label = controller.GetLayout().Children.First();
|
||||
var label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Loading", ((Label)label).Text);
|
||||
|
||||
controller.SwitchToState(StateKey.Loading);
|
||||
label = controller.GetLayout().Children.First();
|
||||
label = controller.GetLayout().Children[0];
|
||||
|
||||
Assert.IsType<Label>(label);
|
||||
Assert.Equal("Loading", ((Label)label).Text);
|
||||
|
@ -542,7 +542,7 @@ public class StateContainerTests : BaseTest
|
|||
public void Controller_GridStateViewSpansParent()
|
||||
{
|
||||
gridController.SwitchToState(StateKey.Loading);
|
||||
var view = (View)gridController.GetLayout().Children.First();
|
||||
var view = (View)gridController.GetLayout().Children[0];
|
||||
|
||||
Assert.Equal(Grid.GetColumnSpan(view), grid.ColumnDefinitions.Count);
|
||||
Assert.Equal(Grid.GetRowSpan(view), grid.RowDefinitions.Count);
|
||||
|
|
|
@ -39,7 +39,7 @@ sealed class MockDispatcherProvider : IDispatcherProvider, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
class DispatcherTimerStub : IDispatcherTimer, IDisposable
|
||||
sealed class DispatcherTimerStub : IDispatcherTimer, IDisposable
|
||||
{
|
||||
readonly DispatcherMock dispatcher;
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@ public partial class Toast
|
|||
return;
|
||||
}
|
||||
|
||||
if (isDisposing)
|
||||
{
|
||||
}
|
||||
|
||||
isDisposed = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ public abstract class BaseBehavior<TView> : Behavior<TView> where TView : Visual
|
|||
defaultBindingContextBinding = null;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -117,6 +116,6 @@ public abstract class BaseBehavior<TView> : Behavior<TView> where TView : Visual
|
|||
catch (Exception ex) when (Options.ShouldSuppressExceptionsInBehaviors)
|
||||
{
|
||||
Trace.WriteLine(ex);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ public class EventToCommandBehavior : BaseBehavior<VisualElement>
|
|||
public static readonly BindableProperty EventArgsConverterProperty =
|
||||
BindableProperty.Create(nameof(EventArgsConverter), typeof(IValueConverter), typeof(EventToCommandBehavior));
|
||||
|
||||
readonly MethodInfo eventHandlerMethodInfo = typeof(EventToCommandBehavior).GetTypeInfo()?.GetDeclaredMethod(nameof(OnTriggerHandled)) ?? throw new InvalidOperationException($"Cannot find method {nameof(OnTriggerHandled)}");
|
||||
readonly MethodInfo eventHandlerMethodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod(nameof(OnTriggerHandled)) ?? throw new InvalidOperationException($"Cannot find method {nameof(OnTriggerHandled)}");
|
||||
|
||||
Delegate? eventHandler;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class EventToCommandBehavior : BaseBehavior<VisualElement>
|
|||
return;
|
||||
}
|
||||
|
||||
eventInfo = View.GetType()?.GetRuntimeEvent(eventName) ??
|
||||
eventInfo = View.GetType().GetRuntimeEvent(eventName) ??
|
||||
throw new ArgumentException($"{nameof(EventToCommandBehavior)}: Couldn't resolve the event.", nameof(EventName));
|
||||
|
||||
ArgumentNullException.ThrowIfNull(eventInfo.EventHandlerType);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
@ -74,7 +75,7 @@ public class SelectAllTextBehavior : PlatformBehavior<InputView>
|
|||
{
|
||||
if (OperatingSystem.IsMacCatalyst())
|
||||
{
|
||||
Console.WriteLine("WARNING: `SelectAllTextBehavior` does not support `Microsoft.Maui.Controls.Editor` on MacCatalyst. For more information, see https://github.com/CommunityToolkit/Maui/issues/432");
|
||||
Trace.WriteLine("WARNING: `SelectAllTextBehavior` does not support `Microsoft.Maui.Controls.Editor` on MacCatalyst. For more information, see https://github.com/CommunityToolkit/Maui/issues/432");
|
||||
}
|
||||
|
||||
if (element is not Editor mauiControl)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);net7.0-tizen</TargetFrameworks>
|
||||
<TargetFrameworks>$(NetVersion);$(NetVersion)-android;$(NetVersion)-ios;$(NetVersion)-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);$(NetVersion)-windows10.0.19041.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(IncludeTizenTargetFrameworks)' == 'true'">$(TargetFrameworks);$(NetVersion)-tizen</TargetFrameworks>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SingleProject>true</SingleProject>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
@ -26,7 +26,7 @@
|
|||
<Authors>Microsoft</Authors>
|
||||
<Owners>Microsoft</Owners>
|
||||
<NeutralLanguage>en</NeutralLanguage>
|
||||
<Product>CommunityToolkit.Maui (net7.0)</Product>
|
||||
<Product>CommunityToolkit.Maui ($(NetVersion))</Product>
|
||||
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<PackageProjectUrl>https://github.com/CommunityToolkit/Maui</PackageProjectUrl>
|
||||
|
|
|
@ -76,7 +76,7 @@ public abstract class CompareConverter<TObject> : BaseConverterOneWay<IComparabl
|
|||
public TObject? FalseObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts an object that implements IComparable to a specified object or a boolean based on a comparaison result.
|
||||
/// Converts an object that implements IComparable to a specified object or a boolean based on a comparison result.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to convert.</param>
|
||||
/// <param name="culture">The culture to use in the converter. This is not implemented.</param>
|
||||
|
@ -90,7 +90,7 @@ public abstract class CompareConverter<TObject> : BaseConverterOneWay<IComparabl
|
|||
|
||||
if (!Enum.IsDefined(typeof(OperatorType), ComparisonOperator))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException($"is expected to be of type {nameof(OperatorType)}", nameof(ComparisonOperator));
|
||||
throw new ArgumentOutOfRangeException(nameof(ComparisonOperator), ComparingValue, $"is expected to be of type {nameof(OperatorType)}");
|
||||
}
|
||||
|
||||
if (!(TrueObject is null ^ FalseObject is not null))
|
||||
|
|
Загрузка…
Ссылка в новой задаче