diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 8fcabf42b..42a224665 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -90,6 +90,12 @@ final class BuildSettings: NSObject { static let applicationWebAppUrlString = "https://app.element.io" + // MARK: - Localization + + /// Whether to allow the app to use a right to left layout or force left to right for all languages + static let disableRightToLeftLayout = true + + // MARK: - Server configuration // Default servers proposed on the authentication screen diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 712088c9a..65aad3b25 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -394,8 +394,11 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [NSBundle mxk_setLanguage:language]; [NSBundle mxk_setFallbackLanguage:@"en"]; - [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; - [[UIView appearanceWhenContainedInInstancesOfClasses:@[UIAlertController.class]] setSemanticContentAttribute:UISemanticContentAttributeUnspecified]; + if (BuildSettings.disableRightToLeftLayout) + { + [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight]; + [[UIView appearanceWhenContainedInInstancesOfClasses:@[UIAlertController.class]] setSemanticContentAttribute:UISemanticContentAttributeUnspecified]; + } // Set app info now as Mac (Designed for iPad) accesses it before didFinishLaunching is called self.appInfo = AppInfo.current; diff --git a/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift b/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift index 449042d78..73f565dbd 100644 --- a/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift +++ b/RiotSwiftUI/Modules/Common/Bridging/VectorContentView.swift @@ -23,10 +23,18 @@ import SwiftUI struct VectorContentModifier: ViewModifier { @ObservedObject private var themePublisher = ThemePublisher.shared + @Environment(\.layoutDirection) private var defaultLayoutDirection + + /// The layout direction to use, taking into account the build settings. SwiftUI generally + /// handles RTL well enough, but we match the behaviour used in UIKit to avoid mixed layouts. + var layoutDirection: LayoutDirection { + BuildSettings.disableRightToLeftLayout ? .leftToRight : defaultLayoutDirection + } func body(content: Content) -> some View { content .theme(themePublisher.theme) + .environment(\.layoutDirection, layoutDirection) } }