-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotificationCell.swift
96 lines (76 loc) · 2.81 KB
/
NotificationCell.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// NotficationBodyViewCell.swift
// ShakerNotifications
//
// Created by Andrew on 10.02.16.
// Copyright © 2016 Andrey. All rights reserved.
//
import UIKit
import TTTAttributedLabel
import Foundation
import Cartography
import SwiftyJSON
class NotificationCell: UITableViewCell {
// MARK: - Properties -
var avatarView: SKAvatarContainerView!
var footerView: SKFooterContainerView!
private(set) var descriptionView: DescriptionView!
func descriptionViewClass() -> DescriptionView.Type {
return DescriptionView.self
}
// MARK: - Initialization -
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.setUpViews()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setUpViews()
}
override func prepareForReuse() {
super.prepareForReuse()
}
private func reset() {
self.selectionStyle = UITableViewCellSelectionStyle.None
self.descriptionView.reset()
self.avatarView.reset()
self.footerView.reset()
}
private func commonInit() {
self.setUpViews()
self.reset()
}
func reload(data: SKBaseActivities) {
self.reset()
self.avatarView.reload(data)
self.footerView.reload(data)
self.descriptionView.reload(data)
}
/*
Настройка контейнеров для аватара, описания и
футера
Настройка constraints
*/
private func setUpViews() {
self.clipsToBounds = true
self.avatarView = SKAvatarContainerView()
self.footerView = SKFooterContainerView()
self.descriptionView = self.descriptionViewClass().init()
self.contentView.addSubview(self.avatarView)
self.contentView.addSubview(self.footerView)
self.contentView.addSubview(self.descriptionView)
constrain(avatarView, footerView, descriptionView) { avatarView, footerView, descriptionView in
guard let superview = avatarView.superview else { return }
avatarView.left == superview.left + 10
avatarView.top == superview.top + 10
avatarView.bottom == superview.bottom
descriptionView.top == superview.top + 10
descriptionView.bottom <= footerView.top - 10
descriptionView.left == avatarView.right + 10
descriptionView.right == superview.right - 10 ~ 751
footerView.bottom == superview.bottom - 10
footerView.left == avatarView.right + 10
footerView.right == superview.right - 10 ~ 751
}
}
}