diff --git a/Microsoft.Maui.Tizen.sln b/._Microsoft.Maui.Tizen.sln similarity index 100% rename from Microsoft.Maui.Tizen.sln rename to ._Microsoft.Maui.Tizen.sln diff --git a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets index d93d10790ec0..cecf6d5cd201 100644 --- a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets +++ b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets @@ -31,9 +31,9 @@ - + - + diff --git a/src/Core/src/Handlers/BoxView/BoxViewHandler.Tizen.cs b/src/Core/src/Handlers/BoxView/BoxViewHandler.Tizen.cs deleted file mode 100644 index 630fd3fdc49c..000000000000 --- a/src/Core/src/Handlers/BoxView/BoxViewHandler.Tizen.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.Maui.Graphics; - -namespace Microsoft.Maui.Handlers -{ - public partial class BoxViewHandler : ViewHandler - { - protected override MauiBoxView CreateNativeView() - { - return new MauiBoxView(NativeParent!) - { - Drawable = new BoxViewDrawable(VirtualView) - }; - } - - public static void MapColor(BoxViewHandler handler, IBoxView boxView) - { - handler.NativeView?.InvalidateBoxView(boxView); - } - - public static void MapCornerRadius(BoxViewHandler handler, IBoxView boxView) - { - handler.NativeView?.InvalidateBoxView(boxView); - } - } -} diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs index d63099842bb0..192e9acd74b8 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs @@ -46,9 +46,18 @@ public static Task MapImageSourceAsync(IButtonHandler handler, IImage image) return handler.ImageSourceLoader.UpdateImageSourceAsync(); } - //TODO : Need to impl - [MissingMapper] - public static void MapImageSource(ButtonHandler handler, IButton image) { } + public static void MapImageSource(IButtonHandler handler, IButton image) => + MapImageSourceAsync(handler, image).FireAndForget(handler); + + public static Task MapImageSourceAsync(IButtonHandler handler, IButton image) + { + if (image.ImageSource == null) + { + return Task.CompletedTask; + } + + return handler.ImageSourceLoader.UpdateImageSourceAsync(); + } [MissingMapper] public static void MapCharacterSpacing(IButtonHandler handler, ITextStyle button) { } diff --git a/src/Core/src/ImageSources/Tizen/ImageSourceServiceResult.cs b/src/Core/src/ImageSources/Tizen/ImageSourceServiceResult.cs deleted file mode 100644 index 6e48ceaec7c1..000000000000 --- a/src/Core/src/ImageSources/Tizen/ImageSourceServiceResult.cs +++ /dev/null @@ -1,39 +0,0 @@ -#nullable enable -using System; - -namespace Microsoft.Maui -{ - public class ImageSourceServiceResult : IImageSourceServiceResult - { - Action? _dispose; - - public ImageSourceServiceResult(bool result, Action? dispose = null) - : this(result, false, dispose) - { - } - - public ImageSourceServiceResult(bool result, bool resolutionDependent, Action? dispose = null) - { - Value = result; - IsResolutionDependent = resolutionDependent; - _dispose = dispose; - } - - public bool Value { get; } - - public bool IsResolutionDependent { get; } - - public bool IsDisposed { get; private set; } - - public void Dispose() - { - if (IsDisposed) - return; - - IsDisposed = true; - - _dispose?.Invoke(); - _dispose = null; - } - } -} \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/BoxViewExtensions.cs b/src/Core/src/Platform/Tizen/BoxViewExtensions.cs deleted file mode 100644 index 1c450ddd290b..000000000000 --- a/src/Core/src/Platform/Tizen/BoxViewExtensions.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.Maui.Graphics; - -namespace Microsoft.Maui -{ - public static class BoxViewExtensions - { - public static void InvalidateBoxView(this MauiBoxView nativeView, IBoxView boxView) - { - nativeView.Invalidate(); - } - } -} \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/ImageExtensions.cs b/src/Core/src/Platform/Tizen/ImageExtensions.cs index 607b99cdc0c0..a11d1aa7a793 100644 --- a/src/Core/src/Platform/Tizen/ImageExtensions.cs +++ b/src/Core/src/Platform/Tizen/ImageExtensions.cs @@ -18,5 +18,58 @@ public static void UpdateIsAnimationPlaying(this Image platformImage, IImageSour platformImage.IsAnimated = image.IsAnimationPlaying; platformImage.IsAnimationPlaying = image.IsAnimationPlaying; } + + public static async Task?> UpdateSourceAsync(this IImageSourcePart image, Image destinationContext, IImageSourceServiceProvider services, Action setImage, CancellationToken cancellationToken = default) + { + image.UpdateIsLoading(false); + + var imageSource = image.Source; + if (imageSource == null) + return null; + + var events = image as IImageSourcePartEvents; + + events?.LoadingStarted(); + image.UpdateIsLoading(true); + + try + { + var service = services.GetRequiredImageSourceService(imageSource); + var result = await service.GetImageAsync(imageSource, destinationContext, cancellationToken); + var tImage = result?.Value; + + var applied = !cancellationToken.IsCancellationRequested && tImage != null && imageSource == image.Source; + + // only set the image if we are still on the same one + if (applied) + { + setImage.Invoke(tImage); + destinationContext.UpdateIsAnimationPlaying(image); + } + + events?.LoadingCompleted(applied); + + return result; + } + catch (OperationCanceledException) + { + // no-op + events?.LoadingCompleted(false); + } + catch (Exception ex) + { + events?.LoadingFailed(ex); + } + finally + { + // only mark as finished if we are still working on the same image + if (imageSource == image.Source) + { + image.UpdateIsLoading(false); + } + } + + return null; + } } }