Skip to content

Commit d91b866

Browse files
authored
Merge pull request #63 from RougeWare/feature/WatchKit-compile-error/2021-07-23
Addressed an oversight which prevented this from compiling for WatchOS
2 parents 2247eff + c319b07 commit d91b866

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Sources/RectangleTools/Default Conformances/EdgeInsets + FourSided.swift

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,25 +157,24 @@ public extension UserInterfaceLayoutDirection {
157157
// TODO: Move this to some other package
158158
@inline(__always)
159159
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+
160168
#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
166169
switch legacyCurrent {
167170
case .leftToRight: return .leftToRight
168171
case .rightToLeft: return .rightToLeft
169172
@unknown default:
170173
assertionFailure("Unknown user interface layout direction (will assume LTR): \(UserInterfaceLayoutDirection.current)")
171174
return .leftToRight
172175
}
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
179178
#endif
180179
}
181180
}

0 commit comments

Comments
 (0)