diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateDatePickerFlowDirection.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateDatePickerFlowDirection.png new file mode 100644 index 000000000000..42e0d75e0b4f Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ValidateDatePickerFlowDirection.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30065.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue30065.cs new file mode 100644 index 000000000000..b53f27e9e3ad --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30065.cs @@ -0,0 +1,48 @@ +namespace Controls.TestCases.HostApp.Issues; + +[Issue(IssueTracker.Github, 30065, "DatePicker Ignores FlowDirection When Set to RightToLeft or MatchParent", PlatformAffected.iOS)] +public class Issue30065 : ContentPage +{ + public Issue30065() + { + DatePicker rtlDatePicker = new DatePicker + { + Date = new DateTime(2002, 5, 14), + WidthRequest = 300, + FlowDirection = FlowDirection.RightToLeft, + }; + + DatePicker ltrDatePicker = new DatePicker + { + Date = new DateTime(2002, 5, 14), + WidthRequest = 300, + FlowDirection = FlowDirection.LeftToRight, + }; + + Button toggleButton = new Button + { + AutomationId = "ToggleFlowDirectionBtn", + Text = "Toggle FlowDirection", + }; + + toggleButton.Clicked += (s, e) => + { + rtlDatePicker.FlowDirection = FlowDirection.LeftToRight; + ltrDatePicker.FlowDirection = FlowDirection.RightToLeft; + }; + + VerticalStackLayout verticalStackLayout = new VerticalStackLayout + { + Padding = new Thickness(20), + VerticalOptions = LayoutOptions.Center, + Children = + { + rtlDatePicker, + ltrDatePicker, + toggleButton + } + }; + + Content = verticalStackLayout; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30065.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30065.cs new file mode 100644 index 000000000000..9562e31089ae --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30065.cs @@ -0,0 +1,25 @@ +#if TEST_FAILS_ON_CATALYST // Issue Link - https://github.com/dotnet/maui/issues/30163 +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue30065 : _IssuesUITest +{ + public Issue30065(TestDevice device) : base(device) + { + } + + public override string Issue => "DatePicker Ignores FlowDirection When Set to RightToLeft or MatchParent"; + + [Test] + [Category(UITestCategories.DatePicker)] + public void ValidateDatePickerFlowDirection() + { + App.WaitForElement("ToggleFlowDirectionBtn"); + App.Tap("ToggleFlowDirectionBtn"); + VerifyScreenshot(); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateDatePickerFlowDirection.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateDatePickerFlowDirection.png new file mode 100644 index 000000000000..f1c3dfcf67c1 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/ValidateDatePickerFlowDirection.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateDatePickerFlowDirection.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateDatePickerFlowDirection.png new file mode 100644 index 000000000000..ac8055014f16 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ValidateDatePickerFlowDirection.png differ diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs index 5a5e86df426e..ddcd1580f373 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.MacCatalyst.cs @@ -70,7 +70,7 @@ public static partial void MapTextColor(IDatePickerHandler handler, IDatePicker } - public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker) + public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker) { } diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.cs index ba750f45223d..873a219eb90e 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.cs @@ -73,7 +73,7 @@ public DatePickerHandler(IPropertyMapper? mapper, CommandMapper? commandMapper) /// /// The associated handler. /// The associated instance. - public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker); + public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker); #endif /// diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs index 8342976a839d..5f2ca547ddb7 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.iOS.cs @@ -80,7 +80,7 @@ public static partial void MapTextColor(IDatePickerHandler handler, IDatePicker handler.PlatformView?.UpdateTextColor(datePicker); } - public static partial void MapFlowDirection(DatePickerHandler handler, IDatePicker datePicker) + public static partial void MapFlowDirection(IDatePickerHandler handler, IDatePicker datePicker) { handler.PlatformView?.UpdateFlowDirection(datePicker); handler.PlatformView?.UpdateTextAlignment(datePicker); diff --git a/src/Core/src/Platform/iOS/DatePickerExtensions.cs b/src/Core/src/Platform/iOS/DatePickerExtensions.cs index 871a749e9bb4..647bf99f8181 100644 --- a/src/Core/src/Platform/iOS/DatePickerExtensions.cs +++ b/src/Core/src/Platform/iOS/DatePickerExtensions.cs @@ -132,7 +132,12 @@ public static void UpdateMaximumDate(this UIDatePicker platformDatePicker, IDate public static void UpdateTextAlignment(this MauiDatePicker nativeDatePicker, IDatePicker datePicker) { - // TODO: Update TextAlignment based on the EffectiveFlowDirection property. + var alignment = nativeDatePicker.EffectiveUserInterfaceLayoutDirection == + UIUserInterfaceLayoutDirection.RightToLeft + ? UITextAlignment.Right + : UITextAlignment.Left; + + nativeDatePicker.TextAlignment = alignment; } } } \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt index bdd4130088cf..8b885ac1b256 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt @@ -2466,7 +2466,6 @@ static Microsoft.Maui.Handlers.ContentViewHandler.Mapper -> Microsoft.Maui.IProp static Microsoft.Maui.Handlers.DatePickerHandler.CommandMapper -> Microsoft.Maui.CommandMapper! static Microsoft.Maui.Handlers.DatePickerHandler.MapCharacterSpacing(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void -static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapFont(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapFormat(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapMaximumDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 7869f46fee56..0d6b14c45612 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -157,3 +157,5 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.$() -> Microsoft.Maui.SwipeV virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type! virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool +*REMOVED*static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void +static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt index 6127e1547bfc..8f818846f0ed 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt @@ -2466,7 +2466,6 @@ static Microsoft.Maui.Handlers.ContentViewHandler.Mapper -> Microsoft.Maui.IProp static Microsoft.Maui.Handlers.DatePickerHandler.CommandMapper -> Microsoft.Maui.CommandMapper! static Microsoft.Maui.Handlers.DatePickerHandler.MapCharacterSpacing(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void -static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapFont(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapFormat(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void static Microsoft.Maui.Handlers.DatePickerHandler.MapMaximumDate(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 7869f46fee56..0d6b14c45612 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -157,3 +157,5 @@ virtual Microsoft.Maui.SwipeViewSwipeStarted.$() -> Microsoft.Maui.SwipeV virtual Microsoft.Maui.SwipeViewSwipeStarted.EqualityContract.get -> System.Type! virtual Microsoft.Maui.SwipeViewSwipeStarted.Equals(Microsoft.Maui.SwipeViewSwipeStarted? other) -> bool virtual Microsoft.Maui.SwipeViewSwipeStarted.PrintMembers(System.Text.StringBuilder! builder) -> bool +*REMOVED*static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.DatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void +static Microsoft.Maui.Handlers.DatePickerHandler.MapFlowDirection(Microsoft.Maui.Handlers.IDatePickerHandler! handler, Microsoft.Maui.IDatePicker! datePicker) -> void \ No newline at end of file