From 138797f06454b88d91cc6e868bace6e15a2101ed Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:01:17 +0530 Subject: [PATCH 01/10] fix added --- .../Handlers/DatePicker/DatePickerHandler.Windows.cs | 11 +++++++++++ src/Core/src/Platform/Windows/DatePickerExtensions.cs | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs index 807af51488de..3d992b9232c6 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs @@ -1,4 +1,5 @@ #nullable enable +using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using WBrush = Microsoft.UI.Xaml.Media.Brush; @@ -11,11 +12,13 @@ public partial class DatePickerHandler : ViewHandler("DateText"); + if (dateTextBlock is not null) + { + dateTextBlock.CharacterSpacing = characterSpacing; + dateTextBlock.RefreshThemeResources(); + } } public static void UpdateFont(this CalendarDatePicker platformDatePicker, IDatePicker datePicker, IFontManager fontManager) => From 397a2e88af2daea02865fcef41d22b4cc1bd99a5 Mon Sep 17 00:00:00 2001 From: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:02:12 +0530 Subject: [PATCH 02/10] Revert "fix added" This reverts commit 138797f06454b88d91cc6e868bace6e15a2101ed. --- .../Handlers/DatePicker/DatePickerHandler.Windows.cs | 11 ----------- src/Core/src/Platform/Windows/DatePickerExtensions.cs | 10 +--------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs index 3d992b9232c6..807af51488de 100644 --- a/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs +++ b/src/Core/src/Handlers/DatePicker/DatePickerHandler.Windows.cs @@ -1,5 +1,4 @@ #nullable enable -using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using WBrush = Microsoft.UI.Xaml.Media.Brush; @@ -12,13 +11,11 @@ public partial class DatePickerHandler : ViewHandler("DateText"); - if (dateTextBlock is not null) - { - dateTextBlock.CharacterSpacing = characterSpacing; - dateTextBlock.RefreshThemeResources(); - } + platformDatePicker.CharacterSpacing = datePicker.CharacterSpacing.ToEm(); } public static void UpdateFont(this CalendarDatePicker platformDatePicker, IDatePicker datePicker, IFontManager fontManager) => From c40aa813d18cd20ba3b1de1430d893cb8a48cf7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 07:44:42 +0000 Subject: [PATCH 03/10] Initial plan From ee4a3f6523852d86ce72f558ae2769ece8419da3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 07:59:32 +0000 Subject: [PATCH 04/10] Add SearchBar FlowDirection support for Android Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> --- .../SearchBar/SearchBarHandler.Android.cs | 5 ++ .../Handlers/SearchBar/SearchBarHandler.cs | 3 + .../Platform/Android/SearchViewExtensions.cs | 14 +++++ .../SearchBarHandlerTests.Android.cs | 63 +++++++++++++++++++ 4 files changed, 85 insertions(+) diff --git a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs index 1d21a1dc52fc..b0111f4310ae 100644 --- a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs +++ b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Android.cs @@ -132,6 +132,11 @@ public static void MapFocus(ISearchBarHandler handler, ISearchBar searchBar, obj handler.QueryEditor?.Focus(request); } + internal static void MapFlowDirection(ISearchBarHandler handler, ISearchBar searchBar) + { + handler.PlatformView?.UpdateFlowDirection(searchBar, handler.QueryEditor); + } + void OnQueryTextSubmit(object? sender, QueryTextSubmitEventArgs e) { VirtualView.SearchButtonPressed(); diff --git a/src/Core/src/Handlers/SearchBar/SearchBarHandler.cs b/src/Core/src/Handlers/SearchBar/SearchBarHandler.cs index ef6615dbbc30..45e659cfd8a5 100644 --- a/src/Core/src/Handlers/SearchBar/SearchBarHandler.cs +++ b/src/Core/src/Handlers/SearchBar/SearchBarHandler.cs @@ -19,6 +19,9 @@ public partial class SearchBarHandler : ISearchBarHandler { #if __IOS__ [nameof(ISearchBar.IsEnabled)] = MapIsEnabled, +#endif +#if ANDROID + [nameof(IView.FlowDirection)] = MapFlowDirection, #endif [nameof(ISearchBar.Background)] = MapBackground, [nameof(ISearchBar.CharacterSpacing)] = MapCharacterSpacing, diff --git a/src/Core/src/Platform/Android/SearchViewExtensions.cs b/src/Core/src/Platform/Android/SearchViewExtensions.cs index cdfe739f80bc..fbc43f22716f 100644 --- a/src/Core/src/Platform/Android/SearchViewExtensions.cs +++ b/src/Core/src/Platform/Android/SearchViewExtensions.cs @@ -171,5 +171,19 @@ internal static void SetInputType(this SearchView searchView, ISearchBar searchB editText.SetInputType(searchBar); } + + internal static void UpdateFlowDirection(this SearchView searchView, ISearchBar searchBar, EditText? editText = null) + { + editText ??= searchView.GetFirstChildOfType(); + + // Update the SearchView itself + searchView.UpdateFlowDirection((IView)searchBar); + + // Update the internal EditText if available + if (editText != null) + { + editText.UpdateFlowDirection((IView)searchBar); + } + } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs index 4f9f9af09ef6..b3b1387e497f 100644 --- a/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs +++ b/src/Core/tests/DeviceTests/Handlers/SearchBar/SearchBarHandlerTests.Android.cs @@ -358,5 +358,68 @@ bool GetNativeIsSpellCheckEnabled(SearchBarHandler searchBarHandler) return !inputTypes.HasFlag(InputTypes.TextFlagNoSuggestions); } + + Android.Views.LayoutDirection GetNativeFlowDirection(SearchBarHandler searchBarHandler) + { + var searchView = GetNativeSearchBar(searchBarHandler); + return searchView.LayoutDirection; + } + + Android.Views.LayoutDirection GetNativeEditTextFlowDirection(SearchBarHandler searchBarHandler) + { + var searchView = GetNativeSearchBar(searchBarHandler); + var editText = searchView.GetChildrenOfType().FirstOrDefault(); + return editText?.LayoutDirection ?? Android.Views.LayoutDirection.Inherit; + } + + [Fact(DisplayName = "FlowDirection Initializes Correctly")] + public async Task FlowDirectionInitializesCorrectly() + { + var searchBarStub = new SearchBarStub() + { + Text = "Test", + FlowDirection = FlowDirection.RightToLeft + }; + + var values = await GetValueAsync(searchBarStub, (handler) => + { + return new + { + ViewValue = searchBarStub.FlowDirection, + PlatformViewValue = GetNativeFlowDirection(handler), + EditTextFlowDirection = GetNativeEditTextFlowDirection(handler) + }; + }); + + Assert.Equal(FlowDirection.RightToLeft, values.ViewValue); + Assert.Equal(Android.Views.LayoutDirection.Rtl, values.PlatformViewValue); + Assert.Equal(Android.Views.LayoutDirection.Rtl, values.EditTextFlowDirection); + } + + [Fact(DisplayName = "FlowDirection Updates Correctly")] + public async Task FlowDirectionUpdatesCorrectly() + { + var searchBarStub = new SearchBarStub() + { + Text = "Test", + FlowDirection = FlowDirection.LeftToRight + }; + + await ValidatePropertyUpdatesValue( + searchBarStub, + nameof(IView.FlowDirection), + GetNativeFlowDirection, + FlowDirection.RightToLeft, + Android.Views.LayoutDirection.Rtl); + + // Also verify EditText flow direction updates + var handler = CreateHandler(searchBarStub); + await InvokeOnMainThreadAsync(() => + { + searchBarStub.FlowDirection = FlowDirection.RightToLeft; + var editTextDirection = GetNativeEditTextFlowDirection(handler); + Assert.Equal(Android.Views.LayoutDirection.Rtl, editTextDirection); + }); + } } } \ No newline at end of file From a7b72a93e1fa361bb9b5035a5ede4ea70b54d0e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 3 Jul 2025 08:03:36 +0000 Subject: [PATCH 05/10] Complete SearchBar FlowDirection fix with test UI Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com> --- .../Controls.Sample.Sandbox/MainPage.xaml | 23 +++++++++++++++++++ .../Controls.Sample.Sandbox/MainPage.xaml.cs | 16 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml index 7363d18deadd..f0a51b94e3d3 100644 --- a/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml +++ b/src/Controls/samples/Controls.Sample.Sandbox/MainPage.xaml @@ -2,4 +2,27 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Maui.Controls.Sample.MainPage" xmlns:local="clr-namespace:Maui.Controls.Sample"> + + +