105 lines
3.3 KiB
Swift
105 lines
3.3 KiB
Swift
|
|
//
|
|||
|
|
// UnlockPriceSetDialogController.swift
|
|||
|
|
// Crush
|
|||
|
|
//
|
|||
|
|
// Created by Leon on 2025/7/23.
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
import UIKit
|
|||
|
|
|
|||
|
|
/// ⚠️废弃
|
|||
|
|
class UnlockPriceSetDialogController: BaseMaskPopDialogController {
|
|||
|
|
var titleLabel: UILabel!
|
|||
|
|
var textFiled: CLTextField!
|
|||
|
|
var button: StyleButton!
|
|||
|
|
|
|||
|
|
override func viewDidLoad() {
|
|||
|
|
super.viewDidLoad()
|
|||
|
|
|
|||
|
|
setupViews()
|
|||
|
|
setupDats()
|
|||
|
|
setupEvents()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private func setupViews() {
|
|||
|
|
titleLabel = {
|
|||
|
|
let v = UILabel()
|
|||
|
|
v.textColor = .c.ctpn
|
|||
|
|
v.font = .t.ttm
|
|||
|
|
v.numberOfLines = 0
|
|||
|
|
block.addSubview(v)
|
|||
|
|
v.textAlignment = .center
|
|||
|
|
v.snp.makeConstraints { make in
|
|||
|
|
make.leading.equalToSuperview().offset(24)
|
|||
|
|
make.trailing.equalToSuperview().offset(-24)
|
|||
|
|
make.top.equalToSuperview().offset(32)
|
|||
|
|
}
|
|||
|
|
return v
|
|||
|
|
}()
|
|||
|
|
|
|||
|
|
textFiled = {
|
|||
|
|
let v = CLTextField()
|
|||
|
|
block.addSubview(v)
|
|||
|
|
v.keyboardType = .decimalPad
|
|||
|
|
v.placeholder = "Price"
|
|||
|
|
v.snp.makeConstraints { make in
|
|||
|
|
make.leading.equalToSuperview().offset(24)
|
|||
|
|
make.trailing.equalToSuperview().offset(-24);
|
|||
|
|
make.top.equalTo(titleLabel.snp.bottom).offset(24)
|
|||
|
|
}
|
|||
|
|
v.setupLeftCoinIconView()
|
|||
|
|
|
|||
|
|
return v
|
|||
|
|
}()
|
|||
|
|
|
|||
|
|
button = {
|
|||
|
|
let v = StyleButton()
|
|||
|
|
v.primary(size: .large)
|
|||
|
|
block.addSubview(v)
|
|||
|
|
v.snp.makeConstraints { make in
|
|||
|
|
make.leading.equalToSuperview().offset(24)
|
|||
|
|
make.trailing.equalToSuperview().offset(-24);
|
|||
|
|
make.top.equalTo(textFiled.snp.bottom).offset(28)
|
|||
|
|
make.bottom.equalToSuperview().offset(-16)
|
|||
|
|
}
|
|||
|
|
return v
|
|||
|
|
}()
|
|||
|
|
|
|||
|
|
titleLabel.text = "Unlock Method"
|
|||
|
|
button.setTitle("Confirm", for: .normal)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private func setupDats() {
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private func setupEvents() {
|
|||
|
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillChanged(noti:)), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@objc func keyboardWillChanged(noti: Notification) {
|
|||
|
|
guard let userInfo = noti.userInfo else { return }
|
|||
|
|
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as! TimeInterval
|
|||
|
|
let endFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
|
|||
|
|
//let curve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey]! as! Int
|
|||
|
|
//let beginFrame = (userInfo[UIResponder.keyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
|
|||
|
|
|
|||
|
|
if endFrame.origin.y >= UIScreen.main.bounds.height {
|
|||
|
|
UIView.animate(withDuration: duration) {[weak self] in
|
|||
|
|
self?.block.snp.updateConstraints { make in
|
|||
|
|
make.centerY.equalToSuperview()
|
|||
|
|
}
|
|||
|
|
self?.view.layoutIfNeeded()
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
UIView.animate(withDuration: duration) {[weak self] in
|
|||
|
|
self?.block.snp.updateConstraints { make in
|
|||
|
|
make.centerY.equalToSuperview().offset(-endFrame.height * 0.5)
|
|||
|
|
}
|
|||
|
|
self?.view.layoutIfNeeded()
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|