Skip to content

Commit 2edf3fd

Browse files
committed
WIP
1 parent 779b6dd commit 2edf3fd

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

Tests/Tests/ViewTypes/ViewTests.swift

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import SwiftUI
2-
import SwiftUIIntrospect
2+
@testable import SwiftUIIntrospect
33
import XCTest
44

55
@MainActor
@@ -32,23 +32,33 @@ final class ViewTests: XCTestCase {
3232
}
3333
}
3434

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
3941

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)
4147
widthConstraint.priority = .defaultLow
4248

43-
let heightConstraint = view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude)
49+
let heightConstraint = controller.view.heightAnchor.constraint(greaterThanOrEqualToConstant: .greatestFiniteMagnitude)
4450
heightConstraint.priority = .defaultLow
4551

4652
NSLayoutConstraint.activate([widthConstraint, heightConstraint])
4753

48-
return view
54+
return controller
55+
}
56+
57+
func updatePlatformViewController(_ controller: PlatformViewController, context: Context) {
58+
// NO-OP
4959
}
5060

51-
func updateUIView(_ uiView: UIViewType, context: Context) {
61+
static func dismantlePlatformViewController(_ controller: PlatformViewController, coordinator: Coordinator) {
5262
// NO-OP
5363
}
5464
}

0 commit comments

Comments
 (0)