Fableon/Fableon/Object/Class/Me/C/FASettingViewController.swift
湖北秦九 e0163dabe3 1
2025-10-31 13:36:20 +08:00

96 lines
3.0 KiB
Swift

//
// FASettingViewController.swift
// Fableon
//
// Created by on 2025/10/16.
//
import UIKit
class FASettingViewController: FAViewController {
private lazy var dataArr: [FAMeItemModel] = [
FAMeItemModel(type: .deleteAccount, name: "Account Deletion".localized, icon: nil)
]
private lazy var tableView: FATableView = {
let tableView = FATableView(frame: .zero, style: .plain)
tableView.delegate = self
tableView.dataSource = self
tableView.rowHeight = 48
tableView.contentInset = .init(top: 25, left: 0, bottom: 0, right: 0)
tableView.separatorStyle = .none
tableView.register(UINib(nibName: "FASettingCell", bundle: nil), forCellReuseIdentifier: "cell")
return tableView
}()
private lazy var footerView: FASettingFooterView = {
let view = FASettingFooterView(frame: .init(x: 0, y: 0, width: UIScreen.width, height: 60))
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Settings".localized
NotificationCenter.default.addObserver(self, selector: #selector(userInfoUpdateNotification), name: FALogin.userInfoUpdateNotification, object: nil)
userInfoUpdateNotification()
fa_setupLayout()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.fa_setNavigationStyle()
}
@objc private func userInfoUpdateNotification() {
if FALogin.manager.isLogin {
tableView.tableFooterView = footerView
} else {
tableView.tableFooterView = nil
}
}
}
extension FASettingViewController {
private func fa_setupLayout() {
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(UIScreen.navBarHeight)
make.bottom.equalToSuperview()
}
}
}
//MARK: UITableViewDelegate UITableViewDataSource
extension FASettingViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let item = dataArr[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FASettingCell
cell.titleLabel.text = item.name
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.dataArr.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = FAAppWebViewController()
vc.webUrl = kFALogoutWebUrl
vc.theme = "theme_4"
self.navigationController?.pushViewController(vc, animated: true)
}
}