Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ extension SelectTreatmentView {
VStack(alignment: .leading, spacing: 0){

TypographyText("시술 일정을 추가해볼게요.", style: .title1_sb_18, color: .gray1000)
.frame(height: 27.adjustedH)
.frame(height: 30.adjustedH)
TypographyText("이미 생각해둔 시술이 있나요?", style: .title1_sb_18, color: .gray1000)
.frame(height: 27.adjustedH)
.frame(height: 30.adjustedH)



Spacer()
.frame(height: 4.adjustedH)
TypographyText("시술을 선택하셨는지 확인할게요.", style: .body1_r_14, color: .gray700)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ import SwiftUI
struct NoTreatmentFilterView: View {
@ObservedObject var viewModel: NoTreatmentViewModel


private let itemHeight: CGFloat = 34.adjustedH
private let spacing: CGFloat = 8.adjustedH
private let maxVisibleCount = 3

private var scrollViewHeight: CGFloat {
let count = min(viewModel.selectedTreatments.count, maxVisibleCount)
let contentHeight = CGFloat(count) * itemHeight + CGFloat(max(count - 1, 0)) * spacing
return contentHeight + 24.adjustedH + 40.adjustedH
}
Comment on lines +14 to +22
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

scrollViewHeight 이중 스케일링 가능성

Line 19-21에서 adjustedH가 이미 적용된 값을 계산하고 있는데, Line 53에서 scrollViewHeight.adjustedH를 다시 적용하고 있습니다. adjustedH가 스케일링이라면 높이가 과대 계산될 수 있으니 한 번만 적용해주세요.

🔧 제안 수정안
-                        24.adjustedH : scrollViewHeight.adjustedH + 24.adjustedH
+                        24.adjustedH : scrollViewHeight + 24.adjustedH

Also applies to: 51-54

🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/NoTreatment/NoTreatmentFilterView.swift`
around lines 14 - 22, The computed property scrollViewHeight currently sums
values where itemHeight and spacing already use adjustedH, but elsewhere the
value is being re-scaled again (scrollViewHeight.adjustedH); fix by ensuring
adjustedH is applied exactly once: keep adjustedH on the base constants
(itemHeight, spacing, any fixed paddings like 24 and 40) and remove any extra
.adjustedH call where scrollViewHeight is used (or alternatively remove
adjustedH from the constants and apply it once to scrollViewHeight) so
scrollViewHeight calculation in NoTreatmentFilterView and its usage uses a
single scaling application; locate symbols itemHeight, spacing, scrollViewHeight
and any usages of scrollViewHeight.adjustedH to update consistently.



var body: some View {
VStack(spacing: 0) {
TitleHeaderView(title: viewModel.selectedCategory?.title ?? "")
Expand All @@ -29,16 +41,19 @@ struct NoTreatmentFilterView: View {
} else {
viewModel.addTreatment(treatment)

}
}
}
)
.padding(.horizontal, 25.adjustedW)

}
Spacer()
.frame(height: 198.adjustedH)
.frame(
height: viewModel.selectedTreatments.isEmpty ?
24.adjustedH : scrollViewHeight.adjustedH + 24.adjustedH
)
}

}
.task {
await viewModel.fetchNoTreatments()
Expand All @@ -58,7 +73,7 @@ private struct TitleHeaderView: View {
TypographyText("관련 시술 리스트", style: .title1_sb_18, color: .gray1000)
.frame(height: 27.adjustedH)
Spacer()

}


Expand Down Expand Up @@ -93,6 +108,6 @@ private struct TitleHeaderView: View {
.gray500()
}
.frame(height: 105.adjustedH )

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,31 @@ import SwiftUI

struct TreatmentFilterView: View {
@ObservedObject var viewModel: TreatmentViewModel

private let itemHeight: CGFloat = 34.adjustedH
private let spacing: CGFloat = 8.adjustedH
private let maxVisibleCount = 3

private var scrollViewHeight: CGFloat {
let count = min(viewModel.selectedTreatments.count, maxVisibleCount)
let contentHeight = CGFloat(count) * itemHeight + CGFloat(max(count - 1, 0)) * spacing
return contentHeight + 24.adjustedH + 40.adjustedH
}
Comment on lines +13 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

scrollViewHeight 재스케일링으로 높이 과대 가능

Line 18-21에서 이미 adjustedH가 적용된 값을 만들고 있는데, Line 80에서 scrollViewHeight.adjustedH를 다시 적용하고 있습니다. 스케일링 중복을 제거해 주세요.

🔧 제안 수정안
-                        24.adjustedH : scrollViewHeight.adjustedH + 24.adjustedH
+                        24.adjustedH : scrollViewHeight + 24.adjustedH

Also applies to: 78-81

🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/View/Treatment/TreatmentFilterView.swift`
around lines 13 - 21, The computed property scrollViewHeight already uses values
with .adjustedH applied (itemHeight, spacing and the added paddings), so remove
the extra scaling where scrollViewHeight is consumed (do not call
scrollViewHeight.adjustedH); update usages (e.g., where scrollViewHeight is
referenced in layout code around the previous Line 78–81) to use
scrollViewHeight directly, or alternatively compute itemHeight/spacing without
.adjustedH and apply .adjustedH only once—ensure scrollViewHeight remains
consistently scaled exactly once.


var body: some View {
VStack(spacing: 0) {
TreatmentSearchBarTextField(
text: $viewModel.searchText,
onTap: {
Task {
try await viewModel.fetchTreatments()
try await viewModel.fetchTreatments()
}
},
isDisabled: false
)
.padding(.horizontal, 25.adjustedW)
.padding(.bottom, 8.adjustedH)
Spacer()
.frame(height: 8.adjustedH)
ScrollView(.vertical, showsIndicators: false) {
HStack(alignment: .top,spacing: 4) {
TypographyText("◎", style: .body3_r_12, color: .gray600)
Expand All @@ -33,14 +45,15 @@ struct TreatmentFilterView: View {
color: .gray600
)
.lineLimit(2)

}

Spacer()

}
.frame(height: 34.adjustedH)
.padding(.horizontal, 25.adjustedW)

Spacer()
.frame(height: 20.adjustedH)

if viewModel.treatments.isEmpty {
Spacer()
.frame(height: 148.adjustedH)
Expand All @@ -62,7 +75,10 @@ struct TreatmentFilterView: View {
.padding(.horizontal, 24.adjustedW)
}
Spacer()
.frame(height: 198.adjustedH)
.frame(
height: viewModel.selectedTreatments.isEmpty ?
24.adjustedH : scrollViewHeight.adjustedH + 24.adjustedH
)
}

}
Expand All @@ -71,7 +87,7 @@ struct TreatmentFilterView: View {
try await viewModel.fetchTreatments()
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ final class NoTreatmentViewModel: ObservableObject{
}

func isDateTextFieldNotEmpty() -> Bool {
guard let scheduledDate = calendarTreatmentFlowState.selectedDate else {
return false
}

guard !year.isEmpty, !month.isEmpty, !day.isEmpty else {
Task { @MainActor in
updateWarning(state: .none)
Expand All @@ -133,14 +137,28 @@ final class NoTreatmentViewModel: ObservableObject{
return false
}


let today = Calendar.current.startOfDay(for: Date())

if date < today {
updateWarning(state: .pastDate)
return false
if date < scheduledDate {
updateWarning(state: .pastDate)
return false
}

} else {
if date < scheduledDate {
if date < today {
updateWarning(state: .pastDate)
}
updateWarning(state: .beforeProcedureDate)
return false
}
Comment on lines 141 to +156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

도달 불가능한 분기 제거로 경고 로직 단순화

Line 149의 else는 date >= today를 보장하므로 Line 151의 date < today는 항상 false입니다. 현재 구조는 경고 업데이트 의도를 흐릴 수 있어 분기 정리를 권장합니다.

🔧 제안 수정안
-        if date < today {
-            if date < scheduledDate {
-                updateWarning(state: .pastDate)
-                return false
-            }
-            
-        } else {
-            if date < scheduledDate {
-                if date < today {
-                    updateWarning(state: .pastDate)
-                }
-                updateWarning(state: .beforeProcedureDate)
-                 return false
-            }
-        }
+        if date < today {
+            if date < scheduledDate {
+                updateWarning(state: .pastDate)
+                return false
+            }
+        } else if date < scheduledDate {
+            updateWarning(state: .beforeProcedureDate)
+            return false
+        }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/ViewModel/NoTreatment/NoTreatmentViewModel.swift`
around lines 141 - 156, The inner check for `date < today` inside the `else`
branch is unreachable because the `else` guarantees `date >= today`; simplify
the branching in NoTreatmentViewModel by removing that impossible condition and
collapsing logic to: if `date < today` -> call `updateWarning(state: .pastDate)`
and return false; else if `date < scheduledDate` -> call `updateWarning(state:
.beforeProcedureDate)` and return false; keep references to `date`, `today`,
`scheduledDate`, and `updateWarning(state:)` intact so behavior remains the same
but with the unreachable branch removed.

}

updateWarning(state: .none)
return true

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ final class TreatmentViewModel: ObservableObject{
}

func isDateTextFieldNotEmpty() -> Bool {
guard let scheduledDate = calendarTreatmentFlowState.selectedDate else {
return false
}

guard !year.isEmpty, !month.isEmpty, !day.isEmpty else {
Task { @MainActor in
updateWarning(state: .none)
Expand All @@ -124,14 +128,28 @@ final class TreatmentViewModel: ObservableObject{
return false
}


let today = Calendar.current.startOfDay(for: Date())

if date < today {
updateWarning(state: .pastDate)
return false
if date < scheduledDate {
updateWarning(state: .pastDate)
return false
}

} else {
if date < scheduledDate {
if date < today {
updateWarning(state: .pastDate)
}
updateWarning(state: .beforeProcedureDate)
return false
}
Comment on lines 132 to +147
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

도달 불가능한 분기 제거로 경고 로직 단순화

Line 140의 else는 date >= today 조건이므로 Line 142의 date < today는 항상 false입니다. 분기를 단순화하면 의도가 명확해집니다.

🔧 제안 수정안
-        if date < today {
-            if date < scheduledDate {
-                updateWarning(state: .pastDate)
-                return false
-            }
-            
-        } else {
-            if date < scheduledDate {
-                if date < today {
-                    updateWarning(state: .pastDate)
-                }
-                updateWarning(state: .beforeProcedureDate)
-                 return false
-            }
-        }
+        if date < today {
+            if date < scheduledDate {
+                updateWarning(state: .pastDate)
+                return false
+            }
+        } else if date < scheduledDate {
+            updateWarning(state: .beforeProcedureDate)
+            return false
+        }
🤖 Prompt for AI Agents
In
`@Cherrish-iOS/Cherrish-iOS/Presentation/Feature/Calendar/Treatment/ViewModel/Treatment/TreatmentViewModel.swift`
around lines 132 - 147, The else branch contains an unreachable check (date <
today) and should be simplified: in the else (where date >= today) remove the
nested "if date < today" and, when date < scheduledDate, call
updateWarning(state: .beforeProcedureDate) and return false; keep the earlier
branch that sets updateWarning(state: .pastDate) when date < today && date <
scheduledDate so .pastDate logic remains intact. Reference: variables date,
today, scheduledDate and the updateWarning(state:
.pastDate)/updateWarning(state: .beforeProcedureDate) calls in
TreatmentViewModel.

}

updateWarning(state: .none)
return true

}


Expand Down