Skip to content
Open
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
16 changes: 15 additions & 1 deletion src/Controls/src/Core/FlyoutPage/FlyoutPage.Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public partial class FlyoutPage
#if IOS
FlyoutViewHandler.Mapper.ReplaceMapping<IFlyoutView, IFlyoutViewHandler>(nameof(PlatformConfiguration.iOSSpecific.Page.PrefersHomeIndicatorAutoHiddenProperty), MapPrefersHomeIndicatorAutoHiddenProperty);
FlyoutViewHandler.Mapper.ReplaceMapping<IFlyoutView, IFlyoutViewHandler>(nameof(PlatformConfiguration.iOSSpecific.Page.PrefersStatusBarHiddenProperty), MapPrefersPrefersStatusBarHiddenProperty);
#endif
#if WINDOWS
FlyoutViewHandler.Mapper.ReplaceMapping<IFlyoutView, IFlyoutViewHandler>(nameof(PlatformConfiguration.WindowsSpecific.FlyoutPage.CollapsedPaneWidthProperty), MapCollapsedPaneWidth);
#endif
}

Expand All @@ -31,5 +34,16 @@ internal static void MapPrefersPrefersStatusBarHiddenProperty(IFlyoutViewHandler
handler.UpdateValue(nameof(PlatformConfiguration.iOSSpecific.Page.PrefersStatusBarHiddenProperty));
}
#endif

#if WINDOWS
internal static void MapCollapsedPaneWidth(IFlyoutViewHandler handler, IFlyoutView view)
{
if (view is BindableObject bindable && handler.PlatformView is Microsoft.Maui.Platform.RootNavigationView navigationView)
{
var collapsedPaneWidth = PlatformConfiguration.WindowsSpecific.FlyoutPage.GetCollapsedPaneWidth(bindable);
navigationView.CompactPaneLength = collapsedPaneWidth;
}
}
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static IPlatformElementConfiguration<Windows, FormsElement> UsePartialCol
/// <summary>Bindable property for attached property <c>CollapsedPaneWidth</c>.</summary>
public static readonly BindableProperty CollapsedPaneWidthProperty =
BindableProperty.CreateAttached("CollapsedPaneWidth", typeof(double),
typeof(FlyoutPage), 48d, validateValue: (bindable, value) => (double)value >= 0);
typeof(FlyoutPage), 48d, validateValue: (bindable, value) => (double)value >= 0, propertyChanged : OnCollapsedPaneWidthChanged);

/// <summary>Gets the width of the collapsed flyout pane on Windows.</summary>
/// <param name="element">The element to get the collapsed pane width from.</param>
Expand All @@ -77,6 +77,14 @@ public static double GetCollapsedPaneWidth(BindableObject element)
return (double)element.GetValue(CollapsedPaneWidthProperty);
}

static void OnCollapsedPaneWidthChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is Microsoft.Maui.Controls.FlyoutPage flyoutPage && flyoutPage.Handler is not null)
{
flyoutPage.Handler.UpdateValue(nameof(CollapsedPaneWidthProperty));
}
}

/// <summary>Sets the width of the collapsed flyout pane on Windows.</summary>
/// <param name="element">The element to set the collapsed pane width on.</param>
/// <param name="collapsedPaneWidth">The collapsed pane width in device-independent units.</param>
Expand Down
76 changes: 76 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue33785.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Microsoft.Maui.Controls.PlatformConfiguration;
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 33785, "[Windows] FlyoutPage CollapsedPaneWidth Not Working", PlatformAffected.UWP)]
public class Issue33785 : TestFlyoutPage
{
Microsoft.Maui.Controls.Label _label;
protected override void Init()
{
this.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().SetCollapseStyle(CollapseStyle.Partial);
this.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().CollapsedPaneWidth(50);

// Set the flyout page properties
FlyoutLayoutBehavior = FlyoutLayoutBehavior.Popover;

// Create the flyout content
var flyoutPage = new ContentPage
{
Title = "Master",
BackgroundColor = Colors.Blue
};

var page1Button = new Button
{
Text = "Change",
AutomationId = "FlyoutItem",
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center
};
page1Button.Clicked += (s, e) =>
{
this.On<Microsoft.Maui.Controls.PlatformConfiguration.Windows>().CollapsedPaneWidth(100);
_label.Text = "CollapsedPaneWidth set to 100";
};

flyoutPage.Content = new VerticalStackLayout
{
Children = { page1Button }
};

// Create the detail content
var detailPage = new ContentPage
{
Title = "Detail",
BackgroundColor = Colors.LightYellow
};

_label = new Microsoft.Maui.Controls.Label
{
Text = "Test for CollapsedPaneWidth",
AutomationId = "CollapsedPaneLabel",
HorizontalOptions = LayoutOptions.Center,
HorizontalTextAlignment = TextAlignment.Center,
};

detailPage.Content = new VerticalStackLayout
{
Children = {
new Microsoft.Maui.Controls.Label
{
Text = "Welcome to .NET MAUI!",
TextColor = Colors.Black,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
},
_label
}
};

// Set the flyout and detail pages
Flyout = flyoutPage;
Detail = detailPage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if WINDOWS //CollapsedPaneWidth is Windows Specific API
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;
public class Issue33785 : _IssuesUITest
{
public Issue33785(TestDevice device) : base(device) { }

public override string Issue => "[Windows] FlyoutPage CollapsedPaneWidth Not Working";
[Test]
[Category(UITestCategories.FlyoutPage)]
public void VerifyFlyoutPageCollapsedPaneWidth()
{
App.WaitForElement("CollapsedPaneLabel");
App.TapFlyoutPageIcon();
App.Tap("FlyoutItem");
App.TapFlyoutPageIcon();
VerifyScreenshot();
}
}
#endif
Loading