jsdw_ios/QuickLocation/Section/Mine/PrivacyPolicy/PrivacyPolicyVC.swift

69 lines
2.0 KiB
Swift

//
// PrivacyPolicyVC.swift
// QuickLocation
//
// Created by on 2026/6/11.
//
import UIKit
import RxSwift
import RxCocoa
import RxDataSources
struct PrivacyPolicyItem {
enum Destination {
case web(String)
case appRestrict
}
let name: String
let destination: Destination
}
class PrivacyPolicyVC: BaseViewController {
fileprivate var rootView: PrivacyPolicyView!
override func loadView() {
rootView = PrivacyPolicyView(frame: UIScreen.main.bounds)
view = rootView
}
private let list: [PrivacyPolicyItem] = [
PrivacyPolicyItem(name: "用户协议", destination: .web(URLManager.shared.userAgreementUrl)),
PrivacyPolicyItem(name: "隐私政策", destination: .web(URLManager.shared.privacyPolicyUrl)),
PrivacyPolicyItem(name: "儿童隐私政策", destination: .web(URLManager.shared.kidsPrivacyUrl)),
PrivacyPolicyItem(name: "应用配对库", destination: .appRestrict)
]
override func viewDidLoad() {
super.viewDidLoad()
bindList()
rootView.tableView.layoutChain.height(CGFloat(list.count * 52))
}
private func bindList() {
// tableView
Observable.just(list)
.bind(to: rootView.tableView.rx.items) { tableView, index, item in
let cell: PrivacyPolicyCell = tableView.dequeueReusableCell(for: IndexPath(row: index, section: 0))
cell.configure(item)
return cell
}
.disposed(by: disposeBag)
//
rootView.tableView.rx.modelSelected(PrivacyPolicyItem.self)
.subscribe(onNext: { item in
switch item.destination {
case .web(let url):
AppRouter.push(Route.web, userInfo: ["url": url])
case .appRestrict:
AppRouter.push(Route.appRestrict)
}
})
.disposed(by: disposeBag)
}
}