236 lines
6.6 KiB
Swift
236 lines
6.6 KiB
Swift
//
|
|
// MyProfileView.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/11.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class MyProfileView: 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(avatarView)
|
|
addSubview(nickNameView)
|
|
addSubview(genderView)
|
|
|
|
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)
|
|
|
|
avatarView.layoutChain
|
|
.topToBottomOfView(navBarView, offset: 30)
|
|
.centerX()
|
|
|
|
nickNameView.layoutChain
|
|
.topToBottomOfView(avatarView, offset: 30)
|
|
.edgesHorzontal(15)
|
|
.height(60)
|
|
|
|
genderView.layoutChain
|
|
.topToBottomOfView(nickNameView, offset: 12)
|
|
.edgesHorzontal(15)
|
|
.height(60)
|
|
}
|
|
|
|
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 avatarView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .clear
|
|
view.isUserInteractionEnabled = true
|
|
|
|
let label = UILabel()
|
|
label.text = "更换头像"
|
|
label.textColor = ThemeManager.shared.color.titleAuxColor
|
|
label.font = .systemFont(ofSize: 16, weight: .medium)
|
|
|
|
view.addSubview(avatarImgView)
|
|
view.addSubview(label)
|
|
|
|
avatarImgView.layoutChain
|
|
.top()
|
|
.width(80)
|
|
.height(80)
|
|
.edgesHorzontal()
|
|
|
|
label.layoutChain
|
|
.topToBottomOfView(avatarImgView, offset: 12)
|
|
.centerX()
|
|
.bottom()
|
|
|
|
return view
|
|
}()
|
|
|
|
lazy var avatarImgView: UIImageView = {
|
|
let view = UIImageView()
|
|
view.cornerRadius = 40
|
|
view.contentMode = .scaleAspectFill
|
|
view.image = AppContextManager.shared.avaterIcon
|
|
return view
|
|
}()
|
|
|
|
lazy var nickNameView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = UIColor(hexStr: "#F5FBFF")
|
|
view.cornerRadius = 10
|
|
|
|
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(nickNameLab)
|
|
nickNameLab.layoutChain
|
|
.rightToLeftOfView(arrow, offset: -8)
|
|
.centerY()
|
|
|
|
return view
|
|
}()
|
|
|
|
lazy var nickNameLab: UILabel = {
|
|
let lab = UILabel()
|
|
lab.text = AppContextManager.shared.name
|
|
lab.font = .systemFont(ofSize: 14, weight: .medium)
|
|
lab.textColor = UIColor(hexStr: "#1A1A1A")
|
|
return lab
|
|
}()
|
|
|
|
// 性别
|
|
lazy var genderView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = UIColor(hexStr: "#F5FBFF")
|
|
view.cornerRadius = 10
|
|
|
|
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()
|
|
|
|
view.addSubview(maleCheckbox)
|
|
view.addSubview(femaleCheckbox)
|
|
|
|
femaleCheckbox.layoutChain
|
|
.right()
|
|
.edgesVertical()
|
|
.width(60)
|
|
|
|
maleCheckbox.layoutChain
|
|
.rightToLeftOfView(femaleCheckbox)
|
|
.edgesVertical()
|
|
.width(60)
|
|
|
|
return view
|
|
}()
|
|
|
|
lazy var maleCheckbox: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setTitle(" 男", for: .normal)
|
|
btn.setTitleColor(UIColor(hexStr: "#1A1A1A"), for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
|
btn.setImage(UIImage(named: "Common/checkbox"), for: .normal)
|
|
btn.setImage(UIImage(named: "Common/checkbox_on"), for: .selected)
|
|
btn.tag = 1
|
|
btn.isSelected = btn.tag == AppContextManager.shared.sex
|
|
return btn
|
|
}()
|
|
|
|
lazy var femaleCheckbox: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setTitle(" 女", for: .normal)
|
|
btn.setTitleColor(UIColor(hexStr: "#1A1A1A"), for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 14, weight: .medium)
|
|
btn.setImage(UIImage(named: "Common/checkbox"), for: .normal)
|
|
btn.setImage(UIImage(named: "Common/checkbox_on"), for: .selected)
|
|
btn.tag = 2
|
|
btn.isSelected = btn.tag == AppContextManager.shared.sex
|
|
return btn
|
|
}()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: .zero)
|
|
backgroundColor = .white
|
|
setupUI()
|
|
setupRx()
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
}
|