Skip to content

Commit

Permalink
Added default layout padding to the style fixes #124
Browse files Browse the repository at this point in the history
  • Loading branch information
Clancey committed Jan 14, 2022
1 parent f4bb8db commit 33d4725
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Comet/Helpers/LayoutExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ public static T Padding<T>(this T view, Thickness padding, bool cascades = false
public static Thickness GetPadding(this View view, Thickness? defaultValue = null)
{
var margin = view.GetEnvironment<Thickness?>(view, EnvironmentKeys.Layout.Padding);
return margin ?? defaultValue ?? Thickness.Zero;
margin ??= defaultValue;
if (margin == null && view is ILayout)
margin = view.GetEnvironment<Thickness>(nameof(Styles.Style.LayoutPadding));
return margin ?? Thickness.Zero;
}


Expand Down
4 changes: 4 additions & 0 deletions src/Comet/Styles/Style.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class Style

public LayoutAlignment HorizontalAlignment { get; set; } = System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? LayoutAlignment.End : LayoutAlignment.Start;

public Thickness LayoutPadding { get; set; } = new Thickness(6);

public TextStyle Label { get; set; } = new TextStyle
{
StyleId = nameof(Label)
Expand Down Expand Up @@ -112,6 +114,8 @@ public virtual void Apply(ContextualObject view = null)
else
view.SetEnvironment(nameof(ITextAlignment.HorizontalTextAlignment), HorizontalAlignment);

SetEnvironmentValue(view, "", nameof(LayoutPadding), LayoutPadding);

ApplyButton(view);
ApplyNavbarStyles(view);
ApplyTextStyle(view, Label);
Expand Down

0 comments on commit 33d4725

Please sign in to comment.