mirror of
https://github.com/EmergeTools/Pow.git
synced 2026-03-31 09:55:57 +00:00
Co-authored-by: Robert Böhnke <robb@robb.is> Co-authored-by: Kasper Lahti <kasper@lahti.email>
35 lines
939 B
Swift
35 lines
939 B
Swift
import SwiftUI
|
|
|
|
#if os(iOS) || os(tvOS)
|
|
protocol ViewRepresentable: UIViewRepresentable {
|
|
associatedtype ViewType = UIViewType
|
|
func makeView(context: Context) -> ViewType
|
|
func updateView(_ view: ViewType, context: Context)
|
|
}
|
|
|
|
extension ViewRepresentable {
|
|
func makeUIView(context: Context) -> ViewType {
|
|
makeView(context: context)
|
|
}
|
|
|
|
func updateUIView(_ uiView: ViewType, context: Context) {
|
|
updateView(uiView, context: context)
|
|
}
|
|
}
|
|
#elseif os(macOS)
|
|
protocol ViewRepresentable: NSViewRepresentable {
|
|
associatedtype ViewType = NSViewType
|
|
func makeView(context: Context) -> ViewType
|
|
func updateView(_ view: ViewType, context: Context)
|
|
}
|
|
|
|
extension ViewRepresentable {
|
|
func makeNSView(context: Context) -> ViewType {
|
|
makeView(context: context)
|
|
}
|
|
|
|
func updateNSView(_ nsView: ViewType, context: Context) {
|
|
updateView(nsView, context: context)
|
|
}
|
|
}
|
|
#endif
|