-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBookmarksCell.swift
59 lines (46 loc) · 2.13 KB
/
BookmarksCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// BookmarksCell.swift
// Sigma
//
// Created by Vinicius Mangueira on 08/09/19.
// Copyright © 2019 Vinicius Mangueira. All rights reserved.
//
import UIKit
class BookmarksCell: UICollectionViewCell, ConfigurableView, Reusable {
let trailImage: UIImageView = {
let image = RoundableImage(frame: .zero)
image.image = UIImage(named: "gallery")
image.translatesAutoresizingMaskIntoConstraints = false
image.widthAnchor.constraint(equalToConstant: 65).isActive = true
return image
}()
let trailName = UILabel(text: "Swift Basic", textColor: .white, font: nil, numberOfLines: nil, lineBreakMode: nil)
let trailPublisher = UILabel(text: "Published by: @Chris Lattner", textColor: .lightGray, font: nil, numberOfLines: nil, lineBreakMode: nil)
override init(frame: CGRect) {
super.init(frame: frame)
buildViewHierarchy()
setupConstraints()
self.backgroundColor = UIColor(named: "Subackground")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func buildViewHierarchy() {
addSubviews([ trailImage,trailName, trailPublisher ])
}
func setupConstraints() {
NSLayoutConstraint.activate([
trailImage.topAnchor.constraint(equalTo: self.topAnchor, constant: 5),
trailImage.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 10),
trailImage.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -5),
trailName.leadingAnchor.constraint(equalTo: trailImage.trailingAnchor, constant: 20),
trailName.topAnchor.constraint(equalTo: trailImage.topAnchor, constant: 5),
trailPublisher.topAnchor.constraint(equalTo: trailName.bottomAnchor, constant: 5),
trailPublisher.leadingAnchor.constraint(equalTo: trailName.leadingAnchor)
])
}
func setup(viewModel: BookmarkCellViewModel) {
trailName.text = viewModel.favoritePost?.title
trailPublisher.text = "Published by: @ Shichibukais"
}
}