From e39d96b2419562e1c0e7fcc4af022e352e08b775 Mon Sep 17 00:00:00 2001 From: Sunghun Kim <81547954+kimsh153@users.noreply.github.com> Date: Wed, 23 Aug 2023 10:45:06 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20[#220]=20InputProjectInfo=20/=20pr?= =?UTF-8?q?eview=20=EC=9D=B4=EB=AF=B8=EC=A7=80=204=EA=B0=9C=20=EB=84=98?= =?UTF-8?q?=EA=B8=B0=EB=A9=B4=20=EA=B2=BD=EA=B3=A0=20=EB=9D=84=EC=9A=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Intent/InputProjectInfoIntent.swift | 14 +++- .../InputProjectInfoIntentProtocol.swift | 3 +- .../Sources/Model/InputProjectInfoModel.swift | 5 ++ .../Model/InputProjectInfoModelProtocol.swift | 2 + .../Sources/Scene/InputProjectInfoView.swift | 71 +++++++++++-------- .../Sources/Model/MyPageWorkInfoModel.swift | 2 +- 6 files changed, 61 insertions(+), 36 deletions(-) diff --git a/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntent.swift b/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntent.swift index fb98d4fa..c552a602 100644 --- a/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntent.swift +++ b/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntent.swift @@ -71,9 +71,13 @@ final class InputProjectInfoIntent: InputProjectInfoIntentProtocol { model?.updateIconImage(index: index, image: image) } - func appendPreviewImageButtonDidTap(index: Int) { - model?.updateFocusedProjectIndex(index: index) - model?.updateIsPresentedPreviewImagePicker(isPresented: true) + func appendPreviewImageButtonDidTap(index: Int, previewsCount: Int) { + if previewsCount == 4 { + model?.updateIsPresentedToast(isPresented: true) + } else { + model?.updateFocusedProjectIndex(index: index) + model?.updateIsPresentedPreviewImagePicker(isPresented: true) + } } func appendPreviewImage(index: Int, image: PickedImageResult) { @@ -175,4 +179,8 @@ final class InputProjectInfoIntent: InputProjectInfoIntentProtocol { func techStackAppendDismissed() { model?.updateIsPresentedTechStackAppend(isPresented: false) } + + func toastDismissed() { + model?.updateIsPresentedToast(isPresented: false) + } } diff --git a/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntentProtocol.swift b/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntentProtocol.swift index 16e895ff..8e089af8 100644 --- a/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntentProtocol.swift +++ b/Projects/Feature/InputProjectInfoFeature/Sources/Intent/InputProjectInfoIntentProtocol.swift @@ -7,7 +7,7 @@ protocol InputProjectInfoIntentProtocol { func projectToggleButtonDidTap(index: Int) func updateProjectName(index: Int, name: String) func updateIconImage(index: Int, image: PickedImageResult) - func appendPreviewImageButtonDidTap(index: Int) + func appendPreviewImageButtonDidTap(index: Int, previewsCount: Int) func appendPreviewImage(index: Int, image: PickedImageResult) func removePreviewImageDidTap(index: Int, previewIndex: Int) func updateProjectContent(index: Int, content: String) @@ -32,4 +32,5 @@ protocol InputProjectInfoIntentProtocol { func endAtDatePickerDismissed() func techStackAppendButtonDidTap(index: Int) func techStackAppendDismissed() + func toastDismissed() } diff --git a/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModel.swift b/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModel.swift index bf715843..6a635fa5 100644 --- a/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModel.swift +++ b/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModel.swift @@ -11,6 +11,7 @@ final class InputProjectInfoModel: ObservableObject, InputProjectInfoStateProtoc @Published var isPresentedStartAtDatePicker: Bool = false @Published var isPresentedEndAtDatePicker: Bool = false @Published var isPresentedTechStackAppend: Bool = false + @Published var isPresentedToast: Bool = false var focusedProjectIndex: Int = 0 } @@ -152,4 +153,8 @@ extension InputProjectInfoModel: InputProjectInfoActionProtocol { func updateIsPresentedTechStackAppend(isPresented: Bool) { self.isPresentedTechStackAppend = isPresented } + + func updateIsPresentedToast(isPresented: Bool) { + self.isPresentedToast = isPresented + } } diff --git a/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModelProtocol.swift b/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModelProtocol.swift index d87208f5..dbf20e33 100644 --- a/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModelProtocol.swift +++ b/Projects/Feature/InputProjectInfoFeature/Sources/Model/InputProjectInfoModelProtocol.swift @@ -49,6 +49,7 @@ protocol InputProjectInfoStateProtocol { var isPresentedStartAtDatePicker: Bool { get } var isPresentedEndAtDatePicker: Bool { get } var isPresentedTechStackAppend: Bool { get } + var isPresentedToast: Bool { get } } protocol InputProjectInfoActionProtocol: AnyObject { @@ -76,4 +77,5 @@ protocol InputProjectInfoActionProtocol: AnyObject { func updateIsPresentedStartAtDatePicker(isPresented: Bool) func updateIsPresentedEndAtDatePicker(isPresented: Bool) func updateIsPresentedTechStackAppend(isPresented: Bool) + func updateIsPresentedToast(isPresented: Bool) } diff --git a/Projects/Feature/InputProjectInfoFeature/Sources/Scene/InputProjectInfoView.swift b/Projects/Feature/InputProjectInfoFeature/Sources/Scene/InputProjectInfoView.swift index 2f4a910e..cbfb54af 100644 --- a/Projects/Feature/InputProjectInfoFeature/Sources/Scene/InputProjectInfoView.swift +++ b/Projects/Feature/InputProjectInfoFeature/Sources/Scene/InputProjectInfoView.swift @@ -77,6 +77,13 @@ struct InputProjectInfoView: View { } ) ) + .smsToast( + text: "이미지는 최대 4개까지만 추가 할 수 있어요.", + isShowing: Binding( + get: { state.isPresentedToast }, + set: { _ in intent.toastDismissed() } + ) + ) .datePicker( isShowing: Binding( get: { state.isPresentedStartAtDatePicker }, @@ -202,38 +209,40 @@ private extension InputProjectInfoView { @ViewBuilder func projectPreviewImageList(index: Int) -> some View { - LazyHStack(spacing: 8) { - let projectPreviewImages = state.projectList[safe: index]?.previewImages ?? [] - ConditionView(projectPreviewImages.count < 4) { - imagePlaceholder(size: 132) - .overlay { - VStack(spacing: 4) { - SMSIcon(.photo) - - SMSText( - "\(projectPreviewImages.count)/4", - font: .body2 - ) - .foregroundColor(.sms(.system(.black))) - } - } - .buttonWrapper { - intent.appendPreviewImageButtonDidTap(index: index) - } - } - - ForEach(projectPreviewImages.indices, id: \.self) { previewIndex in - Image(uiImage: projectPreviewImages[previewIndex].uiImage) - .resizable() - .frame(width: 132, height: 132) - .cornerRadius(8) - .overlay(alignment: .topTrailing) { - SMSIcon(.xmark) - .padding(4) - .buttonWrapper { - intent.removePreviewImageDidTap(index: index, previewIndex: previewIndex) + ScrollView(.horizontal, showsIndicators: false) { + LazyHStack(spacing: 8) { + let projectPreviewImages = state.projectList[safe: index]?.previewImages ?? [] +// ConditionView(projectPreviewImages.count < 4) { + imagePlaceholder(size: 132) + .overlay { + VStack(spacing: 4) { + SMSIcon(.photo) + + SMSText( + "\(projectPreviewImages.count)/4", + font: .body2 + ) + .foregroundColor(.sms(.system(.black))) } - } + } + .buttonWrapper { + intent.appendPreviewImageButtonDidTap(index: index, previewsCount: projectPreviewImages.count) + } +// } + + ForEach(projectPreviewImages.indices, id: \.self) { previewIndex in + Image(uiImage: projectPreviewImages[previewIndex].uiImage) + .resizable() + .frame(width: 132, height: 132) + .cornerRadius(8) + .overlay(alignment: .topTrailing) { + SMSIcon(.xmark) + .padding(4) + .buttonWrapper { + intent.removePreviewImageDidTap(index: index, previewIndex: previewIndex) + } + } + } } } .titleWrapper("미리보기 사진") diff --git a/Projects/Feature/MyPageFeature/Sources/Model/MyPageWorkInfoModel.swift b/Projects/Feature/MyPageFeature/Sources/Model/MyPageWorkInfoModel.swift index ae8da0e6..bf02421f 100644 --- a/Projects/Feature/MyPageFeature/Sources/Model/MyPageWorkInfoModel.swift +++ b/Projects/Feature/MyPageFeature/Sources/Model/MyPageWorkInfoModel.swift @@ -38,7 +38,7 @@ extension MyPageModel: MyPageWorkInfoActionProtocol { func updateSalary(salary: String) { guard let salaryInt = Int(salary).map({ String(min($0, 9999)) }) else { return } - self.salary = salaryInt + self.salary = salaryInt == "0" ? "상관없음" : "\(salaryInt)만원" } func updateFormOfEmployment(form: FormOfEmployment) {