From 8cd8fc30289b04a4a51bc0587334b5a7db3ebe9d Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Wed, 14 Jul 2021 10:04:16 +0900 Subject: [PATCH] Bumt to latest - Effects (#1574) - Improve Window and AnimationManager (#1653) - and so on --- .../Tizen/Renderers/VisualElementRenderer.cs | 4 +- .../Pages/Core/EffectsPage.xaml.cs | 48 +++++++++++++++++++ .../src/Core/Platform/PlatformEffect.cs | 2 + .../src/Platform/Tizen/HandlerExtensions.cs | 8 ++-- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs index 8cb97acd4800..d380e8644495 100644 --- a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs +++ b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs @@ -902,8 +902,8 @@ void OnFocusChangeRequested(object sender, VisualElement.FocusRequestArgs e) /// The effect to register. void OnRegisterEffect(PlatformEffect effect) { - effect.SetContainer(Element.Parent == null ? null : Platform.GetRenderer(Element.Parent)?.NativeView); - effect.SetControl(NativeView); + effect.Container = Element.Parent == null ? null : Platform.GetRenderer(Element.Parent)?.NativeView; + effect.Control = NativeView; } void OnMoved(object sender, EventArgs e) diff --git a/src/Controls/samples/Controls.Sample/Pages/Core/EffectsPage.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Core/EffectsPage.xaml.cs index 3f3320b967db..56f281737c5b 100644 --- a/src/Controls/samples/Controls.Sample/Pages/Core/EffectsPage.xaml.cs +++ b/src/Controls/samples/Controls.Sample/Pages/Core/EffectsPage.xaml.cs @@ -135,5 +135,53 @@ protected override void OnElementPropertyChanged(PropertyChangedEventArgs args) } } } +#elif TIZEN + public class FocusPlatformEffect : PlatformEffect + { + ElmSharp.Color backgroundColor; + + protected override void OnAttached() + { + try + { + (Control as ElmSharp.Widget).BackgroundColor = backgroundColor = ElmSharp.Color.FromRgb(204, 153, 255); + } + catch (Exception ex) + { + Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message); + } + } + + protected override void OnDetached() + { + } + + protected override void OnElementPropertyChanged(PropertyChangedEventArgs args) + { + base.OnElementPropertyChanged(args); + + try + { + if (args.PropertyName == "IsFocused") + { + if (Control is ElmSharp.Widget widget) + { + if (widget.BackgroundColor == backgroundColor) + { + widget.BackgroundColor = ElmSharp.Color.White; + } + else + { + widget.BackgroundColor = backgroundColor; + } + } + } + } + catch (Exception ex) + { + Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message); + } + } + } #endif } \ No newline at end of file diff --git a/src/Controls/src/Core/Platform/PlatformEffect.cs b/src/Controls/src/Core/Platform/PlatformEffect.cs index a087edf1c827..40b0dde21d3c 100644 --- a/src/Controls/src/Core/Platform/PlatformEffect.cs +++ b/src/Controls/src/Core/Platform/PlatformEffect.cs @@ -5,6 +5,8 @@ using NativeView = Android.Views.View; #elif WINDOWS using NativeView = Microsoft.UI.Xaml.FrameworkElement; +#elif TIZEN +using NativeView = ElmSharp.EvasObject; #elif NETSTANDARD using NativeView = System.Object; #endif diff --git a/src/Core/src/Platform/Tizen/HandlerExtensions.cs b/src/Core/src/Platform/Tizen/HandlerExtensions.cs index f69811a80726..43df1d04043b 100644 --- a/src/Core/src/Platform/Tizen/HandlerExtensions.cs +++ b/src/Core/src/Platform/Tizen/HandlerExtensions.cs @@ -6,7 +6,7 @@ namespace Microsoft.Maui { public static class HandlerExtensions { - public static EvasObject ToNative(this IView view, IMauiContext context) + public static EvasObject ToNative(this IElement view, IMauiContext context) { _ = view ?? throw new ArgumentNullException(nameof(view)); _ = context ?? throw new ArgumentNullException(nameof(context)); @@ -44,12 +44,12 @@ public static void SetWindow(this Window nativeWindow, IWindow window, IMauiCont _ = window ?? throw new ArgumentNullException(nameof(window)); _ = mauiContext ?? throw new ArgumentNullException(nameof(mauiContext)); - var handler = window.Handler as IWindowHandler; + var handler = window.Handler; if (handler == null) - handler = mauiContext.Handlers.GetHandler(window.GetType()) as IWindowHandler; + handler = mauiContext.Handlers.GetHandler(window.GetType()); if (handler == null) - throw new Exception($"Handler not found for view {window} or was not {nameof(IWindowHandler)}'"); + throw new Exception($"Handler not found for view {window}."); handler.SetMauiContext(mauiContext);