Skip to content

Commit

Permalink
Improve and simplify sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcginty committed Dec 1, 2021
1 parent 9aeacf9 commit a26869c
Show file tree
Hide file tree
Showing 27 changed files with 615 additions and 704 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
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"
96 changes: 26 additions & 70 deletions Examples/UtiliKit-iOSExample/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

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
}
}
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>
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
}
}
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
}
}
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
}
}
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
}
}
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
}
}
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>
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
}
}
Loading

0 comments on commit a26869c

Please sign in to comment.