Add a RTL BuildSetting and use this for SwiftUI views too.

This commit is contained in:
Doug
2022-03-28 16:52:07 +01:00
parent ac7ab6eb5d
commit 8a82930814
3 changed files with 19 additions and 2 deletions
@@ -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)
}
}