287 lines
8.4 KiB
Swift
287 lines
8.4 KiB
Swift
//
|
|
// InviteJoinView.swift
|
|
// QuickLocation
|
|
//
|
|
// Created by 八条 on 2026/6/1.
|
|
//
|
|
|
|
import UIKit
|
|
import RxSwift
|
|
import RxCocoa
|
|
|
|
class InviteJoinView: UIView {
|
|
|
|
var disposeBag = DisposeBag()
|
|
|
|
private func setupRx() {
|
|
|
|
inviteCodeView.rx.tapGesture.subscribe { _ in
|
|
guard let code = self.inviteCodeLab.text else { return }
|
|
UIPasteboard.general.string = code
|
|
DLToast.showSuccess(text: "已复制")
|
|
}.disposed(by: disposeBag)
|
|
|
|
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(groupIcon)
|
|
addSubview(groupNameLab)
|
|
addSubview(inviteInfoView)
|
|
inviteInfoView.addSubview(inviteInfoTitleLab)
|
|
inviteInfoView.addSubview(inviteTipsLab)
|
|
inviteInfoView.addSubview(inviteCodeView)
|
|
inviteCodeView.addSubview(inviteCodeTipsLab)
|
|
inviteCodeView.addSubview(inviteCodeLab)
|
|
inviteInfoView.addSubview(scanTipsLab)
|
|
inviteInfoView.addSubview(qrCodeView)
|
|
qrCodeView.addSubview(qrCodeBgImg)
|
|
qrCodeView.addSubview(qrCodeImgView)
|
|
addSubview(shareAppBtn)
|
|
addSubview(shareCodeBtn)
|
|
|
|
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)
|
|
|
|
groupIcon.layoutChain
|
|
.topToBottomOfView(navBarView, offset: 24)
|
|
.width(80)
|
|
.height(80)
|
|
.centerX()
|
|
|
|
groupNameLab.layoutChain
|
|
.topToBottomOfView(groupIcon, offset: 4)
|
|
.centerX()
|
|
|
|
shareAppBtn.layoutChain
|
|
.left(44)
|
|
.bottom(kSafeBottomMargin + 10)
|
|
.widthToView(shareCodeBtn)
|
|
.height(50)
|
|
|
|
shareCodeBtn.layoutChain
|
|
.leftToRightOfView(shareAppBtn, offset: 20)
|
|
.right(44)
|
|
.bottomToView(shareAppBtn)
|
|
.widthToView(shareAppBtn)
|
|
.heightToView(shareAppBtn)
|
|
|
|
inviteInfoView.layoutChain
|
|
.topToBottomOfView(groupIcon, offset: 50)
|
|
.edgesHorzontal(30)
|
|
.bottomToTopOfView(shareAppBtn, offset: -32)
|
|
|
|
inviteInfoTitleLab.layoutChain
|
|
.top(20)
|
|
.centerX()
|
|
|
|
inviteTipsLab.layoutChain
|
|
.topToBottomOfView(inviteInfoTitleLab, offset: 9)
|
|
.centerX()
|
|
|
|
inviteCodeView.layoutChain
|
|
.topToBottomOfView(inviteTipsLab, offset: 10)
|
|
.centerX()
|
|
.width(180)
|
|
.height(50)
|
|
|
|
inviteCodeTipsLab.layoutChain
|
|
.top(10)
|
|
.centerX()
|
|
|
|
inviteCodeLab.layoutChain
|
|
.topToBottomOfView(inviteCodeTipsLab)
|
|
.centerX()
|
|
|
|
scanTipsLab.layoutChain
|
|
.topToBottomOfView(inviteCodeView, offset: 20)
|
|
.centerX()
|
|
|
|
qrCodeView.layoutChain
|
|
.topToBottomOfView(scanTipsLab, offset: 15)
|
|
.centerX()
|
|
.widthToHeight(1)
|
|
.bottom(20)
|
|
|
|
qrCodeBgImg.layoutChain.edges()
|
|
|
|
qrCodeImgView.layoutChain
|
|
.edgesHorzontal(4)
|
|
.edgesVertical(4)
|
|
}
|
|
|
|
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 groupIcon: UIImageView = {
|
|
let view = UIImageView()
|
|
view.backgroundColor = .clear
|
|
view.cornerRadius = 40
|
|
return view
|
|
}()
|
|
|
|
lazy var groupNameLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 16, weight: .medium)
|
|
label.textColor = ThemeManager.shared.color.titleAuxColor
|
|
return label
|
|
}()
|
|
|
|
lazy var inviteInfoView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = UIColor(hexStr: "#F5FBFF")
|
|
view.cornerRadius = 20
|
|
return view
|
|
}()
|
|
|
|
lazy var inviteInfoTitleLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "将此邀请码分享给加入圈子的人"
|
|
label.font = .systemFont(ofSize: 16, weight: .medium)
|
|
label.textColor = ThemeManager.shared.color.titleAuxColor
|
|
return label
|
|
}()
|
|
|
|
lazy var inviteTipsLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "此邀请码有效期为24小时"
|
|
label.font = .systemFont(ofSize: 12, weight: .medium)
|
|
label.textColor = UIColor(hexStr: "#16B3FF")
|
|
return label
|
|
}()
|
|
|
|
lazy var inviteCodeView: UIView = {
|
|
let view = UIView()
|
|
view.borderColor = UIColor(hexStr: "#CCCCCC")
|
|
view.borderWidth = 1
|
|
view.cornerRadius = 10
|
|
return view
|
|
}()
|
|
|
|
lazy var inviteCodeTipsLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "点击复制邀请码"
|
|
label.font = .systemFont(ofSize: 12, weight: .medium)
|
|
label.textColor = ThemeManager.shared.color.contentColor
|
|
return label
|
|
}()
|
|
|
|
lazy var inviteCodeLab: UILabel = {
|
|
let label = UILabel()
|
|
label.font = .systemFont(ofSize: 16, weight: .heavy)
|
|
label.textColor = ThemeManager.shared.color.titleAuxColor
|
|
return label
|
|
}()
|
|
|
|
lazy var scanTipsLab: UILabel = {
|
|
let label = UILabel()
|
|
label.text = "— 或扫描以下二维码 —"
|
|
label.font = .systemFont(ofSize: 10)
|
|
label.textColor = ThemeManager.shared.color.contentColor
|
|
return label
|
|
}()
|
|
|
|
lazy var qrCodeView: UIView = {
|
|
let view = UIView()
|
|
view.backgroundColor = .clear
|
|
return view
|
|
}()
|
|
|
|
lazy var qrCodeBgImg: UIImageView = {
|
|
let view = UIImageView()
|
|
view.image = UIImage(named: "Group/scan_bg")
|
|
return view
|
|
}()
|
|
|
|
lazy var qrCodeImgView: UIImageView = {
|
|
let view = UIImageView()
|
|
view.backgroundColor = .clear
|
|
view.contentMode = .scaleAspectFill
|
|
view.cornerRadius = 10
|
|
view.clipsToBounds = true
|
|
return view
|
|
}()
|
|
|
|
lazy var shareAppBtn: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setTitle("分享APP", for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
|
btn.setTitleColor(UIColor(hexStr: "#16B3FF"), for: .normal)
|
|
btn.backgroundColor = .white
|
|
btn.borderWidth = 1
|
|
btn.borderColor = UIColor(hexStr: "#16B3FF")
|
|
btn.cornerRadius = 25
|
|
return btn
|
|
}()
|
|
|
|
lazy var shareCodeBtn: UIButton = {
|
|
let btn = UIButton(type: .custom)
|
|
btn.setTitle("分享邀请码", for: .normal)
|
|
btn.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
|
|
btn.setTitleColor(UIColor(hexStr: "#0F2846"), for: .normal)
|
|
btn.backgroundColor = .clear
|
|
btn.setBackgroundImage(UIImage(named: "Common/gradient_bg"), for: .normal)
|
|
btn.cornerRadius = 25
|
|
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")
|
|
}
|
|
}
|