Skip to content

Commit 769a4e6

Browse files
author
Igors Nemenonoks
committed
Destination page
1 parent 997f063 commit 769a4e6

File tree

21 files changed

+582
-2
lines changed

21 files changed

+582
-2
lines changed

Classes/UI/DesignSystem/Cards/CardDestination/CardDestination.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ final class CardDestination: UICollectionViewCell, ConfigurableCell {
1818
v.contentMode = .scaleAspectFill
1919
v.layer.cornerRadius = 6
2020
v.clipsToBounds = true
21+
v.backgroundColor = .placeholder
2122
return v
2223
}()
2324

@@ -61,7 +62,8 @@ final class CardDestination: UICollectionViewCell, ConfigurableCell {
6162
}
6263

6364
func configure(item: CardDestinationVM) {
64-
self.imageView.kf.setImage(with: URL(string: item.imageUrl))
65+
self.imageView.kf.setImage(with: URL(string: item.imageUrl),
66+
options: [.transition(.fade(0.3))])
6567
self.titleLabel.styledText = item.title
6668
self.subtitleLabel.styledText = item.subtitle
6769
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// CardPhotoThumbnail.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import MagazineLayout
11+
12+
typealias CardPhotoThumbnailConfigurator = MagazineCellConfigurator<CardPhotoThumbnailVM, CardPhotoThumbnail>
13+
final class CardPhotoThumbnail: UICollectionViewCell, ConfigurableCell {
14+
15+
private let imageView: UIImageView = {
16+
let v = UIImageView()
17+
v.contentMode = .scaleAspectFill
18+
v.layer.cornerRadius = 6
19+
v.clipsToBounds = true
20+
v.backgroundColor = .placeholder
21+
return v
22+
}()
23+
24+
override init(frame: CGRect) {
25+
super.init(frame: frame)
26+
27+
self.contentView.addSubview(imageView)
28+
imageView.snp.makeConstraints {
29+
$0.edges.equalToSuperview()
30+
}
31+
}
32+
33+
required init?(coder: NSCoder) {
34+
fatalError("init(coder:) has not been implemented")
35+
}
36+
37+
func configure(item: CardPhotoThumbnailVM) {
38+
self.imageView.kf.setImage(with: URL(string: item.url),
39+
options: [.transition(.fade(0.3))])
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// CardPhotoThumbnailVM.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import MagazineLayout
11+
import RxFlow
12+
import RxSwift
13+
import RxCocoa
14+
15+
struct CardPhotoThumbnailVM: MagazineCellDataType {
16+
17+
var sizeMode: MagazineLayoutItemSizeMode {
18+
return MagazineLayoutItemSizeMode(widthMode: .thirdWidth,
19+
heightMode: .static(height: 120))
20+
}
21+
22+
let url: String
23+
24+
init(url: String) {
25+
self.url = url
26+
}
27+
28+
var diffHash: Int {
29+
return url.hashValue
30+
}
31+
32+
func configurator() -> CellConfigurator {
33+
return CardPhotoThumbnailConfigurator(item: self)
34+
}
35+
36+
func didSelect() {
37+
//
38+
}
39+
}
40+

Classes/UI/DesignSystem/Colors/UIColor+Styles.swift

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ extension UIColor {
1818
return UIColor.color(with: "#888888")
1919
}
2020

21+
class var placeholder: UIColor {
22+
return UIColor.color(with: "#EFEFEF")
23+
}
24+
2125
class func color(with hex: String) -> UIColor {
2226
var hexFormatted: String = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()
2327

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// HeaderHeadline2.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import RxSwift
11+
import RxCocoa
12+
13+
typealias HeaderHeadline2Configurator = MagazineSupplementaryCellConfigurator<HeaderHeadline2VM, HeaderHeadline2>
14+
15+
final class HeaderHeadline2: UICollectionReusableView, ConfigurableCell {
16+
17+
private let textLabel: UILabel = {
18+
let label = UILabel(frame: .zero)
19+
label.bonMotStyle = Typography.Headline2
20+
label.numberOfLines = 0
21+
label.textColor = .mainText
22+
return label
23+
}()
24+
25+
override init(frame: CGRect) {
26+
super.init(frame: frame)
27+
28+
self.addSubview(textLabel)
29+
textLabel.snp.makeConstraints {
30+
$0.leading.trailing.equalToSuperview()
31+
$0.top.bottom.equalToSuperview().inset(8)
32+
}
33+
}
34+
35+
required init?(coder: NSCoder) {
36+
fatalError("init(coder:) has not been implemented")
37+
}
38+
39+
func configure(item: HeaderHeadline2VM) {
40+
textLabel.styledText = item.title
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// HeaderHeadline2VM.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import MagazineLayout
11+
import RxFlow
12+
import RxSwift
13+
import RxCocoa
14+
15+
struct HeaderHeadline2VM: MagazineSupplementaryDataType {
16+
17+
let heightMode: MagazineLayoutHeaderHeightMode = .dynamic
18+
19+
let title: String
20+
21+
init(title: String) {
22+
self.title = title
23+
}
24+
25+
var diffHash: Int {
26+
return title.hashValue
27+
}
28+
29+
func configurator() -> SupplementaryCellConfigurator {
30+
return HeaderHeadline2Configurator(item: self)
31+
}
32+
}
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// RowDestinationTitle.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import MagazineLayout
11+
import RxSwift
12+
13+
typealias RowDestinationTitleConfigurator = MagazineCellConfigurator<RowDestinationTitleVM, RowDestinationTitle>
14+
final class RowDestinationTitle: MagazineLayoutCollectionViewCell, ConfigurableCell {
15+
16+
static var nib: UINib? { return UINib(nibName: self.reuseIdentifier, bundle: nil) }
17+
18+
@IBOutlet weak var textLabel: UILabel!
19+
@IBOutlet weak var likeButton: UIButton!
20+
21+
private var bag = DisposeBag()
22+
23+
func configure(item: RowDestinationTitleVM) {
24+
self.textLabel.styledText = item.title
25+
26+
likeButton.rx.tap.scan(false) { lastState, newValue in
27+
return !lastState
28+
}
29+
.bind(to: self.likeButton.rx.isSelected)
30+
.disposed(by: bag)
31+
}
32+
33+
override func prepareForReuse() {
34+
super.prepareForReuse()
35+
self.bag = DisposeBag()
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
4+
<dependencies>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
7+
<capability name="collection view cell content view" minToolsVersion="11.0"/>
8+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9+
</dependencies>
10+
<objects>
11+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
12+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
13+
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="PDv-99-STU" customClass="RowDestinationTitle" customModule="DesignSystemExample" customModuleProvider="target">
14+
<rect key="frame" x="0.0" y="0.0" width="320" height="72"/>
15+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
16+
<collectionViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="DbH-mn-8EK">
17+
<rect key="frame" x="0.0" y="0.0" width="320" height="72"/>
18+
<autoresizingMask key="autoresizingMask"/>
19+
<subviews>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ico_star" translatesAutoresizingMaskIntoConstraints="NO" id="S2r-6K-r1V">
21+
<rect key="frame" x="0.0" y="2" width="14" height="14"/>
22+
</imageView>
23+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Popular destination" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="CAi-u2-bhr">
24+
<rect key="frame" x="22" y="0.0" width="132.5" height="18"/>
25+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
26+
<color key="textColor" red="1" green="0.47058823529411764" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
27+
<nil key="highlightedColor"/>
28+
<userDefinedRuntimeAttributes>
29+
<userDefinedRuntimeAttribute type="string" keyPath="bonMotStyleName" value="Caption"/>
30+
</userDefinedRuntimeAttributes>
31+
</label>
32+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="top" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vym-b4-Suo">
33+
<rect key="frame" x="240" y="0.0" width="40" height="40"/>
34+
<constraints>
35+
<constraint firstAttribute="height" constant="40" id="GwP-Aw-CEF"/>
36+
<constraint firstAttribute="width" constant="40" id="vyk-1E-9hV"/>
37+
</constraints>
38+
<color key="tintColor" red="1" green="0.47058823529999999" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
39+
<state key="normal" image="ico_heart"/>
40+
<state key="selected" image="ico_heart_filled"/>
41+
</button>
42+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="top" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZCm-U5-8uV">
43+
<rect key="frame" x="280" y="0.0" width="40" height="40"/>
44+
<constraints>
45+
<constraint firstAttribute="height" constant="40" id="oDi-Kj-Icc"/>
46+
<constraint firstAttribute="width" constant="40" id="pAu-63-Y5o"/>
47+
</constraints>
48+
<state key="normal" image="ico_share"/>
49+
</button>
50+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jqq-P8-BgA">
51+
<rect key="frame" x="0.0" y="22" width="320" height="43"/>
52+
<fontDescription key="fontDescription" type="system" pointSize="36"/>
53+
<nil key="textColor"/>
54+
<nil key="highlightedColor"/>
55+
<userDefinedRuntimeAttributes>
56+
<userDefinedRuntimeAttribute type="string" keyPath="bonMotStyleName" value="Headline1"/>
57+
</userDefinedRuntimeAttributes>
58+
</label>
59+
</subviews>
60+
<constraints>
61+
<constraint firstItem="S2r-6K-r1V" firstAttribute="leading" secondItem="DbH-mn-8EK" secondAttribute="leading" id="1fW-su-j4F"/>
62+
<constraint firstAttribute="trailing" secondItem="Jqq-P8-BgA" secondAttribute="trailing" id="7oA-eH-MAL"/>
63+
<constraint firstAttribute="trailing" secondItem="ZCm-U5-8uV" secondAttribute="trailing" id="AmT-9n-J8t"/>
64+
<constraint firstItem="CAi-u2-bhr" firstAttribute="top" secondItem="DbH-mn-8EK" secondAttribute="top" id="EG9-gg-uUI"/>
65+
<constraint firstItem="Jqq-P8-BgA" firstAttribute="top" secondItem="CAi-u2-bhr" secondAttribute="bottom" constant="4" id="GrL-e0-fL4"/>
66+
<constraint firstItem="CAi-u2-bhr" firstAttribute="leading" secondItem="S2r-6K-r1V" secondAttribute="trailing" constant="8" id="OCZ-x0-xXZ"/>
67+
<constraint firstItem="Vym-b4-Suo" firstAttribute="top" secondItem="DbH-mn-8EK" secondAttribute="top" id="S8V-qd-bHz"/>
68+
<constraint firstItem="S2r-6K-r1V" firstAttribute="centerY" secondItem="CAi-u2-bhr" secondAttribute="centerY" id="VDL-JT-Bs6"/>
69+
<constraint firstItem="ZCm-U5-8uV" firstAttribute="leading" secondItem="Vym-b4-Suo" secondAttribute="trailing" id="Xa4-go-bRm"/>
70+
<constraint firstItem="Jqq-P8-BgA" firstAttribute="leading" secondItem="DbH-mn-8EK" secondAttribute="leading" id="nja-SQ-hvl"/>
71+
<constraint firstItem="ZCm-U5-8uV" firstAttribute="top" secondItem="DbH-mn-8EK" secondAttribute="top" id="xP9-V4-BFn"/>
72+
</constraints>
73+
</collectionViewCellContentView>
74+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
75+
<size key="customSize" width="320" height="72"/>
76+
<connections>
77+
<outlet property="likeButton" destination="Vym-b4-Suo" id="O4F-dd-Lu8"/>
78+
<outlet property="textLabel" destination="Jqq-P8-BgA" id="vPG-Gq-g67"/>
79+
</connections>
80+
<point key="canvasLocation" x="253.62318840579712" y="-139.95535714285714"/>
81+
</collectionViewCell>
82+
</objects>
83+
<resources>
84+
<image name="ico_heart" width="25" height="25"/>
85+
<image name="ico_heart_filled" width="25" height="25"/>
86+
<image name="ico_share" width="25" height="25"/>
87+
<image name="ico_star" width="14" height="14"/>
88+
</resources>
89+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// RowDestinationTitleVM.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import MagazineLayout
11+
import RxFlow
12+
import RxSwift
13+
import RxCocoa
14+
15+
final class RowDestinationTitleVM: MagazineCellDataType {
16+
17+
var sizeMode: MagazineLayoutItemSizeMode {
18+
return MagazineLayoutItemSizeMode(widthMode: .fullWidth(respectsHorizontalInsets: true),
19+
heightMode: .static(height: 72))
20+
}
21+
22+
let title: String
23+
24+
init(title: String) {
25+
self.title = title
26+
}
27+
28+
var diffHash: Int {
29+
return title.hashValue
30+
}
31+
32+
func configurator() -> CellConfigurator {
33+
return RowDestinationTitleConfigurator(item: self)
34+
}
35+
36+
func didSelect() {
37+
//
38+
}
39+
}
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// RowText.swift
3+
// Chili Labs
4+
//
5+
// Generated by Chigevara on 14/05/2020.
6+
// Copyright © 2020 Chili Labs. All rights reserved.
7+
//
8+
9+
import UIKit
10+
import MagazineLayout
11+
12+
typealias RowTextConfigurator = MagazineCellConfigurator<RowTextVM, RowText>
13+
final class RowText: MagazineLayoutCollectionViewCell, ConfigurableCell {
14+
15+
private let textLabel: UILabel = {
16+
let label = UILabel(frame: .zero)
17+
label.bonMotStyle = Typography.Text
18+
label.numberOfLines = 0
19+
label.textColor = .captionText
20+
return label
21+
}()
22+
23+
override init(frame: CGRect) {
24+
super.init(frame: frame)
25+
26+
self.contentView.addSubview(textLabel)
27+
textLabel.snp.makeConstraints {
28+
$0.leading.trailing.equalToSuperview()
29+
$0.top.bottom.equalToSuperview()
30+
}
31+
}
32+
33+
required init?(coder: NSCoder) {
34+
fatalError("init(coder:) has not been implemented")
35+
}
36+
37+
func configure(item: RowTextVM) {
38+
textLabel.styledText = item.text
39+
}
40+
}

0 commit comments

Comments
 (0)