Skip to content

Commit

Permalink
[FEAT] #241 - 코칭 불필요한 일기일 경우 text, 컴포넌트 분기 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
cchanmi committed Dec 12, 2024
1 parent 9ffc1be commit f0c3c44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,20 +80,20 @@ 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:
return "잘 작성했어요!🙌\n작은 부분만 다듬으면 완벽해요"
case 2...:
return "대단해요!🥳🎉\n몇 가지 피드백을 준비해 봤어요."
default:
return "대단해요!🥳🎉\n몇 가지 피드백을 준비해 봤어요."
return "완벽한 일기예요!👍\n문장이 자연스럽고 오류가 없어요"
}
}
}
Expand Down

0 comments on commit f0c3c44

Please sign in to comment.