125 lines
4.1 KiB
Swift
125 lines
4.1 KiB
Swift
//
|
|
// AboutView.swift
|
|
// QuickLocation
|
|
//
|
|
|
|
import UIKit
|
|
|
|
final class AboutView: UIView {
|
|
|
|
lazy var navView: BaseNavigationView = {
|
|
BaseNavigationView(title: "关于我们")
|
|
}()
|
|
|
|
lazy var navBgView: UIImageView = {
|
|
let iv = UIImageView(image: UIImage(named: "Common/navBar_bg_2"))
|
|
iv.contentMode = .scaleAspectFill
|
|
return iv
|
|
}()
|
|
|
|
let logoImage = UIImageView(image: UIImage(named: "Mine/"))
|
|
let nameImage = UIImageView(image: UIImage(named: "Mine/about_logo"))
|
|
let versionLab = UILabel()
|
|
|
|
let feedbackBtn = AboutMenuButton(title: "意见反馈")
|
|
let rateBtn = AboutMenuButton(title: "给个好评")
|
|
let agreementBtn = AboutMenuButton(title: "用户协议")
|
|
let privacyBtn = AboutMenuButton(title: "隐私政策")
|
|
let kidsPrivacyBtn = AboutMenuButton(title: "儿童隐私政策")
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
backgroundColor = UIColor(hexStr: "#FAFAFA")
|
|
setupUI()
|
|
}
|
|
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
|
|
private func setupUI() {
|
|
addSubview(navBgView)
|
|
addSubview(navView)
|
|
navBgView.layoutChain.edges(excludingEdge: .bottom).heightToWidth(160 / 375)
|
|
navView.layoutChain.top().edgesHorzontal().height(kNaviHeight)
|
|
|
|
logoImage.contentMode = .scaleAspectFill
|
|
logoImage.backgroundColor = .lightGray
|
|
logoImage.cornerRadius = 30
|
|
|
|
addSubview(logoImage)
|
|
logoImage.layoutChain
|
|
.topToBottomOfView(navView, offset: 67)
|
|
.centerX()
|
|
.width(100)
|
|
.heightToWidth(1)
|
|
|
|
addSubview(nameImage)
|
|
nameImage.layoutChain
|
|
.topToBottomOfView(logoImage, offset: 24)
|
|
.centerX()
|
|
.width(114)
|
|
.height(25)
|
|
|
|
let card1 = makeCard()
|
|
addSubview(card1)
|
|
card1.layoutChain.topToBottomOfView(nameImage, offset: 40).edgesHorzontal(15)
|
|
stackInCard(card1, buttons: [feedbackBtn, rateBtn])
|
|
|
|
let card2 = makeCard()
|
|
addSubview(card2)
|
|
card2.layoutChain.topToBottomOfView(card1, offset: 12).edgesHorzontal(15)
|
|
stackInCard(card2, buttons: [agreementBtn, privacyBtn, kidsPrivacyBtn])
|
|
|
|
versionLab.text = kAppShortVersion
|
|
versionLab.font = .systemFont(ofSize: 12, weight: .medium)
|
|
versionLab.textColor = UIColor(hexStr: "#AAAAAA")
|
|
versionLab.textAlignment = .center
|
|
addSubview(versionLab)
|
|
versionLab.layoutChain.bottom(34).centerX()
|
|
}
|
|
|
|
private func makeCard() -> UIView {
|
|
let v = UIView()
|
|
v.backgroundColor = .white
|
|
v.layer.cornerRadius = 16
|
|
v.layer.shadowColor = UIColor(hexStr: "#0F2846", alpha: 0.08).cgColor
|
|
v.layer.shadowOffset = CGSize(width: 0, height: 2)
|
|
v.layer.shadowOpacity = 1
|
|
v.layer.shadowRadius = 8
|
|
return v
|
|
}
|
|
|
|
private func stackInCard(_ card: UIView, buttons: [AboutMenuButton]) {
|
|
let stack = UIStackView(arrangedSubviews: buttons)
|
|
stack.axis = .vertical
|
|
stack.spacing = 0
|
|
card.addSubview(stack)
|
|
stack.layoutChain.edges()
|
|
buttons.forEach { $0.layoutChain.height(52) }
|
|
for (i, btn) in buttons.enumerated() where i < buttons.count - 1 {
|
|
let line = UIView()
|
|
line.backgroundColor = UIColor(hexStr: "#F2F2F2")
|
|
btn.addSubview(line)
|
|
line.layoutChain.left(15).right(15).bottom(0).height(0.5)
|
|
}
|
|
}
|
|
}
|
|
|
|
final class AboutMenuButton: UIControl {
|
|
private let titleLab = UILabel()
|
|
private let arrow = UIImageView(image: UIImage(named: "Mine/arrow_right"))
|
|
|
|
init(title: String) {
|
|
super.init(frame: .zero)
|
|
titleLab.text = title
|
|
titleLab.font = .systemFont(ofSize: 15, weight: .medium)
|
|
titleLab.textColor = UIColor(hexStr: "#293445")
|
|
addSubview(titleLab)
|
|
titleLab.layoutChain.left(15).centerY()
|
|
arrow.contentMode = .scaleAspectFit
|
|
addSubview(arrow)
|
|
arrow.layoutChain.right(15).centerY().width(12).height(12)
|
|
}
|
|
|
|
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
|
}
|