//
//  ProfileStatusBadgeView.swift
//  suixinkan
//

import SnapKit
import UIKit

/// 个人信息页状态标签，内部委托 `AppStatusBadge`。
final class ProfileStatusBadgeView: UIView {

    enum Style {
        case accountActive
        case scenic
        case auditPending
        case auditApproved
        case auditRejected
        case bankPending
        case bankApproved
        case bankRejected
    }

    private let badge = AppStatusBadge()

    override init(frame: CGRect) {
        super.init(frame: frame)
        addSubview(badge)
        badge.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }

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

    func apply(style: Style, text: String) {
        switch style {
        case .accountActive:
            badge.apply(tone: .success, text: text)
        case .scenic, .auditApproved, .bankApproved:
            badge.apply(tone: .info, text: text)
        case .auditPending, .bankPending:
            badge.apply(tone: .warning, text: text)
        case .auditRejected, .bankRejected:
            badge.apply(tone: .danger, text: text)
        }
    }
}
