Skip to content

Commit 3a4d02f

Browse files
committed
[#60] 코드 정리하기
#60
1 parent aac7d5f commit 3a4d02f

20 files changed

Lines changed: 224 additions & 346 deletions

Codive/Features/Home/Domain/Protocols/HomeRepository.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ protocol HomeRepository {
3636
size: Int32,
3737
direction: Operations.LookBook_getLookBooks.Input.Query.directionPayload
3838
) async throws -> (content: [LookBookEntity], isLast: Bool)
39-
40-
/// 기존 api
4139

4240
// MARK: - 코디가 있는 경우의 Home 관련
4341
/// 오늘의 코디 옷 정보 조회

Codive/Features/Home/Presentation/Component/CategoryCounterView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ struct CategoryCounterView: View {
3030

3131
Spacer()
3232

33-
// 감소 버튼: 이제 상의/하의 등도 isEmpty가 아니면(1이면) 0으로 줄일 수 있습니다.
3433
Button {
3534
if !isFixed && !isEmpty {
3635
count -= 1

Codive/Features/Home/Presentation/Component/CodiClothView.swift

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct ClothCardView: View {
3333
ProgressView()
3434
case .success(let image):
3535
image.resizable().scaledToFit()
36-
case .failure(let error):
36+
case .failure:
3737
Image(systemName: "exclamationmark.triangle")
3838
.foregroundColor(.gray)
3939
@unknown default:
@@ -169,10 +169,10 @@ struct CodiClothCarouselView: View {
169169
)
170170
}
171171
.onChange(of: currentIndex) { newValue in
172-
withAnimation(.spring()) {
173-
proxy.scrollTo(newValue, anchor: .center)
174-
}
175-
}
172+
withAnimation(.spring()) {
173+
proxy.scrollTo(newValue, anchor: .center)
174+
}
175+
}
176176
.scrollDisabled(isEmptyState)
177177
.onAppear {
178178
proxy.scrollTo(currentIndex, anchor: .center)
@@ -188,54 +188,14 @@ struct CodiClothCarouselView: View {
188188
}
189189
}
190190

191-
//struct CodiClothView: View {
192-
// let title: String
193-
// let items: [HomeClothEntity]
194-
// let isEmptyState: Bool
195-
// var onIndexChanged: ((Int) -> Void)?
196-
//
197-
// // Carousel 설정
198-
// let spacing: CGFloat = 12
199-
// let activeScale: CGFloat = 1.0
200-
// let inactiveScale: CGFloat = 0.85
201-
//
202-
// @State private var currentIndex: Int
203-
//
204-
// init(title: String, items: [HomeClothEntity], isEmptyState: Bool, onIndexChanged: ((Int) -> Void)? = nil) {
205-
// self.title = title
206-
// self.items = items
207-
// self.isEmptyState = isEmptyState
208-
// self.onIndexChanged = onIndexChanged
209-
//
210-
// let initialIndex = isEmptyState ? 1 : 0
211-
// _currentIndex = State(initialValue: initialIndex)
212-
// }
213-
//
214-
// var body: some View {
215-
// HStack(spacing: 8) {
216-
// ZStack(alignment: .topLeading) {
217-
// CodiClothCarouselView(
218-
// items: items,
219-
// currentIndex: $currentIndex,
220-
// spacing: spacing,
221-
// activeScale: activeScale,
222-
// inactiveScale: inactiveScale,
223-
// isEmptyState: isEmptyState
224-
// )
225-
// .onChange(of: currentIndex) { newValue in
226-
// onIndexChanged?(newValue)
227-
// }
228191
struct CodiClothView: View {
229192
let title: String
230193
let items: [HomeClothEntity]
231194
let isEmptyState: Bool
232-
// var onIndexChanged: ((Int) -> Void)?
233-
//
234-
// Carousel 설정
235-
let spacing: CGFloat = 12
236-
let activeScale: CGFloat = 1.0
237-
let inactiveScale: CGFloat = 0.85
238-
// 추가: 외부에서 주입받는 인덱스
195+
196+
let spacing: CGFloat = 12
197+
let activeScale: CGFloat = 1.0
198+
let inactiveScale: CGFloat = 0.85
239199
let selectedIndex: Int
240200
var onIndexChanged: ((Int) -> Void)?
241201

@@ -247,7 +207,7 @@ struct CodiClothView: View {
247207
self.isEmptyState = isEmptyState
248208
self.selectedIndex = selectedIndex
249209
self.onIndexChanged = onIndexChanged
250-
210+
251211
// 초기값 설정: 비어있으면 1(중앙), 아니면 전달받은 selectedIndex 사용
252212
let initialIndex = isEmptyState ? 1 : selectedIndex
253213
_currentIndex = State(initialValue: initialIndex)

Codive/Features/Home/Presentation/Component/CompletePopUp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct CompletePopUp: View {
8181

8282
struct CodiCompositeView: View {
8383
let clothes: [HomeClothEntity]
84-
var loadedImages: [Int64: UIImage]? = nil
84+
var loadedImages: [Int64: UIImage]?
8585

8686
let containerSize: CGFloat = 260
8787
let itemSize: CGFloat = 100

Codive/Features/Home/Presentation/Component/DraggableImageView.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ struct DraggableImageView<T: DraggableImageProtocol>: View {
2020
position: $item.position,
2121
scale: $item.scale,
2222
rotation: $item.rotation,
23-
onActivate: { onActivate(item.id) }
24-
) {
25-
// 순서 중요: KFImage 바로 뒤에 Kingfisher 전용 메서드를 배치합니다.
26-
KFImage(URL(string: item.imageUrl))
27-
.placeholder { // 로딩 중 보여줄 뷰
28-
ProgressView()
29-
.frame(width: 180, height: 180)
30-
}
31-
.onFailure { error in // 로드 실패 시 로직
32-
print("이미지 로드 실패: \(error.localizedDescription)")
33-
}
34-
.resizable() // 여기서부터는 일반 SwiftUI View로 변환됨
35-
.scaledToFit()
36-
.frame(width: 180, height: 180)
37-
}
23+
onActivate: { onActivate(item.id) },
24+
content: {
25+
KFImage(URL(string: item.imageUrl))
26+
.placeholder {
27+
ProgressView()
28+
.frame(width: 180, height: 180)
29+
}
30+
.onFailure { error in
31+
print("이미지 로드 실패: \(error.localizedDescription)")
32+
}
33+
.resizable()
34+
.scaledToFit()
35+
.frame(width: 180, height: 180)
36+
}
37+
)
3838
}
3939
}
4040
}

Codive/Features/Home/Presentation/Component/SelectableClothItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct SelectableClothItem: View {
2727
.frame(width: 72, height: 72)
2828
.overlay {
2929
RoundedRectangle(cornerRadius: 8)
30-
.stroke(isSelected ? Color.blue : Color.clear, lineWidth: 2) // 선택 시 강조
30+
.stroke(isSelected ? Color.blue : Color.clear, lineWidth: 2)
3131
}
3232
.onTapGesture {
3333
isSelected.toggle()

Codive/Features/Home/Presentation/Component/ZoomRotateDragView.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ struct ZoomRotateDragView<Content: View>: View {
2121
@GestureState private var gestureRotation: Angle = .zero
2222

2323
// MARK: - 제약 조건 설정
24-
private let minScale: CGFloat = 0.4 // 최소 크기 (40%)
25-
private let maxScale: CGFloat = 4.0 // 최대 크기 (400%)
24+
private let minScale: CGFloat = 0.4
25+
private let maxScale: CGFloat = 4.0
2626

2727
init(
2828
id: Int64,
@@ -42,7 +42,6 @@ struct ZoomRotateDragView<Content: View>: View {
4242

4343
var body: some View {
4444
content
45-
// 화면에 보이는 배율도 제한 범위 내에서만 움직이도록 시각적 보정
4645
.scaleEffect(clampedScale(scale * gestureScale))
4746
.rotationEffect(Angle(degrees: rotation) + gestureRotation)
4847
.offset(x: position.x + gestureOffset.width, y: position.y + gestureOffset.height)
@@ -60,7 +59,6 @@ struct ZoomRotateDragView<Content: View>: View {
6059
MagnificationGesture()
6160
.updating($gestureScale) { v, s, _ in s = v }
6261
.onEnded { v in
63-
// 제스처 종료 시 최종 scale 값을 제한 범위 내로 고정
6462
let newScale = scale * v
6563
scale = min(max(newScale, minScale), maxScale)
6664
}
@@ -73,7 +71,6 @@ struct ZoomRotateDragView<Content: View>: View {
7371
)
7472
}
7573

76-
// 시각적으로 이미지가 너무 작아져서 사라지는 것을 방지하는 보조 함수
7774
private func clampedScale(_ current: CGFloat) -> CGFloat {
7875
return min(max(current, minScale * 0.8), maxScale * 1.2)
7976
}

Codive/Features/Home/Presentation/View/EditCategoryView.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,13 @@ struct EditCategoryView: View {
4444

4545
// MARK: - View Components
4646
private extension EditCategoryView {
47-
48-
/// 상단 네비게이션 바
47+
4948
var navigationBar: some View {
5049
CustomNavigationBar(title: TextLiteral.Home.editCategoryTitle) {
5150
viewModel.handleBackTap()
5251
}
5352
}
54-
55-
/// 현재 카테고리 개수 표시 헤더
53+
5654
var categoryHeader: some View {
5755
Text("\(TextLiteral.Home.currentCategoryCount) (\(viewModel.totalCount)/7)")
5856
.font(.codive_title2)
@@ -61,8 +59,7 @@ private extension EditCategoryView {
6159
.padding(.horizontal, 20)
6260
.padding(.vertical, 24)
6361
}
64-
65-
/// 카테고리 아이템 리스트
62+
6663
var categoryList: some View {
6764
VStack(spacing: 24) {
6865
ForEach($viewModel.categories, id: \.id) { $category in
@@ -78,7 +75,6 @@ private extension EditCategoryView {
7875
.padding(.bottom, 20)
7976
}
8077

81-
/// 하단 초기화 및 적용 버튼
8278
var bottomActionButtons: some View {
8379
HStack(spacing: 9) {
8480
CustomButton(
@@ -102,7 +98,6 @@ private extension EditCategoryView {
10298
.background(Color.white)
10399
}
104100

105-
/// 수정 취소 시 나타나는 알럿 버튼들
106101
@ViewBuilder
107102
var alertButtons: some View {
108103
Button(TextLiteral.Common.cancel, role: .cancel) {

Codive/Features/Home/Presentation/View/HomeHasCodiView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ struct HomeHasCodiView: View {
1919
VStack(alignment: .leading, spacing: 16) {
2020
header
2121

22-
// 메인 캔버스 영역
2322
GeometryReader { canvasProxy in
2423
let canvasSize = canvasProxy.size
2524

@@ -51,8 +50,6 @@ struct HomeHasCodiView: View {
5150

5251
// MARK: - View Components
5352
private extension HomeHasCodiView {
54-
55-
/// 상단 헤더 (오늘의 코디 제목 및 날짜)
5653
var header: some View {
5754
HStack {
5855
Text("\(TextLiteral.Home.todayCodiTitle)(\(viewModel.todayString))")

Codive/Features/Home/Presentation/View/HomeView.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,15 @@ struct HomeView: View {
6363
}
6464
.task {
6565
await viewModel.loadWeather(for: nil)
66-
// 오늘의 코디 여부 확인 (추가)
67-
// viewModel.fetchTodayCodiData()
6866
if !viewModel.isEditingExistingCodi {
69-
viewModel.fetchTodayCodiData()
70-
}
71-
// await viewModel.loadActiveCategoriesWithAPI()
67+
viewModel.fetchTodayCodiData()
68+
}
7269
}
7370
.onChange(of: navigationRouter.currentDestination) { newDestination in
7471
if newDestination == nil {
75-
// viewModel.loadActiveCategories()
7672
if viewModel.todayCodiPreview == nil {
77-
viewModel.loadActiveCategories()
78-
}
79-
// 홈으로 돌아올 때 스크롤 초기화
73+
viewModel.loadActiveCategories()
74+
}
8075
scrollViewID = UUID()
8176
}
8277
}

0 commit comments

Comments
 (0)