Files
suixinkan_uikit/suixinkan/UI/Orders/Views/OrderInfoRowView.swift

47 lines
1.5 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// OrderInfoRowView.swift
// suixinkan
//
import SnapKit
import UIKit
/// key-value Android InfoRow
final class OrderInfoRowView: UIView {
private let titleLabel = UILabel()
private let valueLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
titleLabel.font = .app(.body)
titleLabel.textColor = OrderTokens.label563
valueLabel.font = .systemFont(ofSize: 14, weight: .medium)
valueLabel.textColor = OrderTokens.valueBlack
valueLabel.textAlignment = .right
valueLabel.numberOfLines = 0
addSubview(titleLabel)
addSubview(valueLabel)
titleLabel.snp.makeConstraints { make in
make.leading.top.bottom.equalToSuperview()
make.width.lessThanOrEqualToSuperview().multipliedBy(0.45)
}
valueLabel.snp.makeConstraints { make in
make.trailing.top.bottom.equalToSuperview()
make.leading.greaterThanOrEqualTo(titleLabel.snp.trailing).offset(AppSpacing.xs)
}
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func apply(title: String, value: String, valueColor: UIColor = OrderTokens.valueBlack, usesPrimaryValue: Bool = false) {
titleLabel.text = "\(title)"
valueLabel.text = value
valueLabel.textColor = usesPrimaryValue ? AppColor.primary : valueColor
}
}