diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs index 62a627b2c233..a50886de1f60 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutRenderer.cs @@ -12,6 +12,7 @@ using AView = Android.Views.View; using Color = Microsoft.Maui.Graphics.Color; using LP = Android.Views.ViewGroup.LayoutParams; +using LD = Android.Views.LayoutDirection; using Paint = Android.Graphics.Paint; namespace Microsoft.Maui.Controls.Platform.Compatibility @@ -144,6 +145,7 @@ public ShellFlyoutRenderer(IShellContext shellContext, Context context) : base(c Shell.PropertyChanged += OnShellPropertyChanged; ShellController.AddAppearanceObserver(this, Shell); + UpdateFlowDirection(); this.DrawerClosed += OnDrawerClosed; this.DrawerSlide += OnDrawerSlide; @@ -273,6 +275,10 @@ protected virtual void OnShellPropertyChanged(object sender, PropertyChangedEven UpdateDrawerState(); } + else if(e.PropertyName == Shell.FlowDirectionProperty.PropertyName) + { + UpdateFlowDirection(); + } } void UpdateDrawerState() @@ -290,6 +296,11 @@ void UpdateDrawerState() } } + void UpdateFlowDirection() + { + LayoutDirection = _shellContext.Shell.FlowDirection.ToLayoutDirection(); + } + void OnDualScreenServiceScreenChanged(object sender, EventArgs e) { UpdateFlyoutSize(); diff --git a/src/Core/src/Platform/Android/FlowDirectionExtensions.cs b/src/Core/src/Platform/Android/FlowDirectionExtensions.cs index e62571d8975e..e61cc51459b3 100644 --- a/src/Core/src/Platform/Android/FlowDirectionExtensions.cs +++ b/src/Core/src/Platform/Android/FlowDirectionExtensions.cs @@ -20,6 +20,19 @@ internal static FlowDirection ToFlowDirection(this ALayoutDirection direction) } } + internal static ALayoutDirection ToLayoutDirection(this FlowDirection direction) + { + switch (direction) + { + case FlowDirection.LeftToRight: + return ALayoutDirection.Ltr; + case FlowDirection.RightToLeft: + return ALayoutDirection.Rtl; + default: + return ALayoutDirection.Inherit; + } + } + internal static ATextDirection ToTextDirection(this ALayoutDirection direction) { switch (direction)