From f0c3c44de384516aef731272e262b35f0a00d960 Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Thu, 12 Dec 2024 11:40:23 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20#241=20-=20=EC=BD=94=EC=B9=AD=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=EC=9D=BC=EA=B8=B0?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20text,=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/CoachingCompleteView.swift | 39 +++++++++++-------- .../Coaching/Store/CoachingStore.swift | 12 +++--- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift index 77b9d86b..1758233a 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift @@ -34,7 +34,9 @@ struct CoachingCompleteView: View { highlightIndex: currentIndex )) .font(Font.custom("Pretendard", size: 16)) - .foregroundColor(Color(UIColor.gray400)) + .foregroundColor(coachingAppData.corrections.isEmpty + ? Color(UIColor.black) + : Color(UIColor.gray400)) .lineSpacing(0.375) Spacer() @@ -46,26 +48,29 @@ struct CoachingCompleteView: View { } .padding(.horizontal, screenWidth * 0.048) - VStack(spacing: 20) { - Rectangle() - .frame(height: 8) - .foregroundStyle(Color(UIColor.gray100)) - TabView(selection: $currentIndex) { - ForEach(coachingAppData.corrections.indices, id: \.self) { item in - ScrollView { - VStack(spacing: 8) { - CoachingComparisonView(coachingResponse: $coachingAppData.corrections[item]) - - CoachingExplanationView(coachingResponse: $coachingAppData.corrections[item]) + // 코칭 일기가 있을 때만 보여짐. + if !coachingAppData.corrections.isEmpty { + VStack(spacing: 20) { + Rectangle() + .frame(height: 8) + .foregroundStyle(Color(UIColor.gray100)) + TabView(selection: $currentIndex) { + ForEach(coachingAppData.corrections.indices, id: \.self) { item in + ScrollView { + VStack(spacing: 8) { + CoachingComparisonView(coachingResponse: $coachingAppData.corrections[item]) + + CoachingExplanationView(coachingResponse: $coachingAppData.corrections[item]) + } } } } + .frame(width: screenWidth, height: screenHeight * (326/screenHeight), alignment: .top) + .tabViewStyle(.page(indexDisplayMode: .never)) + + PageControl(currentPage: $currentIndex, + coachingResponse: $coachingAppData.corrections) } - .frame(width: screenWidth, height: screenHeight * (326/screenHeight), alignment: .top) - .tabViewStyle(.page(indexDisplayMode: .never)) - - PageControl(currentPage: $currentIndex, - coachingResponse: $coachingAppData.corrections) } } } diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift index 6ba652f1..7b0b85c0 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift @@ -64,8 +64,8 @@ final class CoachingStore: Store, ObservableObject { state.hiddenIndex += 1 let coachingResponse = try await service.coachingPostAPI(diaryID: ID) state.coachingAppData = CoachingAppData(diaryText: combineCorrectionText(coachingResponse.corrections), - corrections: filiterCorrection(coachingResponse.corrections), - correctResultText: correctTextResult(coachingResponse.corrections.count)) + corrections: filiterCorrection(coachingResponse.corrections) ?? [], + correctResultText: correctTextResult(filiterCorrection(coachingResponse.corrections) ?? [])) state.hiddenIndex += 1 } catch let error { let error = error as? SmeemError @@ -80,12 +80,12 @@ final class CoachingStore: Store, ObservableObject { return response.map{ $0.originalSentence }.joined(separator: " ") } - func filiterCorrection(_ response: [CoachingResponse]) -> [CoachingResponse] { + func filiterCorrection(_ response: [CoachingResponse]) -> [CoachingResponse]? { return response.filter { $0.isCorrected }.prefix(10).map{$0} } - func correctTextResult(_ count: Int) -> String { - switch count { + func correctTextResult(_ response: [CoachingResponse]) -> String { + switch response.count { case 0: return "완벽한 일기예요!👍\n문장이 자연스럽고 오류가 없어요" case 1: @@ -93,7 +93,7 @@ final class CoachingStore: Store, ObservableObject { case 2...: return "대단해요!🥳🎉\n몇 가지 피드백을 준비해 봤어요." default: - return "대단해요!🥳🎉\n몇 가지 피드백을 준비해 봤어요." + return "완벽한 일기예요!👍\n문장이 자연스럽고 오류가 없어요" } } }