Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Text alignment in editor - improvements (#24859) #25158

Merged
Merged
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.
17 changes: 17 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24583.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 24583, "Text in the Editor control disappeared when reducing the Scale", PlatformAffected.iOS)]

public partial class Issue24583 : ContentPage
{
public Issue24583()
{
InitializeComponent();
}

private void Button_Clicked(object sender, EventArgs e)
{
editor1.Scale = editor2.Scale = editor3.Scale = 0.5;
}
}
32 changes: 32 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue24583.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue24583">
<StackLayout>
<Editor x:Name="editor1"
Text="1 2 3 4 5 6 7 8 9"
FontSize="50"
HeightRequest="200"
BackgroundColor="Red"
HorizontalOptions="Fill"
WidthRequest="300"/>
<Editor x:Name="editor2"
Text="1 2 3 4 5 6 7 8 9"
FontSize="50"
HeightRequest="200"
VerticalTextAlignment="Center"
BackgroundColor="Green"
HorizontalOptions="Fill"
WidthRequest="300"/>
<Editor x:Name="editor3"
Text="1 2 3 4 5 6 7 8 9"
FontSize="50"
HeightRequest="200"
VerticalTextAlignment="End"
BackgroundColor="Blue"
HorizontalOptions="Fill"
WidthRequest="300"/>
<Button Clicked="Button_Clicked"
AutomationId="button"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue24583 : _IssuesUITest
{
public override string Issue => "Text in the Editor control disappeared when reducing the Scale";

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

[Test]
[Category(UITestCategories.Editor)]
public void TextInEditorShouldBeCorrectlyPositionedAfterResizing()
{
App.WaitForElement("button");
VerifyScreenshot("TextsInEditorsBeforeScaling");
App.Click("button");
VerifyScreenshot("TextsInEditorsAfterScaling");
}
}
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.
5 changes: 2 additions & 3 deletions src/Core/src/Platform/iOS/MauiTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ void OnChanged(object? sender, EventArgs e)

void ShouldCenterVertically()
{
var fittingSize = new CGSize(Bounds.Width, NFloat.MaxValue);
var sizeThatFits = SizeThatFits(fittingSize);
var availableSpace = Bounds.Height - sizeThatFits.Height * ZoomScale;
var contentHeight = ContentSize.Height;
var availableSpace = Bounds.Height - contentHeight * ZoomScale;
if (availableSpace <= 0)
return;
ContentOffset = VerticalTextAlignment switch
Expand Down