-
-
Notifications
You must be signed in to change notification settings - Fork 298
Expand file tree
/
Copy pathPickServerMessageTableViewCell.swift
More file actions
73 lines (58 loc) · 2.09 KB
/
PickServerMessageTableViewCell.swift
File metadata and controls
73 lines (58 loc) · 2.09 KB
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
//
// PickServerMessageTableViewCell.swift
// Mastodon
//
// Created by MainasuK Cirno on 2021-5-13.
//
import UIKit
import Combine
import MastodonAsset
import MastodonCore
import MastodonUI
import MastodonLocalization
public final class PickServerMessageTableViewCell: UITableViewCell {
let messageLabel: UILabel = {
let label = UILabel()
label.textColor = Asset.Colors.Label.secondary.color
label.textAlignment = .center
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 14, weight: .semibold))
label.numberOfLines = 0
return label
}()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
_init()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
_init()
}
}
extension PickServerMessageTableViewCell {
public func _init() {
selectionStyle = .none
backgroundColor = .clear
messageLabel.translatesAutoresizingMaskIntoConstraints = false
messageLabel.setContentCompressionResistancePriority(.required, for: .vertical)
contentView.addSubview(messageLabel)
NSLayoutConstraint.activate([
messageLabel.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
contentView.readableContentGuide.trailingAnchor.constraint(equalTo: messageLabel.trailingAnchor),
messageLabel.topAnchor.constraint(equalTo: contentView.layoutMarginsGuide.topAnchor),
messageLabel.bottomAnchor.constraint(equalTo: contentView.layoutMarginsGuide.bottomAnchor),
])
}
}
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct PickServerMessageTableViewCell_Previews: PreviewProvider {
static var previews: some View {
UIViewPreview(width: 375) {
let view = PickServerMessageTableViewCell()
view.messageLabel.text = "Hello, world!"
return view
}
.previewLayout(.fixed(width: 375, height: 100))
}
}
#endif