-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShotDesignerTableViewCell.swift
62 lines (45 loc) · 1.57 KB
/
ShotDesignerTableViewCell.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
60
61
62
//
// ShotDesignerTableViewCell.swift
// Swish
//
// Created by Andrew Ervin Gierke on 4/21/17.
// Copyright © 2017 And. All rights reserved.
//
import UIKit
class ShotDesignerTableViewCell: UITableViewCell {
//MARK: - Properties
var shot: Shot? {
didSet {
updateViews()
}
}
//MARK: - Outlets
@IBOutlet weak var designerAvatarImageView: UIImageView!
@IBOutlet weak var designerNameLabel: UILabel!
@IBOutlet weak var designerBiolabel: UILabel!
//MARK: - View lifecycle
override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = Colors.backgroundGray
}
//MARK: - Helpers
func updateViews() {
guard let shot = shot,
let designer = shot.user else { return }
if designer.userAvatar != nil {
designerAvatarImageView.image = designer.userAvatar
} else {
ImageController.image(forURL: designer.userAvatarURL) { (image) in
DispatchQueue.main.async {
self.designerAvatarImageView.image = image
}
}
}
designerAvatarImageView.layer.cornerRadius = designerAvatarImageView.frame.height/2
designerAvatarImageView.clipsToBounds = true
designerNameLabel.text = designer.userName
designerBiolabel.text = designer.bio
designerNameLabel.textColor = Colors.primaryPink
designerBiolabel.textColor = Colors.dribbbleDarkGray
}
}