mastodon-app-ufficiale-ipho.../Mastodon/Scene/Report/Share/Cell/ReportHeadlineTableViewCell...

70 lines
2.2 KiB
Swift

//
// ReportHeadlineTableViewCell.swift
// Mastodon
//
// Created by MainasuK on 2022-2-7.
//
import UIKit
import MastodonAsset
import MastodonLocalization
final class ReportHeadlineTableViewCell: UITableViewCell {
let primaryLabel: UILabel = {
let label = UILabel()
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 28, weight: .bold))
label.textColor = Asset.Colors.Label.primary.color
label.text = L10n.Scene.Report.content1
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 0
return label
}()
let secondaryLabel: UILabel = {
let label = UILabel()
label.font = UIFontMetrics(forTextStyle: .largeTitle).scaledFont(for: .systemFont(ofSize: 17, weight: .regular))
label.textColor = Asset.Colors.Label.secondary.color
label.text = L10n.Scene.Report.step1
label.adjustsFontForContentSizeCategory = true
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 ReportHeadlineTableViewCell {
private func _init() {
selectionStyle = .none
backgroundColor = .clear
let container = UIStackView()
container.axis = .vertical
container.spacing = 16
container.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(container)
NSLayoutConstraint.activate([
container.topAnchor.constraint(equalTo: contentView.topAnchor),
container.leadingAnchor.constraint(equalTo: contentView.readableContentGuide.leadingAnchor),
container.trailingAnchor.constraint(equalTo: contentView.readableContentGuide.trailingAnchor),
contentView.bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: 11),
])
container.addArrangedSubview(secondaryLabel) // put secondary label before primary
container.addArrangedSubview(primaryLabel)
}
}