Skip to content

Commit

Permalink
feat: Initialize property respecting platform spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Oct 5, 2020
1 parent 40fe514 commit 28640cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public bool PreventKeyboardDisplayOnProgrammaticFocus
typeof(TextBox),
new FrameworkPropertyMetadata(false));


partial void InitializePropertiesPartial()
{
OnVerticalContentAlignmentChanged(VerticalAlignment.Center, VerticalContentAlignment);
}

private protected override void OnUnloaded()
{
base.OnUnloaded();
Expand Down
6 changes: 3 additions & 3 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET461 || NETSTANDARD2_0 || __MACOS__
#if NET461 || NETSTANDARD2_0 || __MACOS__
#pragma warning disable CS0067, CS649
#endif

Expand Down Expand Up @@ -97,7 +97,7 @@ private void InitializeProperties()
OnTextAlignmentChanged(CreateInitialValueChangerEventArgs(TextAlignmentProperty, TextAlignmentProperty.GetMetadata(GetType()).DefaultValue, TextAlignment));
OnTextWrappingChanged(CreateInitialValueChangerEventArgs(TextWrappingProperty, TextWrappingProperty.GetMetadata(GetType()).DefaultValue, TextWrapping));
OnFocusStateChanged((FocusState)FocusStateProperty.GetMetadata(GetType()).DefaultValue, FocusState, initial: true);
OnVerticalContentAlignmentChanged(VerticalAlignment.Center, VerticalContentAlignment);
OnVerticalContentAlignmentChanged(VerticalAlignment.Top, VerticalContentAlignment);

var buttonRef = _deleteButton?.GetTarget();

Expand Down Expand Up @@ -726,7 +726,7 @@ protected override void OnVerticalContentAlignmentChanged(VerticalAlignment oldV
if (_placeHolder != null)
{
_placeHolder.VerticalAlignment = newVerticalContentAlignment;
}
}
}
}
}
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public partial class TextBox
OnTextAlignmentChanged(CreateInitialValueChangerEventArgs(TextAlignmentProperty, null, TextAlignment));
OnReturnKeyTypeChanged(ReturnKeyType);
OnKeyboardAppearanceChanged(KeyboardAppearance);
OnVerticalContentAlignmentChanged(GetDefaultVerticalContentAlignment(), VerticalContentAlignment);
}

partial void OnFocusStateChangedPartial(FocusState focusState)
Expand Down Expand Up @@ -324,5 +325,10 @@ private void OnKeyboardAppearanceChanged(UIKeyboardAppearance newValue)
}

#endregion

private VerticalAlignment GetDefaultVerticalContentAlignment() =>
AcceptsReturn || TextWrapping != TextWrapping.NoWrap
? VerticalAlignment.Top
: VerticalAlignment.Center;
}
}
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected TextBox(bool isPassword)
partial void InitializePropertiesPartial()
{
OnTextAlignmentChanged(CreateInitialValueChangerEventArgs(TextAlignmentProperty, null, TextAlignment));
OnVerticalContentAlignmentChanged(VerticalAlignment.Top, VerticalContentAlignment);
}

partial void OnFocusStateChangedPartial(FocusState focusState)
Expand Down Expand Up @@ -232,6 +233,5 @@ protected void SetSecureTextEntry(bool isSecure)

_isSecured = isSecure;
}

}
}

0 comments on commit 28640cc

Please sign in to comment.