From cbe82e5eb9f206c2d9c263b1085db7549f0d84e3 Mon Sep 17 00:00:00 2001 From: MartyIX <203266+MartyIX@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:17:49 +0100 Subject: [PATCH] WIP4 --- .../src/Handlers/Element/ElementHandler.cs | 2 +- src/Core/src/Handlers/Label/LabelHandler.cs | 18 +--- src/Core/src/Handlers/View/ViewHandler.cs | 90 ++++++------------- src/Core/src/Handlers/View/ViewHandlerOfT.cs | 1 - src/Core/src/PlatformPropertyDefaults.cs | 2 + src/Core/src/PropertyMapper.cs | 1 + 6 files changed, 37 insertions(+), 77 deletions(-) diff --git a/src/Core/src/Handlers/Element/ElementHandler.cs b/src/Core/src/Handlers/Element/ElementHandler.cs index d1d6cd26c497..797308200379 100644 --- a/src/Core/src/Handlers/Element/ElementHandler.cs +++ b/src/Core/src/Handlers/Element/ElementHandler.cs @@ -85,7 +85,7 @@ public virtual void SetVirtualView(IElement view) var map = imv.GetPropertyMapperOverrides(); if (map is not null) { - map.Chained = [_defaultMapper]; + map.Chained = new[] { _defaultMapper }; _mapper = map; } } diff --git a/src/Core/src/Handlers/Label/LabelHandler.cs b/src/Core/src/Handlers/Label/LabelHandler.cs index e448e0c4d5f4..5dc235dba18f 100644 --- a/src/Core/src/Handlers/Label/LabelHandler.cs +++ b/src/Core/src/Handlers/Label/LabelHandler.cs @@ -1,6 +1,4 @@ #nullable enable -using System; -using System.Collections.Generic; #if __IOS__ || MACCATALYST using PlatformView = Microsoft.Maui.Platform.MauiLabel; #elif MONOANDROID @@ -78,23 +76,15 @@ public LabelHandler(IPropertyMapper? mapper, CommandMapper? commandMapper) PlatformView ILabelHandler.PlatformView => PlatformView; internal static bool HasDefaultTextDecorations(ILabel label) - { - return label.TextDecorations == TextDecorations.None; - } + => label.TextDecorations == TextDecorations.None; internal static bool HasDefaultCharacterSpacing(ILabel label) - { - return label.CharacterSpacing == 0; - } + => label.CharacterSpacing == 0; internal static bool HasDefaultHorizontalTextAlignment(ILabel label) - { - return label.HorizontalTextAlignment == TextAlignment.Start; - } + => label.HorizontalTextAlignment == TextAlignment.Start; internal static bool HasDefaultVerticalTextAlignment(ILabel label) - { - return label.VerticalTextAlignment == TextAlignment.Start; - } + => label.VerticalTextAlignment == TextAlignment.Start; } } \ No newline at end of file diff --git a/src/Core/src/Handlers/View/ViewHandler.cs b/src/Core/src/Handlers/View/ViewHandler.cs index 87c2311c464d..0cab097da6c7 100644 --- a/src/Core/src/Handlers/View/ViewHandler.cs +++ b/src/Core/src/Handlers/View/ViewHandler.cs @@ -49,6 +49,9 @@ public abstract partial class ViewHandler : ElementHandler, IViewHandler [nameof(IView.RotationX)] = HasDefaultRotationX, [nameof(IView.RotationY)] = HasDefaultRotationY, + [nameof(IView.AnchorX)] = HasDefaultAnchorX, + [nameof(IView.AnchorY)] = HasDefaultAnchorY, + [nameof(IView.Opacity)] = HasDefaultOpacity, [nameof(IView.TranslationX)] = HasDefaultTranslationX, @@ -579,102 +582,67 @@ public static void MapToolTip(IViewHandler handler, IView view) } internal static bool HasDefaultAutomationId(IView view) - { - return string.IsNullOrEmpty(view.AutomationId); - } + => string.IsNullOrEmpty(view.AutomationId); internal static bool HasDefaultClip(IView view) - { - return view.Clip is null; - } + => view.Clip is null; internal static bool HasDefaultPadding(IView view) - { - return view is IPadding padding && (padding.Padding.IsEmpty || padding.Padding.IsNaN); - } + => view is IPadding padding && (padding.Padding.IsEmpty || padding.Padding.IsNaN); internal static bool HasDefaultShadow(IView view) - { - return view.Shadow is null; - } + => view.Shadow is null; internal static bool HasDefaultVisibility(IView view) - { - return view.Visibility == Visibility.Visible; - } - + => view.Visibility == Visibility.Visible; internal static bool HasDefaultFlowDirection(IView view) - { - return view.FlowDirection == FlowDirection.MatchParent; - } + => view.FlowDirection == FlowDirection.MatchParent; internal static bool HasDefaultDimension(IView view) - { - return double.IsNaN(view.MinimumHeight); - } + => double.IsNaN(view.MinimumHeight); internal static bool HasDefaultScale(IView view) - { - return view.Scale == 1; - } + => view.Scale == 1; internal static bool HasDefaultScaleX(IView view) - { - return view.ScaleX == 1; - } + => view.Scale == 1 && view.ScaleX == 1; internal static bool HasDefaultScaleY(IView view) - { - return view.ScaleY == 1; - } + => view.Scale == 1 && view.ScaleY == 1; internal static bool HasDefaultRotation(IView view) - { - return view.Rotation % 360 == 0; - } + => view.Rotation % 360 == 0; internal static bool HasDefaultRotationX(IView view) - { - return view.RotationX % 360 == 0; - } + => view.RotationX % 360 == 0; internal static bool HasDefaultRotationY(IView view) - { - return view.RotationY % 360 == 0; - } + => view.RotationY % 360 == 0; + + internal static bool HasDefaultAnchorX(IView view) + => view.AnchorX == 0.5; + + internal static bool HasDefaultAnchorY(IView view) + => view.AnchorY == 0.5; internal static bool HasDefaultOpacity(IView view) - { - return view.Opacity == 1; - } + => view.Opacity == 1; internal static bool HasDefaultTranslationX(IView view) - { - return view.TranslationX == 0; - } + => view.TranslationX == 0; internal static bool HasDefaultTranslationY(IView view) - { - return ((IView)view).TranslationY == 0; - } + => view.TranslationY == 0; internal static bool HasDefaultContextFlyout(IView view) - { - return view is IContextFlyoutElement { ContextFlyout: null }; - } + => view is IContextFlyoutElement { ContextFlyout: null }; internal static bool HasDefaultInputTransparent(IView view) - { - return !view.InputTransparent; - } + => !view.InputTransparent; internal static bool HasDefaultToolbar(IView view) - { - return view is IToolbarElement { Toolbar: null }; - } + => view is IToolbarElement { Toolbar: null }; internal static bool HasDefaultToolTip(IView view) - { - return view is IToolTipElement { ToolTip: null }; - } + => view is IToolTipElement { ToolTip: null }; } } diff --git a/src/Core/src/Handlers/View/ViewHandlerOfT.cs b/src/Core/src/Handlers/View/ViewHandlerOfT.cs index 5590e2185e3f..53040f66cff0 100644 --- a/src/Core/src/Handlers/View/ViewHandlerOfT.cs +++ b/src/Core/src/Handlers/View/ViewHandlerOfT.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; #if IOS || MACCATALYST using PlatformView = UIKit.UIView; #elif MONOANDROID diff --git a/src/Core/src/PlatformPropertyDefaults.cs b/src/Core/src/PlatformPropertyDefaults.cs index cc0650be5e00..8a5a69ec0ac5 100644 --- a/src/Core/src/PlatformPropertyDefaults.cs +++ b/src/Core/src/PlatformPropertyDefaults.cs @@ -22,7 +22,9 @@ public PlatformPropertyDefaults(params IPlatformPropertyDefaults[] chained) public Func? GetProperty(string key) { if (_mapper.TryGetValue(key, out var action)) + { return action; + } if (_chained.Length <= 0) { diff --git a/src/Core/src/PropertyMapper.cs b/src/Core/src/PropertyMapper.cs index 4a456ed228d8..f5bb167542d1 100644 --- a/src/Core/src/PropertyMapper.cs +++ b/src/Core/src/PropertyMapper.cs @@ -156,6 +156,7 @@ public interface IPropertyMapper Action? GetProperty(string key); IEnumerable GetKeys(); + void UpdateProperties(IElementHandler elementHandler, IElement virtualView); void UpdateProperty(IElementHandler elementHandler, IElement virtualView, string property);