Skip to content

Commit

Permalink
✨ [#220] InputProjectInfo / preview 이미지 4개 넘기면 경고 띄우기
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsh153 committed Aug 23, 2023
1 parent 4ca3dc6 commit e39d96b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -175,4 +179,8 @@ final class InputProjectInfoIntent: InputProjectInfoIntentProtocol {
func techStackAppendDismissed() {
model?.updateIsPresentedTechStackAppend(isPresented: false)
}

func toastDismissed() {
model?.updateIsPresentedToast(isPresented: false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -32,4 +32,5 @@ protocol InputProjectInfoIntentProtocol {
func endAtDatePickerDismissed()
func techStackAppendButtonDidTap(index: Int)
func techStackAppendDismissed()
func toastDismissed()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -152,4 +153,8 @@ extension InputProjectInfoModel: InputProjectInfoActionProtocol {
func updateIsPresentedTechStackAppend(isPresented: Bool) {
self.isPresentedTechStackAppend = isPresented
}

func updateIsPresentedToast(isPresented: Bool) {
self.isPresentedToast = isPresented
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -76,4 +77,5 @@ protocol InputProjectInfoActionProtocol: AnyObject {
func updateIsPresentedStartAtDatePicker(isPresented: Bool)
func updateIsPresentedEndAtDatePicker(isPresented: Bool)
func updateIsPresentedTechStackAppend(isPresented: Bool)
func updateIsPresentedToast(isPresented: Bool)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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("미리보기 사진")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e39d96b

Please sign in to comment.