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

50 lines
1.4 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.

//
// OrderActionButton.swift
// suixinkan
//
import SnapKit
import UIKit
/// Android `AppButton`
final class OrderActionButton: UIButton {
enum Style {
case destructiveLight
case primaryFilled
case primaryLight
case dangerFilled
}
init(title: String, style: Style) {
super.init(frame: .zero)
setTitle(title, for: .normal)
titleLabel?.font = .app(.subtitle)
layer.cornerRadius = AppRadius.sm
clipsToBounds = true
switch style {
case .destructiveLight:
setTitleColor(AppColor.danger, for: .normal)
backgroundColor = AppColor.dangerBackground
case .primaryFilled:
setTitleColor(.white, for: .normal)
backgroundColor = AppColor.primary
case .primaryLight:
setTitleColor(AppColor.primary, for: .normal)
backgroundColor = OrderTokens.chipBackground
layer.cornerRadius = AppRadius.lg
case .dangerFilled:
setTitleColor(.white, for: .normal)
backgroundColor = AppColor.danger
}
snp.makeConstraints { make in
make.height.equalTo(OrderTokens.actionButtonHeight)
}
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}