-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShotHeroTableViewCell.swift
58 lines (47 loc) · 1.48 KB
/
ShotHeroTableViewCell.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
//
// ShotHeroTableViewCell.swift
// Swish
//
// Created by Andrew Ervin Gierke on 4/21/17.
// Copyright © 2017 And. All rights reserved.
//
import UIKit
class ShotHeroTableViewCell: UITableViewCell {
//MARK: - Properties
var shot: Shot? {
didSet {
updateViews()
}
}
//MARK: - Outlets
@IBOutlet weak var shotImageView: UIImageView!
@IBOutlet weak var heroTopConstraint: NSLayoutConstraint!
//MARK: - Actions
//MARK: - View lifecycle
override func awakeFromNib() {
super.awakeFromNib()
backgroundColor = Colors.backgroundGray
}
//MARK: - Helpers
func updateViews() {
guard let shot = shot else { return }
if shot.largeImage != nil {
self.shotImageView.image = shot.largeImage
} else {
if shot.hiDpiImageURL == nil {
ImageController.image(forURL: shot.normalImageURL, completion: { (image) in
DispatchQueue.main.async {
self.shotImageView.image = image
}
})
} else {
guard let hiDpiImageURL = shot.hiDpiImageURL else { return }
ImageController.image(forURL: hiDpiImageURL, completion: { (image) in
DispatchQueue.main.async {
self.shotImageView.image = image
}
})
}
}
}
}