Last active
August 18, 2020 13:20
-
-
Save pteasima/98d98db18a86c2c76431100621132bfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
#if os(macOS) | |
import Cocoa | |
protocol ViewRepresentable: NSViewRepresentable { | |
func makeView(context: Context) -> NSViewType | |
func updateView(_ view: NSViewType, context: Context) | |
} | |
extension ViewRepresentable { | |
func makeNSView(context: Context) -> NSViewType { | |
makeView(context: context) | |
} | |
func updateNSView(_ nsView: NSViewType, context: Context) { | |
updateView(nsView, context: context) | |
} | |
} | |
#endif | |
#if os(iOS) | |
import UIKit | |
protocol ViewRepresentable: UIViewRepresentable { | |
func makeView(context: Context) -> UIViewType | |
func updateView(view: UIViewType, context: Context) | |
} | |
extension ViewRepresentable { | |
func makeUIView(context: Context) -> UIViewType { | |
makeView(context: context) | |
} | |
func updateUIView(_ nsView: UIViewType, context: Context) { | |
updateView(uiView, context: context) | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment