-
Notifications
You must be signed in to change notification settings - Fork 1
/
ShiftTableViewCell.swift
52 lines (44 loc) · 1.18 KB
/
ShiftTableViewCell.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
//
// ShiftTableViewCell.swift
// Where2Help
//
// Created by Aaron Cruz on 4/7/16.
// Copyright © 2016 Where2Help. All rights reserved.
//
import UIKit
class ShiftTableViewCell: UITableViewCell {
@IBOutlet weak var timeLabel: UILabel!
@IBOutlet weak var countLabel: UILabel!
var shift: Shift!
var event: Event!
var shiftPresenter: ShiftPresenter!
override func awakeFromNib() {
super.awakeFromNib()
}
func setShift(shift: Shift) {
self.shift = shift
self.shiftPresenter = ShiftPresenter(shift: shift)
updateCellContent()
}
private func updateCellContent() {
if shift.currentUserAssigned.boolValue {
countLabel.backgroundColor = Theme.youreInColor()
}
else if shift.volunteersCount >= shift.volunteersNeeded {
countLabel.backgroundColor = Theme.optOutColor()
}
else {
countLabel.backgroundColor = Theme.availableColor()
}
countLabel.text = shiftPresenter.volunteersOutOfLabelText()
timeLabel.text = shiftPresenter.timespanLabelText()
}
override func setSelected(selected: Bool, animated: Bool) {
}
deinit {
print("De-init Shift cell")
shift = nil
event = nil
shiftPresenter = nil
}
}