Skip to content

Commit

Permalink
Merge 1f9efd8 into 372610e
Browse files Browse the repository at this point in the history
  • Loading branch information
Oni-zerone committed Sep 19, 2019
2 parents 372610e + 1f9efd8 commit ef34aac
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Example/StoriesLayout/MySafariCollectionViewCell.swift
Expand Up @@ -13,6 +13,7 @@ import PowerTools
class MySafariCollectionViewCell: SafariCollectionViewCell {

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
Expand All @@ -36,4 +37,8 @@ extension MySafariCollectionViewCell: ImageCell {
func set(image: UIImage) {
self.imageView.image = image
}

func set(index: Int) {
self.label.text = "\(index)"
}
}
22 changes: 22 additions & 0 deletions Example/StoriesLayout/MySafariCollectionViewCell.xib
Expand Up @@ -22,18 +22,40 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ewh-vA-xdU">
<rect key="frame" x="0.0" y="0.0" width="434" height="347"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mme-XX-0QY">
<rect key="frame" x="0.0" y="0.0" width="434" height="37"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zWr-AN-thc">
<rect key="frame" x="16" y="8" width="402" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.10000000000000001" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="zWr-AN-thc" secondAttribute="bottom" constant="8" id="L3s-A8-9fl"/>
<constraint firstItem="zWr-AN-thc" firstAttribute="leading" secondItem="mme-XX-0QY" secondAttribute="leading" constant="16" id="NPT-tW-Obz"/>
<constraint firstAttribute="trailing" secondItem="zWr-AN-thc" secondAttribute="trailing" constant="16" id="eHD-wY-dar"/>
<constraint firstItem="zWr-AN-thc" firstAttribute="top" secondItem="mme-XX-0QY" secondAttribute="top" constant="8" id="yDw-ni-5b4"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstItem="mme-XX-0QY" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="2Lr-WA-qXc"/>
<constraint firstItem="ewh-vA-xdU" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="FiF-K9-8en"/>
<constraint firstAttribute="bottom" secondItem="ewh-vA-xdU" secondAttribute="bottom" id="dA4-my-KTd"/>
<constraint firstAttribute="trailing" secondItem="mme-XX-0QY" secondAttribute="trailing" id="dWH-Ut-k5A"/>
<constraint firstAttribute="trailing" secondItem="ewh-vA-xdU" secondAttribute="trailing" id="fdq-AP-Qmc"/>
<constraint firstItem="ewh-vA-xdU" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="ll1-MB-GRr"/>
<constraint firstItem="mme-XX-0QY" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="pQl-TY-p61"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ZTg-uK-7eu"/>
<size key="customSize" width="434" height="347"/>
<connections>
<outlet property="imageView" destination="ewh-vA-xdU" id="ad1-5p-hJJ"/>
<outlet property="label" destination="zWr-AN-thc" id="jQv-Br-NEP"/>
</connections>
<point key="canvasLocation" x="415.94202898550731" y="252.79017857142856"/>
</collectionViewCell>
Expand Down
5 changes: 5 additions & 0 deletions Example/StoriesLayout/MyStoriesCollectionViewCell.swift
Expand Up @@ -18,6 +18,7 @@ class MyStoriesCollectionViewCell: StoriesCollectionViewCell {
}

@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var label: UILabel!

override func prepareForReuse() {
self.imageView.image = nil
Expand All @@ -29,4 +30,8 @@ extension MyStoriesCollectionViewCell: ImageCell {
func set(image: UIImage) {
self.imageView.image = image
}

func set(index: Int) {
self.label.text = "\(index)"
}
}
25 changes: 24 additions & 1 deletion Example/StoriesLayout/MyStoriesCollectionViewCell.xib
Expand Up @@ -22,20 +22,43 @@
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Lla-HF-t3Z">
<rect key="frame" x="0.0" y="0.0" width="260" height="260"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Spo-n0-upp">
<rect key="frame" x="0.0" y="0.0" width="260" height="37"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UuF-td-PnK">
<rect key="frame" x="16" y="8" width="228" height="21"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="highlightedColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.10000000000000001" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="UuF-td-PnK" firstAttribute="leading" secondItem="Spo-n0-upp" secondAttribute="leading" constant="16" id="3OH-yV-Z98"/>
<constraint firstItem="UuF-td-PnK" firstAttribute="top" secondItem="Spo-n0-upp" secondAttribute="top" constant="8" id="OI3-Rg-tKV"/>
<constraint firstAttribute="bottom" secondItem="UuF-td-PnK" secondAttribute="bottom" constant="8" id="OX7-sb-fgY"/>
<constraint firstAttribute="trailing" secondItem="UuF-td-PnK" secondAttribute="trailing" constant="16" id="VJ3-ix-vUG"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="bottom" secondItem="Lla-HF-t3Z" secondAttribute="bottom" id="2WZ-12-cho"/>
<constraint firstAttribute="trailing" secondItem="Lla-HF-t3Z" secondAttribute="trailing" id="6BG-Fq-av4"/>
<constraint firstItem="Spo-n0-upp" firstAttribute="leading" secondItem="nyV-vw-zis" secondAttribute="leading" id="6WY-c0-lee"/>
<constraint firstItem="Lla-HF-t3Z" firstAttribute="leading" secondItem="nyV-vw-zis" secondAttribute="leading" id="bcH-zD-Mbg"/>
<constraint firstItem="Spo-n0-upp" firstAttribute="top" secondItem="nyV-vw-zis" secondAttribute="top" id="c65-YC-9EG"/>
<constraint firstItem="Lla-HF-t3Z" firstAttribute="top" secondItem="nyV-vw-zis" secondAttribute="top" id="fcf-p0-5X0"/>
<constraint firstAttribute="trailing" secondItem="Spo-n0-upp" secondAttribute="trailing" id="yfj-fs-wVX"/>
</constraints>
<viewLayoutGuide key="safeArea" id="iUZ-J7-d69"/>
<size key="customSize" width="260" height="260"/>
<connections>
<outlet property="imageView" destination="Lla-HF-t3Z" id="ouw-mq-Z32"/>
<outlet property="label" destination="UuF-td-PnK" id="8v3-IU-KHa"/>
</connections>
<point key="canvasLocation" x="136" y="75"/>
<point key="canvasLocation" x="134.78260869565219" y="75"/>
</collectionViewCell>
</objects>
</document>
2 changes: 2 additions & 0 deletions Example/StoriesLayout/ViewModels/ImageViewModel.swift
Expand Up @@ -13,6 +13,7 @@ import StoriesLayout
protocol ImageCell {

func set(image: UIImage)
func set(index: Int)
}

struct ImageViewModel: ItemViewModel {
Expand All @@ -32,5 +33,6 @@ struct ImageViewModel: ItemViewModel {
func setup(_ view: UIView, in containerView: UIView, at indexPath: IndexPath) {
guard let image = image else { return }
(view as? ImageCell)?.set(image: image)
(view as? ImageCell)?.set(index: indexPath.item)
}
}

0 comments on commit ef34aac

Please sign in to comment.