Skip to content

Commit

Permalink
Fix VisualElement to have correct default values for properties
Browse files Browse the repository at this point in the history
Fixes #57
  • Loading branch information
Eilon committed Jan 25, 2020
1 parent ae2838a commit 974f79c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,40 @@ public override void ApplyAttribute(ulong attributeEventHandlerId, string attrib
switch (attributeName)
{
case nameof(XF.VisualElement.AnchorX):
VisualElementControl.AnchorX = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.AnchorX = AttributeHelper.StringToDouble((string)attributeValue, 0.50);
break;
case nameof(XF.VisualElement.AnchorY):
VisualElementControl.AnchorY = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.AnchorY = AttributeHelper.StringToDouble((string)attributeValue, 0.50);
break;
case nameof(XF.VisualElement.BackgroundColor):
VisualElementControl.BackgroundColor = AttributeHelper.StringToColor((string)attributeValue);
break;
case nameof(XF.VisualElement.FlowDirection):
VisualElementControl.FlowDirection = (XF.FlowDirection)AttributeHelper.GetInt(attributeValue);
break;
case nameof(XF.VisualElement.HeightRequest):
VisualElementControl.HeightRequest = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.HeightRequest = AttributeHelper.StringToDouble((string)attributeValue, -1.00);
break;
case nameof(XF.VisualElement.InputTransparent):
VisualElementControl.InputTransparent = AttributeHelper.GetBool(attributeValue);
break;
case nameof(XF.VisualElement.IsEnabled):
VisualElementControl.IsEnabled = AttributeHelper.GetBool(attributeValue);
VisualElementControl.IsEnabled = AttributeHelper.GetBool(attributeValue, true);
break;
case nameof(XF.VisualElement.IsTabStop):
VisualElementControl.IsTabStop = AttributeHelper.GetBool(attributeValue);
VisualElementControl.IsTabStop = AttributeHelper.GetBool(attributeValue, true);
break;
case nameof(XF.VisualElement.IsVisible):
VisualElementControl.IsVisible = AttributeHelper.GetBool(attributeValue);
VisualElementControl.IsVisible = AttributeHelper.GetBool(attributeValue, true);
break;
case nameof(XF.VisualElement.MinimumHeightRequest):
VisualElementControl.MinimumHeightRequest = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.MinimumHeightRequest = AttributeHelper.StringToDouble((string)attributeValue, -1.00);
break;
case nameof(XF.VisualElement.MinimumWidthRequest):
VisualElementControl.MinimumWidthRequest = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.MinimumWidthRequest = AttributeHelper.StringToDouble((string)attributeValue, -1.00);
break;
case nameof(XF.VisualElement.Opacity):
VisualElementControl.Opacity = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.Opacity = AttributeHelper.StringToDouble((string)attributeValue, 1.00);
break;
case nameof(XF.VisualElement.Rotation):
VisualElementControl.Rotation = AttributeHelper.StringToDouble((string)attributeValue);
Expand All @@ -87,13 +90,13 @@ public override void ApplyAttribute(ulong attributeEventHandlerId, string attrib
VisualElementControl.RotationY = AttributeHelper.StringToDouble((string)attributeValue);
break;
case nameof(XF.VisualElement.Scale):
VisualElementControl.Scale = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.Scale = AttributeHelper.StringToDouble((string)attributeValue, 1.00);
break;
case nameof(XF.VisualElement.ScaleX):
VisualElementControl.ScaleX = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.ScaleX = AttributeHelper.StringToDouble((string)attributeValue, 1.00);
break;
case nameof(XF.VisualElement.ScaleY):
VisualElementControl.ScaleY = AttributeHelper.StringToDouble((string)attributeValue);
VisualElementControl.ScaleY = AttributeHelper.StringToDouble((string)attributeValue, 1.00);
break;
case nameof(XF.VisualElement.TabIndex):
VisualElementControl.TabIndex = AttributeHelper.GetInt(attributeValue);
Expand All @@ -105,10 +108,7 @@ public override void ApplyAttribute(ulong attributeEventHandlerId, string attrib
VisualElementControl.TranslationY = AttributeHelper.StringToDouble((string)attributeValue);
break;
case nameof(XF.VisualElement.WidthRequest):
VisualElementControl.WidthRequest = AttributeHelper.StringToDouble((string)attributeValue);
break;
case nameof(XF.VisualElement.FlowDirection):
VisualElementControl.FlowDirection = (XF.FlowDirection)AttributeHelper.GetInt(attributeValue);
VisualElementControl.WidthRequest = AttributeHelper.StringToDouble((string)attributeValue, -1.00);
break;
case "onfocused":
Renderer.RegisterEvent(attributeEventHandlerId, () => FocusedEventHandlerId = 0);
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.MobileBlazorBindings/Elements/VisualElement.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

using Microsoft.MobileBlazorBindings.Core;
using Microsoft.AspNetCore.Components;
using XF = Xamarin.Forms;
using Microsoft.MobileBlazorBindings.Core;
using Microsoft.MobileBlazorBindings.Elements.Handlers;
using XF = Xamarin.Forms;

namespace Microsoft.MobileBlazorBindings.Elements
{
Expand Down

0 comments on commit 974f79c

Please sign in to comment.