|
@@ -96,7 +96,6 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
|
|
|
private lazy var titleLabel: UILabel = {
|
|
|
let titleLabel = UILabel()
|
|
|
- titleLabel.text = "绿皮书是一本历史上真实存在的黑人出行指南?是的,真是存在"
|
|
|
titleLabel.textColor = k262626Color
|
|
|
titleLabel.font = kMediumFont16
|
|
|
titleLabel.textAlignment = .left
|
|
@@ -114,13 +113,12 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
|
|
|
private lazy var beanImageView : UIImageView = {
|
|
|
let beanImageView = UIImageView()
|
|
|
- beanImageView.image = kImage(name: "page05")
|
|
|
+ beanImageView.image = kImage(name: "navbar_bean_org")
|
|
|
return beanImageView
|
|
|
}()
|
|
|
|
|
|
private lazy var beanLabel: UILabel = {
|
|
|
let beanLabel = UILabel()
|
|
|
- beanLabel.text = "666彩虹豆待收获"
|
|
|
beanLabel.textColor = kFFA42FColor
|
|
|
beanLabel.font = kRegularFont13
|
|
|
beanLabel.textAlignment = .left
|
|
@@ -129,7 +127,6 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
|
|
|
private lazy var contentLabel: UILabel = {
|
|
|
let contentLabel = UILabel()
|
|
|
- contentLabel.text = "The four-time Tour de France winner crashed at high-speed on Wednesday fracturing his right elbow, and right femur as well as several ribs. The fall took place during a recon of the stage 4 time trial at the Criterium du Dauphine and after several hours of medical assistance on the roadside near Roanne Froome was airlifted to hospital."
|
|
|
contentLabel.textColor = k313334Color
|
|
|
contentLabel.font = kRegularFont15
|
|
|
contentLabel.textAlignment = .left
|
|
@@ -139,7 +136,6 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
|
|
|
private lazy var timeLabel: UILabel = {
|
|
|
let timeLabel = UILabel()
|
|
|
- timeLabel.text = "6个小时前"
|
|
|
timeLabel.textColor = kbbbbbbColor
|
|
|
timeLabel.font = kRegularFont12
|
|
|
timeLabel.textAlignment = .left
|
|
@@ -148,18 +144,25 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
|
|
|
private lazy var readLabel: UILabel = {
|
|
|
let readLabel = UILabel()
|
|
|
- readLabel.text = "6个小时前"
|
|
|
readLabel.textColor = kbbbbbbColor
|
|
|
readLabel.font = kRegularFont12
|
|
|
readLabel.textAlignment = .right
|
|
|
return readLabel
|
|
|
}()
|
|
|
|
|
|
+ lazy var locationButton: UIButton = {
|
|
|
+ let locationButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ locationButton.setImage(kImage(name: "btn_address"), for: UIControl.State.normal)
|
|
|
+ locationButton.setTitleColor(kbbbbbbColor, for: UIControl.State.normal)
|
|
|
+ locationButton.titleLabel?.font = kRegularFont12
|
|
|
+ return locationButton
|
|
|
+ }()
|
|
|
+
|
|
|
private lazy var collectionView: UICollectionView = {
|
|
|
let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
|
|
|
collectionView.backgroundColor = kffffffColor
|
|
|
- collectionView.delegate = self;
|
|
|
- collectionView.dataSource = self;
|
|
|
+ collectionView.delegate = self
|
|
|
+ collectionView.dataSource = self
|
|
|
collectionView.showsVerticalScrollIndicator = false
|
|
|
collectionView.showsHorizontalScrollIndicator = false
|
|
|
collectionView.bounces = false
|
|
@@ -167,30 +170,89 @@ class RecommendDetailContentCell: UITableViewCell {
|
|
|
return collectionView
|
|
|
}()
|
|
|
|
|
|
- private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
|
|
|
+ private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
|
|
|
let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
|
|
|
collectionViewLayout.minimumLineSpacing = 10
|
|
|
collectionViewLayout.minimumInteritemSpacing = 10
|
|
|
collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
|
|
|
- collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 3*10)/4, height: 24)
|
|
|
+ collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 30)/4, height: 24)
|
|
|
+ collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
|
|
return collectionViewLayout
|
|
|
}()
|
|
|
|
|
|
+ var collectionViewheight : CGFloat = 0
|
|
|
//加载数据
|
|
|
func reloadData() {
|
|
|
//collectionView重新加载数据
|
|
|
self.collectionView.reloadData()
|
|
|
//更新collectionView的高度约束
|
|
|
- let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
|
|
|
- collectionView.snp.makeConstraints { (make) in
|
|
|
+ let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
|
|
|
+ collectionViewheight = contentSize.height
|
|
|
+ collectionView.snp.remakeConstraints { (make) in
|
|
|
make.top.equalTo(contentLabel.snp_bottom).offset(15)
|
|
|
- make.left.equalTo(titleLabel.snp_left)
|
|
|
- make.right.equalTo(titleLabel.snp_right)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
make.height.equalTo(contentSize.height)
|
|
|
+ make.bottom.lessThanOrEqualToSuperview()
|
|
|
}
|
|
|
self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
}
|
|
|
|
|
|
+ var communityPostDetailModel : CommunityPostDetailModel? {
|
|
|
+ didSet {
|
|
|
+ beanLabel.text = "\(communityPostDetailModel?.availableBean ?? 0)彩虹豆待收获"
|
|
|
+ contentLabel.text = communityPostDetailModel?.content
|
|
|
+ timeLabel.text = "\(communityPostDetailModel?.createdAt ?? "") I"
|
|
|
+ locationButton.setTitle(communityPostDetailModel?.location, for: UIControl.State.normal)
|
|
|
+ locationButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 3)
|
|
|
+ readLabel.text = "阅读·\(communityPostDetailModel?.pv ?? 0)"
|
|
|
+
|
|
|
+ if communityPostDetailModel?.title == nil || communityPostDetailModel?.title == "" {
|
|
|
+ titleLabel.snp.remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(0)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ rainbowBeanView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.left.equalTo(titleLabel.snp_left)
|
|
|
+ make.height.equalTo(24)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ titleLabel.snp.remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(20)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ rainbowBeanView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.height.equalTo(24)
|
|
|
+ }
|
|
|
+ titleLabel.text = communityPostDetailModel?.title
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var heightModel : HeightModel? {
|
|
|
+ didSet {
|
|
|
+ let contentLabelHeight = communityPostDetailModel?.content?.heightForComment(font: kRegularFont15!, width: kScreenWidth - 28)
|
|
|
+ let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + collectionViewheight + 15.0
|
|
|
+ if communityPostDetailModel?.title == nil || communityPostDetailModel?.title == "" {
|
|
|
+
|
|
|
+ let spacHeight = 20.0 + 10.0 + 15.0 + 15.0 + 20.0
|
|
|
+ heightModel?.height = subViewHeight + CGFloat(spacHeight)
|
|
|
+ }else {
|
|
|
+ let titleHeight = communityPostDetailModel?.title?.heightForComment(font: kMediumFont16!, width: kScreenWidth - 28)
|
|
|
+ let spacHeight = 20.0 + 10.0 + 10.0 + 15.0 + 15.0 + 20.0
|
|
|
+ heightModel?.height = subViewHeight + CGFloat(spacHeight) + (titleHeight ?? 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension RecommendDetailContentCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
|
|
@@ -199,16 +261,21 @@ extension RecommendDetailContentCell: UICollectionViewDelegateFlowLayout,UIColle
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
|
- return 5
|
|
|
+ return communityPostDetailModel?.topic?.count ?? 0
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
let cell = CommunityTagCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
+ cell.communityPostDetailTopicModel = communityPostDetailModel?.topic?[indexPath.row]
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
|
- print("点击了collection----\(indexPath.row)")
|
|
|
+ let communityPostDetailTopicModel = communityPostDetailModel?.topic?[indexPath.row]
|
|
|
+ if let id = communityPostDetailTopicModel?.id {
|
|
|
+ let vc = CommunityFeaturedTopicsViewController()
|
|
|
+ vc.id = id
|
|
|
+ findViewController().navigationController?.pushViewController(vc, animated: true)
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|