Created
January 11, 2021 13:19
-
-
Save VAndrJ/38276ae660a08a0a423bbd52972418e3 to your computer and use it in GitHub Desktop.
Simple extension for Previews of UIView and UIViewController.
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
#if DEBUG | |
#if canImport(SwiftUI) | |
import UIKit | |
import SwiftUI | |
@available (iOS 13.0, *) | |
struct UIViewControllerSwiftUIRepresentable: UIViewControllerRepresentable { | |
let controller: UIViewController | |
func makeUIViewController(context: Context) -> UIViewController { | |
return controller | |
} | |
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} | |
} | |
@available (iOS 13.0, *) | |
extension UIViewController { | |
var sRepresentation: some View { | |
return UIViewControllerSwiftUIRepresentable(controller: self) | |
} | |
} | |
#endif | |
#endif |
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
#if DEBUG | |
#if canImport(SwiftUI) | |
import UIKit | |
import SwiftUI | |
@available (iOS 13.0, *) | |
struct UIViewSwiftUIRepresentable: UIViewRepresentable { | |
let view: UIView | |
func makeUIView(context: Context) -> UIView { | |
return view | |
} | |
func updateUIView(_ uiView: UIView, context: Context) {} | |
} | |
@available (iOS 13.0, *) | |
extension UIView { | |
var sRepresentation: some View { | |
return UIViewSwiftUIRepresentable(view: self) | |
} | |
} | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment