Skip to content

Commit 0b2dfa4

Browse files
committed
Refactor: 토끼 리뷰 반영
1 parent cd7d032 commit 0b2dfa4

7 files changed

Lines changed: 12 additions & 72 deletions

File tree

Projects/Presentation/Sources/Common/Component/RoutineCardView.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ final class RoutineCardView: UIView {
122122
subRoutineLabel.text = "세부 루틴"
123123
subRoutineLabel.font = BitnagilFont(style: .body2, weight: .medium).font
124124
subRoutineLabel.textColor = BitnagilColor.gray40
125+
subRoutineStackView.addArrangedSubview(subRoutineLabel)
125126
subRoutineLabel.snp.makeConstraints { make in
126127
make.height.equalTo(Layout.subLabelHeight)
127128
}
128-
subRoutineStackView.addArrangedSubview(subRoutineLabel)
129129

130130
routine.subRoutines.forEach {
131131
let subRoutineTitleLabel = UILabel()
132132
subRoutineTitleLabel.text = "\($0)"
133133
subRoutineTitleLabel.font = BitnagilFont(style: .body2, weight: .medium).font
134134
subRoutineTitleLabel.textColor = BitnagilColor.gray40
135+
subRoutineStackView.addArrangedSubview(subRoutineTitleLabel)
135136
subRoutineTitleLabel.snp.makeConstraints { make in
136137
make.height.equalTo(Layout.subLabelHeight)
137138
}
138-
subRoutineStackView.addArrangedSubview(subRoutineTitleLabel)
139139
}
140140
} else {
141141
grayLine.isHidden = true
@@ -154,11 +154,10 @@ final class RoutineCardView: UIView {
154154
repeatDayLabel.text = "반복: \(repeatDayText)"
155155
repeatDayLabel.font = BitnagilFont(style: .body2, weight: .medium).font
156156
repeatDayLabel.textColor = BitnagilColor.gray40
157+
infoStackView.addArrangedSubview(repeatDayLabel)
157158
repeatDayLabel.snp.makeConstraints { make in
158159
make.height.equalTo(Layout.subLabelHeight)
159160
}
160-
infoStackView.addArrangedSubview(repeatDayLabel)
161-
162161

163162
// 기간
164163
let periodLabel = UILabel()
@@ -168,22 +167,21 @@ final class RoutineCardView: UIView {
168167
periodLabel.text = "기간: \(periodText)"
169168
periodLabel.font = BitnagilFont(style: .body2, weight: .medium).font
170169
periodLabel.textColor = BitnagilColor.gray40
170+
infoStackView.addArrangedSubview(periodLabel)
171171
periodLabel.snp.makeConstraints { make in
172172
make.height.equalTo(Layout.subLabelHeight)
173173
}
174-
infoStackView.addArrangedSubview(periodLabel)
175-
176174

177175
// 시간
178176
let timeLabel = UILabel()
179177
let textTime = mainRoutine.startTime.convertToString(dateType: .time24hour) == "00:00" ? "하루종일" : mainRoutine.startTime.convertToString(dateType: .amPmTime)
180178
timeLabel.text = "시간: \(textTime)"
181179
timeLabel.font = BitnagilFont(style: .body2, weight: .medium).font
182180
timeLabel.textColor = BitnagilColor.gray40
181+
infoStackView.addArrangedSubview(timeLabel)
183182
timeLabel.snp.makeConstraints { make in
184183
make.height.equalTo(Layout.subLabelHeight)
185184
}
186-
infoStackView.addArrangedSubview(timeLabel)
187185
} else {
188186
grayLine2.isHidden = true
189187
infoStackView.isHidden = true
@@ -212,7 +210,7 @@ final class RoutineCardView: UIView {
212210

213211
plusButton.snp.makeConstraints { make in
214212
make.top.equalToSuperview().offset(Layout.plusButtonTopSpacing)
215-
make.trailing.equalToSuperview().inset(Layout.buttonTrailingSpacing)
213+
make.trailing.equalToSuperview().offset(-Layout.buttonTrailingSpacing)
216214
make.size.equalTo(Layout.plusButtonSize)
217215
}
218216

@@ -242,7 +240,7 @@ final class RoutineCardView: UIView {
242240

243241
editButton.snp.makeConstraints { make in
244242
make.top.equalToSuperview().offset(Layout.plusButtonTopSpacing)
245-
make.trailing.equalTo(deleteButton).inset(Layout.editButtonTrailingSpacing)
243+
make.trailing.equalTo(deleteButton).offset(-Layout.editButtonTrailingSpacing)
246244
make.size.equalTo(Layout.plusButtonSize)
247245
}
248246

Projects/Presentation/Sources/Home/ViewModel/HomeViewModel.swift

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ final class HomeViewModel: ViewModel {
1818
case selectRoutineListDate
1919
case fetchRoutines
2020
case selectRoutine(routine: Routine?)
21-
case deleteDailyRoutine
22-
case deleteAllRoutine
2321
case updateRoutineCompletion(updatedRoutine: Routine)
2422
case refreshSelectedDateRoutine
2523
}
@@ -31,7 +29,6 @@ final class HomeViewModel: ViewModel {
3129
let routineListDatePublisher: AnyPublisher<Date, Never>
3230
let fetchRoutineResultPublisher: AnyPublisher<Bool, Never>
3331
let routinesPublisher: AnyPublisher<[Routine], Never>
34-
let deleteRoutineResultPublisher: AnyPublisher<Bool, Never>
3532
let updateRoutineCompletionResultPublisher: AnyPublisher<Bool, Never>
3633
}
3734

@@ -44,7 +41,6 @@ final class HomeViewModel: ViewModel {
4441
private let fetchRoutineResultSubject = PassthroughSubject<Bool, Never>()
4542
private let routinesSubject = CurrentValueSubject<[Routine], Never>([])
4643
private let selectedRoutineSubject = CurrentValueSubject<Routine?, Never>(nil)
47-
private let deleteRoutineResultSubject = PassthroughSubject<Bool, Never>()
4844
private let updateRoutineCompletionResultSubject = PassthroughSubject<Bool, Never>()
4945

5046
private let calendar = Calendar.current
@@ -70,7 +66,6 @@ final class HomeViewModel: ViewModel {
7066
routineListDatePublisher: routineListDateSubject.eraseToAnyPublisher(),
7167
fetchRoutineResultPublisher: fetchRoutineResultSubject.eraseToAnyPublisher(),
7268
routinesPublisher: routinesSubject.eraseToAnyPublisher(),
73-
deleteRoutineResultPublisher: deleteRoutineResultSubject.eraseToAnyPublisher(),
7469
updateRoutineCompletionResultPublisher: updateRoutineCompletionResultSubject.eraseToAnyPublisher()
7570
)
7671
}
@@ -99,12 +94,6 @@ final class HomeViewModel: ViewModel {
9994
case .selectRoutine(let routine):
10095
selectedRoutineSubject.send(routine)
10196

102-
case .deleteDailyRoutine:
103-
deleteDailyRoutine()
104-
105-
case .deleteAllRoutine:
106-
deleteAllRoutine()
107-
10897
case .updateRoutineCompletion(let updatedRoutine):
10998
updateRoutineCompletion(updatedRoutine: updatedRoutine)
11099

@@ -209,51 +198,6 @@ final class HomeViewModel: ViewModel {
209198
}
210199
}
211200

212-
// 반복 루틴을 삭제합니다.
213-
private func deleteAllRoutine() {
214-
guard let routineId = selectedRoutineSubject.value?.id
215-
else { return }
216-
217-
Task {
218-
do {
219-
try await routineUseCase.deleteAllRoutine(routineId: routineId)
220-
selectedRoutineSubject.send(nil)
221-
deleteRoutineResultSubject.send(true)
222-
fetchRoutines()
223-
} catch {
224-
deleteRoutineResultSubject.send(false)
225-
}
226-
}
227-
}
228-
229-
// 당일 루틴을 삭제합니다.
230-
private func deleteDailyRoutine() {
231-
/*
232-
guard let routine = selectedRoutineSubject.value
233-
else { return }
234-
235-
let deleteSubRoutineEntity = routine.subRoutines.map({
236-
DeleteSubRoutineEntity(subRoutineId: $0.id, routineCompletionId: $0.completionId) })
237-
let deleteRoutinEntity = DeleteRoutineEntity(
238-
routineId: routine.id,
239-
routineCompletionId: routine.completionId,
240-
historySeq: routine.historySeq,
241-
performedDate: selectedDateSubject.value.convertToString(dateType: .yearMonthDate),
242-
routineType: routine.routineType,
243-
subRoutineInfosForDelete: deleteSubRoutineEntity)
244-
245-
Task {
246-
do {
247-
try await routineUseCase.deleteDailyRoutine(routine: deleteRoutinEntity)
248-
deleteRoutineResultSubject.send(true)
249-
fetchRoutines()
250-
} catch {
251-
deleteRoutineResultSubject.send(false)
252-
}
253-
}
254-
*/
255-
}
256-
257201
// 루틴의 완료 여부를 업데이트 합니다.
258202
private func updateRoutineCompletion(updatedRoutine: Routine) {
259203
/*

Projects/Presentation/Sources/Onboarding/Model/OnboardingChoiceType.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import Domain
99

1010
extension OnboardingChoiceType: OnboardingChoiceProtocol {
11-
1211
var title: String {
1312
switch self {
1413
case .morningTime: "아침을 잘 시작하고 싶어요."

Projects/Presentation/Sources/Onboarding/Model/OnboardingType.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import Domain
99

1010
extension OnboardingType {
11-
1211
var step: Int {
1312
switch self {
1413
case .time: 1

Projects/Presentation/Sources/RoutineList/View/RoutineEditAlertViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ final class RoutineEditAlertViewController: UIViewController {
5858
applyTodayButton.addAction(
5959
UIAction { [weak self] _ in
6060
self?.dismiss(animated: true) {
61-
self?.goToRoutineCreationView?(false)
61+
self?.goToRoutineCreationView?(true)
6262
}
6363
},
6464
for: .touchUpInside)

Projects/Presentation/Sources/RoutineList/View/RoutineListViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ extension RoutineListViewController: RoutineCardViewDelegate {
172172
func routineCardView(_ sender: RoutineCardView, didTapPlusButton routine: RecommendedRoutine) { }
173173

174174
func routineCardView(_ sender: RoutineCardView, didTapEditButton routine: Routine) {
175-
viewModel.action(input: .seleteRoutine(routine: routine))
175+
viewModel.action(input: .selectRoutine(routine: routine))
176176

177177
guard !routine.repeatDay.isEmpty else {
178178
goToRoutineCreationView(routineId: routine.id)
@@ -212,7 +212,7 @@ extension RoutineListViewController: RoutineCardViewDelegate {
212212
}
213213

214214
func routineCardView(_ sender: RoutineCardView, didTapDeleteButton routine: Routine) {
215-
viewModel.action(input: .seleteRoutine(routine: routine))
215+
viewModel.action(input: .selectRoutine(routine: routine))
216216

217217
dimmedView?.removeFromSuperview()
218218

Projects/Presentation/Sources/RoutineList/ViewModel/RoutineListViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class RoutineListViewModel: ViewModel {
1414
case fetchRoutineList
1515
case fetchDailyRoutine
1616
case selectDate(date: Date)
17-
case seleteRoutine(routine: Routine?)
17+
case selectRoutine(routine: Routine?)
1818
case deleteRoutine(isDeleteAllRoutines: Bool)
1919
}
2020

@@ -56,7 +56,7 @@ final class RoutineListViewModel: ViewModel {
5656
selectedDateSubject.send(date)
5757
fetchDailyRoutine()
5858

59-
case .seleteRoutine(let routine):
59+
case .selectRoutine(let routine):
6060
selectedRoutine.value = routine
6161

6262
case .deleteRoutine(let isDeleteAllRoutines):

0 commit comments

Comments
 (0)