Skip to content

Commit a579154

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

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
@@ -183,6 +183,7 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
183183
viewModel.output.selectedCategoryPublisher
184184
.receive(on: DispatchQueue.main)
185185
.sink { [weak self] selectedCategory in
186+
self?.showEmotionButton(isShowEmotionButton: selectedCategory == .recommendation)
186187
self?.categoryView.updateSelectedCategory(selectedCategory: selectedCategory)
187188
}
188189
.store(in: &cancellables)
@@ -197,15 +198,13 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
197198

198199
private func fetchRecommendedRoutines(recommendedRoutines: [RecommendedRoutine]) {
199200
recommendedRoutineStackView.arrangedSubviews.forEach { view in
200-
recommendedRoutineStackView.removeArrangedSubview(view)
201-
view.removeFromSuperview()
201+
if view != registerEmotionButton {
202+
recommendedRoutineStackView.removeArrangedSubview(view)
203+
view.removeFromSuperview()
204+
}
202205
}
203206
recommendedRoutineCards.removeAll()
204207

205-
if recommendedRoutines.first?.routineCategory == .recommendation {
206-
showEmotionButton()
207-
}
208-
209208
for routine in recommendedRoutines {
210209
let routineCard = RecommendedRoutineCardView(recommendedRoutine: routine)
211210
recommendedRoutineCards[routine.id] = routineCard
@@ -224,9 +223,17 @@ final class RecommendedRoutineView: BaseViewController<RecommendedRoutineViewMod
224223
presentCustomBottomSheet(contentViewController: levelView, maxHeight: Layout.bottomSheetHeight)
225224
}
226225

227-
private func showEmotionButton() {
228-
recommendedRoutineStackView.addArrangedSubview(registerEmotionButton)
226+
private func showEmotionButton(isShowEmotionButton: Bool) {
227+
guard isShowEmotionButton else {
228+
registerEmotionButton.isHidden = true
229+
return
230+
}
231+
guard !recommendedRoutineStackView.arrangedSubviews.contains(registerEmotionButton) else {
232+
registerEmotionButton.isHidden = false
233+
return
234+
}
229235

236+
recommendedRoutineStackView.addArrangedSubview(registerEmotionButton)
230237
registerEmotionButton.snp.makeConstraints { make in
231238
make.leading.trailing.equalToSuperview()
232239
make.height.equalTo(Layout.registerEmotionButtonHeight)

0 commit comments

Comments
 (0)