forked from BottleRocketStudios/iOS-UtiliKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
615 additions
and
704 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github "pointfreeco/swift-snapshot-testing" "1.5.0" | ||
github "pointfreeco/swift-snapshot-testing" "1.9.0" |
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...it-iOSExample/Collection/Cells, Supplementaries and Decorations/Cells/NibDrivenCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NibDrivenCell.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2021 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UtiliKit | ||
|
||
class NibDrivenCell: UICollectionViewCell { } | ||
|
||
// MARK: - Configurable | ||
extension NibDrivenCell: Configurable { | ||
|
||
func configure(with color: UIColor) { | ||
backgroundColor = color | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...iKit-iOSExample/Collection/Cells, Supplementaries and Decorations/Cells/NibDrivenCell.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" 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="19454"/> | ||
<capability name="collection view cell content view" minToolsVersion="11.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"/> | ||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="NibDrivenCell" id="TRG-OF-4HJ" customClass="NibDrivenCell" customModule="UtiliKit_iOSExample" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="269" height="114"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="FwA-Gr-LvN"> | ||
<rect key="frame" x="0.0" y="0.0" width="269" height="114"/> | ||
<autoresizingMask key="autoresizingMask"/> | ||
</collectionViewCellContentView> | ||
<size key="customSize" width="269" height="114"/> | ||
<point key="canvasLocation" x="187.68115942028987" y="111.16071428571428"/> | ||
</collectionViewCell> | ||
</objects> | ||
</document> |
23 changes: 23 additions & 0 deletions
23
...iOSExample/Collection/Cells, Supplementaries and Decorations/Cells/ProgrammaticCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// ProgrammaticCell.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2017 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UtiliKit | ||
|
||
class ProgrammaticCell: UICollectionViewCell { | ||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
} | ||
} | ||
|
||
// MARK: - Configurable | ||
extension ProgrammaticCell: Configurable { | ||
|
||
func configure(with color: UIColor) { | ||
backgroundColor = color | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...le/Collection/Cells, Supplementaries and Decorations/Decorations/BlueDecorationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// ColoredDecorationView.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2021 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class BlueDecorationView: UICollectionReusableView { | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
backgroundColor = .blue | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../Collection/Cells, Supplementaries and Decorations/Decorations/YellowDecorationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// YellowDecorationView.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2021 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
class YellowDecorationView: UICollectionReusableView { | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
backgroundColor = .yellow | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...ction/Cells, Supplementaries and Decorations/Supplementaries/BadgeSupplementaryView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// BadgeSupplementaryView.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2021 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UtiliKit | ||
|
||
extension UICollectionView.ElementKind { | ||
static let badge = Self(rawValue: "badge-view") | ||
} | ||
|
||
class BadgeSupplementaryView: UICollectionReusableView { | ||
|
||
private lazy var label: UILabel = { | ||
let label = UILabel() | ||
label.translatesAutoresizingMaskIntoConstraints = false | ||
label.font = UIFont.preferredFont(forTextStyle: .caption1) | ||
label.textAlignment = .center | ||
label.textColor = .white | ||
|
||
return label | ||
}() | ||
|
||
// MARK: - Initializers | ||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
configureView() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("Not implemented") | ||
} | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
configureBorder() | ||
} | ||
|
||
var text: String? { | ||
didSet { label.text = text } | ||
} | ||
|
||
override var frame: CGRect { | ||
didSet { configureBorder() } | ||
} | ||
|
||
override var bounds: CGRect { | ||
didSet { configureBorder() } | ||
} | ||
} | ||
|
||
// MARK: - Helper | ||
private extension BadgeSupplementaryView { | ||
|
||
func configureBorder() { | ||
let radius = bounds.width * 0.5 | ||
layer.cornerRadius = radius | ||
layer.borderColor = UIColor.white.cgColor | ||
layer.borderWidth = 1.0 | ||
} | ||
|
||
func configureView() { | ||
addSubview(label) | ||
NSLayoutConstraint.activate([label.centerXAnchor.constraint(equalTo: centerXAnchor), label.centerYAnchor.constraint(equalTo: centerYAnchor) ]) | ||
backgroundColor = .red | ||
} | ||
} | ||
|
||
// MARK: - Configurable | ||
extension BadgeSupplementaryView: Configurable { | ||
|
||
func configure(with text: String) { | ||
label.text = text | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...on/Cells, Supplementaries and Decorations/Supplementaries/NibDrivenHeaderFooterView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// NibDrivenHeaderFooterView.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2021 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UtiliKit | ||
|
||
class NibDrivenHeaderFooterView: UICollectionReusableView { | ||
|
||
@IBOutlet private var label: UILabel! | ||
} | ||
|
||
// MARK: - Configurable | ||
extension NibDrivenHeaderFooterView: Configurable { | ||
|
||
func configure(with text: String) { | ||
label.text = text | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...tion/Cells, Supplementaries and Decorations/Supplementaries/NibDrivenHeaderFooterView.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" 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="19454"/> | ||
<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="NibDrivenHeaderFooterView" id="XG7-fn-sJJ" customClass="NibDrivenHeaderFooterView" customModule="UtiliKit_iOSExample" customModuleProvider="target"> | ||
<rect key="frame" x="0.0" y="0.0" width="414" height="82"/> | ||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | ||
<subviews> | ||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jAc-0M-EV7"> | ||
<rect key="frame" x="186" y="52.5" width="42" height="21"/> | ||
<fontDescription key="fontDescription" type="system" pointSize="17"/> | ||
<nil key="textColor"/> | ||
<nil key="highlightedColor"/> | ||
</label> | ||
</subviews> | ||
<viewLayoutGuide key="safeArea" id="5am-b4-emA"/> | ||
<constraints> | ||
<constraint firstItem="jAc-0M-EV7" firstAttribute="centerY" secondItem="5am-b4-emA" secondAttribute="centerY" id="3lN-U9-eFd"/> | ||
<constraint firstItem="jAc-0M-EV7" firstAttribute="centerX" secondItem="5am-b4-emA" secondAttribute="centerX" id="gbz-zR-oVO"/> | ||
</constraints> | ||
<connections> | ||
<outlet property="label" destination="jAc-0M-EV7" id="ggU-ee-4d3"/> | ||
</connections> | ||
<point key="canvasLocation" x="36.231884057971016" y="92.410714285714278"/> | ||
</collectionReusableView> | ||
</objects> | ||
</document> |
40 changes: 40 additions & 0 deletions
40
...Cells, Supplementaries and Decorations/Supplementaries/ProgrammaticHeaderFooterView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// ProgrammaticHeaderFooterView.swift | ||
// UtiliKit | ||
// | ||
// Copyright © 2017 Bottle Rocket Studios. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import UtiliKit | ||
|
||
class ProgrammaticHeaderFooterView: UICollectionReusableView { | ||
|
||
private var label = UILabel() | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
initializeView() | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
super.init(coder: aDecoder) | ||
initializeView() | ||
} | ||
|
||
private func initializeView() { | ||
addSubview(label) | ||
label.textAlignment = .center | ||
|
||
label.translatesAutoresizingMaskIntoConstraints = false | ||
label.constrainEdgesToSuperview() | ||
} | ||
} | ||
|
||
// MARK: - Configurable | ||
extension ProgrammaticHeaderFooterView: Configurable { | ||
|
||
func configure(with text: String) { | ||
label.text = text | ||
} | ||
} |
Oops, something went wrong.