Skip to content

Commit 187d0e3

Browse files
committed
Refactor: 맞춤 추천 카테고리인 경우 감정 등록 버튼 보여주기
1 parent 3b8c740 commit 187d0e3

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

Projects/DataSource/Sources/DTO/RecommendedRoutineDTO.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct RecommendedRoutineDTO: Decodable {
1919
case routineName = "recommendedRoutineName"
2020
case routineDescription = "recommendedRoutineDescription"
2121
case routineLevel = "recommendedRoutineLevel"
22-
case subRoutines = "recommendedSubRoutineDetailSearchResult"
22+
case subRoutines = "recommendedSubRoutineSearchResult"
2323
}
2424

2525
func toRecommendedRoutineEntity(category: String? = nil) -> RecommendedRoutineEntity {

Projects/Presentation/Sources/RecommendedRoutine/View/RecommendedRoutineView.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
174174
viewModel.output.selectedCategoryPublisher
175175
.receive(on: DispatchQueue.main)
176176
.sink { [weak self] selectedCategory in
177+
self?.showEmotionButton(isShowEmotionButton: selectedCategory == .recommendation)
177178
self?.categoryView.updateSelectedCategory(selectedCategory: selectedCategory)
178179
}
179180
.store(in: &cancellables)
@@ -188,15 +189,13 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
188189

189190
private func fetchRecommendedRoutines(recommendedRoutines: [RecommendedRoutine]) {
190191
recommendedRoutineStackView.arrangedSubviews.forEach { view in
191-
recommendedRoutineStackView.removeArrangedSubview(view)
192-
view.removeFromSuperview()
192+
if view != registerEmotionButton {
193+
recommendedRoutineStackView.removeArrangedSubview(view)
194+
view.removeFromSuperview()
195+
}
193196
}
194197
recommendedRoutineCards.removeAll()
195198

196-
if recommendedRoutines.first?.routineCategory == .recommendation {
197-
showEmotionButton()
198-
}
199-
200199
for routine in recommendedRoutines {
201200
let routineCard = RecommendedRoutineCardView(recommendedRoutine: routine)
202201
recommendedRoutineCards[routine.id] = routineCard
@@ -215,9 +214,17 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
215214
presentCustomBottomSheet(contentViewController: levelView, maxHeight: Layout.bottomSheetHeight)
216215
}
217216

218-
private func showEmotionButton() {
219-
recommendedRoutineStackView.addArrangedSubview(registerEmotionButton)
217+
private func showEmotionButton(isShowEmotionButton: Bool) {
218+
guard isShowEmotionButton else {
219+
registerEmotionButton.isHidden = true
220+
return
221+
}
222+
guard !recommendedRoutineStackView.arrangedSubviews.contains(registerEmotionButton) else {
223+
registerEmotionButton.isHidden = false
224+
return
225+
}
220226

227+
recommendedRoutineStackView.addArrangedSubview(registerEmotionButton)
221228
registerEmotionButton.snp.makeConstraints { make in
222229
make.leading.trailing.equalToSuperview()
223230
make.height.equalTo(Layout.registerEmotionButtonHeight)

0 commit comments

Comments
 (0)