-
Notifications
You must be signed in to change notification settings - Fork 5
/
ListCollectionViewCell.swift
56 lines (46 loc) · 2.11 KB
/
ListCollectionViewCell.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
//
// ListCollectionViewCell.swift
//
// Made with ❤️ by Novum
//
// Copyright © Telefonica. All rights reserved.
//
import UIKit
open class ListCollectionViewCell: UICollectionViewCell {
public var listCellContentView = ListCellContentView()
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
@available(*, unavailable)
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func commonInit() {
layoutViews()
}
func layoutViews() {
contentView.addSubview(listCellContentView, constraints: [
contentView.topAnchor.constraint(equalTo: listCellContentView.topAnchor),
contentView.trailingAnchor.constraint(equalTo: listCellContentView.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: listCellContentView.bottomAnchor),
contentView.leadingAnchor.constraint(equalTo: listCellContentView.leadingAnchor),
contentView.widthAnchor.constraint(equalToConstant: ListCellContentView.ViewStyles.cellWidth)
])
}
override public func systemLayoutSizeFitting(_ targetSize: CGSize,
withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority,
verticalFittingPriority: UILayoutPriority) -> CGSize {
let size = super.systemLayoutSizeFitting(
targetSize,
withHorizontalFittingPriority: horizontalFittingPriority,
verticalFittingPriority: verticalFittingPriority
)
return CGSize(width: size.width, height: max(size.height, listCellContentView.cellStyle.minHeight))
}
override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle else { return }
listCellContentView.cellBorderView.layer.borderColor = listCellContentView.cellStyle.borderColor
}
}