From 0ba74ae28e03d57856125a081a488d3b3bde1292 Mon Sep 17 00:00:00 2001 From: Anton Paliakou Date: Fri, 15 Oct 2021 21:22:49 +0300 Subject: [PATCH] Add NSViewControllerPreview for Cocoa. --- .../NSViewControllerPreview.swift | 33 +++++++++++++++++++ .../UIViewControllerPreview.swift | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Sources/PreviewDevice/CocoaPreivew/NSViewControllerPreview.swift diff --git a/Sources/PreviewDevice/CocoaPreivew/NSViewControllerPreview.swift b/Sources/PreviewDevice/CocoaPreivew/NSViewControllerPreview.swift new file mode 100644 index 0000000..93dde15 --- /dev/null +++ b/Sources/PreviewDevice/CocoaPreivew/NSViewControllerPreview.swift @@ -0,0 +1,33 @@ +// +// NSViewControllerPreview.swift +// +// +// Created by Anton Paliakou on 10/15/21. +// + +#if canImport(Cocoa) && canImport(SwiftUI) +import SwiftUI +import Cocoa + +public struct NSViewControllerPreview: NSViewControllerRepresentable { + + // MARK: - Properties + + private let viewController: NSViewController + + // MARK: - Init + + public init(viewController: NSViewController) { + self.viewController = viewController + } + + // MARK: - UIViewControllerRepresentable + + public func makeNSViewController(context: Context) -> NSViewController { + viewController + } + + public func updateNSViewController(_ nsViewController: NSViewController, context: Context) { + } +} +#endif diff --git a/Sources/PreviewDevice/UIKitPreview/UIViewControllerPreview.swift b/Sources/PreviewDevice/UIKitPreview/UIViewControllerPreview.swift index 695b7ac..4fbef25 100644 --- a/Sources/PreviewDevice/UIKitPreview/UIViewControllerPreview.swift +++ b/Sources/PreviewDevice/UIKitPreview/UIViewControllerPreview.swift @@ -1,5 +1,5 @@ // -// File.swift +// UIViewControllerPreview.swift // // // Created by Anton Paliakou on 10/15/21.