Skip to content

Commit

Permalink
Add .TextJustify()
Browse files Browse the repository at this point in the history
  • Loading branch information
brminnick committed Nov 18, 2024
1 parent 66ac82a commit b23c3b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ namespace CommunityToolkit.Maui.Markup
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
{{textAlignmentClassMetadata.ClassAcessModifier}} static partial class TextAlignmentExtensions_{{textAlignmentClassMetadata.ClassName}}
{
/// <summary>
/// <see cref="ITextAlignment.HorizontalTextAlignment"/> = <see cref="TextAlignment.Justify"/>
/// </summary>
/// <param name="textAlignmentControl"></param>
/// <returns><typeparamref name="TAssignable"/> with added <see cref="TextAlignment.Justify"/></returns>
public static TAssignable TextJustify{{genericTypeParameters}}(this TAssignable textAlignmentControl)
where TAssignable : {{textAlignmentClassMetadata.Namespace}}.{{textAlignmentClassMetadata.ClassName}}{{genericArguments}}{{textAlignmentClassMetadata.GenericConstraints}}
{
ArgumentNullException.ThrowIfNull(textAlignmentControl);

if (textAlignmentControl is not ITextAlignment)
{
throw new ArgumentException($"Element must implement {nameof(ITextAlignment)}", nameof(textAlignmentControl));
}

textAlignmentControl.HorizontalTextAlignment = TextAlignment.Justify;
return textAlignmentControl;
}

/// <summary>
/// <see cref="ITextAlignment.HorizontalTextAlignment"/> = <see cref="TextAlignment.Start"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public void TextLeft()
public void TextRight()
=> TestPropertiesSet(l => l.TextRight(), (Label.HorizontalTextAlignmentProperty, TextAlignment.Start, TextAlignment.End));

[Test]
public void TextJustify()
=> TestPropertiesSet(l => l.TextJustify(), (Label.HorizontalTextAlignmentProperty, TextAlignment.Start, TextAlignment.Justify));

[Test]
public void SupportDerivedFromLabel() => Assert.That(new DerivedFromLabel().TextLeft().TextRight(), Is.InstanceOf<DerivedFromLabel>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public void TextLeft()
public void TextRight()
=> TestPropertiesSet(l => l.TextRight(), (Label.HorizontalTextAlignmentProperty, TextAlignment.End, TextAlignment.Start));

[Test]
public void TextJustify()
=> TestPropertiesSet(l => l.TextJustify(), (Label.HorizontalTextAlignmentProperty, TextAlignment.Start, TextAlignment.Justify));

[Test]
public void SupportDerivedFromLabel() => Assert.That(new DerivedFromLabel().TextLeft().TextRight(), Is.InstanceOf<DerivedFromLabel>());

Expand Down

0 comments on commit b23c3b8

Please sign in to comment.