|
|
@ -28,11 +28,7 @@ class HomeViewController: TableViewController {
|
|
|
|
var bannerArray = [String]()
|
|
|
|
var bannerArray = [String]()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let noLoginBottomView: NoLoginBottomView = {
|
|
|
|
|
|
|
|
let noLoginBottomView = NoLoginBottomView.init()
|
|
|
|
|
|
|
|
// noLoginBottomView.backgroundColor = .systemBlue
|
|
|
|
|
|
|
|
return noLoginBottomView
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
super.viewDidLoad()
|
|
|
@ -44,27 +40,18 @@ class HomeViewController: TableViewController {
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
|
super.viewWillAppear(animated)
|
|
|
|
super.viewWillAppear(animated)
|
|
|
|
|
|
|
|
|
|
|
|
// let vm = JournalDetailViewModel.init(provider: viewModel!.provider)
|
|
|
|
|
|
|
|
// let vc = JournalDetailController.init(viewModel: vm, navigator: navigator)
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// self.navigationController?.pushViewController(vc, animated: true)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let tabbar = self.tabBarController as? HomeTabBarController {
|
|
|
|
if let tabbar = self.tabBarController as? HomeTabBarController {
|
|
|
|
tabbar.showAllBar(true, animated: true)
|
|
|
|
tabbar.showAllBar(true, animated: true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
guard let viewModel = viewModel as? HomeViewModel else { return }
|
|
|
|
self.navigationItem.leftBarButtonItem = nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let loginViewModel = LoginViewModel.init(provider: viewModel.provider)
|
|
|
|
|
|
|
|
// let login = LoginViewController.init(viewModel: loginViewModel, navigator: navigator)
|
|
|
|
|
|
|
|
// self.navigationController?.pushViewController(login, animated: true)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override func makeUI() {
|
|
|
|
override func makeUI() {
|
|
|
|
super.makeUI()
|
|
|
|
super.makeUI()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let headerView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: BaseDimensions.screenWidth, height: 120))
|
|
|
|
let headerView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: BaseDimensions.screenWidth, height: 120))
|
|
|
|
pagerView.frame = headerView.bounds
|
|
|
|
pagerView.frame = headerView.bounds
|
|
|
|
pagerView.backgroundColor = .red
|
|
|
|
pagerView.backgroundColor = .red
|
|
|
@ -74,10 +61,8 @@ class HomeViewController: TableViewController {
|
|
|
|
headerView.addSubview(pagerView)
|
|
|
|
headerView.addSubview(pagerView)
|
|
|
|
|
|
|
|
|
|
|
|
tableView.tableHeaderView = headerView
|
|
|
|
tableView.tableHeaderView = headerView
|
|
|
|
|
|
|
|
tableView.separatorColor = .clear
|
|
|
|
tableView.register(HomeViewCell.self, forCellReuseIdentifier: "HomeViewCell")
|
|
|
|
tableView.register(HomeViewCell.self, forCellReuseIdentifier: "HomeViewCell")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.addSubview(noLoginBottomView)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -88,41 +73,40 @@ class HomeViewController: TableViewController {
|
|
|
|
guard let viewModel = viewModel as? HomeViewModel else { return }
|
|
|
|
guard let viewModel = viewModel as? HomeViewModel else { return }
|
|
|
|
|
|
|
|
|
|
|
|
let input = HomeViewModel.Input.init(viewWillAppear: rx.viewWillAppear,
|
|
|
|
let input = HomeViewModel.Input.init(viewWillAppear: rx.viewWillAppear,
|
|
|
|
selection: tableView.rx.itemSelected.asDriver(), loginButtonTrigger: self.noLoginBottomView.loginButton.rx.tap.asDriver())
|
|
|
|
selection: tableView.rx.itemSelected.asDriver())
|
|
|
|
let output = viewModel.transform(input: input)
|
|
|
|
let output = viewModel.transform(input: input)
|
|
|
|
|
|
|
|
|
|
|
|
let dataSource = HomeViewController.dataSource()
|
|
|
|
let dataSource = HomeViewController.dataSource { cell, item in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let loginViewModel = LoginViewModel.init(provider: viewModel.provider)
|
|
|
|
|
|
|
|
self.navigator.show(segue: .login(viewModel: loginViewModel), sender: self)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
output.items.bind(to: tableView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
|
|
|
|
output.items.bind(to: tableView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output.itemSelected.subscribe { [weak self] sectionItem in
|
|
|
|
output.itemSelected.subscribe { [weak self] sectionItem in
|
|
|
|
switch sectionItem {
|
|
|
|
switch sectionItem {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let journalDetailViewModel = JournalDetailViewModel.init(provider: viewModel.provider)
|
|
|
|
let journalDetailViewModel = JournalDetailViewModel.init(provider: viewModel.provider)
|
|
|
|
self?.navigator.show(segue: .journalDetail(viewModel: journalDetailViewModel), sender: self)
|
|
|
|
self?.navigator.show(segue: .journalDetail(viewModel: journalDetailViewModel), sender: self)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isFooterLoading.accept((.loadMore, false))
|
|
|
|
|
|
|
|
|
|
|
|
self.noLoginBottomView.loginButton.rx.tap.subscribe { _ in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let loginViewModel = LoginViewModel.init(provider: viewModel.provider)
|
|
|
|
|
|
|
|
self.navigator.show(segue: .login(viewModel: loginViewModel), sender: self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loggedIn.subscribe { isloggedIn in
|
|
|
|
|
|
|
|
if isloggedIn.element == true {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
self.tableView.mj_footer?.rx.refreshFooterState.onNext(RxMJRefreshFooterState.noMoreData)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.tableView.reloadData()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}.disposed(by: rx.disposeBag)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -130,13 +114,6 @@ class HomeViewController: TableViewController {
|
|
|
|
super.viewDidLayoutSubviews()
|
|
|
|
super.viewDidLayoutSubviews()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noLoginBottomView.snp.makeConstraints { make in
|
|
|
|
|
|
|
|
make.bottom.equalTo(view).offset( -BaseDimensions.tabBarHeight)
|
|
|
|
|
|
|
|
make.left.equalTo(view)
|
|
|
|
|
|
|
|
make.right.equalTo(view)
|
|
|
|
|
|
|
|
make.height.equalTo(100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -171,7 +148,6 @@ extension HomeViewController: FSPagerViewDataSource {
|
|
|
|
|
|
|
|
|
|
|
|
cell.imageView?.kf.setImage(with: URL.init(string: ""))
|
|
|
|
cell.imageView?.kf.setImage(with: URL.init(string: ""))
|
|
|
|
cell.imageView?.backgroundColor = .red
|
|
|
|
cell.imageView?.backgroundColor = .red
|
|
|
|
|
|
|
|
|
|
|
|
return cell
|
|
|
|
return cell
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -180,7 +156,7 @@ extension HomeViewController: FSPagerViewDataSource {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension HomeViewController {
|
|
|
|
extension HomeViewController {
|
|
|
|
static func dataSource() -> RxTableViewSectionedReloadDataSource<HomeSectionModel> {
|
|
|
|
static func dataSource(_ buttonTapHandler: @escaping (UITableViewCell, HomeSectionItem) -> Void) -> RxTableViewSectionedReloadDataSource<HomeSectionModel> {
|
|
|
|
return RxTableViewSectionedReloadDataSource { dataSource, tableView, indexPath, item in
|
|
|
|
return RxTableViewSectionedReloadDataSource { dataSource, tableView, indexPath, item in
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -189,9 +165,17 @@ extension HomeViewController {
|
|
|
|
let cell: HomeViewCell = tableView.dequeueReusableCell(withIdentifier: "HomeViewCell", for: indexPath) as! HomeViewCell
|
|
|
|
let cell: HomeViewCell = tableView.dequeueReusableCell(withIdentifier: "HomeViewCell", for: indexPath) as! HomeViewCell
|
|
|
|
|
|
|
|
|
|
|
|
cell.homeJournal = model
|
|
|
|
cell.homeJournal = model
|
|
|
|
return cell
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: UITableViewCell()
|
|
|
|
if indexPath.row == tableView.numberOfRows(inSection: indexPath.section) - 1 {
|
|
|
|
|
|
|
|
cell.homeNoLoginView.isHidden = AuthManager.shared.token?.isValid ?? false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cell.loginClosures = {
|
|
|
|
|
|
|
|
buttonTapHandler(cell, item)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cell
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -219,7 +203,7 @@ extension HomeViewController {
|
|
|
|
let navigator = self?.navigator else { return }
|
|
|
|
let navigator = self?.navigator else { return }
|
|
|
|
|
|
|
|
|
|
|
|
let filterViewModel = FilterViewModel.init(provider: viewModel.provider)
|
|
|
|
let filterViewModel = FilterViewModel.init(provider: viewModel.provider)
|
|
|
|
let filter = FilterViewController.init(viewModel: filterViewModel, navigator: navigator)
|
|
|
|
// let filter = FilterViewController.init(viewModel: filterViewModel, navigator: navigator)
|
|
|
|
// self.present(filter, animated: true)
|
|
|
|
// self.present(filter, animated: true)
|
|
|
|
navigator.show(segue: .filter(viewModel: filterViewModel), sender: self, transition: .navigationPresent(type: .filter))
|
|
|
|
navigator.show(segue: .filter(viewModel: filterViewModel), sender: self, transition: .navigationPresent(type: .filter))
|
|
|
|
}
|
|
|
|
}
|
|
|
|