Skip to content

Commit 8313457

Browse files
committed
Fix: Fixed support for RTL
1 parent a012777 commit 8313457

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

src/Files.App/Helpers/Application/AppLanguageHelper.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ public static class AppLanguageHelper
2727
/// </summary>
2828
public static AppLanguageItem PreferredLanguage { get; private set; }
2929

30+
/// <summary>
31+
/// Gets the preferred language.
32+
/// </summary>
33+
public static bool IsPreferredLanguageRtl
34+
{
35+
get
36+
{
37+
if (PreferredLanguage.Code is null)
38+
return false;
39+
40+
var culture = new CultureInfo(PreferredLanguage.Code);
41+
return culture.TextInfo.IsRightToLeft;
42+
}
43+
}
44+
3045
/// <summary>
3146
/// Initializes the <see cref="AppLanguageHelper"/> class.
3247
/// </summary>

src/Files.App/UserControls/TabBar/TabBar.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private async void DragAreaRectangle_Loaded(object sender, RoutedEventArgs e)
363363
if (HorizontalTabView.ActualWidth <= 0 && TabBarAddNewTabButton.Width <= 0)
364364
await Task.Delay(100);
365365

366-
var titleBarInset = ((FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft
366+
var titleBarInset = ((AppLanguageHelper.IsPreferredLanguageRtl
367367
? MainWindow.Instance.AppWindow.TitleBar.LeftInset
368368
: MainWindow.Instance.AppWindow.TitleBar.RightInset) / DragAreaRectangle.XamlRoot.RasterizationScale) + 40;
369369

src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ public static class FilePropertiesHelpers
2121
{
2222
private static IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();
2323

24-
/// <summary>
25-
/// Whether LayoutDirection (FlowDirection) is set to right-to-left (RTL)
26-
/// </summary>
27-
public static readonly bool FlowDirectionSettingIsRightToLeft =
28-
new ResourceManager().CreateResourceContext().QualifierValues["LayoutDirection"] == "RTL";
29-
3024
/// <summary>
3125
/// Get window handle (hWnd) of the given properties window instance
3226
/// </summary>

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Microsoft.UI.Xaml.Navigation;
1414
using Windows.Foundation.Metadata;
1515
using Windows.Graphics;
16+
using WinUIEx;
1617
using GridSplitter = Files.App.Controls.GridSplitter;
1718
using VirtualKey = Windows.System.VirtualKey;
1819

@@ -41,8 +42,11 @@ public MainPage()
4142
SidebarAdaptiveViewModel.PaneFlyout = (MenuFlyout)Resources["SidebarContextMenu"];
4243
ViewModel = Ioc.Default.GetRequiredService<MainPageViewModel>();
4344

44-
if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft)
45+
if (AppLanguageHelper.IsPreferredLanguageRtl)
46+
{
47+
MainWindow.Instance.SetExtendedWindowStyle(ExtendedWindowStyle.LayoutRtl);
4548
FlowDirection = FlowDirection.RightToLeft;
49+
}
4650

4751
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
4852
UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent;

src/Files.App/Views/Properties/MainPropertiesPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public MainPropertiesPage()
2626
{
2727
InitializeComponent();
2828

29-
if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft)
29+
if (AppLanguageHelper.IsPreferredLanguageRtl)
3030
FlowDirection = FlowDirection.RightToLeft;
3131
}
3232

src/Files.App/Views/Shells/BaseShellPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel)
176176

177177
DisplayFilesystemConsentDialogAsync();
178178

179-
if (FilePropertiesHelpers.FlowDirectionSettingIsRightToLeft)
179+
if (AppLanguageHelper.IsPreferredLanguageRtl)
180180
FlowDirection = FlowDirection.RightToLeft;
181181

182182
ToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested;

0 commit comments

Comments
 (0)