Skip to content

Commit

Permalink
reproduce
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrium committed May 1, 2021
1 parent 566673e commit 7f222b1
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 17 deletions.
Expand Up @@ -13,6 +13,8 @@
E3C73F41263DA7770000C0D3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E3C73F3F263DA7770000C0D3 /* Main.storyboard */; };
E3C73F43263DA7790000C0D3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E3C73F42263DA7790000C0D3 /* Assets.xcassets */; };
E3C73F46263DA7790000C0D3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E3C73F44263DA7790000C0D3 /* LaunchScreen.storyboard */; };
E3C73F4F263DA8190000C0D3 /* SomeFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3C73F4D263DA8190000C0D3 /* SomeFooterView.swift */; };
E3C73F50263DA8190000C0D3 /* SomeFooterView.xib in Resources */ = {isa = PBXBuildFile; fileRef = E3C73F4E263DA8190000C0D3 /* SomeFooterView.xib */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -24,6 +26,8 @@
E3C73F42263DA7790000C0D3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E3C73F45263DA7790000C0D3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
E3C73F47263DA7790000C0D3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E3C73F4D263DA8190000C0D3 /* SomeFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SomeFooterView.swift; sourceTree = "<group>"; };
E3C73F4E263DA8190000C0D3 /* SomeFooterView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SomeFooterView.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -60,6 +64,8 @@
E3C73F3B263DA7770000C0D3 /* SceneDelegate.swift */,
E3C73F3D263DA7770000C0D3 /* ViewController.swift */,
E3C73F3F263DA7770000C0D3 /* Main.storyboard */,
E3C73F4D263DA8190000C0D3 /* SomeFooterView.swift */,
E3C73F4E263DA8190000C0D3 /* SomeFooterView.xib */,
E3C73F42263DA7790000C0D3 /* Assets.xcassets */,
E3C73F44263DA7790000C0D3 /* LaunchScreen.storyboard */,
E3C73F47263DA7790000C0D3 /* Info.plist */,
Expand Down Expand Up @@ -125,6 +131,7 @@
buildActionMask = 2147483647;
files = (
E3C73F46263DA7790000C0D3 /* LaunchScreen.storyboard in Resources */,
E3C73F50263DA8190000C0D3 /* SomeFooterView.xib in Resources */,
E3C73F43263DA7790000C0D3 /* Assets.xcassets in Resources */,
E3C73F41263DA7770000C0D3 /* Main.storyboard in Resources */,
);
Expand All @@ -138,6 +145,7 @@
buildActionMask = 2147483647;
files = (
E3C73F3E263DA7770000C0D3 /* ViewController.swift in Sources */,
E3C73F4F263DA8190000C0D3 /* SomeFooterView.swift in Sources */,
E3C73F3A263DA7770000C0D3 /* AppDelegate.swift in Sources */,
E3C73F3C263DA7770000C0D3 /* SceneDelegate.swift in Sources */,
);
Expand Down
3 changes: 1 addition & 2 deletions dequeueConfiguredReusableSupplementary/AppDelegate.swift
Expand Up @@ -9,8 +9,7 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {


var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
Expand Down
41 changes: 29 additions & 12 deletions dequeueConfiguredReusableSupplementary/Base.lproj/Main.storyboard
@@ -1,24 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<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="9Mh-p6-YTR">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<scene sceneID="k8r-qI-46L">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<collectionViewController id="9Mh-p6-YTR" customClass="ViewController" customModule="dequeueConfiguredReusableSupplementary" customModuleProvider="target" sceneMemberID="viewController">
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="Dzi-eh-pAc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="f8e-YW-fRE">
<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/>
<connections>
<outlet property="dataSource" destination="9Mh-p6-YTR" id="a1e-9z-QFQ"/>
<outlet property="delegate" destination="9Mh-p6-YTR" id="gZr-23-Q7i"/>
</connections>
</collectionView>
</collectionViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="K0u-4H-Xb8" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-214" y="-32"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
11 changes: 11 additions & 0 deletions dequeueConfiguredReusableSupplementary/SomeFooterView.swift
@@ -0,0 +1,11 @@
//
// SomeFooterView.swift
// dequeueConfiguredReusableSupplementary
//
// Created by gurrium on 2021/05/02.
//

import UIKit

class SomeFooterView: UICollectionReusableView {
}
33 changes: 33 additions & 0 deletions dequeueConfiguredReusableSupplementary/SomeFooterView.xib
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<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="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionReusableView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="SomeFooterView" id="U6b-Vx-4bR" customClass="SomeFooterView" customModule="dequeueConfiguredReusableSupplementary" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Footer" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gZa-8Q-U9k" customClass="somefoo">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="VXr-Tz-HHm"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="gZa-8Q-U9k" secondAttribute="trailing" id="HCj-ww-zVa"/>
<constraint firstItem="VXr-Tz-HHm" firstAttribute="bottom" secondItem="gZa-8Q-U9k" secondAttribute="bottom" id="Mre-DD-qP8"/>
<constraint firstItem="gZa-8Q-U9k" firstAttribute="leading" secondItem="U6b-Vx-4bR" secondAttribute="leading" id="NUL-mY-Oqg"/>
<constraint firstItem="gZa-8Q-U9k" firstAttribute="top" secondItem="U6b-Vx-4bR" secondAttribute="top" id="fhs-SY-BW6"/>
</constraints>
<point key="canvasLocation" x="35" y="154"/>
</collectionReusableView>
</objects>
</document>
26 changes: 23 additions & 3 deletions dequeueConfiguredReusableSupplementary/ViewController.swift
Expand Up @@ -7,13 +7,33 @@

import UIKit

class ViewController: UIViewController {
class ViewController: UICollectionViewController {
private var dataSource: UICollectionViewDiffableDataSource<Int, Int>!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

var config = UICollectionLayoutListConfiguration(appearance: .plain)
config.footerMode = .supplementary
collectionView.setCollectionViewLayout(UICollectionViewCompositionalLayout.list(using: config), animated: false)

let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Int> { cell, _, number in
var config = cell.defaultContentConfiguration()
config.text = "\(number)"

cell.contentConfiguration = config
}
dataSource = UICollectionViewDiffableDataSource<Int, Int>(collectionView: collectionView) { $0.dequeueConfiguredReusableCell(using: cellRegistration, for: $1, item: $2) }

let footerRegistration = UICollectionView.SupplementaryRegistration<SomeFooterView>(supplementaryNib: UINib(nibName: "SomeFooterView", bundle: nil), elementKind: UICollectionView.elementKindSectionFooter) { _, _, _ in }
dataSource.supplementaryViewProvider = {
$0.dequeueConfiguredReusableSupplementary(using: footerRegistration, for: $2)
}

var snapshot = NSDiffableDataSourceSnapshot<Int, Int>()
snapshot.appendSections([0])
snapshot.appendItems([0, 1, 2])
dataSource.apply(snapshot)
}
}

0 comments on commit 7f222b1

Please sign in to comment.