Skip to content

Instantly share code, notes, and snippets.

@ethanjdiamond
ethanjdiamond / swift
Created June 29, 2019 17:44
Using Live Preview with Xcode11 and UIKit
#if DEBUG && canImport(SwiftUI)
import SwiftUI
extension SomeViewController: UIViewControllerRepresentable {
typealias UIViewControllerType = SomeViewController
func makeUIViewController(context: UIViewControllerRepresentableContext<UIViewControllerType>) -> UIViewControllerType {
return SomeViewController()
}
protocol Presentable: class {
var viewController: UIViewController { get }
}
protocol Presenter: Presentable {
}
extension UIViewController: Presenter {
var viewController: UIViewController { return self }
protocol Routable: class {
associatedtype I: Interactable
func configure(interactor: I, viewController: UIViewController?)
func attach(router: Router<I>)
func detach(router: Router<I>)
}
class Router<I: Interactable>: Routable {
var interactor: Interactable!
protocol Interactable: class {//, StoreSubscriber {
associatedtype R: Routable
associatedtype P: Presentable
func configure(store: AppStore, router: R, presenter: P?)
func interactorDidAttach()
func interactorWillDetach()
func newState(state: AppState)
}
protocol Buildable: class {
associatedtype R: Routable
associatedtype I: Interactable
associatedtype P: Presentable
func build(store: AppStore) -> R!
func configure(store: AppStore, router: R, interactor: I, presenter: P?)
}
class Builder<R: Routable, I: Interactable, P: Presentable> {