Files
suixinkan_uikit/suixinkan/UI/Profile/ProfileStatusBadgeView.swift

51 lines
1.2 KiB
Swift
Raw Permalink 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.

//
// 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)
}
}
}