|
@@ -0,0 +1,471 @@
|
|
|
|
+//
|
|
|
|
+// CircleEssenceView.swift
|
|
|
|
+// RainbowPlanet
|
|
|
|
+//
|
|
|
|
+// Created by 南鑫林 on 2019/10/15.
|
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
|
+//
|
|
|
|
+
|
|
|
|
+import UIKit
|
|
|
|
+import JXPagingView
|
|
|
|
+import SwiftyMediator
|
|
|
|
+
|
|
|
|
+class CircleEssenceView: BaseView {
|
|
|
|
+
|
|
|
|
+ deinit {
|
|
|
|
+ listViewDidScrollCallback = nil
|
|
|
|
+ if observe != nil {
|
|
|
|
+ NotificationCenter.default.removeObserver(observe!)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ weak var observe : NSObjectProtocol?
|
|
|
|
+ var listViewDidScrollCallback: ((UIScrollView) -> ())?
|
|
|
|
+ var circleId : Int?
|
|
|
|
+ var communityRecommendDataModels = Array<CommunityRecommendDataModel>()
|
|
|
|
+ /// 评论需要的模型
|
|
|
|
+ var communityRecommendDataModel : CommunityRecommendDataModel?
|
|
|
|
+
|
|
|
|
+ override func setupViews() {
|
|
|
|
+ addSubview(tableView)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func setupLayouts() {
|
|
|
|
+ tableView.snp.makeConstraints { (make) in
|
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
|
+ make.height.equalTo(kScreenHeight - kNavBarTotalHeight - 44)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func setupData() {
|
|
|
|
+
|
|
|
|
+ tableView.addHeader(withBeginRefresh: true, animation: false) {
|
|
|
|
+ [weak self] (page) in
|
|
|
|
+ self?.communityCircleArticlesApi(page: page)
|
|
|
|
+ }
|
|
|
|
+ tableView.addAutoNormalFooter(withAutomaticallyRefresh: true, loadMoreBlock: {
|
|
|
|
+ [weak self] (page) in
|
|
|
|
+ self?.communityCircleArticlesApi(page: page)
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("followApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let followStatusModel = notification.object as? FollowStatusModel
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
|
|
|
|
+ if communityRecommendDataModel.uid == followStatusModel?.uid {
|
|
|
|
+ communityRecommendDataModel.isFollow = followStatusModel?.isFollowStatus
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("unlikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let followStatusModel = notification.object as? FollowStatusModel
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
|
|
|
|
+ if communityRecommendDataModel.id == followStatusModel?.postId {
|
|
|
|
+ communityRecommendDataModel.isDislike = followStatusModel?.isFollowStatus
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("islikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let followStatusModel = notification.object as? FollowStatusModel
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
|
|
|
|
+ if communityRecommendDataModel.id == followStatusModel?.postId {
|
|
|
|
+ communityRecommendDataModel.isLike = followStatusModel?.isFollowStatus
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCollectApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let followStatusModel = notification.object as? FollowStatusModel
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
|
|
|
|
+ if communityRecommendDataModel.id == followStatusModel?.postId {
|
|
|
|
+ communityRecommendDataModel.isCollect = followStatusModel?.isFollowStatus
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCommnetLikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let followStatusModel = notification.object as? FollowStatusModel
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
|
|
|
|
+ if communityRecommendDataModel.id == followStatusModel?.postId {
|
|
|
|
+ if !(communityRecommendDataModel.comment?.isEmpty ?? true ){
|
|
|
|
+ for communityRecommendCommentModel in communityRecommendDataModel.comment! {
|
|
|
|
+ if communityRecommendCommentModel.id == followStatusModel?.commnetId {
|
|
|
|
+ communityRecommendCommentModel.isLike = followStatusModel?.isFollowStatus
|
|
|
|
+ communityRecommendCommentModel.likeCount = followStatusModel?.commentLikeCount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("communityDeletePostApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
|
|
|
|
+ let postId = notification.object as? Int
|
|
|
|
+ if !(self?.communityRecommendDataModels.isEmpty ?? true) {
|
|
|
|
+ for (index,communityRecommendDataModel) in (self?.communityRecommendDataModels)!.enumerated() {
|
|
|
|
+ if communityRecommendDataModel.id == postId {
|
|
|
|
+ self?.communityRecommendDataModels.remove(at: index)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private lazy var tableView: UITableView = {
|
|
|
|
+ let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
|
|
|
|
+ tableView.separatorStyle = .none
|
|
|
|
+ tableView.backgroundColor = UIColor.clear
|
|
|
|
+ tableView.dataSource = self
|
|
|
|
+ tableView.delegate = self
|
|
|
|
+ return tableView
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ /// 帖子
|
|
|
|
+ func communityCircleArticlesApi(page:Int) {
|
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityCircleArticlesApi(id: circleId ?? 0, page: page, completion: {
|
|
|
|
+ [weak self] (communityRecommendFeedModel) -> (Void) in
|
|
|
|
+ let communityRecommendFeedModel = communityRecommendFeedModel as? CommunityRecommendFeedModel
|
|
|
|
+ if communityRecommendFeedModel?.pagination?.currentPage == 1{
|
|
|
|
+ self?.communityRecommendDataModels.removeAll()
|
|
|
|
+ self?.tableView.resetNoMoreData()
|
|
|
|
+ }
|
|
|
|
+ self?.communityRecommendDataModels = (self?.communityRecommendDataModels)! + (communityRecommendFeedModel?.data!)!
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ MJRefreshManager.mjRefreshManagerPaginationNoHiddenFooter(tableView: self?.tableView, pagination: communityRecommendFeedModel?.pagination)
|
|
|
|
+ }) {
|
|
|
|
+ [weak self] loadingStatus in
|
|
|
|
+ MJRefreshManager.mjRefreshManagerLoadingStatus(tableView: self?.tableView,loadingStatus: loadingStatus)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 删除帖子
|
|
|
|
+ func communityDeleteApi(postId:Int,section:Int) {
|
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityDeleteApi(postId: postId) { [weak self] (data) -> (Void) in
|
|
|
|
+ self?.communityRecommendDataModels.remove(at: section)
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 评论
|
|
|
|
+ func communityPostCommentApi(text:String,complete: @escaping () -> ()) {
|
|
|
|
+ let communityCustomCommnetModel = CommunityCustomCommnetModel()
|
|
|
|
+ communityCustomCommnetModel.postId = communityRecommendDataModel?.id ?? 0
|
|
|
|
+ communityCustomCommnetModel.content = text
|
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(communityCustomCommnetModel: communityCustomCommnetModel) {
|
|
|
|
+ [weak self] (communityPostCommentIdModel) -> (Void) in
|
|
|
|
+
|
|
|
|
+ let communityPostCommentIdModel = communityPostCommentIdModel as? CommunityPostCommentIdModel
|
|
|
|
+
|
|
|
|
+ let communityRecommendCommentModel = CommunityRecommendCommentModel()
|
|
|
|
+ communityRecommendCommentModel.content = text
|
|
|
|
+ communityRecommendCommentModel.id = communityPostCommentIdModel?.id
|
|
|
|
+ communityRecommendCommentModel.username = UserModel.shared().getModel()?.username
|
|
|
|
+ communityRecommendCommentModel.uid = UserModel.shared().getModel()?.uid
|
|
|
|
+
|
|
|
|
+ if self?.communityRecommendDataModel?.comment?.isEmpty ?? true {
|
|
|
|
+ self?.communityRecommendDataModel?.comment = Array<CommunityRecommendCommentModel>()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self?.communityRecommendDataModel?.comment?.insert(communityRecommendCommentModel, at: 0)
|
|
|
|
+
|
|
|
|
+ VirusViewModel.shared.comment(communityRecommendDataModel: self?.communityRecommendDataModel, id: communityPostCommentIdModel?.id ?? 0,content: text)
|
|
|
|
+ let count = self?.communityRecommendDataModel?.commentCount ?? 0 + 1
|
|
|
|
+ self?.communityRecommendDataModel?.commentCount = count
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+ complete()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// 显示键盘
|
|
|
|
+ func showKeyBoardCommentView() {
|
|
|
|
+ KeyBoardInputView.show(inputViewResultClosure: {
|
|
|
|
+ [weak self] (text) in
|
|
|
|
+ self?.communityPostCommentApi(text: text, complete: {
|
|
|
|
+ [weak self] in
|
|
|
|
+ self?.communityRecommendDataModel = nil
|
|
|
|
+ })
|
|
|
|
+ }) {
|
|
|
|
+ [weak self] in
|
|
|
|
+ self?.communityRecommendDataModel = nil
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+extension CircleEssenceView : UITableViewDelegate,UITableViewDataSource {
|
|
|
|
+
|
|
|
|
+ func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
|
+ return communityRecommendDataModels.isEmpty ? 0 : communityRecommendDataModels.count
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
|
+ return 6
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
|
+ let communityRecommendDataModel = communityRecommendDataModels[indexPath.section]
|
|
|
|
+ switch indexPath.row {
|
|
|
|
+ //贴子用户
|
|
|
|
+ case 0:
|
|
|
|
+ let cell = CardContentUserTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+
|
|
|
|
+ cell.followClosure = {
|
|
|
|
+ [weak self] in
|
|
|
|
+ CommunityFollowUserViewModel.shared.follow(communityRecommendDataModel: communityRecommendDataModel, communityRecommendDataModels: (self?.communityRecommendDataModels)!, tableView: (self?.tableView)!)
|
|
|
|
+ }
|
|
|
|
+ cell.likeClosure = {[weak self] y in
|
|
|
|
+ if UserModel.shared().isEqualUid(uid: communityRecommendDataModel.uid ?? 0) {
|
|
|
|
+ CardContentUserDeleteView.sheetDeleteView(y: y, sureClosure: { [weak self] (cardContentUserDeleteView) in
|
|
|
|
+ self?.communityDeleteApi(postId: communityRecommendDataModel.id ?? 0, section: indexPath.section)
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }else {
|
|
|
|
+ VirusViewModel.shared.like(communityRecommendDataModel: communityRecommendDataModel, y: y, tableView: (self?.tableView)!)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return cell
|
|
|
|
+
|
|
|
|
+ //内容标题
|
|
|
|
+ case 1:
|
|
|
|
+
|
|
|
|
+ if PostType(rawValue: communityRecommendDataModel.type ?? "html") == .html {
|
|
|
|
+ let cell = CardTitleHTMLTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ return cell
|
|
|
|
+ }else {
|
|
|
|
+ let cell = CardContentTitleTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ return cell
|
|
|
|
+ }
|
|
|
|
+ //图片视频
|
|
|
|
+ case 2:
|
|
|
|
+ if PostType(rawValue: communityRecommendDataModel.type ?? "html") == .html {
|
|
|
|
+ let cell = CardContentPicHTMLTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ return cell
|
|
|
|
+ }else {
|
|
|
|
+ let cell = CardContentPicVideoTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.type = .recommend
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ return cell
|
|
|
|
+ }
|
|
|
|
+ //点赞,收藏,分享
|
|
|
|
+ case 3:
|
|
|
|
+ let cell = CardContentActionTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ cell.praiseClosureName = {
|
|
|
|
+ [weak self] (button:UIButton) in
|
|
|
|
+ VirusViewModel.shared.praise(communityRecommendDataModel: communityRecommendDataModel, tableView: (self?.tableView)!)
|
|
|
|
+ }
|
|
|
|
+ cell.collectClosureName = {
|
|
|
|
+ [weak self] (button:UIButton) in
|
|
|
|
+ VirusViewModel.shared.collection(communityRecommendDataModel: communityRecommendDataModel, tableView: (self?.tableView)!)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cell
|
|
|
|
+ //评论列表
|
|
|
|
+ case 4:
|
|
|
|
+ let cell = CardContentCommentListTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityRecommendDataModel = communityRecommendDataModel
|
|
|
|
+ return cell
|
|
|
|
+ //评论
|
|
|
|
+ case 5:
|
|
|
|
+ let cell = CardContentCommnetTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.addCommnetClosureName = {
|
|
|
|
+ [weak self] in
|
|
|
|
+ self?.communityRecommendDataModel = self?.communityRecommendDataModels[indexPath.section]
|
|
|
|
+ self?.showKeyBoardCommentView()
|
|
|
|
+ }
|
|
|
|
+ cell.isAvatar = true
|
|
|
|
+ return cell
|
|
|
|
+ default:
|
|
|
|
+ return UITableViewCell()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
+ let communityRecommendDataModel = communityRecommendDataModels[indexPath.section]
|
|
|
|
+
|
|
|
|
+ switch indexPath.row {
|
|
|
|
+ //贴子用户
|
|
|
|
+ case 0:
|
|
|
|
+ break
|
|
|
|
+ //图片视频/内容标题/评论列表
|
|
|
|
+ case 1,2:
|
|
|
|
+ if PostType(rawValue: communityRecommendDataModel.type ?? "video") == .video {
|
|
|
|
+ Mediator.push(CommunityRouterModuleType.pushPostDetailVoide(postId: "\(communityRecommendDataModel.id ?? 0)", departType: .others, topicId: 0))
|
|
|
|
+ }else {
|
|
|
|
+ Mediator.push(CommunityRouterModuleType.pushPostDetailContent(postId: "\(communityRecommendDataModel.id ?? 0)"))
|
|
|
|
+ }
|
|
|
|
+ break
|
|
|
|
+ //点赞,收藏,分享
|
|
|
|
+ case 3:
|
|
|
|
+ break
|
|
|
|
+ //评论
|
|
|
|
+ case 5:
|
|
|
|
+ break
|
|
|
|
+ default:
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
|
|
+
|
|
|
|
+ let communityRecommendDataModel = communityRecommendDataModels[indexPath.section]
|
|
|
|
+ switch indexPath.row {
|
|
|
|
+ //贴子用户
|
|
|
|
+ case 0:
|
|
|
|
+ if communityRecommendDataModel.uid != nil {
|
|
|
|
+ return 80
|
|
|
|
+ }
|
|
|
|
+ return 0
|
|
|
|
+
|
|
|
|
+ //内容标题
|
|
|
|
+ case 1:
|
|
|
|
+
|
|
|
|
+ if PostType(rawValue: communityRecommendDataModel.type ?? "html") == .html {
|
|
|
|
+ var titleStr = communityRecommendDataModel.title ?? ""
|
|
|
|
+ titleStr = titleStr.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\r", with: "")
|
|
|
|
+ let subtitleLabelHeight = titleStr.heightForComment(font: kMediumFont16!, width: kScreenWidth-28, maxHeight: 44.0)
|
|
|
|
+ return subtitleLabelHeight
|
|
|
|
+ }else {
|
|
|
|
+ var titleStr = communityRecommendDataModel.title ?? ""
|
|
|
|
+ titleStr = titleStr.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\r", with: "")
|
|
|
|
+
|
|
|
|
+ var str = communityRecommendDataModel.content ?? ""
|
|
|
|
+ str = str.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\r", with: "")
|
|
|
|
+
|
|
|
|
+ let subtitleLabelHeight = str.heightForComment(font: kRegularFont14!, width: kScreenWidth-28, maxHeight: 40.0)
|
|
|
|
+
|
|
|
|
+ if titleStr == "" {
|
|
|
|
+ return subtitleLabelHeight
|
|
|
|
+ }else {
|
|
|
|
+ return 22 + 6 + subtitleLabelHeight
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //图片视频
|
|
|
|
+ case 2:
|
|
|
|
+
|
|
|
|
+ if PostType(rawValue: communityRecommendDataModel.type ?? "html") == .html {
|
|
|
|
+
|
|
|
|
+ return 82
|
|
|
|
+ }else {
|
|
|
|
+ let cardContentPicVideoModel = CardContentPicVideoModel()
|
|
|
|
+ cardContentPicVideoModel.postType = PostType(rawValue: communityRecommendDataModel.type ?? "html")
|
|
|
|
+
|
|
|
|
+ let imgStr = communityRecommendDataModel.img
|
|
|
|
+ if communityRecommendDataModel.imgs?.count ?? 0 == 0 {
|
|
|
|
+ if communityRecommendDataModel.img != "" && communityRecommendDataModel.img != nil {
|
|
|
|
+ cardContentPicVideoModel.number = 1
|
|
|
|
+ cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
|
|
|
|
+ cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
|
|
|
|
+ return cardContentPicVideoModel.collectionViewHeight() + 12
|
|
|
|
+ }else {
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if communityRecommendDataModel.imgs?.count ?? 0 == 1 {
|
|
|
|
+ if communityRecommendDataModel.img != "" || communityRecommendDataModel.img != nil {
|
|
|
|
+ cardContentPicVideoModel.number = 1
|
|
|
|
+ cardContentPicVideoModel.width = getImageWidth(imgStr: (imgStr)!)
|
|
|
|
+ cardContentPicVideoModel.height = getImageHeight(imgStr: (imgStr)!)
|
|
|
|
+ return cardContentPicVideoModel.collectionViewHeight() + 12
|
|
|
|
+ }else {
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ cardContentPicVideoModel.number = communityRecommendDataModel.imgs?.count ?? 0
|
|
|
|
+ return cardContentPicVideoModel.collectionViewHeight() + 12
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //点赞,收藏,分享
|
|
|
|
+ case 3:
|
|
|
|
+ return 54
|
|
|
|
+ //评论列表
|
|
|
|
+ case 4:
|
|
|
|
+ if !(communityRecommendDataModel.comment?.isEmpty ?? true) {
|
|
|
|
+
|
|
|
|
+ var height : CGFloat?
|
|
|
|
+ for communityRecommendCommentModel in communityRecommendDataModel.comment!.prefix(2) {
|
|
|
|
+
|
|
|
|
+ let nameStr = "\(communityRecommendCommentModel.username ?? ""):"
|
|
|
|
+ let contentStr = "\(communityRecommendCommentModel.content ?? "")"
|
|
|
|
+ let likeCountStr = "\(communityRecommendCommentModel.likeCount ?? 0)"
|
|
|
|
+ let likeWidth = likeCountStr.widthForComment(font: kRegularFont14!, height: 25.5)
|
|
|
|
+
|
|
|
|
+ let str = nameStr + contentStr
|
|
|
|
+ let strHeight = (str.heightForComment(font: kRegularFont14!, width: kScreenWidth-28-10-20-5-likeWidth) + 5)
|
|
|
|
+ height = (height ?? 0) + strHeight
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (communityRecommendDataModel.commentCount ?? 0) <= 2 {
|
|
|
|
+ return (height ?? 0)
|
|
|
|
+ }else {
|
|
|
|
+ return 23 + (height ?? 0)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0
|
|
|
|
+ //评论
|
|
|
|
+ case 5:
|
|
|
|
+ return 50
|
|
|
|
+ default:
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
|
|
+ return 0.000001
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
|
|
|
|
+ return 10
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
|
|
+
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
|
|
|
|
+ let view = UIView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 10))
|
|
|
|
+ view.backgroundColor = kf7f8faColor
|
|
|
|
+ return view
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+extension CircleEssenceView : JXPagingViewListViewDelegate {
|
|
|
|
+ public func listView() -> UIView {
|
|
|
|
+ return self
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public func listViewDidScrollCallback(callback: @escaping (UIScrollView) -> ()) {
|
|
|
|
+ self.listViewDidScrollCallback = callback
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public func listScrollView() -> UIScrollView {
|
|
|
|
+ return UIScrollView()
|
|
|
|
+ }
|
|
|
|
+}
|