Skip to content

Commit 2b44ead

Browse files
committed
Fix visionOS build
1 parent 17c914c commit 2b44ead

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

Sources/SwiftUIKit/Colors/ColorRepresentable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import class AppKit.NSColor
1616
public typealias ColorRepresentable = NSColor
1717
#endif
1818

19-
#if os(iOS) || os(tvOS) || os(watchOS)
19+
#if canImport(UIKit)
2020
import class UIKit.UIColor
2121

2222
/**

Sources/SwiftUIKit/Fonts/FontRepresentable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import class AppKit.NSFont
1616
public typealias FontRepresentable = NSFont
1717
#endif
1818

19-
#if os(iOS) || os(tvOS) || os(watchOS)
19+
#if canImport(UIKit)
2020
import class UIKit.UIFont
2121

2222
/**

Sources/SwiftUIKit/Gestures/SwipeGestureViewModifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2020-2024 Daniel Saidi. All rights reserved.
77
//
88

9-
#if os(iOS) || os(macOS) || os(watchOS)
9+
#if os(iOS) || os(macOS) || os(watchOS) || os(visionOS)
1010
import SwiftUI
1111

1212
/**

Sources/SwiftUIKit/Images/ImageRepresentable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public extension Image {
3232

3333
/// Create an image from a certain ``ImageRepresentable``.
3434
init(image: ImageRepresentable) {
35-
#if os(iOS) || os(watchOS) || os(tvOS)
35+
#if canImport(UIKit)
3636
self.init(uiImage: image)
37-
#elseif os(macOS)
37+
#elseif canImport(AppKit)
3838
self.init(nsImage: image)
3939
#endif
4040
}

Sources/SwiftUIKit/Pages/PageIndicatorDisplayMode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public enum PageIndicatorDisplayMode {
2121
case never
2222
}
2323

24-
#if os(iOS) || os(tvOS) || os(watchOS)
24+
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
2525
extension PageIndicatorDisplayMode {
2626

2727
var tabViewMode: PageTabViewStyle.IndexDisplayMode {
28-
#if os(iOS) || os(tvOS)
28+
#if os(iOS) || os(tvOS) || os(visionOS)
2929
switch self {
3030
case .always: return .always
3131
case .automatic: return .automatic

Sources/SwiftUIKit/Pages/PageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2020-2024 Daniel Saidi. All rights reserved.
77
//
88

9-
#if os(iOS) || os(tvOS) || os(watchOS)
9+
#if os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
1010
import SwiftUI
1111

1212
/**

Sources/SwiftUIKit/Text/MultilineSubmitViewModifier.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,19 @@ public struct MultilineSubmitViewModifier: ViewModifier {
4343
content
4444
.focused($isFocused)
4545
.submitLabel(submitLabel)
46-
.onChange(of: text) { newValue in
47-
guard isFocused else { return }
48-
guard newValue.contains("\n") else { return }
49-
isFocused = false
50-
text = newValue.replacingOccurrences(of: "\n", with: "")
51-
onSubmit()
52-
}
46+
#if os(visionOS)
47+
.onChange(of: text) { handle($1) }
48+
#else
49+
.onChange(of: text) { handle($0) }
50+
#endif
51+
}
52+
53+
private func handle(_ newText: String) {
54+
guard isFocused else { return }
55+
guard newText.contains("\n") else { return }
56+
isFocused = false
57+
text = newText.replacingOccurrences(of: "\n", with: "")
58+
onSubmit()
5359
}
5460
}
5561

0 commit comments

Comments
 (0)