Remove UIview dependency
This commit is contained in:
parent
4db7508f38
commit
f608f74f74
|
@ -3,10 +3,8 @@ import SwiftUI
|
|||
#endif
|
||||
import UIKit
|
||||
|
||||
// TODO: remove UIView dependency
|
||||
|
||||
@available(iOS 14, *)
|
||||
struct CatalogItem<Content: UIViewCatalogPresentable>: View {
|
||||
struct CatalogItem<Content: UICatalogPresentable>: View {
|
||||
let configuration: UICatalog.PreviewConfiguration
|
||||
|
||||
var body: some View {
|
||||
|
|
|
@ -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) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue