diff --git a/Sources/UIPreview/UICatalog/CatalogItem.swift b/Sources/UIPreview/UICatalog/CatalogItem.swift index 1832f3d..e8dfdf5 100644 --- a/Sources/UIPreview/UICatalog/CatalogItem.swift +++ b/Sources/UIPreview/UICatalog/CatalogItem.swift @@ -3,10 +3,8 @@ import SwiftUI #endif import UIKit -// TODO: remove UIView dependency - @available(iOS 14, *) -struct CatalogItem: View { +struct CatalogItem: View { let configuration: UICatalog.PreviewConfiguration var body: some View { diff --git a/Sources/UIPreview/UICatalog/UICatalogPresentable.swift b/Sources/UIPreview/UICatalog/UICatalogPresentable.swift index 06be1a1..4af50ae 100644 --- a/Sources/UIPreview/UICatalog/UICatalogPresentable.swift +++ b/Sources/UIPreview/UICatalog/UICatalogPresentable.swift @@ -11,18 +11,24 @@ public protocol UICatalogPresentable { static var previewModels: [PreviewModel] { get } static func makePreviewInstance() -> Self + + @available(iOS 13, *) + func preview(with model: PreviewModel) -> AnyView +} + +@available(iOS 13, *) +extension UICatalogPresentable { + public static func preview(with model: PreviewModel) -> some View { + makePreviewInstance().preview(with: model) + } } public typealias UIViewCatalogPresentable = UIView & UICatalogPresentable @available(iOS 13, *) extension UICatalogPresentable where Self: UIView { - public func preview(with model: PreviewModel) -> some View { - UIViewWrapper(self) { $0.apply(previewModel: model) } - } - - public static func preview(with model: PreviewModel) -> some View { - makePreviewInstance().preview(with: model) + public func preview(with model: PreviewModel) -> AnyView { + AnyView(UIViewWrapper(self) { $0.apply(previewModel: model) }) } }