Skip to content

Commit

Permalink
Merge pull request #140 from enisn/2.0-inputfield-spacing
Browse files Browse the repository at this point in the history
Made inputfield spacings fixed for all
  • Loading branch information
enisn authored Nov 25, 2022
2 parents 945d977 + 9c7e9a3 commit 1e5eab4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
31 changes: 18 additions & 13 deletions src/UraniumUI.Material/Controls/InputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public virtual View Content
VerticalOptions = LayoutOptions.Center,
WidthRequest = 20,
HeightRequest = 20,
Margin = new Thickness(10,0),
Margin = new Thickness(10, 0, 0, 0),
};
});

Expand Down Expand Up @@ -100,6 +100,7 @@ public InputField()

InitializeValidation();
}

~InputField()
{
ReleaseEvents();
Expand All @@ -112,18 +113,18 @@ protected override async void OnSizeAllocated(double width, double height)
InitializeBorder();
}

// TODO: Remove this member hiding after android unfocus fixed.
public new void Unfocus()
{
base.Unfocus();
// TODO: Remove this member hiding after android unfocus fixed.
public new void Unfocus()
{
base.Unfocus();
#if ANDROID
var view = Content.Handler.PlatformView as Android.Views.View;

view?.ClearFocus();
#endif
}
}

private void InitializeBorder()
private void InitializeBorder()
{
var perimeter = (this.Width + this.Height) * 2;
var calculatedFirstDash = FirstDash + CornerRadius.Clamp(FirstDash, double.MaxValue);
Expand Down Expand Up @@ -212,13 +213,13 @@ protected virtual void RegisterForEvents()
}
}

protected virtual void ReleaseEvents()
{
Content.Focused -= Content_Focused;
Content.Unfocused -= Content_Unfocused;
}
protected virtual void ReleaseEvents()
{
Content.Focused -= Content_Focused;
Content.Unfocused -= Content_Unfocused;
}

private void Content_Unfocused(object sender, FocusEventArgs e)
private void Content_Unfocused(object sender, FocusEventArgs e)
{
border.Stroke = BorderColor;
labelTitle.TextColor = TitleColor;
Expand Down Expand Up @@ -256,6 +257,10 @@ protected virtual void OnIconChanged()
{
rootGrid.Add(imageIcon.Value, column: 0);
}

var leftMargin = Icon != null ? 5 : 10;
this.Content.Margin = new Thickness(leftMargin, 0, 0, 0);

}
protected virtual void OnCornerRadiusChanged()
{
Expand Down
4 changes: 2 additions & 2 deletions src/UraniumUI.Material/Controls/PickerField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class PickerField : InputField
public override View Content { get; set; } = new PickerView
{
VerticalOptions = LayoutOptions.Center,
Margin = new Thickness(10, 0),
Margin = new Thickness(15,0),
#if WINDOWS
Opacity = 0,
#endif
Expand All @@ -27,7 +27,7 @@ public class PickerField : InputField
InputTransparent = true,
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center,
Margin = new Thickness(10,0),
Margin = new Thickness(15,0),
TextColor = ColorResource.GetColor("OnBackground", "OnBackgroundDark", Colors.Gray)
};
#endif
Expand Down
6 changes: 1 addition & 5 deletions src/UraniumUI.Material/Controls/TextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ public partial class TextField : InputField

public override View Content { get; set; } = new EntryView
{
#if WINDOWS
Margin = new Thickness(0, 1),
#else
Margin = new Thickness(5, 1),
#endif
Margin = new Thickness(10, 0),
BackgroundColor = Colors.Transparent,
VerticalOptions = LayoutOptions.Center
};
Expand Down

0 comments on commit 1e5eab4

Please sign in to comment.