Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor updates to the sample
  • Loading branch information
shaps80 committed Jul 22, 2019
commit 2d5684889ccae21debf26af2dc0a87fc21c6e0ba
12 changes: 5 additions & 7 deletions Playground/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ezn-Pn-EiE">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14835.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ezn-Pn-EiE">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14790.5"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -16,7 +14,7 @@
<tabBarItem key="tabBarItem" title="Item" id="8S0-f9-ba0"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Yky-nN-IHs">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down Expand Up @@ -51,7 +49,7 @@
<tabBarItem key="tabBarItem" title="Sections" id="Pul-b2-Kem"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="cQ8-d3-rwW">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
22 changes: 20 additions & 2 deletions Playground/SectionsViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Composed

final class SectionsViewController: UICollectionViewController {
final class SectionsViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {

private var coordinator: CollectionViewSectionProviderCoordinator!

Expand All @@ -16,10 +16,28 @@ final class SectionsViewController: UICollectionViewController {
Person(name: "Joseph Duffy", age: 29),
Person(name: "Joseph Duffy", age: 30),
])

let sectionProvider = ComposedSectionProvider()
sectionProvider.append(personSection)
coordinator = CollectionViewSectionProviderCoordinator(collectionView: collectionView, sectionProvider: sectionProvider)
sectionProvider.append(personSection)

collectionView.alwaysBounceVertical = true

let layout = FlowLayout()
layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
collectionView.collectionViewLayout = layout

coordinator = CollectionViewSectionProviderCoordinator(collectionView: collectionView, sectionProvider: sectionProvider)

DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
personSection.append(element: Person(name: "Shaps", age: 39))
}
}

let cell = PersonCell.fromNib
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let target = CGSize(width: collectionView.bounds.width - 40, height: 0)
return cell.contentView.systemLayoutSizeFitting(target, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
}

}
Expand Down