You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.1 KiB
111 lines
4.1 KiB
// |
|
// MineViewController.swift |
|
// Lookfit |
|
// |
|
// Created by lemo. on 2020/3/7. |
|
// Copyright © 2020 Sheldon. All rights reserved. |
|
// |
|
|
|
import UIKit |
|
|
|
fileprivate enum Resuable { |
|
static let tableViewCell = ReusableCell<CommonTableViewCell>(nibName: "CommonTableViewCell") |
|
} |
|
|
|
class MineViewController: TableViewController { |
|
|
|
lazy var headerView: MineHeaderView = { |
|
let view = MineHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenW, height: kScaleWidth(180))) |
|
return view |
|
}() |
|
|
|
override func viewDidLoad() { |
|
super.viewDidLoad() |
|
} |
|
|
|
override func makeUI() { |
|
super.makeUI() |
|
isTitleCenter = true |
|
navigationTitle = MultiLanguageKey.mine.localized |
|
tableViewStyle = .grouped |
|
tableView.backgroundColor = kHexColor(0xFAFAFA) |
|
tableView.register(Resuable.tableViewCell) |
|
var top = kBatteryH; |
|
|
|
if #available(iOS 15.0, *) { |
|
top+=22 |
|
} |
|
|
|
tableView.contentInset = UIEdgeInsets(top: -top, left: 0, bottom: 0, right: 0) |
|
view.bringSubviewToFront(tableView) |
|
// 头视图 |
|
tableView.tableHeaderView = headerView |
|
tableView.isScrollEnabled = false |
|
headerView.rx.tap |
|
.subscribe(onNext: { [weak self] _ in |
|
guard let `self` = self else { return } |
|
let vm = UserInfoViewModel() |
|
self.navigator.show(segue: .userInfo(viewModel: vm), sender: self) |
|
}) |
|
.disposed(by: rx.disposeBag) |
|
layoutUI() |
|
} |
|
|
|
func layoutUI() { |
|
tableView.snp.makeConstraints { (make) in |
|
make.edges.equalToSuperview() |
|
} |
|
} |
|
|
|
override func bindViewModel() { |
|
super.bindViewModel() |
|
guard let viewModel = viewModel as? MineViewModel else { return } |
|
let dataSource = RxTableViewSectionedReloadDataSource |
|
<SectionModel<String, TableViewCellModel>>(configureCell: { |
|
(dataSource, tv, indexPath, element) in |
|
let cell = tv.dequeue(Resuable.tableViewCell, for: indexPath) |
|
cell.bindViewModel(model: element) |
|
return cell |
|
}) |
|
viewModel.relay |
|
.bind(to: tableView.rx.items(dataSource: dataSource)) |
|
.disposed(by: rx.disposeBag) |
|
viewModel.userIcon |
|
.bind(to: headerView.userIconImg.rx.image()) |
|
.disposed(by: rx.disposeBag) |
|
viewModel.userNickname |
|
.bind(to: headerView.userNameLabel.rx.text) |
|
.disposed(by: rx.disposeBag) |
|
tableView.rx.modelSelected(TableViewCellModel.self) |
|
.subscribe(onNext: { [weak self] (cellVM) in |
|
guard let type = cellVM.mineSetType else { return } |
|
switch type { |
|
case .unitSet: |
|
self?.navigator.show(segue: .unitSet, sender: self) |
|
case .targetSet: |
|
let vm = TargetVM() |
|
self?.navigator.show(segue: .target(viewModel: vm), sender: self) |
|
case .about: |
|
self?.navigator.show(segue: .about, sender: self) |
|
case .privacy: |
|
print("隐私政策") |
|
let vc = commWebViewController() |
|
vc.view.backgroundColor = UIColor.white; |
|
vc.navTitle = MultiLanguageKey.privacy.localized |
|
vc.url = "http://wx.ecellsz.com/mp/iosPrivacy.html" |
|
vc.hidesBottomBarWhenPushed = true; |
|
self?.navigationController!.pushViewController(vc, animated: true) |
|
case .service: |
|
print("用户协议") |
|
let vc = commWebViewController() |
|
vc.view.backgroundColor = UIColor.white; |
|
vc.navTitle = MultiLanguageKey.service.localized |
|
vc.url = "http://wx.ecellsz.com/mp/appAgreement.html" |
|
vc.hidesBottomBarWhenPushed = true; |
|
self?.navigationController!.pushViewController(vc, animated: true) |
|
} |
|
}) |
|
.disposed(by: rx.disposeBag) |
|
} |
|
|
|
}
|
|
|