Skip to content

Commit

Permalink
[iOS] Text alignment in editor - improvements (#24859)
Browse files Browse the repository at this point in the history
* [iOS] Text alignment in editor - improvements

* Update Issue24583.cs

* Try old way but use content height

* less noise

* Added the first batch of snapshots

* add more screenshots

---------

Co-authored-by: tj-devel709 <tj.devel709@gmail.com>
  • Loading branch information
2 people authored and rmarinho committed Oct 16, 2024
1 parent bdbb259 commit e14bc5c
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 3 deletions.
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

0 comments on commit e14bc5c

Please sign in to comment.