From 6e4c4b8a335ee16b42706389c11119aa10d22acc Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Mon, 1 Apr 2024 23:35:53 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20#360=20-=20=ED=8C=8C=ED=8A=B8=20?= =?UTF-8?q?=EC=B0=A8=ED=8A=B8=20=EB=9E=AD=ED=82=B9=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=B0=94=EC=9D=B8=EB=94=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/STPartChartRectangleView.swift | 8 +++++++- .../RankingScene/Cells/PartRankingChartCVC.swift | 1 - .../Sources/RankingScene/VC/PartRankingVC.swift | 15 ++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SOPT-iOS/Projects/Features/StampFeature/Sources/Components/STPartChartRectangleView.swift b/SOPT-iOS/Projects/Features/StampFeature/Sources/Components/STPartChartRectangleView.swift index b91fa9ac..e032a4bb 100644 --- a/SOPT-iOS/Projects/Features/StampFeature/Sources/Components/STPartChartRectangleView.swift +++ b/SOPT-iOS/Projects/Features/StampFeature/Sources/Components/STPartChartRectangleView.swift @@ -124,6 +124,12 @@ extension STPartChartRectangleView { } } + private func updateLayout() { + rectangleView.snp.updateConstraints { make in + make.height.equalTo(self.calculateRectangleViewHeight()) + } + } + private func calculateRectangleViewHeight() -> CGFloat { return 27.f * (7 - rank).f } @@ -131,10 +137,10 @@ extension STPartChartRectangleView { extension STPartChartRectangleView { public func setData(rank: Int, partName: String) { - print(rank) self.rank = rank self.partName = partName self.setUI() + self.updateLayout() } } diff --git a/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/Cells/PartRankingChartCVC.swift b/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/Cells/PartRankingChartCVC.swift index cc4649c2..70be3e57 100644 --- a/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/Cells/PartRankingChartCVC.swift +++ b/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/Cells/PartRankingChartCVC.swift @@ -69,7 +69,6 @@ extension PartRankingChartCVC { // MARK: - Methods extension PartRankingChartCVC { - public func setData(model: RankingChartModel) { let models = model.ranking self.models = models diff --git a/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/VC/PartRankingVC.swift b/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/VC/PartRankingVC.swift index 81b89fec..b37fe908 100644 --- a/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/VC/PartRankingVC.swift +++ b/SOPT-iOS/Projects/Features/StampFeature/Sources/RankingScene/VC/PartRankingVC.swift @@ -82,10 +82,10 @@ public class PartRankingVC: UIViewController, PartRankingViewControllable { self.setDataSource() // TODO: 제거 - applySnapshot(model: [.init(username: "a", score: 1, sentence: "test"), + applySnapshot(model: [.init(username: "a", score: 4, sentence: "test"), .init(username: "b", score: 1, sentence: "test"), - .init(username: "c", score: 1, sentence: "test"), - .init(username: "d", score: 1, sentence: "test")] + .init(username: "c", score: 3, sentence: "test"), + .init(username: "d", score: 2, sentence: "test")] ) } } @@ -161,7 +161,7 @@ extension PartRankingVC { guard let rankingListCell = collectionView.dequeueReusableCell(withReuseIdentifier: RankingListCVC.className, for: indexPath) as? RankingListCVC, let rankingListCellModel = itemIdentifier as? RankingModel else { return UICollectionViewCell() } rankingListCell.setData(model: rankingListCellModel, - rank: indexPath.row + 1 + 3) + rank: indexPath.row+1) return rankingListCell } @@ -171,12 +171,9 @@ extension PartRankingVC { func applySnapshot(model: [RankingModel]) { var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.chart, .list]) - guard model.count >= 4 else { return } - guard let chartCellModels = Array(model[0...2]) as? [RankingModel], - let rankingListModel = Array(model[3...model.count-1]) as? [RankingModel] else { return } - let chartCellModel = RankingChartModel.init(ranking: chartCellModels) + let chartCellModel = RankingChartModel.init(ranking: model) snapshot.appendItems([chartCellModel], toSection: .chart) - snapshot.appendItems(rankingListModel, toSection: .list) + snapshot.appendItems(model, toSection: .list) dataSource.apply(snapshot, animatingDifferences: false) self.view.setNeedsLayout() }