From 19a3cec9bbafe352d67a57ae9a1c4c601c73b6c0 Mon Sep 17 00:00:00 2001 From: younger_times <841720330@qq.com> Date: 星期四, 27 七月 2023 22:19:27 +0800 Subject: [PATCH] fix --- WanPai/Root/Course/TCell/StudentRemarkTCell.swift | 67 +++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 9 deletions(-) diff --git a/WanPai/Root/Course/TCell/StudentRemarkTCell.swift b/WanPai/Root/Course/TCell/StudentRemarkTCell.swift index aca48b3..d6fcd64 100644 --- a/WanPai/Root/Course/TCell/StudentRemarkTCell.swift +++ b/WanPai/Root/Course/TCell/StudentRemarkTCell.swift @@ -1,17 +1,35 @@ -// -// StudentRemarkTCell.swift -// WanPai -// -// Created by 无故事王国 on 2023/6/27. -// + // + // StudentRemarkTCell.swift + // WanPai + // + // Created by 无故事王国 on 2023/6/27. + // import UIKit import JQTools +import Lantern class StudentRemarkTCell: UITableViewCell { - private let cellW:Double = (JQ_ScreenW - 48.0) / 3.0 + var studentCommentModel:StudentCommentModel!{ + didSet{ + img_profile.sd_setImage(with: URL(string: studentCommentModel.headImg)) + label_name.text = studentCommentModel.stuName + label_datetime.text = studentCommentModel.comTime + + label_content.attributedText = AttributedStringbuilder.build().add(string: studentCommentModel.contents, withFont: UIFont.systemFont(ofSize: 12), withColor: UIColor.black.withAlphaComponent(0.8), lineSpace: 5).mutableAttributedString + let count = studentCommentModel.imgs.count + cons_imgHei.constant = ceil(Double(count) / 3) * cellW + floor(Double(count) / 3) * 9 + collectionView.reloadData() + } + } + + private let cellW:Double = (JQ_ScreenW - 55.0) / 3.0 @IBOutlet weak var collectionView: UICollectionView! + @IBOutlet weak var img_profile: UIImageView! + @IBOutlet weak var label_name: UILabel! + @IBOutlet weak var label_datetime: UILabel! + @IBOutlet weak var label_content: UILabel! @IBOutlet weak var cons_imgHei: NSLayoutConstraint! override func awakeFromNib() { @@ -22,7 +40,7 @@ collectionView.dataSource = self collectionView.isScrollEnabled = false collectionView.register(UINib(nibName: "CommonSingleImgCCell", bundle: nil), forCellWithReuseIdentifier: "_CommonSingleImgCCell") - cons_imgHei.constant = ceil(9 / 3) * cellW + floor(9 / 3) * 9 + cons_imgHei.constant = 0 } } @@ -34,11 +52,42 @@ } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 9 + return studentCommentModel.imgs.count } } extension StudentRemarkTCell:UICollectionViewDelegate{ + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let lantern = Lantern() + lantern.numberOfItems = {[weak self] in + return self?.studentCommentModel.imgs.count ?? 0 + } + + lantern.cellClassAtIndex = { _ in + LanternImageCell.self + } + + lantern.transitionAnimator = LanternZoomAnimator(previousView: { index -> UIView? in + + let cell = collectionView.cellForItem(at: IndexPath(item: index, section: indexPath.section)) as! CommonSingleImgCCell + return cell.img + }) + + + // UIPageIndicator样式的页码指示器 + lantern.pageIndicator = LanternDefaultPageIndicator() + + lantern.pageIndex = indexPath.item + + lantern.reloadCellAtIndex = { context in + let lanternCell = context.cell as? CommonSingleImgCCell + + let cell = collectionView.cellForItem(at: IndexPath(item:context.index, section: indexPath.section)) as! CommonSingleImgCCell + lanternCell?.img.image = cell.img.image + } + //不要使用push + lantern.show() + } } -- Gitblit v1.7.1