Skip to content

Instantly share code, notes, and snippets.

@LucasVanDongen
Created February 3, 2021 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LucasVanDongen/b11109b2f427138b1c93ec5cf18a5199 to your computer and use it in GitHub Desktop.
Save LucasVanDongen/b11109b2f427138b1c93ec5cf18a5199 to your computer and use it in GitHub Desktop.
//
// ViewControllerRepresentable.swift
//
// Created by Lucas van Dongen on 03/02/2021.
//
import SwiftUI
/// Helps you hosting the UIViewControllers in a simple way for Previews
struct ViewControllerRepresentable<Controller: UIViewController>: UIViewControllerRepresentable {
/// Add the code to initialize the UIViewController you want to preview here
let initializer: () -> Controller
func makeCoordinator() -> Coordinator {
return Coordinator()
}
func makeUIViewController(context: Context) -> Controller {
return initializer()
}
func updateUIViewController(_ uiViewController: Controller, context: Context) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment