-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Added a Flow Direction Property to action sheets and alert dialogs #11679
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review the option to use EffectiveFlowDirection to make the code more concise.
if (options.FlowDirection == FlowDirection.MatchParent) | ||
{ | ||
if (sender.FlowDirection == FlowDirection.RightToLeft) | ||
options.FlowDirection = FlowDirection.RightToLeft; | ||
else if (sender.FlowDirection == FlowDirection.LeftToRight) | ||
options.FlowDirection = FlowDirection.LeftToRight; | ||
else | ||
{ | ||
if (Device.FlowDirection == FlowDirection.RightToLeft) | ||
options.FlowDirection = FlowDirection.RightToLeft; | ||
else if (Device.FlowDirection == FlowDirection.LeftToRight) | ||
options.FlowDirection = FlowDirection.LeftToRight; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking the FlowDirection
values for the Page (and then the Device) here, I think you can just use the Page's EffectiveFlowDirection
- it should already be set to either RightToLeft
or LeftToRight
(depending on its FlowDirection
settings.
if (sender.FlowDirection == FlowDirection.LeftToRight) | ||
{ | ||
layoutDirection = LayoutDirection.Ltr; | ||
textDirection = TextDirection.Ltr; | ||
} | ||
else if (sender.FlowDirection == FlowDirection.RightToLeft) | ||
{ | ||
layoutDirection = LayoutDirection.Rtl; | ||
textDirection = TextDirection.Rtl; | ||
} | ||
else | ||
{ | ||
if (Device.FlowDirection == FlowDirection.LeftToRight) | ||
{ | ||
layoutDirection = LayoutDirection.Ltr; | ||
textDirection = TextDirection.Ltr; | ||
} | ||
else if (Device.FlowDirection == FlowDirection.RightToLeft) | ||
{ | ||
layoutDirection = LayoutDirection.Rtl; | ||
textDirection = TextDirection.Rtl; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing as the UWP implementation - I think you can just look at the Page's EffectiveFlowDirection
here instead of having to check for each possible setting of FlowDirection
.
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2448.xaml.cs
Outdated
Show resolved
Hide resolved
…amarin#11679) * added constructor actionsheet * added flow direction to action sheets on Android * added flow direction to alerts on Android * added Android alert dialog flow direction * UWP alert/actionsheet flow direction * add alert dialog flow direction * added flow direction to UWP alert and actionsheets * fixes xamarin#2448 * fixes xamarin#2448 * fixes xamarin#2448 * fixes xamarin#2448 * fixes xamarin#2448 * fixes xamarin#2448 * fixes xamarin#2448 * Fix rebase errors * - fix rebase Co-authored-by: E.Z. Hart <hartez@gmail.com> Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Description of Change
Added a Flow Direction Property to action sheets and alert dialogs. Also, changed the default flow direction of action sheets and alert dialogs to follow the page's effective flow direction.
Issues Resolved
API Changes
Added:
Platforms Affected
Behavioral/Visual Changes
The action sheets and alert dialogs may change depending on the flow direction of the parent page.
Before/After Screenshots
Before (no flow direction):
After (RTL flow direction):
Testing Procedure
Create an alert dialog and action sheet on Android and UWP and set the FlowDirection property to right-to-left and left-to-right to see if the alert dialog and actions sheet follows the flow direction properly. Also, can play around with changing the phone culture to right-to-left and left-to-right languages and see if the default flow direction of the alerts and action sheets follow the phone setting properly.
PR Checklist