-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
PRRow.swift
36 lines (26 loc) · 1.13 KB
/
PRRow.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
import WatchKit
final class PRRow: NSObject {
@IBOutlet private var titleL: WKInterfaceLabel!
@IBOutlet private var detailsL: WKInterfaceLabel!
@IBOutlet private var totalCommentsL: WKInterfaceLabel!
@IBOutlet private var totalCommentsGroup: WKInterfaceGroup!
@IBOutlet private var unreadCommentsL: WKInterfaceLabel!
@IBOutlet private var unreadCommentsGroup: WKInterfaceGroup!
@IBOutlet private var counterGroup: WKInterfaceGroup!
var itemId: String?
var hasUnread: Bool!
func populate(from itemData: [AnyHashable: Any]) {
let title = itemData["title"] as! NSAttributedString
titleL.setAttributedText(title)
let subtitle = itemData["subtitle"] as! NSAttributedString
detailsL.setAttributedText(subtitle)
itemId = itemData["localId"] as? String
let c = itemData["commentCount"] as? Int ?? 0
totalCommentsL.setText(String(c))
totalCommentsGroup.setHidden(c == 0)
let u = itemData["unreadCount"] as? Int ?? 0
unreadCommentsL.setText(String(u))
unreadCommentsGroup.setHidden(u == 0)
hasUnread = u > 0
}
}