//
//  OrderTypeChipView.swift
//  suixinkan
//

import SnapKit
import UIKit

/// 订单类型标签 chip。
final class OrderTypeChipView: UIView {

    private let label = UILabel()

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = OrderTokens.chipBackground
        layer.cornerRadius = OrderTokens.pillRadius
        clipsToBounds = true

        label.font = .app(.caption)
        label.textColor = AppColor.primary
        addSubview(label)
        label.snp.makeConstraints { make in
            make.edges.equalToSuperview().inset(UIEdgeInsets(top: 0, left: AppSpacing.xxs, bottom: 0, right: AppSpacing.xxs))
        }
    }

    @available(*, unavailable)
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func apply(text: String) {
        label.text = text
        isHidden = text.isEmpty
    }
}
