diff --git a/Examples/MainViewController.swift b/Examples/MainViewController.swift index fed63bea..91eb8ad1 100644 --- a/Examples/MainViewController.swift +++ b/Examples/MainViewController.swift @@ -3,7 +3,7 @@ import CollectionKit class MainViewController: UIViewController { - typealias SourceData = (UIViewController.Type, String) + typealias SourceData = (makeViewController: ()->(UIViewController), exampleTitle:String) let collectionView = CollectionView() @@ -22,18 +22,18 @@ class MainViewController: UIViewController { func setupcollection() { let dataSource = ArrayDataSource(data: [ - (BuiltInTransitionExampleViewController1.self, "Built In Animations"), - (MatchExampleViewController1.self, "Match Animation"), - (MatchInCollectionExampleViewController1.self, "Match Cell in Collection"), - (AppStoreViewController1.self, "App Store Transition"), + ({ BuiltInTransitionExampleViewController1() }, "Built In Animations"), + ({ MatchExampleViewController1() }, "Match Animation"), + ({ MatchInCollectionExampleViewController1() }, "Match Cell in Collection"), + ({ AppStoreViewController1() }, "App Store Transition"), ]) if #available(iOS 13.0, *) { - dataSource.data.insert((SwiftUIMatchExampleViewController.self, "Match SwiftUI"), at: 2) + dataSource.data.insert(({ SwiftUIMatchExampleViewController() }, "Match SwiftUI"), at: 2) } let viewSource = ClosureViewSource { (label: UILabel, data: SourceData, index) in - label.text = "\(index + 1). \(data.1)" + label.text = "\(index + 1). \(data.exampleTitle)" label.textAlignment = .center if #available(iOS 13.0, *) { label.textColor = .label @@ -57,7 +57,7 @@ class MainViewController: UIViewController { sizeSource: sizeSource, layout: FlowLayout(lineSpacing: 10)) { (context) in - let vc = context.data.0.init() + let vc = context.data.makeViewController() vc.modalPresentationStyle = .fullScreen self.present(vc, animated: true, completion: nil) } diff --git a/Examples/SwiftUIMatchExample.swift b/Examples/SwiftUIMatchExample.swift index 5ddfe350..efc4ed2b 100644 --- a/Examples/SwiftUIMatchExample.swift +++ b/Examples/SwiftUIMatchExample.swift @@ -6,14 +6,14 @@ import SwiftUI @available(iOS 13.0, *) class SwiftUIMatchExampleViewController: UIHostingController { - override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + required init() { super.init(rootView: ImagesTableView()) rootView.onTapRow = { image in let destinationViewController = UIHostingController(rootView: ImageViewWrapper(name: image.name, heroID: image.name) - .onTapGesture { [weak self] in - self?.presentedViewController?.dismiss(animated: true, completion: nil) + .onTapGesture { [weak self] in + self?.presentedViewController?.dismiss(animated: true, completion: nil) }) destinationViewController.isHeroEnabled = true