Skip to content

Commit 3e72a26

Browse files
devanathan-vaithiyanathanPureWeen
authored andcommitted
[iOS] Fix FlyoutPage does not respond to changes in the FlyoutLayoutBehavior property (#28884)
* Fix added * fix updated * test added * test modified * null check added
1 parent 31d201c commit 3e72a26

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

src/Controls/src/Core/Compatibility/Handlers/FlyoutPage/iOS/PhoneFlyoutPageRenderer.cs

+22
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
366366
UpdateBackground();
367367
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.FlyoutPage.ApplyShadowProperty.PropertyName)
368368
UpdateApplyShadow(((FlyoutPage)Element).OnThisPlatform().GetApplyShadow());
369+
else if (e.PropertyName == Microsoft.Maui.Controls.FlyoutPage.FlyoutLayoutBehaviorProperty.PropertyName)
370+
UpdateFlyoutLayoutBehaviorChanges();
369371
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty.PropertyName ||
370372
e.PropertyName == PlatformConfiguration.iOSSpecific.Page.PrefersStatusBarHiddenProperty.PropertyName)
371373
UpdatePageSpecifics();
@@ -476,6 +478,26 @@ void LayoutChildren(bool animated)
476478
UpdateClickOffViewFrame();
477479
}
478480

481+
void UpdateFlyoutLayoutBehaviorChanges()
482+
{
483+
LayoutChildren(true);
484+
FlyoutPage flyoutPage = Element as FlyoutPage;
485+
if (flyoutPage == null)
486+
return;
487+
FlyoutLayoutBehavior flyoutBehavior = FlyoutPage.FlyoutLayoutBehavior;
488+
bool shouldPresent = FlyoutPageController.ShouldShowSplitMode;
489+
if (flyoutBehavior == FlyoutLayoutBehavior.Popover || flyoutBehavior == FlyoutLayoutBehavior.Default)
490+
{
491+
shouldPresent = false;
492+
}
493+
494+
if (shouldPresent != flyoutPage.IsPresented)
495+
{
496+
((IElementController)Element).SetValueFromRenderer(FlyoutPage.IsPresentedProperty, shouldPresent);
497+
UpdateLeftBarButton();
498+
}
499+
}
500+
479501
void PackContainers()
480502
{
481503
_detailController.View.BackgroundColor = new UIColor(1, 1, 1, 1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Collections.ObjectModel;
2+
using System.Collections.Specialized;
3+
using System.ComponentModel;
4+
5+
namespace Maui.Controls.Sample.Issues;
6+
7+
[Issue(IssueTracker.Github, 18158, "FlyoutPage does not respond to changes in the FlyoutLayoutBehavior property", PlatformAffected.iOS)]
8+
public class Issue18158 : TestFlyoutPage
9+
{
10+
Button _button;
11+
protected override void Init()
12+
{
13+
_button = new Button{ Text="Click", AutomationId = "Button"};
14+
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
15+
// Define the Flyout page
16+
Flyout = new ContentPage
17+
{
18+
Title = "Menu",
19+
20+
Content = new StackLayout
21+
{
22+
Children =
23+
{
24+
_button,
25+
}
26+
}
27+
};
28+
29+
_button.Clicked += (s,e) =>
30+
{
31+
if (this.FlyoutLayoutBehavior == FlyoutLayoutBehavior.Split)
32+
{
33+
this.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;
34+
}
35+
else
36+
{
37+
this.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
38+
}
39+
};
40+
41+
42+
// Define the Detail page
43+
Detail = new NavigationPage(new ContentPage
44+
{
45+
Title = "Detail Page",
46+
Content = new StackLayout
47+
{
48+
Children =
49+
{
50+
new Label { Text = "Welcome to the Detail Page!", AutomationId = "Label" },
51+
}
52+
}
53+
});
54+
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_IOS //FlyoutLayoutBehavior changes are not supported on Android and iOS
2+
using NUnit.Framework;
3+
using UITest.Appium;
4+
using UITest.Core;
5+
6+
namespace Microsoft.Maui.TestCases.Tests.Issues;
7+
8+
public class Issue18158 : _IssuesUITest
9+
{
10+
public Issue18158(TestDevice device)
11+
: base(device)
12+
{ }
13+
14+
public override string Issue => "FlyoutPage does not respond to changes in the FlyoutLayoutBehavior property";
15+
16+
[Test]
17+
[Category(UITestCategories.FlyoutPage)]
18+
public void VerifyFlyoutLayoutBehaviorChanges()
19+
{
20+
App.WaitForElement("Button");
21+
App.Tap("Button");
22+
App.WaitForElement("Label");
23+
App.WaitForNoElement("Button");
24+
}
25+
}
26+
27+
#endif

0 commit comments

Comments
 (0)