Skip to content

Commit 808b51b

Browse files
BagavathiPerumalrmarinho
authored andcommitted
[iOS] Fix for Flyout title is not broken over multiple lines when you rotate your screen. (#29171)
* fix-15154-Added proper Auto Layout constraints to ensure content wraps instead of truncating in landscape mode. * fix-15154-Prepared the testcase and snapshot added for android and iOS. * fix-15154-Modified the test condition. * fix-15154-Modified the code to align the edges of ContentView with the edges of platformView. * fix-15154-Adjusted inset constraints to respect view margins in FlyoutItem and updated Android snapshot. * fix-15154-Replaced individual .Active=true calls with batch NSLayoutConstraint.ActivateConstraints() for better performance with Shell flyout margins.
1 parent 9dbdf1a commit 808b51b

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed

src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/UIContainerCell.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ internal UIContainerCell(string cellId, View view, Shell shell, object context)
3131
var platformView = view.ToPlatform();
3232
ContentView.AddSubview(platformView);
3333
platformView.AccessibilityTraits |= UIAccessibilityTrait.Button;
34+
platformView.TranslatesAutoresizingMaskIntoConstraints = false;
35+
36+
var margin = view.Margin;
37+
var constraints = new NSLayoutConstraint[]
38+
{
39+
platformView.LeadingAnchor.ConstraintEqualTo(ContentView.LeadingAnchor, (nfloat)margin.Left),
40+
platformView.TrailingAnchor.ConstraintEqualTo(ContentView.TrailingAnchor, (nfloat)(-margin.Right)),
41+
platformView.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor, (nfloat)margin.Top),
42+
platformView.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor, (nfloat)(-margin.Bottom))
43+
};
44+
NSLayoutConstraint.ActivateConstraints(constraints);
3445

3546
_renderer.PlatformView.ClipsToBounds = true;
3647
ContentView.ClipsToBounds = true;
122 KB
Loading
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
namespace Maui.Controls.Sample.Issues;
2+
3+
[Issue(IssueTracker.Github, 15154, "iOS Flyout title is not broken over multiple lines when you rotate your screen", PlatformAffected.iOS)]
4+
public class Issue15154 : Shell
5+
{
6+
public Issue15154()
7+
{
8+
this.Items.Add(new ShellContent
9+
{
10+
Title = "EmptyView Template with behavior with height",
11+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
12+
});
13+
14+
this.Items.Add(new ShellContent
15+
{
16+
Title = "EmptyView Template Grid",
17+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
18+
});
19+
20+
this.Items.Add(new ShellContent
21+
{
22+
Title = "EmptyView Template Grid with behavior with height",
23+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
24+
});
25+
26+
this.Items.Add(new ShellContent
27+
{
28+
Title = "EmptyView Template Grid with behavior without height",
29+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
30+
});
31+
32+
this.Items.Add(new ShellContent
33+
{
34+
Title = "EmptyView Text ScrollView",
35+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
36+
});
37+
38+
this.Items.Add(new ShellContent
39+
{
40+
Title = "EmptyView Template ScrollView",
41+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
42+
});
43+
44+
this.Items.Add(new ShellContent
45+
{
46+
Title = "EmptyView Text ScrollView with behavior with height",
47+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
48+
});
49+
50+
this.Items.Add(new ShellContent
51+
{
52+
Title = "EmptyView Text ScrollView without behavior with height",
53+
ContentTemplate = new DataTemplate(typeof(Issue15154_MainPage))
54+
});
55+
}
56+
57+
public class Issue15154_MainPage : ContentPage
58+
{
59+
public Issue15154_MainPage()
60+
{
61+
var OpenFlyoutButton = new Button
62+
{
63+
Text = "Open Flyout",
64+
AutomationId = "OpenFlyoutButton"
65+
};
66+
67+
OpenFlyoutButton.Clicked += (sender, args) => Shell.Current.FlyoutIsPresented = true;
68+
Content = new StackLayout()
69+
{
70+
Children = { OpenFlyoutButton }
71+
};
72+
}
73+
}
74+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //The test fails on Windows and MacCatalyst because the SetOrientation method, which is intended to change the device orientation, is only supported on mobile platforms iOS and Android.
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues;
7+
8+
public class Issue15154 : _IssuesUITest
9+
{
10+
public Issue15154(TestDevice testDevice) : base(testDevice)
11+
{
12+
}
13+
14+
public override string Issue => "iOS Flyout title is not broken over multiple lines when you rotate your screen";
15+
16+
[Test]
17+
[Category(UITestCategories.Shell)]
18+
public void ShouldFlyoutTextWrapsInLandscape()
19+
{
20+
App.WaitForElement("OpenFlyoutButton");
21+
App.Tap("OpenFlyoutButton");
22+
App.SetOrientationLandscape();
23+
VerifyScreenshot();
24+
}
25+
}
26+
#endif
110 KB
Loading

0 commit comments

Comments
 (0)