Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/Core/src/Handlers/Picker/PickerHandler.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void OnClick(object? sender, EventArgs e)
if (_dialog == null)
return;

_dialog.UpdateFlowDirection(PlatformView);

_dialog.SetCanceledOnTouchOutside(true);

_dialog.DismissEvent += (sender, args) =>
Expand Down
13 changes: 13 additions & 0 deletions src/Core/src/Platform/Android/FlowDirectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,18 @@ internal static FlowDirection ToFlowDirection(this ALayoutDirection direction)
return FlowDirection.MatchParent;
}
}

internal static ATextDirection ToTextDirection(this ALayoutDirection direction)
{
switch (direction)
{
case ALayoutDirection.Ltr:
return ATextDirection.Ltr;
case ALayoutDirection.Rtl:
return ATextDirection.Rtl;
default:
return ATextDirection.Inherit;
}
}
}
}
22 changes: 21 additions & 1 deletion src/Core/src/Platform/Android/PickerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Android.Content.Res;
using Android.App;
using Android.Content.Res;

namespace Microsoft.Maui.Platform
{
Expand Down Expand Up @@ -45,5 +46,24 @@ internal static void UpdatePicker(this MauiPicker platformPicker, IPicker picker
else
platformPicker.Text = picker.GetItem(picker.SelectedIndex);
}

internal static void UpdateFlowDirection(this AlertDialog alertDialog, MauiPicker platformPicker)
{
var platformLayoutDirection = platformPicker.LayoutDirection;

// Propagate the MauiPicker LayoutDirection to the AlertDialog
var dv = alertDialog.Window?.DecorView;

if (dv is not null)
dv.LayoutDirection = platformLayoutDirection;

var lv = alertDialog?.ListView;

if (lv is not null)
{
lv.LayoutDirection = platformLayoutDirection;
lv.TextDirection = platformLayoutDirection.ToTextDirection();
}
}
}
}