Skip to content

Commit

Permalink
availability, better generic usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Mar 27, 2024
1 parent 0a84bcc commit e5d9d51
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Sources/NSUI/ViewControllerRepresentable.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SwiftUI

#if canImport(AppKit) && !targetEnvironment(macCatalyst)
public protocol NSUIViewControllerRepresentable: NSViewControllerRepresentable {
public protocol NSUIViewControllerRepresentable: NSViewControllerRepresentable where NSViewControllerType == NSUIViewControllerType {
associatedtype NSUIViewControllerType: NSUIViewController

@MainActor
Expand Down Expand Up @@ -42,7 +42,7 @@ public extension NSUIViewControllerRepresentable {
}

#elseif canImport(UIKit)
public protocol NSUIViewControllerRepresentable: UIViewControllerRepresentable {
public protocol NSUIViewControllerRepresentable: UIViewControllerRepresentable where UIViewControllerType == NSUIViewControllerType {
associatedtype NSUIViewControllerType: NSUIViewController

@MainActor
Expand Down Expand Up @@ -75,6 +75,7 @@ public extension NSUIViewControllerRepresentable {
Self.dismantleNSUIViewController(viewController, coordinator: coordinator)
}

@available(iOS 16.0, tvOS 16.0, *)
@MainActor
func sizeThatFits(
_ proposal: ProposedViewSize,
Expand Down
6 changes: 2 additions & 4 deletions Tests/NSUITests/ViewControllerRepresentableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import NSUI

@MainActor
struct RepresentedViewController: NSUIViewControllerRepresentable {
typealias NSUIViewControllerType = NSUIViewController

func makeNSUIViewController(context: Context) -> NSUIViewControllerType {
func makeNSUIViewController(context: Context) -> NSUIViewController {
NSUIViewControllerType(nibName: nil, bundle: nil)
}

func updateNSUIViewController(_ viewController: NSUIViewControllerType, context: Context) {
func updateNSUIViewController(_ viewController: NSUIViewController, context: Context) {
}

final class Coordinator {}
Expand Down
4 changes: 1 addition & 3 deletions Tests/NSUITests/ViewRepresentableTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import XCTest
@testable import NSUI
import NSUI

@MainActor
struct RepresentedView: NSUIViewRepresentable {
typealias NSUIViewType = NSUIView

func makeNSUIView(context: Context) -> NSUIView {
NSUIView()
}
Expand Down

0 comments on commit e5d9d51

Please sign in to comment.