From a2ec539a13008cb1b4565195a6e96a2c3884b4bb Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Tue, 10 Dec 2024 21:21:33 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[CHORE]=20#235=20-=20=ED=8F=B4=EB=8D=94?= =?UTF-8?q?=EB=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj | 6 ------ .../{ => Coaching}/Components/CoachingCompleteView.swift | 0 .../{ => Coaching}/Components/DiaryDetailView.swift | 0 .../Presentation/{ => Coaching}/Store/CoachingStore.swift | 0 4 files changed, 6 deletions(-) rename Smeem-iOS/Smeem-iOS/Presentation/{ => Coaching}/Components/CoachingCompleteView.swift (100%) rename Smeem-iOS/Smeem-iOS/Presentation/{ => Coaching}/Components/DiaryDetailView.swift (100%) rename Smeem-iOS/Smeem-iOS/Presentation/{ => Coaching}/Store/CoachingStore.swift (100%) diff --git a/Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj b/Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj index 0169dc70..b503e31a 100644 --- a/Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj +++ b/Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj @@ -450,8 +450,6 @@ 377B3BF12CF618B90086E0BC /* SwiftUI */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = SwiftUI; sourceTree = ""; }; 4A17370E2D05C02E00B772C3 /* Toast */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Toast; sourceTree = ""; }; 4A17370F2D05C03600B772C3 /* LoadingView */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = LoadingView; sourceTree = ""; }; - 4A1737152D05C06E00B772C3 /* Components */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Components; sourceTree = ""; }; - 4A1737192D05C07100B772C3 /* Store */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Store; sourceTree = ""; }; 4AB3494E2CF22A070047C484 /* Global */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Global; sourceTree = ""; }; 4AB3494F2CF22A250047C484 /* Button */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = Button; sourceTree = ""; }; 4AB349502CF22A2E0047C484 /* TextView */ = {isa = PBXFileSystemSynchronizedRootGroup; explicitFileTypes = {}; explicitFolders = (); path = TextView; sourceTree = ""; }; @@ -615,8 +613,6 @@ isa = PBXGroup; children = ( 4AF050D82CEA01EA0055BC3F /* Coaching */, - 4A1737192D05C07100B772C3 /* Store */, - 4A1737152D05C06E00B772C3 /* Components */, 4AC047232A8FCA9700EBDC0E /* AuthManagement */, 4AA6FEE72C3ABD7C00E588E9 /* ResignSummray */, 4AA5E4B52BF24CEB00F308C8 /* BadgeBottomSheet */, @@ -1744,8 +1740,6 @@ 377B3BF12CF618B90086E0BC /* SwiftUI */, 4A17370E2D05C02E00B772C3 /* Toast */, 4A17370F2D05C03600B772C3 /* LoadingView */, - 4A1737152D05C06E00B772C3 /* Components */, - 4A1737192D05C07100B772C3 /* Store */, 4AB3494E2CF22A070047C484 /* Global */, 4AB3494F2CF22A250047C484 /* Button */, 4AB349502CF22A2E0047C484 /* TextView */, diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Components/CoachingCompleteView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift similarity index 100% rename from Smeem-iOS/Smeem-iOS/Presentation/Components/CoachingCompleteView.swift rename to Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Components/DiaryDetailView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/DiaryDetailView.swift similarity index 100% rename from Smeem-iOS/Smeem-iOS/Presentation/Components/DiaryDetailView.swift rename to Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/DiaryDetailView.swift diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Store/CoachingStore.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift similarity index 100% rename from Smeem-iOS/Smeem-iOS/Presentation/Store/CoachingStore.swift rename to Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift From c75f54c0d256923e571868313fb172f5a371273f Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Tue, 10 Dec 2024 21:54:26 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[CHORE]=20#235=20-=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20=ED=8F=B0?= =?UTF-8?q?=ED=8A=B8=20weight=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Coaching/Components/CoachingCompleteView.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift index 38e3bca9..291a820c 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift @@ -21,7 +21,7 @@ struct CoachingCompleteView: View { VStack(spacing: 16) { HStack { Text(coachingAppData.correctResultText) - .font(Font.custom("Pretendard", size: 16)) + .font(Font.custom("Pretendard", size: 16)).fontWeight(.regular) .foregroundColor(Color(UIColor.black)) .lineSpacing(0.375) Spacer() @@ -45,7 +45,6 @@ struct CoachingCompleteView: View { Spacer() } - .padding(.top) .padding(.horizontal, screenWidth * 0.048) VStack(spacing: 20) { From e9c77c3e2f1f598ec56e239f3b9c486306e2295e Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Tue, 10 Dec 2024 22:13:35 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[CHORE]=20#235=20-=20=EC=99=84=EB=B2=BD?= =?UTF-8?q?=ED=95=9C=20=EB=AC=B8=EC=9E=A5=20filter=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Coaching/Store/CoachingStore.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift index 4e9966d4..e8bace4a 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift @@ -61,7 +61,7 @@ final class CoachingStore: Store, ObservableObject { do { state.hiddenIndex += 1 let coachingResponse = try await service.coachingPostAPI(diaryID: ID) - state.coachingAppData = CoachingAppData(corrections: coachingResponse.corrections, + state.coachingAppData = CoachingAppData(corrections: filiterCorrection(coachingResponse.corrections), correctResultText: correctTextResult(coachingResponse.corrections.count)) state.hiddenIndex += 1 } catch let error { @@ -73,6 +73,10 @@ final class CoachingStore: Store, ObservableObject { } } + func filiterCorrection(_ response: [CoachingResponse]) -> [CoachingResponse] { + return response.filter { $0.isCorrected } + } + func correctTextResult(_ count: Int) -> String { switch count { case 0: From f3f9a74d0c0d8ec1460e0fbd40c1bfb9a7ed589c Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Tue, 10 Dec 2024 22:59:19 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[FEAT]=20#235=20-=20=EC=B2=A8=EC=82=AD=20?= =?UTF-8?q?=EC=9D=BC=EA=B8=B0=2010=EA=B0=9C=20=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Coaching/Store/CoachingStore.swift | 2 +- .../Coaching/Store/CoachingStoreTest.swift | 70 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift index e8bace4a..8efbb008 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift @@ -74,7 +74,7 @@ final class CoachingStore: Store, ObservableObject { } func filiterCorrection(_ response: [CoachingResponse]) -> [CoachingResponse] { - return response.filter { $0.isCorrected } + return response.filter { $0.isCorrected }.prefix(10).map{$0} } func correctTextResult(_ count: Int) -> String { diff --git a/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift b/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift new file mode 100644 index 00000000..aec0166c --- /dev/null +++ b/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift @@ -0,0 +1,70 @@ +// +// CoachingStore.swift +// Smeem-iOSTests +// +// Created by 황찬미 on 12/10/24. +// + +import XCTest + +@testable import Smeem_iOS + +final class CoachingStoreTest: XCTestCase { + + var sut: CoachingStore! + var service: CoachingServiceProtocol! + + override func setUpWithError() throws { + service = CoachingService() + sut = CoachingStore(service: service, + diaryResponse: PostDiaryResponse.empty) + } + + override func tearDownWithError() throws { + sut = nil + } + + func test_첨삭데이터15개일때_10개로잘필터하는지() { + // Given + var filterResult = [CoachingResponse]() + for _ in 1...15 { + filterResult.append(CoachingResponse(originalSentence: "", + correctedSentence: "", + reason: "", + isCorrected: true)) + } + + var expectedResult = [CoachingResponse]() + for _ in 1...10 { + expectedResult.append(CoachingResponse(originalSentence: "", + correctedSentence: "", + reason: "", + isCorrected: true)) + } + + // When + let outputResult = sut.filiterCorrection(filterResult) + + // Then + XCTAssertEqual(outputResult, expectedResult) + } + + func test_첨삭데이터0개일때_0개로잘필터하는지() { + // Given + var filterResult = [CoachingResponse]() + for _ in 1...15 { + filterResult.append(CoachingResponse(originalSentence: "", + correctedSentence: "", + reason: "", + isCorrected: false)) + } + + var expectedResult = [CoachingResponse]() + + // When + let outputResult = sut.filiterCorrection(filterResult) + + // Then + XCTAssertEqual(outputResult, expectedResult) + } +} From b0f6c0226864fe7eedc411d8edda4ad5abdab788 Mon Sep 17 00:00:00 2001 From: cchanmi <113524@naver.com> Date: Tue, 10 Dec 2024 23:26:16 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[FEAT]=20#235=20-=20=EC=9B=90=EB=AC=B8=20?= =?UTF-8?q?=EB=AC=B8=EC=9E=A5=20=EC=A1=B0=ED=95=A9=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/CoachingCompleteView.swift | 19 ++++++++++--------- .../Coaching/Store/CoachingStore.swift | 11 +++++++++-- .../Coaching/View/CoachingView.swift | 3 +-- .../Coaching/Store/CoachingStoreTest.swift | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift index 291a820c..77b9d86b 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Components/CoachingCompleteView.swift @@ -9,7 +9,6 @@ import SwiftUI struct CoachingCompleteView: View { - @Binding var diaryText: String @Binding var coachingAppData: CoachingAppData @State var currentIndex = 0 @@ -28,9 +27,9 @@ struct CoachingCompleteView: View { } HStack { - Text(diaryText) + Text(coachingAppData.diaryText) .modifier(HighlightModifier( - diaryText: diaryText, + diaryText: coachingAppData.diaryText, corrections: coachingAppData.corrections, highlightIndex: currentIndex )) @@ -90,9 +89,11 @@ struct PageControl: View { } } -#Preview { - @State var diaryText = "I watched Avatar with my boyfriend at Hongdae CGV. I should have skimmed the previous season 
what they were saying and the universe(??). What I was annoyed then was 두팔 didn’t know that as me. I think 두팔 who is my boyfriend should study before wathcing…. but Avatar2 is amazing movie I think. In my personal opinion, the jjin main character " - @State var coachingResponse = CoachingAppData(corrections: CoachingsResponse.sample.corrections, correctResultText: "테스트") - - CoachingCompleteView(diaryText: $diaryText, coachingAppData: $coachingResponse) -} +//#Preview { +// @State var diaryText = "I watched Avatar with my boyfriend at Hongdae CGV. I should have skimmed the previous season 
what they were saying and the universe(??). What I was annoyed then was 두팔 didn’t know that as me. I think 두팔 who is my boyfriend should study before wathcing…. but Avatar2 is amazing movie I think. In my personal opinion, the jjin main character " +// @State var coachingResponse = CoachingAppData(diaryText: "", +// corrections: CoachingsResponse.sample.corrections, +// correctResultText: "테스트") +// +// CoachingCompleteView(coachingAppData: coachingResponse, currentIndex: 0) +//} diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift index 8efbb008..6ba652f1 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/Store/CoachingStore.swift @@ -8,6 +8,7 @@ import Foundation struct CoachingAppData { + var diaryText: String var corrections: [CoachingResponse] var correctResultText: String } @@ -30,7 +31,8 @@ final class CoachingStore: Store, ObservableObject { struct State { var detailDiaryResponse = DetailDiaryResponse.empty - var coachingAppData = CoachingAppData(corrections: CoachingsResponse.sample.corrections, + var coachingAppData = CoachingAppData(diaryText: "", + corrections: CoachingsResponse.sample.corrections, correctResultText: "첨삭 중이에요") var toastErrorMessage: SmeemError? = nil var toastMessage: SmeemToast? = .completed @@ -61,7 +63,8 @@ final class CoachingStore: Store, ObservableObject { do { state.hiddenIndex += 1 let coachingResponse = try await service.coachingPostAPI(diaryID: ID) - state.coachingAppData = CoachingAppData(corrections: filiterCorrection(coachingResponse.corrections), + state.coachingAppData = CoachingAppData(diaryText: combineCorrectionText(coachingResponse.corrections), + corrections: filiterCorrection(coachingResponse.corrections), correctResultText: correctTextResult(coachingResponse.corrections.count)) state.hiddenIndex += 1 } catch let error { @@ -73,6 +76,10 @@ final class CoachingStore: Store, ObservableObject { } } + func combineCorrectionText(_ response: [CoachingResponse]) -> String { + return response.map{ $0.originalSentence }.joined(separator: " ") + } + func filiterCorrection(_ response: [CoachingResponse]) -> [CoachingResponse] { return response.filter { $0.isCorrected }.prefix(10).map{$0} } diff --git a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/View/CoachingView.swift b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/View/CoachingView.swift index 28d4c25b..1d330497 100644 --- a/Smeem-iOS/Smeem-iOS/Presentation/Coaching/View/CoachingView.swift +++ b/Smeem-iOS/Smeem-iOS/Presentation/Coaching/View/CoachingView.swift @@ -86,8 +86,7 @@ struct CoachingView: View { // MARK: 첨삭 화면 } else { - CoachingCompleteView(diaryText: $store.state.detailDiaryResponse.content, - coachingAppData: $store.state.coachingAppData) + CoachingCompleteView(coachingAppData: $store.state.coachingAppData) } // MARK: 첫 진입시 토스트뷰 실행 diff --git a/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift b/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift index aec0166c..f03c754c 100644 --- a/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift +++ b/Smeem-iOS/Smeem-iOSTests/Coaching/Store/CoachingStoreTest.swift @@ -67,4 +67,23 @@ final class CoachingStoreTest: XCTestCase { // Then XCTAssertEqual(outputResult, expectedResult) } + + func test_원문일기_잘조합해주는지() { + // Given + var filterResult = [CoachingResponse]() + for i in 1...3 { + filterResult.append(CoachingResponse(originalSentence: "안녕", + correctedSentence: "", + reason: "", + isCorrected: false)) + } + + var expectedResult = "안녕 안녕 안녕" + + // When + let outputResult = sut.combineCorrectionText(filterResult) + + // Then + XCTAssertEqual(outputResult, expectedResult) + } }