Skip to content

Commit

Permalink
Tweak storyboard examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Bofei Zhu committed Oct 23, 2016
1 parent 9d31a1a commit eea57dd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 26 deletions.
10 changes: 5 additions & 5 deletions Example/Demo.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="LKS-vo-Ytk" firstAttribute="top" secondItem="s2P-10-T78" secondAttribute="top" id="IQP-dj-gaM"/>
<constraint firstItem="LKS-vo-Ytk" firstAttribute="leading" secondItem="s2P-10-T78" secondAttribute="leading" id="cc8-Hj-dNE"/>
<constraint firstItem="wYR-29-GPY" firstAttribute="top" secondItem="LKS-vo-Ytk" secondAttribute="bottom" id="gUx-kz-UpS"/>
<constraint firstItem="LKS-vo-Ytk" firstAttribute="top" secondItem="VEL-Rj-Wcy" secondAttribute="bottom" id="mfr-lC-pWc"/>
<constraint firstAttribute="bottom" secondItem="LKS-vo-Ytk" secondAttribute="bottom" id="hhH-sV-DXp"/>
<constraint firstAttribute="trailing" secondItem="LKS-vo-Ytk" secondAttribute="trailing" id="tnZ-7G-n7P"/>
</constraints>
</view>
Expand All @@ -66,7 +66,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="WwB-xb-Qef" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-145" y="91"/>
<point key="canvasLocation" x="-146.40000000000001" y="90.404797601199405"/>
</scene>
<!--Single Section Storyboard View Controller-->
<scene sceneID="VLx-Fb-fo0">
Expand Down Expand Up @@ -117,9 +117,9 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Lqf-9C-lS3" firstAttribute="leading" secondItem="bMx-bC-IhF" secondAttribute="leading" id="2B9-1H-mjw"/>
<constraint firstItem="Lqf-9C-lS3" firstAttribute="top" secondItem="bMx-bC-IhF" secondAttribute="top" id="4rw-Vn-NT0"/>
<constraint firstAttribute="trailing" secondItem="Lqf-9C-lS3" secondAttribute="trailing" id="6St-9C-UOf"/>
<constraint firstItem="jSR-p6-C72" firstAttribute="top" secondItem="Lqf-9C-lS3" secondAttribute="bottom" id="DXu-g4-tJP"/>
<constraint firstItem="Lqf-9C-lS3" firstAttribute="top" secondItem="VaC-h1-D9B" secondAttribute="bottom" id="WaC-lj-82X"/>
<constraint firstAttribute="bottom" secondItem="Lqf-9C-lS3" secondAttribute="bottom" id="Hwt-35-Ha0"/>
</constraints>
</view>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ class DemoItem: NSObject {

let name: String
let controllerClass: UIViewController.Type
let controllerIdentifier: String?

init(
name: String,
controllerClass: UIViewController.Type
controllerClass: UIViewController.Type,
controllerIdentifier: String?=nil
) {
self.name = name
self.controllerClass = controllerClass
self.controllerIdentifier = controllerIdentifier
}

}
Expand All @@ -51,16 +54,15 @@ class DemoSectionController: IGListSectionController, IGListSectionType {
func didUpdate(to object: Any) {
self.object = object as? DemoItem
}

private func controllerFromStorybard(withIdentifier identifier: String) {

}

func didSelectItem(at index: Int) {
if object?.name == "Storyboard" {
let storyboard = UIStoryboard(name: "Demo", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "demo") as! StoryboardViewController
controller.title = object?.name
viewController?.navigationController?.pushViewController(controller, animated: true)
} else if object?.name == "Single Section Storyboard" {
if let identifier = object?.controllerIdentifier {
let storyboard = UIStoryboard(name: "Demo", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "singleSectionDemo") as! SingleSectionStoryboardViewController
let controller = storyboard.instantiateViewController(withIdentifier: identifier)
controller.title = object?.name
viewController?.navigationController?.pushViewController(controller, animated: true)
} else if let controller = object?.controllerClass.init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class DemosViewController: UIViewController, IGListAdapterDataSource {
DemoItem(name: "Nested Adapter", controllerClass: NestedAdapterViewController.self),
DemoItem(name: "Empty View", controllerClass: EmptyViewController.self),
DemoItem(name: "Single Section Controller", controllerClass: SingleSectionViewController.self),
DemoItem(name: "Storyboard", controllerClass: SingleSectionViewController.self),
DemoItem(name: "Single Section Storyboard", controllerClass: SingleSectionViewController.self),
DemoItem(name: "Storyboard", controllerClass: SingleSectionViewController.self, controllerIdentifier: "demo"),
DemoItem(name: "Single Section Storyboard", controllerClass: SingleSectionViewController.self, controllerIdentifier: "singleSectionDemo"),
DemoItem(name: "Working Range", controllerClass: WorkingRangeViewController.self)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ final class SingleSectionStoryboardViewController: UIViewController, IGListAdapt

override func viewDidLoad() {
super.viewDidLoad()

view.addSubview(collectionView)
adapter.collectionView = collectionView
adapter.dataSource = self
}
Expand All @@ -51,16 +49,14 @@ final class SingleSectionStoryboardViewController: UIViewController, IGListAdapt
guard let cell = cell as? StoryboardCell, let number = data as? Int else { return }
cell.textLabel.text = "Cell: \(number + 1)"
}

let sizeBlock = { (context: IGListCollectionContext?) -> CGSize in
guard let context = context else { return CGSize() }
guard let context = context else { return .zero }
return CGSize(width: context.containerSize.width, height: 44)
}
let sectionController = IGListSingleSectionController(storyboardCellIdentifier: "cell",
configureBlock: configureBlock,
sizeBlock: sizeBlock)
sectionController.selectionDelegate = self

return sectionController
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@ class StoryboardViewController: UIViewController, IGListAdapterDataSource {

override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(collectionView)
adapter.collectionView = collectionView
adapter.dataSource = self
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
collectionView.frame = view.bounds
}

//MARK: IGListAdapterDataSource

func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] {
Expand Down

0 comments on commit eea57dd

Please sign in to comment.