jsdw_ios/QuickLocation/Section/Mine/Account/AccountView.swift

320 lines
9.1 KiB
Swift

//
// AccountView.swift
// QuickLocation
//
// Created by on 2026/6/10.
//
import UIKit
import RxSwift
import RxCocoa
class AccountView: UIView {
var disposeBag = DisposeBag()
private func setupRx() {
backBtn.rx.tap.subscribe(onNext: { _ in
AppRouter.shared.popOrDismiss()
}).disposed(by: disposeBag)
}
private func setupUI() {
addSubview(navBgView)
addSubview(navBarView)
navBarView.addSubview(navTitleLabel)
navBarView.addSubview(backBtn)
addSubview(infoView)
infoView.addSubview(infoStackView)
addSubview(otherInfoView)
otherInfoView.addSubview(otherInfoStackView)
addSubview(logoutBtn)
addSubview(cancelledBtn)
navBgView.layoutChain
.edges(excludingEdge: .bottom)
.heightToWidth(160/375)
navBarView.layoutChain
.edges(excludingEdge: .bottom)
.height(kNaviHeight)
navTitleLabel.layoutChain
.top(kStatusBarHeight + 12)
.centerY(backBtn)
.centerX()
backBtn.layoutChain
.centerY(navTitleLabel)
.left(15)
.width(24)
.height(24)
infoView.layoutChain
.topToBottomOfView(navBarView, offset: 18)
.edgesHorzontal(16)
infoStackView.layoutChain.edges()
userIdView.layoutChain.height(52)
phoneView.layoutChain.height(52)
otherInfoView.layoutChain
.topToBottomOfView(infoView, offset: 18)
.edgesHorzontal(16)
otherInfoStackView.layoutChain.edges()
versionView.layoutChain.height(52)
clearView.layoutChain.height(52)
logoutBtn.layoutChain
.edgesHorzontal(30)
.bottomToTopOfView(cancelledBtn, offset: -10)
.height(50)
cancelledBtn.layoutChain
.edgesHorzontal(30)
.bottom(kSafeBottomMargin + 10)
.height(50)
}
lazy var navBgView: UIImageView = {
let iv = UIImageView()
iv.image = UIImage(named: "Common/navBar_bg_2")
iv.contentMode = .scaleAspectFill
return iv
}()
lazy var navBarView: UIView = {
let view = UIView()
view.backgroundColor = .clear
return view
}()
lazy var navTitleLabel: UILabel = {
let label = UILabel()
label.text = "账号与安全"
label.font = .systemFont(ofSize: 18, weight: .medium)
label.textColor = ThemeManager.shared.color.titleAuxColor
label.textAlignment = .center
return label
}()
lazy var backBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setImage(UIImage(named: "Common/back"), for: .normal)
btn.extendEdgeInsets = UIEdgeInsets(top: 54, left: 15, bottom: 100, right: 100)
return btn
}()
lazy var infoView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.layer.shadowColor = UIColor(hexStr: "#0F2846", alpha: 0.1).cgColor
view.layer.shadowOffset = CGSize(width: 0, height: 0)
view.layer.shadowOpacity = 1
view.layer.shadowRadius = 10
return view
}()
lazy var infoStackView: UIStackView = {
let view = UIStackView(arrangedSubviews: [userIdView, phoneView])
view.axis = .vertical
view.alignment = .fill
view.distribution = .fill
view.spacing = 0
view.backgroundColor = .white
view.cornerRadius = 10
return view
}()
/// UserID
lazy var userIdView: UIView = {
let view = UIView()
view.backgroundColor = .clear
let titleLab = UILabel()
titleLab.text = "ID"
titleLab.font = .systemFont(ofSize: 14, weight: .medium)
titleLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(titleLab)
titleLab.layoutChain
.left(15)
.centerY()
let contentLab = UILabel()
contentLab.text = AppContextManager.shared.userId
contentLab.font = .systemFont(ofSize: 14, weight: .medium)
contentLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(contentLab)
contentLab.layoutChain
.right(15)
.centerY()
let line = UIView()
line.backgroundColor = ThemeManager.shared.color.lineColor
view.addSubview(line)
line.layoutChain
.bottom()
.height(0.5)
.edgesHorzontal(15)
return view
}()
///
lazy var phoneView: UIView = {
let view = UIView()
view.backgroundColor = .clear
let titleLab = UILabel()
titleLab.text = "手机号"
titleLab.font = .systemFont(ofSize: 14, weight: .medium)
titleLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(titleLab)
titleLab.layoutChain
.left(15)
.centerY()
let arrow = UIImageView(image: UIImage(named: "Group/arrow"))
view.addSubview(arrow)
arrow.layoutChain
.right(15)
.width(14)
.height(14)
.centerY()
view.addSubview(phoneLab)
phoneLab.layoutChain
.rightToLeftOfView(arrow, offset: -8)
.centerY()
return view
}()
lazy var phoneLab: UILabel = {
let lab = UILabel()
lab.text = AppContextManager.shared.userPhone
lab.font = .systemFont(ofSize: 14, weight: .medium)
lab.textColor = UIColor(hexStr: "#1A1A1A")
return lab
}()
//
lazy var otherInfoView: UIView = {
let view = UIView()
view.backgroundColor = .clear
view.layer.shadowColor = UIColor(hexStr: "#0F2846", alpha: 0.1).cgColor
view.layer.shadowOffset = CGSize(width: 0, height: 0)
view.layer.shadowOpacity = 1
view.layer.shadowRadius = 10
return view
}()
lazy var otherInfoStackView: UIStackView = {
let view = UIStackView(arrangedSubviews: [versionView, clearView])
view.axis = .vertical
view.alignment = .fill
view.distribution = .fill
view.spacing = 0
view.backgroundColor = .white
view.cornerRadius = 10
return view
}()
///
lazy var versionView: UIView = {
let view = UIView()
view.backgroundColor = .clear
let titleLab = UILabel()
titleLab.text = "当前版本"
titleLab.font = .systemFont(ofSize: 14, weight: .medium)
titleLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(titleLab)
titleLab.layoutChain
.left(15)
.centerY()
let contentLab = UILabel()
contentLab.text = kAppShortVersion
contentLab.font = .systemFont(ofSize: 14, weight: .medium)
contentLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(contentLab)
contentLab.layoutChain
.right(15)
.centerY()
let line = UIView()
line.backgroundColor = ThemeManager.shared.color.lineColor
view.addSubview(line)
line.layoutChain
.bottom()
.height(0.5)
.edgesHorzontal(15)
return view
}()
///
lazy var clearView: UIView = {
let view = UIView()
view.backgroundColor = .clear
let titleLab = UILabel()
titleLab.text = "清除缓存"
titleLab.font = .systemFont(ofSize: 14, weight: .medium)
titleLab.textColor = UIColor(hexStr: "#1A1A1A")
view.addSubview(titleLab)
titleLab.layoutChain
.left(15)
.centerY()
let arrow = UIImageView(image: UIImage(named: "Group/arrow"))
view.addSubview(arrow)
arrow.layoutChain
.right(15)
.width(14)
.height(14)
.centerY()
return view
}()
lazy var logoutBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("退出登录", for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
btn.setTitleColor(.white, for: .normal)
btn.setBackgroundImage(UIImage(named: "Common/button_bg_2"), for: .normal)
btn.cornerRadius = 25
return btn
}()
lazy var cancelledBtn: UIButton = {
let btn = UIButton(type: .custom)
btn.setTitle("注销账号", for: .normal)
btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
btn.setTitleColor(UIColor(hexStr: "#767676"), for: .normal)
btn.backgroundColor = .clear
return btn
}()
override init(frame: CGRect) {
super.init(frame: .zero)
backgroundColor = UIColor(hexStr: "#FAFAFA")
setupUI()
setupRx()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}