MastoSearch/MastoSearchMobile/StatusTableHeaderView.swift

76 lines
3.2 KiB
Swift
Raw Normal View History

2022-07-03 23:00:17 +00:00
//
// StatusTableHeaderView.swift
// MastoSearchMobile
//
// Created by Shadowfacts on 7/3/22.
//
import UIKit
class StatusTableHeaderView: UICollectionReusableView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .systemBackground
let dateLabel = UILabel()
dateLabel.text = "Date"
dateLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .callout).withSymbolicTraits(.traitBold)!, size: 0)
dateLabel.textColor = .tintColor
dateLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(dateLabel)
let contentWarningLabel = UILabel()
contentWarningLabel.text = "Content Warning"
contentWarningLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .callout).withSymbolicTraits(.traitBold)!, size: 0)
contentWarningLabel.textColor = .tintColor
contentWarningLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentWarningLabel)
let contentLabel = UILabel()
contentLabel.text = "Content"
contentLabel.font = UIFont(descriptor: .preferredFontDescriptor(withTextStyle: .callout).withSymbolicTraits(.traitBold)!, size: 0)
contentLabel.textColor = .tintColor
contentLabel.translatesAutoresizingMaskIntoConstraints = false
addSubview(contentLabel)
let fakeDateLabel = UILabel()
fakeDateLabel.text = "07/03/2022, 02:31 PM"
fakeDateLabel.translatesAutoresizingMaskIntoConstraints = false
fakeDateLabel.font = .monospacedDigitSystemFont(ofSize: 17, weight: .regular)
fakeDateLabel.isHidden = true
addSubview(fakeDateLabel)
let separator = UIView()
separator.backgroundColor = .separator
separator.translatesAutoresizingMaskIntoConstraints = false
addSubview(separator)
NSLayoutConstraint.activate([
dateLabel.leadingAnchor.constraint(equalToSystemSpacingAfter: leadingAnchor, multiplier: 2),
dateLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
fakeDateLabel.leadingAnchor.constraint(equalToSystemSpacingAfter: leadingAnchor, multiplier: 2),
fakeDateLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
contentWarningLabel.leadingAnchor.constraint(equalToSystemSpacingAfter: fakeDateLabel.trailingAnchor, multiplier: 2),
contentWarningLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
contentLabel.leadingAnchor.constraint(equalToSystemSpacingAfter: centerXAnchor, multiplier: 1),
contentLabel.centerYAnchor.constraint(equalTo: centerYAnchor),
separator.leadingAnchor.constraint(equalTo: leadingAnchor),
separator.trailingAnchor.constraint(equalTo: trailingAnchor),
separator.bottomAnchor.constraint(equalTo: bottomAnchor),
separator.heightAnchor.constraint(equalToConstant: 0.5),
heightAnchor.constraint(greaterThanOrEqualToConstant: 32),
])
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}