Skip to content

Commit

Permalink
feat: Added collection view, and diffable support
Browse files Browse the repository at this point in the history
  • Loading branch information
andrej.jasso@goodrequest.com committed Jun 8, 2021
1 parent 6adff59 commit 085a369
Show file tree
Hide file tree
Showing 18 changed files with 1,542 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class ___VARIABLE_ID___Coordinator: Coordinator<AppStep> {
private extension ___VARIABLE_ID___Coordinator {

func navigate(to step: ___VARIABLE_ID___Step) -> StepAction {

return .none
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//___FILEHEADER___

import UIKit
import GRProvider

// MARK: - Section Factory

final class ___VARIABLE_ID___Factory {

// MARK: - Provider Section

enum SectionType: Int {

case first = 0
case second = 1

}

struct Section: Sectionable, Equatable {

var type: SectionType
var items: [Item]

enum Item: Equatable {

static func == (lhs: Item, rhs: Item) -> Bool {
return lhs.hashValue == rhs.hashValue
}

case item

}

var title: String? {
switch type {
case .first:
return "First"

case .second:
return "Second"
}
}

}

}

extension ___VARIABLE_ID___Factory {

func makeSections(for response: String?) -> [Section] {
var sections = [Section]()

return sections
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//___FILEHEADER___

import UIKit
import GRProvider

// MARK: - Section Factory

final class ___VARIABLE_ID___LayoutComposer {

// MARK: - Typealiases

typealias Section = ___VARIABLE_ID___Factory.Section

// MARK: - Constants

private enum C {

static let defaultContentInsets = NSDirectionalEdgeInsets(
top: 16,
leading: 16,
bottom: 16,
trailing: 16
)

}

// MARK: - Public

func prepareLayout(
provider: GRCollectionViewProvider<Section>,
heightDimension: CGFloat
) -> UICollectionViewCompositionalLayout {
return UICollectionViewCompositionalLayout { [unowned provider] index, _ -> NSCollectionLayoutSection? in
switch provider.sections[index].type {
case .first:
return self.prepareFirstSection()

case .second:
return self.prepareSecondSection()
}
}
}

}

// MARK: - Private

private extension ___VARIABLE_ID___LayoutComposer {

func prepareFirstSection() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(230)
)
let item = NSCollectionLayoutItem(layoutSize: itemSize)

let group = NSCollectionLayoutGroup.horizontal(
layoutSize: itemSize,
subitem: item,
count: 1
)

let section = NSCollectionLayoutSection(group: group)
section.interGroupSpacing = 16.0
section.contentInsets = C.defaultContentInsets

return section
}

func prepareSecondSection() -> NSCollectionLayoutSection {
let itemSize = NSCollectionLayoutSize(
widthDimension: .absolute(80.0),
heightDimension: .absolute(80.0)
)

let item = NSCollectionLayoutItem(layoutSize: itemSize)

let group = NSCollectionLayoutGroup.horizontal(
layoutSize: itemSize,
subitems: [item]
)
let section = NSCollectionLayoutSection(group: group)
section.interGroupSpacing = 8
section.contentInsets = C.defaultContentInsets
section.orthogonalScrollingBehavior = .continuous

return section
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="collection view cell content view" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" customClass="___VARIABLE_ID___ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="WQV-89-epP">
<rect key="frame" x="0.0" y="44" width="414" height="852"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="PPH-oc-kHr">
<size key="itemSize" width="128" height="128"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="Qvl-vJ-zdo">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="PGo-CX-yuA">
<rect key="frame" x="0.0" y="0.0" width="128" height="128"/>
<autoresizingMask key="autoresizingMask"/>
</collectionViewCellContentView>
</collectionViewCell>
</cells>
</collectionView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="___COPYRIGHT___" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="855.5" width="414" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="___PACKAGENAME___" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="0.0" y="278" width="414" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstAttribute="bottom" secondItem="WQV-89-epP" secondAttribute="bottom" id="AI8-Mo-b6p"/>
<constraint firstItem="WQV-89-epP" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" id="HRa-Hf-dUm"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="WQV-89-epP" firstAttribute="top" secondItem="Bcu-3y-fUS" secondAttribute="top" id="cCO-vm-67E"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="trailing" secondItem="WQV-89-epP" secondAttribute="trailing" id="cRI-md-HHg"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
</view>
<connections>
<outlet property="collectionView" destination="WQV-89-epP" id="vWp-9M-P1"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading

0 comments on commit 085a369

Please sign in to comment.