From b33e87e34571a93613a4ec4e3cc1f7b8b3c7983e Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Tue, 11 Oct 2022 10:51:01 +0900 Subject: [PATCH 01/22] Implements tizen platform --- 6.0.312.json | 10 - 6.0.541.json | 10 + Directory.Build.props | 3 + azure-pipelines.yml | 19 +- .../CommunityToolkit.Maui.Sample.csproj | 2 + .../Platforms/Tizen/Main.cs | 16 ++ .../Platforms/Tizen/tizen-manifest.xml | 15 ++ .../Views/Popups/ButtonPopup.xaml | 2 +- .../Views/Popups/CsharpBindingPopup.xaml | 2 +- .../Views/Popups/MultipleButtonPopup.xaml | 2 +- .../Popups/NoOutsideTapDismissPopup.xaml | 2 +- .../Views/Popups/OpenedEventSimplePopup.xaml | 2 +- .../Views/Popups/ReturnResultPopup.xaml | 2 +- .../Views/Popups/SimplePopup.xaml | 2 +- .../Views/Popups/ToggleSizePopup.xaml | 2 +- .../Views/Popups/XamlBindingPopup.xaml | 2 +- .../CommunityToolkit.Maui.Core.csproj | 7 + .../DrawingView/DrawingViewHandler.shared.cs | 2 +- .../Handlers/Popup/PopupHandler.tizen.cs | 96 ++++++++ .../Platform/StatusBar/StatusBar.tizen.cs | 17 ++ .../PlatformView/MauiDrawingView.tizen.cs | 64 ++++++ .../Service/DrawingViewService.tizen.cs | 210 ++++++++++++++++++ .../Views/Popup/MauiPopup.tizen.cs | 134 +++++++++++ .../Alerts/Snackbar/Snackbar.tizen.cs | 177 +++++++++++++++ .../Alerts/Toast/Toast.tizen.cs | 35 +++ .../SelectAllTextBehavior.tizen.cs | 50 +++++ .../StatusBar/StatusBarBehavior.shared.cs | 2 +- .../CommunityToolkit.Maui.csproj | 7 + 28 files changed, 871 insertions(+), 23 deletions(-) delete mode 100644 6.0.312.json create mode 100644 6.0.541.json create mode 100644 samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/Main.cs create mode 100644 samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/tizen-manifest.xml create mode 100644 src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs create mode 100644 src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs create mode 100644 src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs create mode 100644 src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs create mode 100644 src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs create mode 100644 src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs create mode 100644 src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs create mode 100644 src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs diff --git a/6.0.312.json b/6.0.312.json deleted file mode 100644 index a4dbbaebf..000000000 --- a/6.0.312.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "microsoft.net.sdk.android": "32.0.301", - "microsoft.net.sdk.ios": "15.4.303", - "microsoft.net.sdk.maccatalyst": "15.4.303", - "microsoft.net.sdk.macos": "12.3.303", - "microsoft.net.sdk.maui": "6.0.312", - "microsoft.net.sdk.tvos": "15.4.303", - "microsoft.net.workload.mono.toolchain": "6.0.5", - "microsoft.net.workload.emscripten": "6.0.4" -} diff --git a/6.0.541.json b/6.0.541.json new file mode 100644 index 000000000..22d1c36ad --- /dev/null +++ b/6.0.541.json @@ -0,0 +1,10 @@ +{ + "microsoft.net.sdk.android": "32.0.476", + "microsoft.net.sdk.ios": "16.0.517", + "microsoft.net.sdk.maccatalyst": "15.4.465", + "microsoft.net.sdk.macos": "12.3.465", + "microsoft.net.sdk.maui": "6.0.541", + "microsoft.net.sdk.tvos": "16.0.517", + "microsoft.net.workload.mono.toolchain": "6.0.10", + "microsoft.net.workload.emscripten": "6.0.10" +} diff --git a/Directory.Build.props b/Directory.Build.props index d437ceffb..3c381232f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -20,4 +20,7 @@ + + true + \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ab67f11bb..7b2ed4ba0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ variables: PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)] CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)' NugetPackageVersion: '$(CurrentSemanticVersion)' - TOOLKIT_NET6_VERSION: '6.0.300' + TOOLKIT_NET6_VERSION: '6.0.400' LATEST_NET6_VERSION: '6.0.x' PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln' PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln' @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: '6.0.312.json' + DotNetMauiRollbackFile: '6.0.541.json' ShouldCheckDependencies: true trigger: @@ -57,6 +57,11 @@ jobs: - powershell: dotnet workload install maui --from-rollback-file $(DotNetMauiRollbackFile) --source https://api.nuget.org/v3/index.json displayName: Install .NET MAUI $(TOOLKIT_NET6_VERSION) + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET6_VERSION) + displayName: Install tizen workload + # if this is a tagged build, then update the version number - powershell: | $buildSourceBranch = "$(Build.SourceBranch)" @@ -201,6 +206,11 @@ jobs: - powershell: dotnet workload install maui displayName: Install Latest .NET MAUI Workload + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET6_VERSION) + displayName: Install tizen workload + # build sample - task: VSBuild@1 displayName: 'Build Community Toolkit Sample' @@ -223,6 +233,11 @@ jobs: - powershell: dotnet workload install maui displayName: Install Latest .NET MAUI Workload + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET6_VERSION) + displayName: Install tizen workload + - task: Bash@3 displayName: 'Verify Formatting' env: diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj index d0834e843..e8225f51a 100644 --- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj +++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj @@ -3,6 +3,7 @@ net6.0-ios;net6.0-android;net6.0-maccatalyst $(TargetFrameworks);net6.0-windows10.0.19041.0 + $(TargetFrameworks);net6.0-tizen Exe true true @@ -51,6 +52,7 @@ 21.0 10.0.17763.0 10.0.17763.0 + 6.5 diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/Main.cs b/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/Main.cs new file mode 100644 index 000000000..c3a1b02ba --- /dev/null +++ b/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/Main.cs @@ -0,0 +1,16 @@ +using System; +using Microsoft.Maui; +using Microsoft.Maui.Hosting; + +namespace CommunityToolkit.Maui.Sample; + +class Program : MauiApplication +{ + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } +} \ No newline at end of file diff --git a/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/tizen-manifest.xml b/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/tizen-manifest.xml new file mode 100644 index 000000000..2233229bd --- /dev/null +++ b/samples/CommunityToolkit.Maui.Sample/Platforms/Tizen/tizen-manifest.xml @@ -0,0 +1,15 @@ + + + + + + maui-appicon-placeholder + + + + + http://tizen.org/privilege/internet + + + + \ No newline at end of file diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml index 5a5fa85cc..09436fa23 100644 --- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ButtonPopup.xaml @@ -25,7 +25,7 @@ diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml b/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml index 0e829d0bb..c6e746967 100644 --- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/MultipleButtonPopup.xaml @@ -25,7 +25,7 @@ diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/OpenedEventSimplePopup.xaml b/samples/CommunityToolkit.Maui.Sample/Views/Popups/OpenedEventSimplePopup.xaml index d3db689ac..9f25f615f 100644 --- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/OpenedEventSimplePopup.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/OpenedEventSimplePopup.xaml @@ -24,7 +24,7 @@ diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml index 6e4b86b06..f6acc30ba 100644 --- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ReturnResultPopup.xaml @@ -24,7 +24,7 @@ diff --git a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ToggleSizePopup.xaml b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ToggleSizePopup.xaml index 43043d69d..fa0854036 100644 --- a/samples/CommunityToolkit.Maui.Sample/Views/Popups/ToggleSizePopup.xaml +++ b/samples/CommunityToolkit.Maui.Sample/Views/Popups/ToggleSizePopup.xaml @@ -26,7 +26,7 @@ diff --git a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj index 65df674b9..789ca7edf 100644 --- a/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj +++ b/src/CommunityToolkit.Maui.Core/CommunityToolkit.Maui.Core.csproj @@ -3,6 +3,7 @@ net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst $(TargetFrameworks);net6.0-windows10.0.19041.0 + $(TargetFrameworks);net6.0-tizen true true true @@ -73,6 +74,12 @@ + + + + + + diff --git a/src/CommunityToolkit.Maui.Core/Handlers/DrawingView/DrawingViewHandler.shared.cs b/src/CommunityToolkit.Maui.Core/Handlers/DrawingView/DrawingViewHandler.shared.cs index 3f72b3ad2..121ab2cac 100644 --- a/src/CommunityToolkit.Maui.Core/Handlers/DrawingView/DrawingViewHandler.shared.cs +++ b/src/CommunityToolkit.Maui.Core/Handlers/DrawingView/DrawingViewHandler.shared.cs @@ -49,7 +49,7 @@ public DrawingViewHandler() : this(DrawingViewMapper, DrawingViewCommandMapper) } } -#if ANDROID || IOS || MACCATALYST || WINDOWS +#if ANDROID || IOS || MACCATALYST || WINDOWS || TIZEN public partial class DrawingViewHandler : ViewHandler, IDrawingViewHandler { diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs new file mode 100644 index 000000000..4de59279c --- /dev/null +++ b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs @@ -0,0 +1,96 @@ +using CommunityToolkit.Maui.Core.Views; +using Tizen.UIExtensions.NUI; + +namespace CommunityToolkit.Maui.Core.Handlers; + +public partial class PopupHandler : Microsoft.Maui.Handlers.ElementHandler +{ + /// + protected override MauiPopup CreatePlatformElement() => new MauiPopup(MauiContext ?? throw new NullReferenceException(nameof(MauiContext))); + + /// + /// 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(); + } + + 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) + { + } + + /// + /// Action that's triggered when the Popup property changes. + /// + /// An instance of . + /// An instance of . + public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view) + { + } + + /// + /// Action that's triggered when the Popup property changes. + /// + /// An instance of . + /// An instance of . + public static void MapColor(PopupHandler handler, IPopup 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); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs new file mode 100644 index 000000000..72ec18508 --- /dev/null +++ b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs @@ -0,0 +1,17 @@ +using System.Runtime.Versioning; +using Microsoft.Maui.Platform; + +namespace CommunityToolkit.Maui.Core.Platform; + +static partial class StatusBar +{ + static void PlatformSetColor(Color color) + { + throw new NotSupportedException("Tizen does not currently support changing the status bar color"); + } + + static void PlatformSetStyle(StatusBarStyle style) + { + throw new NotSupportedException("Tizen does not currently support changing the status bar color"); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs new file mode 100644 index 000000000..3d99e69a1 --- /dev/null +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs @@ -0,0 +1,64 @@ +using Microsoft.Maui.Platform; +using NPointStateType = Tizen.NUI.PointStateType; + +namespace CommunityToolkit.Maui.Core.Views; + +public partial class MauiDrawingView : PlatformTouchGraphicsView +{ + /// + /// Initialize a new instance of . + /// + public MauiDrawingView() : base(null) + { + previousPoint = new(); + TouchEvent += OnTouch; + } + + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + currentPath.Dispose(); + } + + base.Dispose(disposing); + } + + /// + /// Initialize resources + /// + public void Initialize() + { + Drawable = new DrawingViewDrawable(this); + Lines.CollectionChanged += OnLinesCollectionChanged; + } + + bool OnTouch(object source, TouchEventArgs e) + { + var point = new PointF(e.Touch.GetLocalPosition(0).X.ToScaledDP(), e.Touch.GetLocalPosition(0).Y.ToScaledDP()); + switch (e.Touch.GetState(0)) + { + case NPointStateType.Down: + OnStart(point); + break; + case NPointStateType.Motion: + OnMoving(point); + break; + case NPointStateType.Up: + OnFinish(); + break; + case NPointStateType.Interrupted: + OnCancel(); + break; + } + Redraw(); + + return true; + } + + void Redraw() + { + Invalidate(); + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs new file mode 100644 index 000000000..f86be8786 --- /dev/null +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -0,0 +1,210 @@ +using Microsoft.Maui.Graphics.Skia; +using SkiaSharp; + +namespace CommunityToolkit.Maui.Core.Views; + +/// +/// Drawing view service +/// +public static class DrawingViewService +{ + /// + /// Get image stream from points + /// + /// Drawing points + /// Image size + /// Line Width + /// Line color + /// Image background + /// Image stream + public static ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) + { + var image = GetBitmapForPoints(points, lineWidth, strokeColor, background); + if (image == null) + { + return ValueTask.FromResult(Stream.Null); + } + return new ValueTask(Task.Run(() => + { + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); + return stream; + })); + } + + /// + /// Get image stream from lines + /// + /// Drawing lines + /// Image size + /// Image background + /// Image stream + public static ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) + { + var image = GetBitmapForLines(lines, background); + if (image == null) + { + return ValueTask.FromResult(Stream.Null); + } + return new ValueTask(Task.Run(() => + { + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); + + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); + return stream; + })); + } + + static (SKBitmap?, SizeF offset) GetBitmap(ICollection points) + { + if (points.Count is 0) + { + return (null, SizeF.Zero); + } + + var minPointX = points.Min(p => p.X); + var minPointY = points.Min(p => p.Y); + var drawingWidth = points.Max(p => p.X) - minPointX; + var drawingHeight = points.Max(p => p.Y) - minPointY; + const int minSize = 1; + if (drawingWidth < minSize || drawingHeight < minSize) + { + return (null, SizeF.Zero); + } + + var bitmap = new SKBitmap((int)drawingWidth, (int)drawingHeight, SKColorType.Bgra8888, SKAlphaType.Opaque); + + return (bitmap, new SizeF(minPointX, minPointY)); + } + + static SKBitmap? GetBitmapForLines(IList lines, Paint? background) + { + var points = lines.SelectMany(x => x.Points).ToList(); + var (image, offset) = GetBitmap(points); + if (image is null) + { + return null; + } + + using var canvas = new SKCanvas(image); + DrawBackground(canvas, image.Info, background); + foreach (var line in lines) + { + DrawStrokes(canvas, line.Points, line.LineWidth, line.LineColor, offset); + } + return image; + } + + static SKBitmap? GetBitmapForPoints(ICollection points, + float lineWidth, + Color strokeColor, + Paint? background) + { + var (image, offset) = GetBitmap(points); + if (image is null) + { + return null; + } + + using var canvas = new SKCanvas(image); + DrawBackground(canvas, image.Info, background); + DrawStrokes(canvas, points, lineWidth, strokeColor, offset); + return image; + } + + + static void DrawBackground(SKCanvas canvas, SKImageInfo info, Paint? brush) + { + switch (brush) + { + case SolidPaint solidColorBrush: + canvas.DrawColor(solidColorBrush.Color != null ? solidColorBrush.Color.AsSKColor() : DrawingViewDefaults.BackgroundColor.AsSKColor()); + break; + case LinearGradientPaint linearGradientBrush: + { + var paint = new SKPaint(); + var colors = new SKColor[linearGradientBrush.GradientStops.Length]; + var positions = new float[linearGradientBrush.GradientStops.Length]; + for (var index = 0; index < linearGradientBrush.GradientStops.Length; index++) + { + var gradientStop = linearGradientBrush.GradientStops[index]; + colors[index] = gradientStop.Color.AsSKColor(); + positions[index] = gradientStop.Offset; + } + + var x1 = (float)linearGradientBrush.StartPoint.X * info.Width; + var y1 = (float)linearGradientBrush.StartPoint.Y * info.Height; + var x2 = (float)linearGradientBrush.EndPoint.X * info.Width; + var y2 = (float)linearGradientBrush.EndPoint.Y * info.Height; + + var shader = SKShader.CreateLinearGradient( + new SKPoint(x1, y1), + new SKPoint(x2, y2), + colors, + positions, + SKShaderTileMode.Clamp); + paint.Shader = shader; + canvas.DrawRect(0, 0, info.Width, info.Height, paint); + break; + } + case RadialGradientPaint radialGradientBrush: + { + var paint = new SKPaint(); + var colors = new SKColor[radialGradientBrush.GradientStops.Length]; + var positions = new float[radialGradientBrush.GradientStops.Length]; + + for (var index = 0; index < radialGradientBrush.GradientStops.Length; index++) + { + var gradientStop = radialGradientBrush.GradientStops[index]; + colors[index] = gradientStop.Color.AsSKColor(); + positions[index] = gradientStop.Offset; + } + + float centerX = (float)(radialGradientBrush.Center.X * info.Width); + float centerY = (float)(radialGradientBrush.Center.Y * info.Height); + float radius = (float)(radialGradientBrush.Radius * info.Width); + + var shader = SKShader.CreateRadialGradient( + new SKPoint(centerX, centerX), + radius, + colors, + positions, + SKShaderTileMode.Clamp); + paint.Shader = shader; + canvas.DrawRect(0, 0, info.Width, info.Height, paint); + break; + } + default: + canvas.DrawColor(DrawingViewDefaults.BackgroundColor.AsSKColor()); + break; + } + } + + static void DrawStrokes(SKCanvas canvas, ICollection points, float lineWidth, Color strokeColor, SizeF offset) + { + using var paint = new SKPaint + { + StrokeWidth = lineWidth, + StrokeJoin = SKStrokeJoin.Round, + StrokeCap = SKStrokeCap.Round, + IsAntialias = true, + Color = strokeColor.AsSKColor(), + Style = SKPaintStyle.Stroke, + }; + + var pointsCount = points.Count; + for (var i = 0; i < pointsCount - 1; i++) + { + var p1 = points.ElementAt(i); + var p2 = points.ElementAt(i + 1); + + canvas.DrawLine(p1.X - offset.Width, p1.Y - offset.Height, p2.X - offset.Width, p2.Y - offset.Height, paint); + } + } +} \ 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 new file mode 100644 index 000000000..f500c44e5 --- /dev/null +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -0,0 +1,134 @@ +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. +/// +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; + } + + void OnOutsideClicked(object? sender, EventArgs e) + { + if (VirtualView == null || VirtualView.Handler == null) + { + return; + } + + if (VirtualView.CanBeDismissedByTappingOutsideOfPopup) + { + Close(); + VirtualView.Handler.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup)); + } + } + + /// + /// An instance of the . + /// + public IPopup? VirtualView { get; private set; } + + /// + /// 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"); + + if (Content == null) + { + return; + } + + BackgroundColor = new Tizen.NUI.Color(0.1f, 0.1f, 0.1f, 0.5f); + Content.BackgroundColor = (VirtualView.Color ?? Colors.Transparent).ToNUIColor(); + + if (VirtualView.Anchor != null) + { + var anchorView = VirtualView.Anchor.ToPlatform(); + var anchorPosition = anchorView.ScreenPosition; + Content.ScreenToLocal(out float x, out float y, anchorPosition.X, anchorPosition.Y); + Layout = new AbsoluteLayout(); + Content.UpdatePosition(new Tizen.UIExtensions.Common.Point(x, y)); + } + else + { + Layout = new LinearLayout + { + LinearOrientation = LinearLayout.Orientation.Vertical, + VerticalAlignment = ToVerticalAlignment(VirtualView.VerticalOptions), + HorizontalAlignment = ToHorizontalAlignment(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 == 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); + } + } + + NVerticalAlignment ToVerticalAlignment(LayoutAlignment align) => align switch + { + LayoutAlignment.Start => NVerticalAlignment.Top, + LayoutAlignment.End => NVerticalAlignment.Bottom, + _ => NVerticalAlignment.Center + }; + + NHorizontalAlignment ToHorizontalAlignment(LayoutAlignment align) => align switch + { + LayoutAlignment.Start => NHorizontalAlignment.Begin, + LayoutAlignment.End => NHorizontalAlignment.End, + _ => NHorizontalAlignment.Center + }; +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs new file mode 100644 index 000000000..e9d6f614b --- /dev/null +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -0,0 +1,177 @@ +using Microsoft.Maui.Platform; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using NLinearLayout = Tizen.NUI.LinearLayout; +using NVerticalAlignment = Tizen.NUI.VerticalAlignment; +using NView = Tizen.NUI.BaseComponents.View; +using TButton = Tizen.UIExtensions.NUI.Button; +using TLabel = Tizen.UIExtensions.NUI.Label; +using TPopup = Tizen.UIExtensions.NUI.Popup; + +namespace CommunityToolkit.Maui.Alerts; + +public partial class Snackbar +{ + static TPopup? PopupStatic { get; set; } + + TPopup? PopupInstance { get; set; } + + /// + /// Dispose Snackbar + /// + protected virtual void Dispose(bool isDisposing) + { + if (isDisposed) + { + return; + } + + if (isDisposing) + { + PopupInstance?.Close(); + PopupInstance?.Dispose(); + PopupInstance = null; + } + isDisposed = true; + } + + /// + Task ShowPlatform(CancellationToken token) + { + // close and cleanup the previously opened snackbar + if (PopupStatic != null && PopupStatic.IsOpen) + { + PopupStatic.Close(); + PopupStatic.Dispose(); + PopupStatic = null; + } + + var popup = new OutsidePassThroughPopup + { + Layout = new NLinearLayout + { + LinearOrientation = NLinearLayout.Orientation.Vertical, + VerticalAlignment = NVerticalAlignment.Bottom, + } + }; + + var content = new NView + { + Margin = new Extents((ushort)10d.ToScaledPixel()), + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.WrapContent, + + BackgroundColor = VisualOptions.BackgroundColor.ToNUIColor(), + CornerRadius = new Vector4(10, 10, 10, 10), + Layout = new NLinearLayout + { + LinearOrientation = NLinearLayout.Orientation.Horizontal, + VerticalAlignment = NVerticalAlignment.Center, + } + }; + + var margin = (ushort)10d.ToScaledPixel(); + + var message = new TLabel() + { + MultiLine = true, + Margin = margin, + WidthSpecification = LayoutParamPolicies.MatchParent, + Text = Text, + TextColor = VisualOptions.TextColor.ToPlatform(), + PixelSize = VisualOptions.Font.Size.ToPixel(), + FontAttributes = LabelExtensions.GetFontAttributes(VisualOptions.Font), + }; + content.Add(message); + + var actionButton = new TButton() + { + Margin = margin, + WidthSpecification = LayoutParamPolicies.WrapContent, + BackgroundColor = Tizen.NUI.Color.Transparent, + TextColor = VisualOptions.ActionButtonTextColor.ToPlatform(), + Text = ActionButtonText, + }; + actionButton.TextLabel.PixelSize = 15d.ToPixel(); + actionButton.SizeWidth = actionButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2; + actionButton.Clicked += (s, e) => + { + if (Action != null) + { + Action.Invoke(); + } + else + { + popup.Close(); + } + }; + + content.Add(actionButton); + popup.Content = content; + + if (Anchor != null) + { + var anchorPlatformView = Anchor.ToPlatform(); + + // can't measure height of content on NUI + var maximumHeight = 100d.ToScaledPixel(); + popup.SizeHeight = maximumHeight; + + if (maximumHeight < anchorPlatformView.ScreenPosition.Y) + { + // display top outside of anchor + popup.Position = new Position(0, anchorPlatformView.ScreenPosition.Y - popup.SizeHeight); + } + else + { + // display bottom innter of anchor + popup.Position = new Position(0, anchorPlatformView.ScreenPosition.Y - (maximumHeight - anchorPlatformView.SizeHeight)); + } + } + else + { + popup.Position = new Position(0, 0); + popup.WidthSpecification = LayoutParamPolicies.MatchParent; + popup.HeightSpecification = LayoutParamPolicies.MatchParent; + } + + popup.Closed += (s, e) => OnDismissed(); + popup.Open(); + + var timer = (Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher!).CreateTimer(); + timer.IsRepeating = false; + timer.Interval = Duration; + timer.Tick += (s, e) => popup.Close(); + timer.Start(); + + PopupStatic = popup; + PopupInstance = popup; + + OnShown(); + return Task.CompletedTask; + } + + /// + Task DismissPlatform(CancellationToken token) + { + token.ThrowIfCancellationRequested(); + + if (PopupInstance == null) + { + return Task.CompletedTask; + } + + PopupInstance.Close(); + PopupInstance.Dispose(); + PopupInstance = null; + return Task.CompletedTask; + } + + class OutsidePassThroughPopup : TPopup + { + protected override bool HitTest(Touch touch) + { + return false; + } + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs new file mode 100644 index 000000000..d1c40f1f0 --- /dev/null +++ b/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs @@ -0,0 +1,35 @@ +namespace CommunityToolkit.Maui.Alerts; + +public partial class Toast +{ + /// + /// Dispose Toast + /// + protected virtual void Dispose(bool isDisposing) + { + if (isDisposed) + { + return; + } + + isDisposed = true; + } + + /// + /// Show Toast + /// + void ShowPlatform(CancellationToken token) + { + new Tizen.Applications.ToastMessage + { + Message = Text + }.Post(); + } + + /// + /// Dismiss Toast + /// + static void DismissPlatform(CancellationToken token) + { + } +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs new file mode 100644 index 000000000..760272f5c --- /dev/null +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tizen.NUI.BaseComponents; +using NView = Tizen.NUI.BaseComponents.View; + +namespace CommunityToolkit.Maui.Behaviors; + +/// +/// A behavior that selects all text when the view is focused. +/// +public class SelectAllTextBehavior : PlatformBehavior +{ + /// + protected override void OnAttachedTo(InputView bindable, NView platformView) => ApplyEffect(true, platformView); + + /// + protected override void OnDetachedFrom(InputView bindable, NView platformView) => ApplyEffect(false, platformView); + + + void ApplyEffect(bool apply, NView inputView) + { + if (inputView is null) + { + throw new InvalidOperationException("The Platform View can't be null."); + } + + inputView.FocusGained -= OnFocused; + + if (apply) + { + inputView.FocusGained += OnFocused; + } + + void OnFocused(object? sender, EventArgs e) + { + if (sender is TextField tf && tf.HasFocus()) + { + tf.SelectWholeText(); + } + else if (sender is TextEditor te && te.HasFocus()) + { + te.SelectWholeText(); + } + } + } + +} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs index e33adc511..73e388c58 100644 --- a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs @@ -44,7 +44,7 @@ public StatusBarStyle StatusBarStyle set => SetValue(StatusBarStyleProperty, value); } -#if !(WINDOWS || MACCATALYST) +#if !(WINDOWS || MACCATALYST || TIZEN) /// #if IOS diff --git a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj index a9ae3cad2..b9e2033a5 100644 --- a/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj +++ b/src/CommunityToolkit.Maui/CommunityToolkit.Maui.csproj @@ -3,6 +3,7 @@ net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst $(TargetFrameworks);net6.0-windows10.0.19041.0 + $(TargetFrameworks);net6.0-tizen true true true @@ -74,6 +75,12 @@ + + + + + + From 90d9000e4c28a606f5054792e24e58cd17498f44 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Sat, 15 Oct 2022 12:28:04 +0900 Subject: [PATCH 02/22] Apply review comment --- .../PlatformView/MauiDrawingView.tizen.cs | 1 + .../Service/DrawingViewService.tizen.cs | 4 ++-- .../Views/Popup/MauiPopup.tizen.cs | 19 +++++++++++++++---- .../Alerts/Snackbar/Snackbar.tizen.cs | 4 +++- 4 files changed, 21 insertions(+), 7 deletions(-) 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 3d99e69a1..4f885fe29 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs @@ -20,6 +20,7 @@ protected override void Dispose(bool disposing) if (disposing) { currentPath.Dispose(); + TouchEvent -= OnTouch; } base.Dispose(disposing); diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs index f86be8786..c89c5c683 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -20,7 +20,7 @@ public static class DrawingViewService public static ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) { var image = GetBitmapForPoints(points, lineWidth, strokeColor, background); - if (image == null) + if (image is null) { return ValueTask.FromResult(Stream.Null); } @@ -45,7 +45,7 @@ public static ValueTask GetImageStream(IList points, Size imageS public static ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) { var image = GetBitmapForLines(lines, background); - if (image == null) + if (image is null) { return ValueTask.FromResult(Stream.Null); } diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs index f500c44e5..32b41ffb2 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -25,9 +25,20 @@ public MauiPopup(IMauiContext mauiContext) OutsideClicked += OnOutsideClicked; } + /// + protected override void Dispose(bool isDisposing) + { + if (isDisposing) + { + OutsideClicked -= OnOutsideClicked; + } + + base.Dispose(isDisposing); + } + void OnOutsideClicked(object? sender, EventArgs e) { - if (VirtualView == null || VirtualView.Handler == null) + if (VirtualView is null || VirtualView.Handler is null) { return; } @@ -62,7 +73,7 @@ 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"); - if (Content == null) + if (Content is null) { return; } @@ -70,7 +81,7 @@ public void ShowPopup() BackgroundColor = new Tizen.NUI.Color(0.1f, 0.1f, 0.1f, 0.5f); Content.BackgroundColor = (VirtualView.Color ?? Colors.Transparent).ToNUIColor(); - if (VirtualView.Anchor != null) + if (VirtualView.Anchor is not null) { var anchorView = VirtualView.Anchor.ToPlatform(); var anchorPosition = anchorView.ScreenPosition; @@ -102,7 +113,7 @@ public void ShowPopup() public void UpdateContentSize() { _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null"); - if (Content == null) + if (Content is null) { return; } diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index e9d6f614b..461b0e4bd 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -38,6 +38,8 @@ protected virtual void Dispose(bool isDisposing) /// Task ShowPlatform(CancellationToken token) { + var dispatcher = Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher ?? throw new InvalidOperationException($"There is no IDispatcher object, application is not initalized"); + // close and cleanup the previously opened snackbar if (PopupStatic != null && PopupStatic.IsOpen) { @@ -138,7 +140,7 @@ Task ShowPlatform(CancellationToken token) popup.Closed += (s, e) => OnDismissed(); popup.Open(); - var timer = (Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher!).CreateTimer(); + var timer = dispatcher.CreateTimer(); timer.IsRepeating = false; timer.Interval = Duration; timer.Tick += (s, e) => popup.Close(); From c042667c649df7aa7e749e385722707e05f034f7 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Sat, 15 Oct 2022 07:55:46 +0300 Subject: [PATCH 03/22] Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs --- src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index 461b0e4bd..a63b09087 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -98,7 +98,7 @@ Task ShowPlatform(CancellationToken token) actionButton.SizeWidth = actionButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2; actionButton.Clicked += (s, e) => { - if (Action != null) + if (Action is not null) { Action.Invoke(); } From 377773e912c7df2fd4defbf135f28cfd85eb3365 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Sat, 15 Oct 2022 07:55:52 +0300 Subject: [PATCH 04/22] Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs --- src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index a63b09087..70253ea5b 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -111,7 +111,7 @@ Task ShowPlatform(CancellationToken token) content.Add(actionButton); popup.Content = content; - if (Anchor != null) + if (Anchor is not null) { var anchorPlatformView = Anchor.ToPlatform(); From 4cfe69381ce8bb9a41ccc9443007e8a3440aecf3 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Sat, 15 Oct 2022 07:55:57 +0300 Subject: [PATCH 05/22] Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs --- src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index 70253ea5b..be9884685 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -158,7 +158,7 @@ Task DismissPlatform(CancellationToken token) { token.ThrowIfCancellationRequested(); - if (PopupInstance == null) + if (PopupInstance is null) { return Task.CompletedTask; } From e212b8776a242246df911c90ea8806d465a81e35 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Sun, 16 Oct 2022 18:10:25 +0300 Subject: [PATCH 06/22] Update src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs Co-authored-by: Pedro Jesus --- src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index be9884685..a47b2b428 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -41,7 +41,7 @@ Task ShowPlatform(CancellationToken token) var dispatcher = Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher ?? throw new InvalidOperationException($"There is no IDispatcher object, application is not initalized"); // close and cleanup the previously opened snackbar - if (PopupStatic != null && PopupStatic.IsOpen) + if (PopupStatic is not null && PopupStatic.IsOpen) { PopupStatic.Close(); PopupStatic.Dispose(); From 636b387cdc68cea31022ab14c070e73ea9c1a7ce Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 17 Oct 2022 07:52:42 +0900 Subject: [PATCH 07/22] Apply review comment --- .../Handlers/Popup/PopupHandler.tizen.cs | 3 ++ .../Views/Popup/MauiPopup.tizen.cs | 45 +++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs index 4de59279c..c8dc82d0c 100644 --- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs @@ -58,6 +58,7 @@ public static void MapOnDismissedByTappingOutsideOfPopup(PopupHandler handler, I /// An instance of . public static void MapAnchor(PopupHandler handler, IPopup view) { + // On Tizen, Anchor only update when popup is opened } /// @@ -67,6 +68,7 @@ public static void MapAnchor(PopupHandler handler, IPopup view) /// An instance of . public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler, IPopup view) { + // this property directly access on platform view } /// @@ -76,6 +78,7 @@ public static void MapCanBeDismissedByTappingOutsideOfPopup(PopupHandler handler /// An instance of . public static void MapColor(PopupHandler handler, IPopup view) { + // this property directly access on platform view } /// diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs index 32b41ffb2..6cbcd3482 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -25,6 +25,11 @@ public MauiPopup(IMauiContext mauiContext) OutsideClicked += OnOutsideClicked; } + /// + /// An instance of the . + /// + public IPopup? VirtualView { get; private set; } + /// protected override void Dispose(bool isDisposing) { @@ -36,25 +41,6 @@ protected override void Dispose(bool isDisposing) base.Dispose(isDisposing); } - void OnOutsideClicked(object? sender, EventArgs e) - { - if (VirtualView is null || VirtualView.Handler is null) - { - return; - } - - if (VirtualView.CanBeDismissedByTappingOutsideOfPopup) - { - Close(); - VirtualView.Handler.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup)); - } - } - - /// - /// An instance of the . - /// - public IPopup? VirtualView { get; private set; } - /// /// Method to initialize the native implementation. /// @@ -64,7 +50,6 @@ public void SetElement(IPopup? element) VirtualView = element; } - /// /// Method to show the Popup /// @@ -103,7 +88,7 @@ public void ShowPopup() UpdateContentSize(); Open(); - VirtualView?.OnOpened(); + VirtualView.OnOpened(); } /// @@ -129,14 +114,28 @@ public void UpdateContentSize() } } - NVerticalAlignment ToVerticalAlignment(LayoutAlignment align) => align switch + void OnOutsideClicked(object? sender, EventArgs e) + { + if (VirtualView is null || VirtualView.Handler is null) + { + return; + } + + if (VirtualView.CanBeDismissedByTappingOutsideOfPopup) + { + Close(); + VirtualView.Handler.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup)); + } + } + + static NVerticalAlignment ToVerticalAlignment(LayoutAlignment align) => align switch { LayoutAlignment.Start => NVerticalAlignment.Top, LayoutAlignment.End => NVerticalAlignment.Bottom, _ => NVerticalAlignment.Center }; - NHorizontalAlignment ToHorizontalAlignment(LayoutAlignment align) => align switch + static NHorizontalAlignment ToHorizontalAlignment(LayoutAlignment align) => align switch { LayoutAlignment.Start => NHorizontalAlignment.Begin, LayoutAlignment.End => NHorizontalAlignment.End, From 2c97be78a84f5e659dd0edf0b19a617f0f95f318 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:31:49 +0300 Subject: [PATCH 08/22] attempt to use 6.0.300 --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7b2ed4ba0..d50a5fd6d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ variables: PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)] CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)' NugetPackageVersion: '$(CurrentSemanticVersion)' - TOOLKIT_NET6_VERSION: '6.0.400' + TOOLKIT_NET6_VERSION: '6.0.300' LATEST_NET6_VERSION: '6.0.x' PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln' PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln' @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: '6.0.541.json' + DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.312.json' ShouldCheckDependencies: true trigger: From ce550ba91ac8c60748d7531b2a594867a213d337 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:50:40 +0300 Subject: [PATCH 09/22] 6.0.400 --- 6.0.541.json | 10 ---------- azure-pipelines.yml | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 6.0.541.json diff --git a/6.0.541.json b/6.0.541.json deleted file mode 100644 index 22d1c36ad..000000000 --- a/6.0.541.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "microsoft.net.sdk.android": "32.0.476", - "microsoft.net.sdk.ios": "16.0.517", - "microsoft.net.sdk.maccatalyst": "15.4.465", - "microsoft.net.sdk.macos": "12.3.465", - "microsoft.net.sdk.maui": "6.0.541", - "microsoft.net.sdk.tvos": "16.0.517", - "microsoft.net.workload.mono.toolchain": "6.0.10", - "microsoft.net.workload.emscripten": "6.0.10" -} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d50a5fd6d..49c100cdf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ variables: PreviewNumber: $[counter(variables['CurrentSemanticVersionBase'], 1001)] CurrentSemanticVersion: '$(CurrentSemanticVersionBase)-preview$(PreviewNumber)' NugetPackageVersion: '$(CurrentSemanticVersion)' - TOOLKIT_NET6_VERSION: '6.0.300' + TOOLKIT_NET6_VERSION: '6.0.400' LATEST_NET6_VERSION: '6.0.x' PathToLibrarySolution: 'src/CommunityToolkit.Maui.sln' PathToSamplesSolution: 'samples/CommunityToolkit.Maui.Sample.sln' @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.312.json' + DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.400.json' ShouldCheckDependencies: true trigger: From a2c860f5ce7f610ea46d832e26d590d35a9d5c69 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:03:06 +0300 Subject: [PATCH 10/22] 6.0.424 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 49c100cdf..972074c4f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.400.json' + DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.424.json' ShouldCheckDependencies: true trigger: From 3327e8ccfd6debfb6db67b175d629a844d73c088 Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:15:46 +0300 Subject: [PATCH 11/22] 486 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 972074c4f..59508466d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.424.json' + DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.486.json' ShouldCheckDependencies: true trigger: From a5f05f78031dfc82b7b97c28598994ee9143b34d Mon Sep 17 00:00:00 2001 From: Vladislav Antonyuk <33021114+VladislavAntonyuk@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:27:19 +0300 Subject: [PATCH 12/22] 540 --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 59508466d..bafca60c1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ variables: PathToCommunityToolkitAnalyzersUnitTestCsproj: 'src/CommunityToolkit.Maui.Analyzers.UnitTests/CommunityToolkit.Maui.Analyzers.UnitTests.csproj' Xcode13Version: '13.3.1' Xcode14Version: '14.0.1' - DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.486.json' + DotNetMauiRollbackFile: 'https://maui.blob.core.windows.net/metadata/rollbacks/6.0.540.json' ShouldCheckDependencies: true trigger: From c431204d443256918516d508905883cd60c2f146 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 17:42:09 -0700 Subject: [PATCH 13/22] Update azure-pipelines.yml --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1838b438f..799d5896a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -64,7 +64,7 @@ jobs: - pwsh: | Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' - .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET6_VERSION) + .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET_VERSION) displayName: Install tizen workload # build sample From 947056d463d90f2620ece5ed7fe79cf6531f9674 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:27:09 -0700 Subject: [PATCH 14/22] Formatting Updates --- .../CommunityToolkit.Maui.Sample.csproj | 2 +- .../Handlers/Popup/PopupHandler.tizen.cs | 10 +- .../Platform/StatusBar/StatusBar.tizen.cs | 1 + .../PlatformView/MauiDrawingView.tizen.cs | 35 ++-- .../Service/DrawingViewService.tizen.cs | 168 +++++++++--------- .../Views/Popup/MauiPopup.tizen.cs | 28 +-- .../Alerts/Snackbar/Snackbar.tizen.cs | 2 + .../Alerts/Toast/Toast.tizen.cs | 4 + .../SelectAllTextBehavior.tizen.cs | 6 +- 9 files changed, 141 insertions(+), 115 deletions(-) diff --git a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj index e8225f51a..a1c64f05d 100644 --- a/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj +++ b/samples/CommunityToolkit.Maui.Sample/CommunityToolkit.Maui.Sample.csproj @@ -51,8 +51,8 @@ 14.0 21.0 10.0.17763.0 - 10.0.17763.0 6.5 + 10.0.17763.0 diff --git a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs index c8dc82d0c..174a0a44c 100644 --- a/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Handlers/Popup/PopupHandler.tizen.cs @@ -5,9 +5,6 @@ namespace CommunityToolkit.Maui.Core.Handlers; public partial class PopupHandler : Microsoft.Maui.Handlers.ElementHandler { - /// - protected override MauiPopup CreatePlatformElement() => new MauiPopup(MauiContext ?? throw new NullReferenceException(nameof(MauiContext))); - /// /// Action that's triggered when the Popup is closed. /// @@ -96,4 +93,11 @@ 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/Platform/StatusBar/StatusBar.tizen.cs b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs index 72ec18508..86c85aeaf 100644 --- a/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Platform/StatusBar/StatusBar.tizen.cs @@ -3,6 +3,7 @@ namespace CommunityToolkit.Maui.Core.Platform; +[UnsupportedOSPlatform("Tizen")] static partial class StatusBar { static void PlatformSetColor(Color color) 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 4f885fe29..235e44dc5 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs @@ -14,6 +14,15 @@ public MauiDrawingView() : base(null) TouchEvent += OnTouch; } + /// + /// Initialize resources + /// + public void Initialize() + { + Drawable = new DrawingViewDrawable(this); + Lines.CollectionChanged += OnLinesCollectionChanged; + } + /// protected override void Dispose(bool disposing) { @@ -26,33 +35,39 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } - /// - /// Initialize resources - /// - public void Initialize() - { - Drawable = new DrawingViewDrawable(this); - Lines.CollectionChanged += OnLinesCollectionChanged; - } - bool OnTouch(object source, TouchEventArgs e) { var point = new PointF(e.Touch.GetLocalPosition(0).X.ToScaledDP(), e.Touch.GetLocalPosition(0).Y.ToScaledDP()); - switch (e.Touch.GetState(0)) + var pointStateType = e.Touch.GetState(0); + + switch (pointStateType) { + case NPointStateType.Finished: + case NPointStateType.Leave: + case NPointStateType.Started: + case NPointStateType.Stationary: + break; + case NPointStateType.Down: OnStart(point); break; + case NPointStateType.Motion: OnMoving(point); break; + case NPointStateType.Up: OnFinish(); break; + case NPointStateType.Interrupted: OnCancel(); break; + + default: + throw new NotSupportedException($"{pointStateType} not supported"); } + Redraw(); return true; diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs index c89c5c683..15aa388ad 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -20,19 +20,20 @@ public static class DrawingViewService public static ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) { var image = GetBitmapForPoints(points, lineWidth, strokeColor, background); + if (image is null) { return ValueTask.FromResult(Stream.Null); } - return new ValueTask(Task.Run(() => - { - var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); - var data = resized.Encode(SKEncodedImageFormat.Png, 100); - var stream = new MemoryStream(); - data.SaveTo(stream); - stream.Seek(0, SeekOrigin.Begin); - return stream; - })); + + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); + + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); + + return ValueTask.FromResult(stream); } /// @@ -45,34 +46,35 @@ public static ValueTask GetImageStream(IList points, Size imageS public static ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) { var image = GetBitmapForLines(lines, background); + if (image is null) { return ValueTask.FromResult(Stream.Null); } - return new ValueTask(Task.Run(() => - { - var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); - var data = resized.Encode(SKEncodedImageFormat.Png, 100); - - var stream = new MemoryStream(); - data.SaveTo(stream); - stream.Seek(0, SeekOrigin.Begin); - return stream; - })); + + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); + + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); + + return ValueTask.FromResult(stream); } - static (SKBitmap?, SizeF offset) GetBitmap(ICollection points) + static (SKBitmap?, SizeF offset) GetBitmap(in ICollection points) { if (points.Count is 0) { return (null, SizeF.Zero); } - var minPointX = points.Min(p => p.X); - var minPointY = points.Min(p => p.Y); - var drawingWidth = points.Max(p => p.X) - minPointX; - var drawingHeight = points.Max(p => p.Y) - minPointY; const int minSize = 1; + var minPointX = points.Min(static p => p.X); + var minPointY = points.Min(static p => p.Y); + var drawingWidth = points.Max(static p => p.X) - minPointX; + var drawingHeight = points.Max(static p => p.Y) - minPointY; + if (drawingWidth < minSize || drawingHeight < minSize) { return (null, SizeF.Zero); @@ -83,28 +85,29 @@ public static ValueTask GetImageStream(IList lines, Size i return (bitmap, new SizeF(minPointX, minPointY)); } - static SKBitmap? GetBitmapForLines(IList lines, Paint? background) + static SKBitmap? GetBitmapForLines(in IList lines, in Paint? background) { - var points = lines.SelectMany(x => x.Points).ToList(); + var points = lines.SelectMany(static x => x.Points).ToList(); var (image, offset) = GetBitmap(points); + if (image is null) { return null; } using var canvas = new SKCanvas(image); + DrawBackground(canvas, image.Info, background); + foreach (var line in lines) { DrawStrokes(canvas, line.Points, line.LineWidth, line.LineColor, offset); } + return image; } - static SKBitmap? GetBitmapForPoints(ICollection points, - float lineWidth, - Color strokeColor, - Paint? background) + static SKBitmap? GetBitmapForPoints(in ICollection points, in float lineWidth, in Color strokeColor, in Paint? background) { var (image, offset) = GetBitmap(points); if (image is null) @@ -113,80 +116,81 @@ public static ValueTask GetImageStream(IList lines, Size i } using var canvas = new SKCanvas(image); + DrawBackground(canvas, image.Info, background); DrawStrokes(canvas, points, lineWidth, strokeColor, offset); + return image; } - - static void DrawBackground(SKCanvas canvas, SKImageInfo info, Paint? brush) + static void DrawBackground(in SKCanvas canvas, in SKImageInfo info, in Paint? brush) { switch (brush) { case SolidPaint solidColorBrush: - canvas.DrawColor(solidColorBrush.Color != null ? solidColorBrush.Color.AsSKColor() : DrawingViewDefaults.BackgroundColor.AsSKColor()); + canvas.DrawColor(solidColorBrush.Color is not null + ? solidColorBrush.Color.AsSKColor() + : DrawingViewDefaults.BackgroundColor.AsSKColor()); break; + case LinearGradientPaint linearGradientBrush: + var paint = new SKPaint(); + var colors = new SKColor[linearGradientBrush.GradientStops.Length]; + var positions = new float[linearGradientBrush.GradientStops.Length]; + + for (var index = 0; index < linearGradientBrush.GradientStops.Length; index++) { - var paint = new SKPaint(); - var colors = new SKColor[linearGradientBrush.GradientStops.Length]; - var positions = new float[linearGradientBrush.GradientStops.Length]; - for (var index = 0; index < linearGradientBrush.GradientStops.Length; index++) - { - var gradientStop = linearGradientBrush.GradientStops[index]; - colors[index] = gradientStop.Color.AsSKColor(); - positions[index] = gradientStop.Offset; - } - - var x1 = (float)linearGradientBrush.StartPoint.X * info.Width; - var y1 = (float)linearGradientBrush.StartPoint.Y * info.Height; - var x2 = (float)linearGradientBrush.EndPoint.X * info.Width; - var y2 = (float)linearGradientBrush.EndPoint.Y * info.Height; - - var shader = SKShader.CreateLinearGradient( - new SKPoint(x1, y1), - new SKPoint(x2, y2), - colors, - positions, - SKShaderTileMode.Clamp); - paint.Shader = shader; - canvas.DrawRect(0, 0, info.Width, info.Height, paint); - break; + var gradientStop = linearGradientBrush.GradientStops[index]; + colors[index] = gradientStop.Color.AsSKColor(); + positions[index] = gradientStop.Offset; } + + var x1 = (float)linearGradientBrush.StartPoint.X * info.Width; + var y1 = (float)linearGradientBrush.StartPoint.Y * info.Height; + var x2 = (float)linearGradientBrush.EndPoint.X * info.Width; + var y2 = (float)linearGradientBrush.EndPoint.Y * info.Height; + + var shader = SKShader.CreateLinearGradient(new SKPoint(x1, y1), + new SKPoint(x2, y2), + colors, + positions, + SKShaderTileMode.Clamp); + paint.Shader = shader; + canvas.DrawRect(0, 0, info.Width, info.Height, paint); + break; + case RadialGradientPaint radialGradientBrush: + var paint = new SKPaint(); + var colors = new SKColor[radialGradientBrush.GradientStops.Length]; + var positions = new float[radialGradientBrush.GradientStops.Length]; + + for (var index = 0; index < radialGradientBrush.GradientStops.Length; index++) { - var paint = new SKPaint(); - var colors = new SKColor[radialGradientBrush.GradientStops.Length]; - var positions = new float[radialGradientBrush.GradientStops.Length]; - - for (var index = 0; index < radialGradientBrush.GradientStops.Length; index++) - { - var gradientStop = radialGradientBrush.GradientStops[index]; - colors[index] = gradientStop.Color.AsSKColor(); - positions[index] = gradientStop.Offset; - } - - float centerX = (float)(radialGradientBrush.Center.X * info.Width); - float centerY = (float)(radialGradientBrush.Center.Y * info.Height); - float radius = (float)(radialGradientBrush.Radius * info.Width); - - var shader = SKShader.CreateRadialGradient( - new SKPoint(centerX, centerX), - radius, - colors, - positions, - SKShaderTileMode.Clamp); - paint.Shader = shader; - canvas.DrawRect(0, 0, info.Width, info.Height, paint); - break; + var gradientStop = radialGradientBrush.GradientStops[index]; + colors[index] = gradientStop.Color.AsSKColor(); + positions[index] = gradientStop.Offset; } + + float centerX = (float)(radialGradientBrush.Center.X * info.Width); + float centerY = (float)(radialGradientBrush.Center.Y * info.Height); + float radius = (float)(radialGradientBrush.Radius * info.Width); + + var shader = SKShader.CreateRadialGradient(new SKPoint(centerX, centerX), + radius, + colors, + positions, + SKShaderTileMode.Clamp); + paint.Shader = shader; + canvas.DrawRect(0, 0, info.Width, info.Height, paint); + break; + default: canvas.DrawColor(DrawingViewDefaults.BackgroundColor.AsSKColor()); break; } } - static void DrawStrokes(SKCanvas canvas, ICollection points, float lineWidth, Color strokeColor, SizeF offset) + static void DrawStrokes(in SKCanvas canvas, in ICollection points, in float lineWidth, in Color strokeColor, in SizeF offset) { using var paint = new SKPaint { diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs index 6cbcd3482..61a4e1dbc 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -114,20 +114,6 @@ public void UpdateContentSize() } } - void OnOutsideClicked(object? sender, EventArgs e) - { - if (VirtualView is null || VirtualView.Handler is null) - { - return; - } - - if (VirtualView.CanBeDismissedByTappingOutsideOfPopup) - { - Close(); - VirtualView.Handler.Invoke(nameof(IPopup.OnDismissedByTappingOutsideOfPopup)); - } - } - static NVerticalAlignment ToVerticalAlignment(LayoutAlignment align) => align switch { LayoutAlignment.Start => NVerticalAlignment.Top, @@ -141,4 +127,18 @@ void OnOutsideClicked(object? sender, EventArgs e) LayoutAlignment.End => NHorizontalAlignment.End, _ => NHorizontalAlignment.Center }; + + void OnOutsideClicked(object? sender, EventArgs e) + { + if (VirtualView is null || 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/Alerts/Snackbar/Snackbar.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs index a47b2b428..ae9a01b8c 100644 --- a/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs @@ -150,6 +150,7 @@ Task ShowPlatform(CancellationToken token) PopupInstance = popup; OnShown(); + return Task.CompletedTask; } @@ -166,6 +167,7 @@ Task DismissPlatform(CancellationToken token) PopupInstance.Close(); PopupInstance.Dispose(); PopupInstance = null; + return Task.CompletedTask; } diff --git a/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs b/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs index d1c40f1f0..02476e5ee 100644 --- a/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs +++ b/src/CommunityToolkit.Maui/Alerts/Toast/Toast.tizen.cs @@ -20,6 +20,9 @@ protected virtual void Dispose(bool isDisposing) /// void ShowPlatform(CancellationToken token) { + DismissPlatform(token); + token.ThrowIfCancellationRequested(); + new Tizen.Applications.ToastMessage { Message = Text @@ -31,5 +34,6 @@ void ShowPlatform(CancellationToken token) /// static void DismissPlatform(CancellationToken token) { + token.ThrowIfCancellationRequested(); } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs index 760272f5c..7480966a4 100644 --- a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs @@ -22,10 +22,7 @@ public class SelectAllTextBehavior : PlatformBehavior void ApplyEffect(bool apply, NView inputView) { - if (inputView is null) - { - throw new InvalidOperationException("The Platform View can't be null."); - } + ArgumentNullException.ThrowIfNull(inputView); inputView.FocusGained -= OnFocused; @@ -46,5 +43,4 @@ void OnFocused(object? sender, EventArgs e) } } } - } \ No newline at end of file From c7ff6658316fe0a30f27821b1c0adc0264b92d22 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:32:05 -0700 Subject: [PATCH 15/22] Add --- azure-pipelines.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 799d5896a..ca7cc98ad 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -65,7 +65,7 @@ jobs: - pwsh: | Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET_VERSION) - displayName: Install tizen workload + displayName: Install Tizen Workload # build sample - task: CmdLine@2 @@ -117,6 +117,11 @@ jobs: inputs: script: dotnet workload install maui --from-rollback-file $(DotNetMauiRollbackFile) --source https://api.nuget.org/v3/index.json + - pwsh: | + Invoke-WebRequest 'https://raw.githubusercontent.com/Samsung/Tizen.NET/main/workload/scripts/workload-install.ps1' -OutFile 'workload-install.ps1' + .\workload-install.ps1 -DotnetTargetVersionBand $(TOOLKIT_NET_VERSION) + displayName: Install Tizen Workload + - task: CmdLine@2 displayName: 'Build CommunityToolkit.Maui.Analyzers' inputs: From 0434c1e8679eb2d68751d3a30f7c2bef7f1991a0 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:47:49 -0700 Subject: [PATCH 16/22] Remove duplicate enums --- .../Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs | 2 -- 1 file changed, 2 deletions(-) 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 235e44dc5..772c45099 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/PlatformView/MauiDrawingView.tizen.cs @@ -42,9 +42,7 @@ bool OnTouch(object source, TouchEventArgs e) switch (pointStateType) { - case NPointStateType.Finished: case NPointStateType.Leave: - case NPointStateType.Started: case NPointStateType.Stationary: break; From e654f337f772a241365abb0b21b678f771f7f333 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 19:00:44 -0700 Subject: [PATCH 17/22] Fix variable conflicts --- .../Service/DrawingViewService.tizen.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs index 15aa388ad..11039adf0 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -160,28 +160,28 @@ static void DrawBackground(in SKCanvas canvas, in SKImageInfo info, in Paint? br break; case RadialGradientPaint radialGradientBrush: - var paint = new SKPaint(); - var colors = new SKColor[radialGradientBrush.GradientStops.Length]; - var positions = new float[radialGradientBrush.GradientStops.Length]; + var skPaint = new SKPaint(); + var skColors = new SKColor[radialGradientBrush.GradientStops.Length]; + var positionsArray = new float[radialGradientBrush.GradientStops.Length]; for (var index = 0; index < radialGradientBrush.GradientStops.Length; index++) { var gradientStop = radialGradientBrush.GradientStops[index]; - colors[index] = gradientStop.Color.AsSKColor(); - positions[index] = gradientStop.Offset; + skColors[index] = gradientStop.Color.AsSKColor(); + positionsArray[index] = gradientStop.Offset; } float centerX = (float)(radialGradientBrush.Center.X * info.Width); float centerY = (float)(radialGradientBrush.Center.Y * info.Height); float radius = (float)(radialGradientBrush.Radius * info.Width); - var shader = SKShader.CreateRadialGradient(new SKPoint(centerX, centerX), + var skShader = SKShader.CreateRadialGradient(new SKPoint(centerX, centerX), radius, - colors, - positions, + skColors, + positionsArray, SKShaderTileMode.Clamp); - paint.Shader = shader; - canvas.DrawRect(0, 0, info.Width, info.Height, paint); + skPaint.Shader = skShader; + canvas.DrawRect(0, 0, info.Width, info.Height, skPaint); break; default: From 186938f00da1b65d171b1ad3eee9c05566a4ca48 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Thu, 20 Oct 2022 19:18:36 -0700 Subject: [PATCH 18/22] Defer to thread pool thread --- .../Service/DrawingViewService.tizen.cs | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs index 11039adf0..e1e6ffb66 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -17,23 +17,27 @@ public static class DrawingViewService /// Line color /// Image background /// Image stream - public static ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) + public static async ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) { var image = GetBitmapForPoints(points, lineWidth, strokeColor, background); if (image is null) { - return ValueTask.FromResult(Stream.Null); + return Stream.Null; } - var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); - var data = resized.Encode(SKEncodedImageFormat.Png, 100); + // Defer to thread pool thread https://github.com/CommunityToolkit/Maui/pull/692#pullrequestreview-1150202727 + return await Task.Run(() => + { + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); - var stream = new MemoryStream(); - data.SaveTo(stream); - stream.Seek(0, SeekOrigin.Begin); + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); - return ValueTask.FromResult(stream); + return stream; + }).ConfigureAwait(false); } /// @@ -43,23 +47,27 @@ public static ValueTask GetImageStream(IList points, Size imageS /// Image size /// Image background /// Image stream - public static ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) + public static async ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) { var image = GetBitmapForLines(lines, background); if (image is null) { - return ValueTask.FromResult(Stream.Null); + return Stream.Null; } - var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); - var data = resized.Encode(SKEncodedImageFormat.Png, 100); + // Defer to thread pool thread https://github.com/CommunityToolkit/Maui/pull/692#pullrequestreview-1150202727 + return await Task.Run(() => + { + var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); + var data = resized.Encode(SKEncodedImageFormat.Png, 100); - var stream = new MemoryStream(); - data.SaveTo(stream); - stream.Seek(0, SeekOrigin.Begin); + var stream = new MemoryStream(); + data.SaveTo(stream); + stream.Seek(0, SeekOrigin.Begin); - return ValueTask.FromResult(stream); + return stream; + }).ConfigureAwait(false); } static (SKBitmap?, SizeF offset) GetBitmap(in ICollection points) From 29d147ca203260595f9355dfe956855a32590a7c Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 24 Oct 2022 14:52:33 +0900 Subject: [PATCH 19/22] Fix MauiPopup anchor position --- src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs index 61a4e1dbc..4341fbd0d 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -70,9 +70,8 @@ public void ShowPopup() { var anchorView = VirtualView.Anchor.ToPlatform(); var anchorPosition = anchorView.ScreenPosition; - Content.ScreenToLocal(out float x, out float y, anchorPosition.X, anchorPosition.Y); Layout = new AbsoluteLayout(); - Content.UpdatePosition(new Tizen.UIExtensions.Common.Point(x, y)); + Content.UpdatePosition(new Tizen.UIExtensions.Common.Point(anchorPosition.X, anchorPosition.Y)); } else { From 08bf36d8729def1dc90146d50b67369f0461f672 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 24 Oct 2022 15:12:32 +0900 Subject: [PATCH 20/22] Apply review comment --- .../Views/Popup/MauiPopup.tizen.cs | 7 +------ .../SelectAllText/SelectAllTextBehavior.tizen.cs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs index 4341fbd0d..ffd21b410 100644 --- a/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs @@ -58,11 +58,6 @@ 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"); - if (Content is null) - { - return; - } - BackgroundColor = new Tizen.NUI.Color(0.1f, 0.1f, 0.1f, 0.5f); Content.BackgroundColor = (VirtualView.Color ?? Colors.Transparent).ToNUIColor(); @@ -129,7 +124,7 @@ public void UpdateContentSize() void OnOutsideClicked(object? sender, EventArgs e) { - if (VirtualView is null || VirtualView.Handler is null) + if (VirtualView?.Handler is null) { return; } diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs index 7480966a4..8cdeccfef 100644 --- a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/SelectAllText/SelectAllTextBehavior.tizen.cs @@ -31,7 +31,7 @@ void ApplyEffect(bool apply, NView inputView) inputView.FocusGained += OnFocused; } - void OnFocused(object? sender, EventArgs e) + static void OnFocused(object? sender, EventArgs e) { if (sender is TextField tf && tf.HasFocus()) { From 91e9cc7f50a246c762acdd918f409350e480a27d Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 24 Oct 2022 15:20:58 +0900 Subject: [PATCH 21/22] Fix GetImageStream without await --- .../Service/DrawingViewService.tizen.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs index e1e6ffb66..42cc97695 100644 --- a/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs +++ b/src/CommunityToolkit.Maui.Core/Views/DrawingView/Service/DrawingViewService.tizen.cs @@ -17,17 +17,17 @@ public static class DrawingViewService /// Line color /// Image background /// Image stream - public static async ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) + public static ValueTask GetImageStream(IList points, Size imageSize, float lineWidth, Color strokeColor, Paint? background) { var image = GetBitmapForPoints(points, lineWidth, strokeColor, background); if (image is null) { - return Stream.Null; + return ValueTask.FromResult(Stream.Null); } // Defer to thread pool thread https://github.com/CommunityToolkit/Maui/pull/692#pullrequestreview-1150202727 - return await Task.Run(() => + return new ValueTask(Task.Run(() => { var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); var data = resized.Encode(SKEncodedImageFormat.Png, 100); @@ -37,7 +37,7 @@ public static async ValueTask GetImageStream(IList points, Size stream.Seek(0, SeekOrigin.Begin); return stream; - }).ConfigureAwait(false); + })); } /// @@ -47,17 +47,17 @@ public static async ValueTask GetImageStream(IList points, Size /// Image size /// Image background /// Image stream - public static async ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) + public static ValueTask GetImageStream(IList lines, Size imageSize, Paint? background) { var image = GetBitmapForLines(lines, background); if (image is null) { - return Stream.Null; + return ValueTask.FromResult(Stream.Null); } // Defer to thread pool thread https://github.com/CommunityToolkit/Maui/pull/692#pullrequestreview-1150202727 - return await Task.Run(() => + return new ValueTask(Task.Run(() => { var resized = image.Resize(new SKImageInfo((int)imageSize.Width, (int)imageSize.Height, SKColorType.Bgra8888, SKAlphaType.Opaque), SKFilterQuality.High); var data = resized.Encode(SKEncodedImageFormat.Png, 100); @@ -67,7 +67,7 @@ public static async ValueTask GetImageStream(IList lines, stream.Seek(0, SeekOrigin.Begin); return stream; - }).ConfigureAwait(false); + })); } static (SKBitmap?, SizeF offset) GetBitmap(in ICollection points) From 6af8ec7d8386745a5ce5571399738bae0d7e0300 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 24 Oct 2022 15:52:38 +0900 Subject: [PATCH 22/22] Add UnsupportedOSPlatform attribute on unsupported behaviors --- .../IconTintColor/IconTintColorBehavior.shared.cs | 2 +- .../PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.shared.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.shared.cs index 10aa7e92f..5f122e5fd 100644 --- a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.shared.cs +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/IconTintColor/IconTintColorBehavior.shared.cs @@ -5,7 +5,7 @@ namespace CommunityToolkit.Maui.Behaviors; /// /// A behavior that allows you to tint an icon with a specified . /// -[UnsupportedOSPlatform("windows")] +[UnsupportedOSPlatform("windows"), UnsupportedOSPlatform("Tizen")] public partial class IconTintColorBehavior : PlatformBehavior { /// diff --git a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs index 73e388c58..a6e9cc6f9 100644 --- a/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs +++ b/src/CommunityToolkit.Maui/Behaviors/PlatformBehaviors/StatusBar/StatusBarBehavior.shared.cs @@ -10,7 +10,7 @@ namespace CommunityToolkit.Maui.Behaviors; /// /// that controls the Status bar color /// -[UnsupportedOSPlatform("Windows"), UnsupportedOSPlatform("MacCatalyst"), UnsupportedOSPlatform("MacOS")] +[UnsupportedOSPlatform("Windows"), UnsupportedOSPlatform("MacCatalyst"), UnsupportedOSPlatform("MacOS"), UnsupportedOSPlatform("Tizen")] public class StatusBarBehavior : PlatformBehavior { ///