File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
Sources/RectangleTools/Default Conformances Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -157,25 +157,24 @@ public extension UserInterfaceLayoutDirection {
157
157
// TODO: Move this to some other package
158
158
@inline ( __always)
159
159
static var current : UserInterfaceLayoutDirection {
160
+ #if canImport(WatchKit)
161
+ let legacyCurrent = WKInterfaceDevice . current ( ) . layoutDirection
162
+ #elseif canImport(UIKit)
163
+ let legacyCurrent = UIApplication . shared. userInterfaceLayoutDirection
164
+ #elseif canImport(AppKit)
165
+ let legacyCurrent = NSApp ? . userInterfaceLayoutDirection ?? . leftToRight
166
+ #endif
167
+
160
168
#if canImport(SwiftUI)
161
- #if canImport(UIKit)
162
- let legacyCurrent = UIApplication . shared. userInterfaceLayoutDirection
163
- #elseif canImport(AppKit)
164
- let legacyCurrent = NSApp ? . userInterfaceLayoutDirection ?? . leftToRight
165
- #endif
166
169
switch legacyCurrent {
167
170
case . leftToRight: return . leftToRight
168
171
case . rightToLeft: return . rightToLeft
169
172
@unknown default :
170
173
assertionFailure ( " Unknown user interface layout direction (will assume LTR): \( UserInterfaceLayoutDirection . current) " )
171
174
return . leftToRight
172
175
}
173
- #elseif canImport(WatchKit)
174
- return WKInterfaceDevice . current ( ) . layoutDirection
175
- #elseif canImport(UIKit)
176
- return UIApplication . shared. userInterfaceLayoutDirection
177
- #elseif canImport(AppKit)
178
- return NSApp ? . userInterfaceLayoutDirection ?? . leftToRight
176
+ #else
177
+ return legacyCurrent
179
178
#endif
180
179
}
181
180
}
You can’t perform that action at this time.
0 commit comments