Skip to content

Commit ddf0d1f

Browse files
kubaflotj-devel709
authored andcommitted
[iOS] Text alignment in editor - improvements (#24859)
* [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 <[email protected]>
1 parent 769c407 commit ddf0d1f

File tree

10 files changed

+74
-3
lines changed

10 files changed

+74
-3
lines changed
35.2 KB
Loading
52.2 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[XamlCompilation(XamlCompilationOptions.Compile)]
4+
[Issue(IssueTracker.Github, 24583, "Text in the Editor control disappeared when reducing the Scale", PlatformAffected.iOS)]
5+
6+
public partial class Issue24583 : ContentPage
7+
{
8+
public Issue24583()
9+
{
10+
InitializeComponent();
11+
}
12+
13+
private void Button_Clicked(object sender, EventArgs e)
14+
{
15+
editor1.Scale = editor2.Scale = editor3.Scale = 0.5;
16+
}
17+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="Maui.Controls.Sample.Issues.Issue24583">
5+
<StackLayout>
6+
<Editor x:Name="editor1"
7+
Text="1 2 3 4 5 6 7 8 9"
8+
FontSize="50"
9+
HeightRequest="200"
10+
BackgroundColor="Red"
11+
HorizontalOptions="Fill"
12+
WidthRequest="300"/>
13+
<Editor x:Name="editor2"
14+
Text="1 2 3 4 5 6 7 8 9"
15+
FontSize="50"
16+
HeightRequest="200"
17+
VerticalTextAlignment="Center"
18+
BackgroundColor="Green"
19+
HorizontalOptions="Fill"
20+
WidthRequest="300"/>
21+
<Editor x:Name="editor3"
22+
Text="1 2 3 4 5 6 7 8 9"
23+
FontSize="50"
24+
HeightRequest="200"
25+
VerticalTextAlignment="End"
26+
BackgroundColor="Blue"
27+
HorizontalOptions="Fill"
28+
WidthRequest="300"/>
29+
<Button Clicked="Button_Clicked"
30+
AutomationId="button"/>
31+
</StackLayout>
32+
</ContentPage>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using NUnit.Framework;
2+
using UITest.Appium;
3+
using UITest.Core;
4+
5+
namespace Microsoft.Maui.TestCases.Tests.Issues;
6+
public class Issue24583 : _IssuesUITest
7+
{
8+
public override string Issue => "Text in the Editor control disappeared when reducing the Scale";
9+
10+
public Issue24583(TestDevice testDevice) : base(testDevice)
11+
{
12+
}
13+
14+
[Test]
15+
[Category(UITestCategories.Editor)]
16+
public void TextInEditorShouldBeCorrectlyPositionedAfterResizing()
17+
{
18+
App.WaitForElement("button");
19+
VerifyScreenshot("TextsInEditorsBeforeScaling");
20+
App.Click("button");
21+
VerifyScreenshot("TextsInEditorsAfterScaling");
22+
}
23+
}
10.8 KB
Loading
16.8 KB
Loading
37.9 KB
Loading
68.4 KB
Loading

src/Core/src/Platform/iOS/MauiTextView.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,8 @@ void OnChanged(object? sender, EventArgs e)
162162

163163
void ShouldCenterVertically()
164164
{
165-
var fittingSize = new CGSize(Bounds.Width, NFloat.MaxValue);
166-
var sizeThatFits = SizeThatFits(fittingSize);
167-
var availableSpace = Bounds.Height - sizeThatFits.Height * ZoomScale;
165+
var contentHeight = ContentSize.Height;
166+
var availableSpace = Bounds.Height - contentHeight * ZoomScale;
168167
if (availableSpace <= 0)
169168
return;
170169
ContentOffset = VerticalTextAlignment switch

0 commit comments

Comments
 (0)