80 lines
2.4 KiB
Swift
80 lines
2.4 KiB
Swift
//
|
|
// PrivilegeDeniedOverlay.swift
|
|
// QuickLocation
|
|
//
|
|
|
|
import UIKit
|
|
|
|
final class PrivilegeDeniedOverlay: UIView {
|
|
|
|
var onAction: (() -> Void)?
|
|
|
|
private let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .light))
|
|
private let dimView = UIView()
|
|
private let titleLab = UILabel()
|
|
private let messageLab = UILabel()
|
|
private let actionBtn = UIButton(type: .custom)
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
isHidden = true
|
|
clipsToBounds = true
|
|
|
|
blurView.isUserInteractionEnabled = false
|
|
addSubview(blurView)
|
|
blurView.layoutChain.edges()
|
|
|
|
dimView.backgroundColor = UIColor.white.withAlphaComponent(0.45)
|
|
dimView.isUserInteractionEnabled = false
|
|
addSubview(dimView)
|
|
dimView.layoutChain.edges()
|
|
|
|
titleLab.font = .systemFont(ofSize: 16, weight: .semibold)
|
|
titleLab.textColor = UIColor(hexStr: "#293445")
|
|
titleLab.textAlignment = .center
|
|
addSubview(titleLab)
|
|
|
|
messageLab.font = .systemFont(ofSize: 16, weight: .semibold)
|
|
messageLab.textColor = UIColor(hexStr: "#293445")
|
|
messageLab.textAlignment = .center
|
|
addSubview(messageLab)
|
|
|
|
actionBtn.titleLabel?.font = .systemFont(ofSize: 16, weight: .semibold)
|
|
actionBtn.setTitleColor(.white, for: .normal)
|
|
actionBtn.backgroundColor = UIColor(hexStr: "#16B3FF")
|
|
actionBtn.cornerRadius = 10
|
|
actionBtn.addTarget(self, action: #selector(tapAction), for: .touchUpInside)
|
|
addSubview(actionBtn)
|
|
|
|
titleLab.layoutChain.centerX()
|
|
titleLab.centerYAnchor.constraint(equalTo: centerYAnchor, constant: -28).isActive = true
|
|
messageLab.layoutChain
|
|
.topToBottomOfView(titleLab, offset: 6)
|
|
.centerX()
|
|
actionBtn.layoutChain
|
|
.topToBottomOfView(messageLab, offset: 16)
|
|
.centerX()
|
|
.width(160)
|
|
.height(44)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
func configure(title: String, message: String, actionTitle: String) {
|
|
titleLab.text = title
|
|
messageLab.text = message
|
|
actionBtn.setTitle(actionTitle, for: .normal)
|
|
}
|
|
|
|
func setVisible(_ visible: Bool) {
|
|
isHidden = !visible
|
|
isUserInteractionEnabled = visible
|
|
}
|
|
|
|
@objc private func tapAction() {
|
|
onAction?()
|
|
}
|
|
}
|