From c9ba0cec82e1d28376ab3b38396f63e40d2b1de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 30 May 2024 23:36:30 +0900 Subject: [PATCH 01/10] =?UTF-8?q?ADD=20::=20[#334]=20=EC=9E=90=EC=84=B8=20?= =?UTF-8?q?-=20=EB=94=94=ED=85=8C=EC=9D=BC=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Supporter/Detail/PostureDetailExplanView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift new file mode 100644 index 00000000..ece1a9d5 --- /dev/null +++ b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift @@ -0,0 +1,9 @@ +// +// PostureDetailExplanView.swift +// PostureFeatureInterface +// +// Created by 이은호 on 5/27/24. +// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. +// + +import Foundation From f0b3fd8c52566d591764a29d4893a21d91036fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 30 May 2024 23:38:11 +0900 Subject: [PATCH 02/10] =?UTF-8?q?FIX=20::=20[#334]=20=EC=9E=90=EC=84=B8=20?= =?UTF-8?q?-=20=EB=94=94=ED=85=8C=EC=9D=BC=20ViewModel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PostureScene/ViewModel/Detail/PostureDetailViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Features/PostureFeature/Sources/PostureScene/ViewModel/Detail/PostureDetailViewModel.swift b/Projects/Features/PostureFeature/Sources/PostureScene/ViewModel/Detail/PostureDetailViewModel.swift index 246830d9..59350b00 100644 --- a/Projects/Features/PostureFeature/Sources/PostureScene/ViewModel/Detail/PostureDetailViewModel.swift +++ b/Projects/Features/PostureFeature/Sources/PostureScene/ViewModel/Detail/PostureDetailViewModel.swift @@ -8,7 +8,7 @@ import Core import Domain import MGLogger -public class PostureDetailViewModel: BaseViewModel { +public class PostureDetailViewModel: PostureViewModelType { public typealias ViewModel = PostureDetailViewModel From 3a367858307a8b85d8279f2a76beca15abc984d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 30 May 2024 23:38:35 +0900 Subject: [PATCH 03/10] =?UTF-8?q?ADD=20::=20[#334]=20=EC=9E=90=EC=84=B8=20?= =?UTF-8?q?-=20=EB=94=94=ED=85=8C=EC=9D=BC=20=EC=84=A4=EB=AA=85=20View?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/PostureDetailExplanView.swift | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift index ece1a9d5..71e9f2ab 100644 --- a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift +++ b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift @@ -1,9 +1,30 @@ -// -// PostureDetailExplanView.swift -// PostureFeatureInterface -// -// Created by 이은호 on 5/27/24. -// Copyright © 2024 MaeumGaGym-iOS. All rights reserved. -// - -import Foundation +import UIKit + +import SnapKit +import Then + +import DSKit +import Core + +public class PostureDetailExplanView: BaseView { + + private var titleLabel = MGLabel( + font: UIFont.Pretendard.titleMedium, + isCenter: false + ) + + private var contentsLabel = MGLabel( + font: UIFont.Pretendard.bodyMedium, + isCenter: false + ) + + public override func layout() { + addSubviews([titleLabel]) + + titleLabel.snp.makeConstraints { + $0.top.equalToSuperview().offset(12) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(32) + } + } +} From 698dc76c4cb16262116ad727cc89244bd899e7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Thu, 30 May 2024 23:38:58 +0900 Subject: [PATCH 04/10] =?UTF-8?q?FIX=20::=20[#334]=20sceneDelegate=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Demo/Sources/SceneDelegate.swift | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Projects/Features/PostureFeature/Demo/Sources/SceneDelegate.swift b/Projects/Features/PostureFeature/Demo/Sources/SceneDelegate.swift index 8d1cabd7..dfef9366 100644 --- a/Projects/Features/PostureFeature/Demo/Sources/SceneDelegate.swift +++ b/Projects/Features/PostureFeature/Demo/Sources/SceneDelegate.swift @@ -22,14 +22,20 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { window = UIWindow(frame: scene.coordinateSpace.bounds) window?.windowScene = scene - - mainFlow = PostureFlow() - - coordinator.coordinate(flow: mainFlow, with: OneStepper(withSingleStep: MGStep.postureMainIsRequired)) - Flows.use(mainFlow, when: .created) { root in - self.window?.rootViewController = root - self.window?.makeKey() - } + + let useCase = DefaultPostureUseCase(repository: PostureRepository(networkService: PostureService())) + let viewModel = PostureDetailViewModel(useCase: useCase) + let viewController = PostureDetailViewController(viewModel) + + window?.rootViewController = viewController + +// mainFlow = PostureFlow() +// +// coordinator.coordinate(flow: mainFlow, with: OneStepper(withSingleStep: MGStep.postureDetailIsRequired(withDetailId: 0))) +// Flows.use(mainFlow, when: .created) { root in +// self.window?.rootViewController = root +// self.window?.makeKey() +// } window?.makeKeyAndVisible() } } From abb2004ed08ce02204a5fa84af864c5ce2e3aa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:07:31 +0900 Subject: [PATCH 05/10] =?UTF-8?q?FEAT=20::=20[#334]=20=EC=9E=90=EC=84=B8?= =?UTF-8?q?=20-=20=EB=94=94=ED=85=8C=EC=9D=BC=20TableViewCell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 디테일 자극 부위, 시작자세, 운동 방법, 호흡법, 주의 사항에 사용할 tableViewCell 구현 --- .../Detail/PostureDetailTableViewCell.swift | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift new file mode 100644 index 00000000..c3dc0d8e --- /dev/null +++ b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift @@ -0,0 +1,134 @@ +import UIKit + +import SnapKit +import Then + +import DSKit +import Core +import Domain + +public class PostureDetailTableViewCell: BaseTableViewCell { + + static let identifier: String = "PostureDetailTableViewCell" + + private var titleLabel = MGLabel( + font: UIFont.Pretendard.titleMedium, + isCenter: false + ) + + private var contentsLabel = MGLabel( + font: UIFont.Pretendard.bodyMedium, + isCenter: false + ) + + private var detailTextCollectionView: UICollectionView = { + let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout().then { + $0.scrollDirection = .vertical + $0.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 16, right: 0) + } + + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout).then { + $0.register(PostureDetailTextCollectionViewCell.self, + forCellWithReuseIdentifier: PostureDetailTextCollectionViewCell.identifier) + $0.translatesAutoresizingMaskIntoConstraints = false + $0.showsHorizontalScrollIndicator = false + $0.showsVerticalScrollIndicator = false + $0.backgroundColor = .white + $0.isScrollEnabled = false + } + return collectionView + }() + + private var detailTextModel: [PostureDetailInfoTextModel] = [] { + didSet { + detailTextCollectionView.reloadData() + } + } + + public override func layout() { + addSubviews([titleLabel]) + + titleLabel.snp.makeConstraints { + $0.top.equalToSuperview().offset(12) + $0.leading.trailing.equalToSuperview() + $0.height.equalTo(32) + } + } + + public override func attribute() { + super.attribute() + + detailTextCollectionView.delegate = self + detailTextCollectionView.dataSource = self + } + + private func setLayout(dataCount: Int) { + switch dataCount { + case 1: + addSubviews([contentsLabel]) + + contentsLabel.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(12) + $0.leading.trailing.equalToSuperview() + $0.bottom.equalToSuperview().inset(12) + } + default: + addSubviews([detailTextCollectionView]) + + detailTextCollectionView.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(24) + $0.leading.trailing.equalToSuperview() + $0.bottom.equalToSuperview().inset(12) + } + } + } +} + +public extension PostureDetailTableViewCell { + func setup(with model: PostureDetailInfoModel) { + switch model.infoText.count { + case 1: + setLayout(dataCount: 1) + contentsLabel.changeText(text: "\(model.infoText[0].text)") + default: + setLayout(dataCount: 0) + detailTextModel = model.infoText + } + titleLabel.changeText(text: model.titleText) + } +} + +extension PostureDetailTableViewCell: UICollectionViewDelegateFlowLayout { + public func collectionView( + _ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + sizeForItemAt indexPath: IndexPath + ) -> CGSize { + let lineCount = detailTextModel[indexPath.row].text.components(separatedBy: "\n").count - 1 + + return CGSize(width: detailTextCollectionView.frame.width, height: 32.0 + (CGFloat(lineCount) * 20.0)) + } +} + +extension PostureDetailTableViewCell: UICollectionViewDataSource { + public func collectionView( + _ collectionView: UICollectionView, + numberOfItemsInSection section: Int + ) -> Int { + return detailTextModel.count + } + + public func collectionView( + _ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath + ) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell( + withReuseIdentifier: PostureDetailTextCollectionViewCell.identifier, + for: indexPath + ) as? PostureDetailTextCollectionViewCell + let model = detailTextModel + cell?.setup(index: indexPath.row + 1, with: model) + return cell ?? UICollectionViewCell() + } +} + From 645ac582868b258c106c080fb913f99fbbed3b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:07:42 +0900 Subject: [PATCH 06/10] =?UTF-8?q?BURN=20::=20[#334]=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/PostureDetailExplanView.swift | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift deleted file mode 100644 index 71e9f2ab..00000000 --- a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailExplanView.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit - -import SnapKit -import Then - -import DSKit -import Core - -public class PostureDetailExplanView: BaseView { - - private var titleLabel = MGLabel( - font: UIFont.Pretendard.titleMedium, - isCenter: false - ) - - private var contentsLabel = MGLabel( - font: UIFont.Pretendard.bodyMedium, - isCenter: false - ) - - public override func layout() { - addSubviews([titleLabel]) - - titleLabel.snp.makeConstraints { - $0.top.equalToSuperview().offset(12) - $0.leading.trailing.equalToSuperview() - $0.height.equalTo(32) - } - } -} From 72ba645584a8e0a914140f1cea7abce512fdbd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:08:13 +0900 Subject: [PATCH 07/10] FEAT :: [#334] PostureService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 자세 - 더미 값 추가 --- .../Sources/Service/PostureService.swift | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Projects/Modules/MGNetworks/Sources/Service/PostureService.swift b/Projects/Modules/MGNetworks/Sources/Service/PostureService.swift index 6e7bb665..07d16194 100644 --- a/Projects/Modules/MGNetworks/Sources/Service/PostureService.swift +++ b/Projects/Modules/MGNetworks/Sources/Service/PostureService.swift @@ -174,6 +174,20 @@ private extension PostureService { titleTextData: PostureDetailTitleTextModel(englishName: "푸쉬업", koreanName: "팔굽혀펴기"), exerciseKindData: [PostureDetailExerciseKindModel(exerciseTag: "맨몸"), PostureDetailExerciseKindModel(exerciseTag: "가슴")], + exercisePartData: + PostureDetailInfoModel( + titleText: "자극 부위", + infoText: + [ + PostureDetailInfoTextModel(text: "대흉근, 삼두근, 이두근"), + ]), + exerciseStartData: + PostureDetailInfoModel( + titleText: "시작 자세", + infoText: + [ + PostureDetailInfoTextModel(text: "양팔을 가슴 옆에 두고 바닥에 엎드립니다."), + ]), exerciseWayData: PostureDetailInfoModel( titleText: "운동 방법", @@ -182,8 +196,13 @@ private extension PostureService { PostureDetailInfoTextModel(text: "양팔을 가슴 옆에 두고 바닥에 엎드립니다."), PostureDetailInfoTextModel(text: "복근과 둔근에 힘을 준 상태로 팔꿈치를 피며\n올라옵니다."), PostureDetailInfoTextModel(text: "천천히 팔꿈치를 굽히며 시작 자세로 돌아갑니다."), - PostureDetailInfoTextModel(text: "양팔을 가슴 옆에 두고 바닥에 엎드립니다."), - PostureDetailInfoTextModel(text: "양팔을 가슴 옆에 두고 바닥에 엎드립니다.") + ]), + exerciseBreathData: + PostureDetailInfoModel( + titleText: "호흡법", + infoText: + [ + PostureDetailInfoTextModel(text: "흡 하 흡 하 흡흡흡 하하하"), ]), exerciseCautionData: PostureDetailInfoModel( From 5fc14365008b4fb8b18a551f75db914b2ff60ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:08:57 +0900 Subject: [PATCH 08/10] =?UTF-8?q?FEAT=20::=20[#334]=20=EC=9E=90=EC=84=B8?= =?UTF-8?q?=20-=20=EB=94=94=ED=85=8C=EC=9D=BC=20VC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 유동적인 tableViewCell 높이 지정, 코드 리펙토링 --- .../Detail/PostureDetailViewController.swift | 116 ++++++++++++------ .../PostureDetailTextCollectionViewCell.swift | 0 2 files changed, 81 insertions(+), 35 deletions(-) rename Projects/Features/PostureFeature/Sources/Supporter/Detail/{CollectionViewCell => }/PostureDetailTextCollectionViewCell.swift (100%) diff --git a/Projects/Features/PostureFeature/Sources/PostureScene/View/Detail/PostureDetailViewController.swift b/Projects/Features/PostureFeature/Sources/PostureScene/View/Detail/PostureDetailViewController.swift index fc87d43b..2226461b 100644 --- a/Projects/Features/PostureFeature/Sources/PostureScene/View/Detail/PostureDetailViewController.swift +++ b/Projects/Features/PostureFeature/Sources/PostureScene/View/Detail/PostureDetailViewController.swift @@ -24,22 +24,34 @@ public class PostureDetailViewController: BaseViewController CGFloat { + let model = model + var lineCount = 0 + var modelCount = model.count + var middleDistance = 12 + + for data in model { + lineCount += data.text.components(separatedBy: "\n").count - 1 + } + + if modelCount == 1 { + modelCount = 0 + lineCount += 1 + } else { + middleDistance = 8 + } + + return CGFloat(80 + (modelCount * 48) + (lineCount * 20) + middleDistance) + } } extension PostureDetailViewController: UITableViewDelegate { @@ -97,26 +126,19 @@ extension PostureDetailViewController: UITableViewDelegate { case 2: return 60 case 3: - let model = postureDetailModel.exerciseWayData.infoText - var lineCount = 0 - for data in model { - lineCount += data.text.components(separatedBy: "\n").count - 1 - } - print("\(lineCount)") - print("\(model.count)") - print(92 + (model.count * 48) + (lineCount * 20)) - return CGFloat(92 + (model.count * 48) + (lineCount * 20)) + return calculateCellHeight(model: postureDetailModel.exercisePartData.infoText) case 4: - let model = postureDetailModel.exerciseCautionData.infoText - var lineCount = 0 - for data in model { - lineCount += data.text.components(separatedBy: "\n").count - 1 - } - return CGFloat(92 + (model.count * 48) + (lineCount * 20)) + return calculateCellHeight(model: postureDetailModel.exerciseStartData.infoText) case 5: + return calculateCellHeight(model: postureDetailModel.exerciseWayData.infoText) + case 6: + return calculateCellHeight(model: postureDetailModel.exerciseBreathData.infoText) + case 7: + return calculateCellHeight(model: postureDetailModel.exerciseCautionData.infoText) + case 8: return 360 default: - return UITableView.automaticDimension + return 0 } } } @@ -126,7 +148,7 @@ extension PostureDetailViewController: UITableViewDataSource { _ tableView: UITableView, numberOfRowsInSection section: Int ) -> Int { - return 6 + return 9 } public func tableView( @@ -160,21 +182,45 @@ extension PostureDetailViewController: UITableViewDataSource { return cell ?? UITableViewCell() case 3: let cell = postureDetailTableView.dequeueReusableCell( - withIdentifier: PostureDetailInfoTableViewCell.identifier, - for: indexPath) as? PostureDetailInfoTableViewCell - let model = postureDetailModel.exerciseWayData + withIdentifier: PostureDetailTableViewCell.identifier, + for: indexPath) as? PostureDetailTableViewCell + let model = postureDetailModel.exercisePartData cell?.setup(with: model) cell?.selectionStyle = .none return cell ?? UITableViewCell() case 4: let cell = postureDetailTableView.dequeueReusableCell( - withIdentifier: PostureDetailInfoTableViewCell.identifier, - for: indexPath) as? PostureDetailInfoTableViewCell - let model = postureDetailModel.exerciseCautionData + withIdentifier: PostureDetailTableViewCell.identifier, + for: indexPath) as? PostureDetailTableViewCell + let model = postureDetailModel.exerciseStartData cell?.setup(with: model) cell?.selectionStyle = .none return cell ?? UITableViewCell() case 5: + let cell = postureDetailTableView.dequeueReusableCell( + withIdentifier: PostureDetailTableViewCell.identifier, + for: indexPath) as? PostureDetailTableViewCell + let model = postureDetailModel.exerciseWayData + cell?.setup(with: model) + cell?.selectionStyle = .none + return cell ?? UITableViewCell() + case 6: + let cell = postureDetailTableView.dequeueReusableCell( + withIdentifier: PostureDetailTableViewCell.identifier, + for: indexPath) as? PostureDetailTableViewCell + let model = postureDetailModel.exerciseBreathData + cell?.setup(with: model) + cell?.selectionStyle = .none + return cell ?? UITableViewCell() + case 7: + let cell = postureDetailTableView.dequeueReusableCell( + withIdentifier: PostureDetailTableViewCell.identifier, + for: indexPath) as? PostureDetailTableViewCell + let model = postureDetailModel.exerciseCautionData + cell?.setup(with: model) + cell?.selectionStyle = .none + return cell ?? UITableViewCell() + case 8: let cell = postureDetailTableView.dequeueReusableCell( withIdentifier: PostureDetailPickeTableViewCell.identifier, for: indexPath) as? PostureDetailPickeTableViewCell diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/CollectionViewCell/PostureDetailTextCollectionViewCell.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTextCollectionViewCell.swift similarity index 100% rename from Projects/Features/PostureFeature/Sources/Supporter/Detail/CollectionViewCell/PostureDetailTextCollectionViewCell.swift rename to Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTextCollectionViewCell.swift From 75b11d4cfbbcb47141ce31bd9db4972cf112c082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:09:09 +0900 Subject: [PATCH 09/10] =?UTF-8?q?ADD=20::=20[#334]=20=EB=8D=94=EB=AF=B8?= =?UTF-8?q?=EA=B0=92=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Model/Posture/PostureDetailModel.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Projects/Domain/Sources/Model/Posture/PostureDetailModel.swift b/Projects/Domain/Sources/Model/Posture/PostureDetailModel.swift index e8e45955..2a23715b 100644 --- a/Projects/Domain/Sources/Model/Posture/PostureDetailModel.swift +++ b/Projects/Domain/Sources/Model/Posture/PostureDetailModel.swift @@ -4,21 +4,30 @@ public struct PostureDetailModel { public var detailImage: UIImage public var titleTextData: PostureDetailTitleTextModel public var exerciseKindData: [PostureDetailExerciseKindModel] + public var exercisePartData: PostureDetailInfoModel + public var exerciseStartData: PostureDetailInfoModel public var exerciseWayData: PostureDetailInfoModel + public var exerciseBreathData: PostureDetailInfoModel public var exerciseCautionData: PostureDetailInfoModel public var relatedPickleData: PostureDetailPickleModel public init(detailImage: UIImage, titleTextData: PostureDetailTitleTextModel, exerciseKindData: [PostureDetailExerciseKindModel], + exercisePartData: PostureDetailInfoModel, + exerciseStartData: PostureDetailInfoModel, exerciseWayData: PostureDetailInfoModel, + exerciseBreathData: PostureDetailInfoModel, exerciseCautionData: PostureDetailInfoModel, relatedPickleData: PostureDetailPickleModel) { self.detailImage = detailImage self.titleTextData = titleTextData self.exerciseKindData = exerciseKindData + self.exercisePartData = exercisePartData + self.exerciseStartData = exerciseStartData self.exerciseWayData = exerciseWayData + self.exerciseBreathData = exerciseBreathData self.exerciseCautionData = exerciseCautionData self.relatedPickleData = relatedPickleData } From 831e5eb3c51202d9e5e127f4cdbb3bcbf8541d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=80=ED=98=B8?= <127753071+Eunho0922@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:09:53 +0900 Subject: [PATCH 10/10] =?UTF-8?q?REFACT=20::=20[#334]=20=EC=9E=90=EC=84=B8?= =?UTF-8?q?=20-=20=EB=94=94=ED=85=8C=EC=9D=BC=20-=20tableViewCell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 리펙토링 진행 --- .../Detail/PostureDetailTableViewCell.swift | 65 +++++++++++-------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift index c3dc0d8e..81204cca 100644 --- a/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift +++ b/Projects/Features/PostureFeature/Sources/Supporter/Detail/PostureDetailTableViewCell.swift @@ -10,6 +10,8 @@ import Domain public class PostureDetailTableViewCell: BaseTableViewCell { static let identifier: String = "PostureDetailTableViewCell" + + private var containerView = BaseView() private var titleLabel = MGLabel( font: UIFont.Pretendard.titleMedium, @@ -18,13 +20,13 @@ public class PostureDetailTableViewCell: BaseTableViewCell { private var contentsLabel = MGLabel( font: UIFont.Pretendard.bodyMedium, - isCenter: false + isCenter: false, + numberOfLineCount: 3 ) private var detailTextCollectionView: UICollectionView = { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout().then { $0.scrollDirection = .vertical - $0.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 16, right: 0) } let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout).then { @@ -46,13 +48,35 @@ public class PostureDetailTableViewCell: BaseTableViewCell { } public override func layout() { - addSubviews([titleLabel]) + addSubviews([containerView]) + containerView.addSubviews([titleLabel, contentsLabel, detailTextCollectionView]) + containerView.snp.makeConstraints { + $0.top.equalToSuperview().offset(24.0) + $0.centerX.bottom.equalToSuperview() + $0.width.equalToSuperview().inset(20.0) + } + titleLabel.snp.makeConstraints { $0.top.equalToSuperview().offset(12) - $0.leading.trailing.equalToSuperview() + $0.centerX.equalToSuperview() + $0.width.equalToSuperview() $0.height.equalTo(32) } + + detailTextCollectionView.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(8) + $0.bottom.equalToSuperview().inset(12) + $0.centerX.equalToSuperview() + $0.width.equalToSuperview() + } + + contentsLabel.snp.makeConstraints { + $0.top.equalTo(titleLabel.snp.bottom).offset(12) + $0.bottom.equalToSuperview().inset(12) + $0.centerX.equalToSuperview() + $0.width.equalToSuperview() + } } public override func attribute() { @@ -61,38 +85,19 @@ public class PostureDetailTableViewCell: BaseTableViewCell { detailTextCollectionView.delegate = self detailTextCollectionView.dataSource = self } - - private func setLayout(dataCount: Int) { - switch dataCount { - case 1: - addSubviews([contentsLabel]) - - contentsLabel.snp.makeConstraints { - $0.top.equalTo(titleLabel.snp.bottom).offset(12) - $0.leading.trailing.equalToSuperview() - $0.bottom.equalToSuperview().inset(12) - } - default: - addSubviews([detailTextCollectionView]) - - detailTextCollectionView.snp.makeConstraints { - $0.top.equalTo(titleLabel.snp.bottom).offset(24) - $0.leading.trailing.equalToSuperview() - $0.bottom.equalToSuperview().inset(12) - } - } - } } public extension PostureDetailTableViewCell { func setup(with model: PostureDetailInfoModel) { switch model.infoText.count { case 1: - setLayout(dataCount: 1) contentsLabel.changeText(text: "\(model.infoText[0].text)") + detailTextCollectionView.isHidden = true + contentsLabel.isHidden = false default: - setLayout(dataCount: 0) detailTextModel = model.infoText + detailTextCollectionView.isHidden = false + contentsLabel.isHidden = true } titleLabel.changeText(text: model.titleText) } @@ -106,7 +111,11 @@ extension PostureDetailTableViewCell: UICollectionViewDelegateFlowLayout { ) -> CGSize { let lineCount = detailTextModel[indexPath.row].text.components(separatedBy: "\n").count - 1 - return CGSize(width: detailTextCollectionView.frame.width, height: 32.0 + (CGFloat(lineCount) * 20.0)) + return CGSize(width: self.frame.width, height: 32.0 + (CGFloat(lineCount) * 20.0)) + } + + public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + return 16 } }