123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- //
- // CommunityMyFollowTopicController.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/6/12.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import SwiftyMediator
- class CommunityMyFollowTopicController: BaseViewController {
-
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- }
-
- var communityMemberFollowTopicListDataModels = Array<CommunityMemberFollowTopicListDataModel>()
-
- override func viewDidLoad() {
- super.viewDidLoad()
- setupViews()
- setupLayouts()
- setupData()
-
- }
-
- override func setupViews() {
- navigationBar.title = "我的关注话题"
- view.backgroundColor = kf7f8faColor
- view.addSubview(tableView)
- view.insertSubview(navigationBar, aboveSubview: tableView)
- }
-
- override func setupLayouts() {
- tableView.snp.makeConstraints { (make) in
- make.top.equalToSuperview().offset(kNavBarTotalHeight)
- make.left.right.bottom.equalTo(0)
- }
-
- if #available(iOS 11.0, *) {
- tableView.contentInsetAdjustmentBehavior = .never
- }
- }
-
- override func setupData() {
-
- tableView.addHeader(withBeginRefresh: true, animation: false) {
- [weak self] (page) in
- self?.communityMemberFollowTopicListApi(page: page)
- }
- tableView.addAutoNormalFooter(withAutomaticallyRefresh: true, loadMoreBlock: {
- [weak self] (page) in
- self?.communityMemberFollowTopicListApi(page: page)
- })
- }
-
- lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
- tableView.separatorStyle = .none
- tableView.backgroundColor = kf7f8faColor
- tableView.dataSource = self
- tableView.delegate = self
- tableView.rowHeight = 60
- return tableView
- }()
- }
- extension CommunityMyFollowTopicController {
- //我的关注话题
- func communityMemberFollowTopicListApi(page:Int) {
- SwiftMoyaNetWorkServiceCommunity.shared().communityMemberFollowTopicListApi(page: page, completion: {
- [weak self] (communityMemberFollowTopicListModel) -> (Void) in
- DIYEmptyView.emptyNoDataTableView(tableView: self?.tableView, imageStr: .twelve, detailStr: .twelve)
- let communityMemberFollowTopicListModel = communityMemberFollowTopicListModel as? CommunityMemberFollowTopicListModel
- if communityMemberFollowTopicListModel?.pagination?.currentPage == 1{
- self?.communityMemberFollowTopicListDataModels.removeAll()
- self?.tableView.resetNoMoreData()
- }
- self?.communityMemberFollowTopicListDataModels = (self?.communityMemberFollowTopicListDataModels)! + (communityMemberFollowTopicListModel?.data!)!
- self?.tableView.reloadData()
- MJRefreshManager.mjRefreshManagerPaginationNoHiddenFooter(tableView: self?.tableView, pagination:communityMemberFollowTopicListModel?.pagination)
- }) {[weak self] loadingStatus in
- MJRefreshManager.mjRefreshManagerLoadingStatus(tableView: self?.tableView,loadingStatus: loadingStatus)
-
- }
- }
- }
- // MARK: - tableView dataSource && delegate
- extension CommunityMyFollowTopicController: UITableViewDataSource, UITableViewDelegate {
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return communityMemberFollowTopicListDataModels.isEmpty ? 0 : communityMemberFollowTopicListDataModels.count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = CommunityMyFollowTopicCell.cellWith(tableView: tableView, indexPath: indexPath)
- cell.communityMemberFollowTopicListDataModel = communityMemberFollowTopicListDataModels[indexPath.row]
- return cell
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- tableView.deselectRow(at: indexPath, animated: true)
-
- Mediator.push(CommunityRouterModuleType.pushFeaturedTopics(id: communityMemberFollowTopicListDataModels[indexPath.row].topicId ?? 0))
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 60
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 10
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0
- }
-
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- return nil
- }
-
- func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
- return nil
- }
-
- }
|