|
1 | 1 | import SwiftUI |
2 | | -import SwiftUIIntrospect |
| 2 | +@testable import SwiftUIIntrospect |
3 | 3 | import XCTest |
4 | 4 |
|
5 | 5 | @MainActor |
@@ -32,23 +32,33 @@ final class ViewTests: XCTestCase { |
32 | 32 | } |
33 | 33 | } |
34 | 34 |
|
35 | | -struct SUTView: UIViewRepresentable { |
36 | | - func makeUIView(context: Context) -> some UIView { |
37 | | - let view = UIView() |
38 | | - view.translatesAutoresizingMaskIntoConstraints = false |
| 35 | +struct SUTView: PlatformViewControllerRepresentable { |
| 36 | + #if canImport(UIKit) |
| 37 | + typealias UIViewControllerType = PlatformViewController |
| 38 | + #elseif canImport(AppKit) |
| 39 | + typealias NSViewControllerType = PlatformViewController |
| 40 | + #endif |
39 | 41 |
|
40 | | - let widthConstraint = view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) |
| 42 | + func makePlatformViewController(context: Context) -> PlatformViewController { |
| 43 | + let controller = PlatformViewController(nibName: nil, bundle: nil) |
| 44 | + controller.view.translatesAutoresizingMaskIntoConstraints = false |
| 45 | + |
| 46 | + let widthConstraint = controller.view.widthAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) |
41 | 47 | widthConstraint.priority = .defaultLow |
42 | 48 |
|
43 | | - let heightConstraint = view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) |
| 49 | + let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude) |
44 | 50 | heightConstraint.priority = .defaultLow |
45 | 51 |
|
46 | 52 | NSLayoutConstraint.activate([widthConstraint, heightConstraint]) |
47 | 53 |
|
48 | | - return view |
| 54 | + return controller |
| 55 | + } |
| 56 | + |
| 57 | + func updatePlatformViewController(_ controller: PlatformViewController, context: Context) { |
| 58 | + // NO-OP |
49 | 59 | } |
50 | 60 |
|
51 | | - func updateUIView(_ uiView: UIViewType, context: Context) { |
| 61 | + static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) { |
52 | 62 | // NO-OP |
53 | 63 | } |
54 | 64 | } |
0 commit comments