Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue32316.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 32316, "RTL mode: Padding for the label is not mirroring properly", PlatformAffected.iOS | PlatformAffected.Android)]
public class Issue32316 : ContentPage
{
private readonly HorizontalStackLayout _row1;
private readonly HorizontalStackLayout _row2;

public Issue32316()
{
var toggleButton = new Button
{
Text = "Toggle FlowDirection",
AutomationId = "ToggleFlowDirectionButton",
HorizontalOptions = LayoutOptions.Center
};

toggleButton.Clicked += OnToggleClicked;

_row1 = BuildRow();
_row2 = BuildRow();

Content = new VerticalStackLayout
{
Spacing = 12,
Padding = 12,
Children =
{
toggleButton,
_row1,
_row2,
}
};
}

private void OnToggleClicked(object sender, EventArgs e)
{
_row2.FlowDirection = FlowDirection.RightToLeft;
}

private static HorizontalStackLayout BuildRow()
{
var stackLayout = new HorizontalStackLayout
{
HorizontalOptions = LayoutOptions.Center,
};

stackLayout.Children.Add(CreateIconBorder("✂"));
stackLayout.Children.Add(CreateIconBorder("✖"));

return stackLayout;
}

private static View CreateIconBorder(string icon)
{
return new Border
{
BackgroundColor = Colors.LightGray,
Stroke = Colors.Gray,
StrokeThickness = 1,
WidthRequest = 60,
HeightRequest = 40,
InputTransparent = true,
Content = CreateIconView(icon)
};
}

private static View CreateIconView(string icon)
{
var iconLabel = new Label
{
Text = icon,
FontSize = 16,
FontAutoScalingEnabled = false,
Padding = new Thickness(10, 0, 0, 0),
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center,
VerticalTextAlignment = TextAlignment.Center,
BackgroundColor = Colors.Transparent,
HeightRequest = 40
};

var dropDownLabel = new Label
{
Text = "V",
FontSize = 16,
Margin = new Thickness(0, 0, 10, 0),
FontFamily = "MauiMaterialAssets",
VerticalTextAlignment = TextAlignment.Center,
VerticalOptions = LayoutOptions.Center,
BackgroundColor = Colors.Transparent
};

return new HorizontalStackLayout
{
HorizontalOptions = LayoutOptions.Center,
HeightRequest = 40,
Children = { iconLabel, dropDownLabel }
};
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue32316 : _IssuesUITest
{

public Issue32316(TestDevice testDevice) : base(testDevice)
{
}

public override string Issue => "RTL mode: Padding for the label is not mirroring properly";

[Test]
[Category(UITestCategories.Label)]
public void RTLModePaddingShouldWork()
{
App.WaitForElement("ToggleFlowDirectionButton");
App.Tap("ToggleFlowDirectionButton");
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending snapshots, running a build.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snapshots are available in the latest build.
image
Could you commit the images?

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Core/src/Platform/Android/TextViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void UpdateVerticalTextAlignment(this TextView textView, ITextAlig

public static void UpdatePadding(this TextView textView, ILabel label)
{
textView.SetPadding(
textView.SetPaddingRelative(
(int)textView.ToPixels(label.Padding.Left),
(int)textView.ToPixels(label.Padding.Top),
(int)textView.ToPixels(label.Padding.Right),
Expand Down
15 changes: 14 additions & 1 deletion src/Core/src/Platform/iOS/MauiLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ public MauiLabel()

public override void DrawText(RectangleF rect)
{
rect = TextInsets.InsetRect(rect);
var insets = TextInsets;

// Respect RTL (flip left/right insets)
if (EffectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirection.RightToLeft)
{
insets = new UIEdgeInsets(
insets.Top,
insets.Right,
insets.Bottom,
insets.Left);
}

rect = insets.InsetRect(rect);


if (_verticalAlignment != UIControlContentVerticalAlignment.Center
&& _verticalAlignment != UIControlContentVerticalAlignment.Fill)
Expand Down
Loading