Skip to content

Commit

Permalink
WIP4
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyIX committed Jan 11, 2025
1 parent d27dce5 commit b48688f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/Element/ElementHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
18 changes: 4 additions & 14 deletions src/Core/src/Handlers/Label/LabelHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#nullable enable
using System;
using System.Collections.Generic;
#if __IOS__ || MACCATALYST
using PlatformView = Microsoft.Maui.Platform.MauiLabel;
#elif MONOANDROID
Expand Down Expand Up @@ -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;
}
}
90 changes: 29 additions & 61 deletions src/Core/src/Handlers/View/ViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 };
}
}
1 change: 0 additions & 1 deletion src/Core/src/Handlers/View/ViewHandlerOfT.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
#if IOS || MACCATALYST
using PlatformView = UIKit.UIView;
#elif MONOANDROID
Expand Down
2 changes: 2 additions & 0 deletions src/Core/src/PlatformPropertyDefaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public PlatformPropertyDefaults(params IPlatformPropertyDefaults[] chained)
public Func<IElement, bool>? GetProperty(string key)
{
if (_mapper.TryGetValue(key, out var action))
{
return action;
}

if (_chained.Length <= 0)
{
Expand Down

0 comments on commit b48688f

Please sign in to comment.