-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChannelTableViewCell.swift
65 lines (56 loc) · 2.5 KB
/
ChannelTableViewCell.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
63
64
65
//
// ChannelTableViewCell.swift
// SmartChannel
//
// Created by Marc Anderson on 3/5/16.
// Copyright © 2016 SmartChannel. All rights reserved.
//
import UIKit
class ChannelTableViewCell: UITableViewCell {
@IBOutlet weak var channelImageView: UIImageView!
@IBOutlet weak var channelNameLabel: UILabel!
@IBOutlet weak var channelTopicsLabel: UILabel!
var channel: Channel! {
didSet {
channelNameLabel.text = channel.title
if let thumbnail = channel.thumbnail_url {
let request = NSURLRequest(URL: NSURL(string: thumbnail)!)
channelImageView.setImageWithURLRequest(request, placeholderImage: UIImage(named: "placeholder"), success: { (request: NSURLRequest, response: NSHTTPURLResponse?, image: UIImage) -> Void in
self.channelImageView.image = image
self.channelImageView.layer.opacity = 0
UIView.transitionWithView(self.channelImageView, duration: 0.3, options: UIViewAnimationOptions.CurveEaseIn, animations: { () -> Void in
self.channelImageView.layer.opacity = 1
}, completion: { (bool: Bool) -> Void in
//
})
}, failure: { (request: NSURLRequest, response: NSHTTPURLResponse?, error: NSError) -> Void in
//
})
}
if let topics = channel.topics where topics.count > 0 {
channelTopicsLabel.text = topics.joinWithSeparator(", ")
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
channelImageView.image = UIImage(named: "placeholder")
backgroundColor = UIColor.clearColor()
channelNameLabel.textColor = Theme.Colors.HighlightColor.color
channelTopicsLabel.textColor = Theme.Colors.HighlightLightColor.color
channelImageView.layer.cornerRadius = 6
self.layoutMargins = UIEdgeInsetsZero
}
override func setHighlighted(highlighted: Bool, animated: Bool) {
if highlighted {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.contentView.backgroundColor = Theme.Colors.LightBackgroundColor.color
})
} else {
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.contentView.backgroundColor = UIColor.clearColor()
})
}
}
}