Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: [#252] ν•„μˆ˜μš”μ†Œ κ²€μ‚¬ν•΄μ„œ μ—λŸ¬ λ„μš°κΈ° #263

Merged
merged 6 commits into from
Aug 29, 2023
38 changes: 20 additions & 18 deletions Projects/Feature/FilterFeature/Sources/Scene/FilterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,25 +409,27 @@ struct FilterView: View {
intent.techStackAppendIsRequired()
}

TagLayoutView(
state.techStacks,
tagFont: UIFont(
font: DesignSystemFontFamily.Pretendard.regular,
size: 24
) ?? .init(),
padding: 20,
parentWidth: geometry.size.width
) { techStack in
HStack {
SMSText(techStack, font: .body2)

SMSIcon(.xmarkOutline, width: 20, height: 20)
ScrollView(.horizontal, showsIndicators: false) {
TagLayoutView(
state.techStacks,
tagFont: UIFont(
font: DesignSystemFontFamily.Pretendard.regular,
size: 24
) ?? .init(),
padding: 20,
parentWidth: geometry.size.width
) { techStack in
HStack {
SMSText(techStack, font: .body2)

SMSIcon(.xmarkOutline, width: 20, height: 20)
}
.padding(.horizontal, 12)
.padding(.vertical, 10)
.background(Color.sms(.neutral(.n10)))
.fixedSize()
.clipShape(RoundedRectangle(cornerRadius: 4))
}
.padding(.horizontal, 12)
.padding(.vertical, 10)
.background(Color.sms(.neutral(.n10)))
.fixedSize()
.clipShape(RoundedRectangle(cornerRadius: 4))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import InputPrizeInfoFeatureInterface
import FoundationUtil

final class InputPrizeInfoIntent: InputPrizeInfoIntentProtocol {
private weak var model: (any InputPrizeInfoActionProtocol)?
Expand All @@ -18,13 +19,34 @@ final class InputPrizeInfoIntent: InputPrizeInfoIntentProtocol {
}

func completeButtonDidTap(prizes: [PrizeInfo]) {
let prizeInfoObjects = prizes.map {
return InputPrizeInfoObject(
name: $0.name,
prize: $0.prize,
prizeAt: $0.prizeAt
)
}
var errorSet: [Set<InputPrizeInfoErrorField>] = []

let prizeInfoObjects = prizes
.enumerated()
.map { index, prize in
errorSet.append([])

if prize.name.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.name)
}

if prize.prize.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.type)
}

if prize.prizeAt.description.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.date)
}

return InputPrizeInfoObject(
name: prize.name,
prize: prize.prize,
prizeAt: prize.prizeAt
)
}
model?.updateErrorSetList(set: errorSet)
guard !errorSet.contains(where: { $0.isNotEmpty }) else { return }

delegate?.completeToInputPrizeInfo(input: prizeInfoObjects)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FoundationUtil
final class InputPrizeInfoModel: ObservableObject, InputPrizeInfoStateProtocol {
@Published var prizeList: [PrizeInfo] = []
@Published var collapsedPrize: [Bool] = []
@Published var prizeErrorSetList: [Set<InputPrizeInfoErrorField>] = []
@Published var isPresentedPrizeAtDatePicker: Bool = false
var focusedPrizeIndex: Int = 0
}
Expand Down Expand Up @@ -52,4 +53,8 @@ extension InputPrizeInfoModel: InputPrizeInfoActionProtocol {
func updateIsPresentedPrizeAtDatePicker(isPresented: Bool) {
self.isPresentedPrizeAtDatePicker = isPresented
}

func updateErrorSetList(set: [Set<InputPrizeInfoErrorField>]) {
self.prizeErrorSetList = set
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ struct PrizeInfo: Equatable {
}
}

enum InputPrizeInfoErrorField: Hashable {
case name
case type
case date
}

protocol InputPrizeInfoStateProtocol {
var prizeList: [PrizeInfo] { get }
var collapsedPrize: [Bool] { get }
var prizeErrorSetList: [Set<InputPrizeInfoErrorField>] { get }
var isPresentedPrizeAtDatePicker: Bool { get }
var focusedPrizeIndex: Int { get }
}
Expand All @@ -27,4 +34,5 @@ protocol InputPrizeInfoActionProtocol: AnyObject {
func removePrize(index: Int)
func updateFocusedPrizeIndex(index: Int)
func updateIsPresentedPrizeAtDatePicker(isPresented: Bool)
func updateErrorSetList(set: [Set<InputPrizeInfoErrorField>])
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ private extension InputPrizeInfoView {
text: Binding(
get: { state.prizeList[safe: index]?.name ?? "" },
set: { intent.updatePrizeName(index: index, name: $0) }
)
),
errorText: "μˆ˜μƒ 이름을 μž…λ ₯ν•΄ μ£Όμ„Έμš”.",
isError: state.prizeErrorSetList[safe: index]?.contains(.name) ?? false
)
.titleWrapper("이름")
}
Expand All @@ -116,18 +118,27 @@ private extension InputPrizeInfoView {
text: Binding(
get: { state.prizeList[safe: index]?.prize ?? "" },
set: { intent.updatePrizePrize(index: index, prize: $0)}
)
),
errorText: "μˆ˜μƒ μ’…λ₯˜λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”.",
isError: state.prizeErrorSetList[safe: index]?.contains(.type) ?? false
)
.titleWrapper("μ’…λ₯˜")
}

@ViewBuilder
func prizePrizeAt(index: Int) -> some View {
let prize = state.prizeList[safe: index]
DatePickerField(dateText: prize?.prizeAtString ?? "") {
intent.prizeAtButtonDidTap(index: index)
VStack(alignment: .leading, spacing: 8) {
let prize = state.prizeList[safe: index]
DatePickerField(dateText: prize?.prizeAtString ?? "") {
intent.prizeAtButtonDidTap(index: index)
}
.frame(maxWidth: .infinity)
.titleWrapper("μˆ˜μƒ 일자")

if state.prizeErrorSetList[safe: index]?.contains(.date) ?? false {
SMSText("μˆ˜μƒ 일자λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”.", font: .caption1)
.foregroundColor(.sms(.error(.e2)))
}
}
.frame(maxWidth: .infinity)
.titleWrapper("μˆ˜μƒ 일자")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,30 @@ struct InputProfileInfoView: View {
intent.techStackAppendIsRequired()
}

TagLayoutView(
state.techStacks,
tagFont: UIFont(
font: DesignSystemFontFamily.Pretendard.regular,
size: 24
) ?? .init(),
padding: 20,
parentWidth: geometry.size.width
) { techStack in
HStack {
SMSText(techStack, font: .body2)
ScrollView(.horizontal, showsIndicators: false) {
TagLayoutView(
state.techStacks,
tagFont: UIFont(
font: DesignSystemFontFamily.Pretendard.regular,
size: 24
) ?? .init(),
padding: 20,
parentWidth: geometry.size.width
) { techStack in
HStack {
SMSText(techStack, font: .body2)

SMSIcon(.xmarkOutline, width: 20, height: 20)
.buttonWrapper {
intent.removeTechStack(techStack: techStack)
}
SMSIcon(.xmarkOutline, width: 20, height: 20)
.buttonWrapper {
intent.removeTechStack(techStack: techStack)
}
}
.padding(.horizontal, 12)
.padding(.vertical, 10)
.background(Color.sms(.neutral(.n10)))
.fixedSize()
.clipShape(RoundedRectangle(cornerRadius: 4))
}
.padding(.horizontal, 12)
.padding(.vertical, 10)
.background(Color.sms(.neutral(.n10)))
.fixedSize()
.clipShape(RoundedRectangle(cornerRadius: 4))
}
}
.titleWrapper("μ„ΈλΆ€μŠ€νƒ (μ΅œλŒ€ 5개)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,70 @@ final class InputProjectInfoIntent: InputProjectInfoIntentProtocol {
}

func nextButtonDidTap(projects: [ProjectInfo]) {
let projectInfoObjects = projects.map {
var iconImage: InputProjectInfoObject.ImageFile?

if let unwrapIconImage = $0.iconImage {
iconImage = InputProjectInfoObject.ImageFile(
name: unwrapIconImage.fileName,
data: unwrapIconImage.uiImage.jpegData(compressionQuality: 0.2) ?? .init()
var errorSet = [Set<InputProjectInfoErrorField>]()

let projectInfoObjects = projects
.enumerated()
.map { index, project in
errorSet.append([])
var iconImage: InputProjectInfoObject.ImageFile?

if let unwrapIconImage = project.iconImage {
iconImage = InputProjectInfoObject.ImageFile(
name: unwrapIconImage.fileName,
data: unwrapIconImage.uiImage.jpegData(compressionQuality: 0.2) ?? .init()
)
} else {
iconImage = nil
}

if iconImage == nil, errorSet[safe: index] != nil {
errorSet[index].insert(.icon)
}

if project.name.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.name)
}

if project.content.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.content)
}

if project.techStacks.isEmpty, errorSet[safe: index] != nil {
errorSet[index].insert(.techstaks)
}

if project.endAt == nil && !project.isInProgress, errorSet[safe: index] != nil {
errorSet[index].insert(.date)
}

let previewImages = project.previewImages.map {
return InputProjectInfoObject.ImageFile(
name: $0.fileName,
data: $0.uiImage.jpegData(compressionQuality: 0.2) ?? .init()
)
}

let relatedLinks = project.relatedLinks
.filter { $0.name.isNotEmpty && $0.url.isNotEmpty }
.map { InputProjectInfoObject.RelatedLink(name: $0.name, url: $0.url) }

return InputProjectInfoObject(
name: project.name,
iconImage: iconImage,
previewImages: previewImages,
content: project.content,
techStacks: Array(project.techStacks),
mainTask: project.mainTask,
startAt: project.startAt,
endAt: project.isInProgress ? nil : project.endAt,
relatedLinks: relatedLinks
)
} else {
iconImage = nil
}

let previewImages = $0.previewImages.map {
return InputProjectInfoObject.ImageFile(
name: $0.fileName,
data: $0.uiImage.jpegData(compressionQuality: 0.2) ?? .init()
)
}
model?.updateErrorFieldSet(set: errorSet)
guard !errorSet.contains(where: { $0.isNotEmpty }) else { return }

let relatedLinks = $0.relatedLinks
.filter { $0.name.isNotEmpty && $0.url.isNotEmpty }
.map { InputProjectInfoObject.RelatedLink(name: $0.name, url: $0.url) }

return InputProjectInfoObject(
name: $0.name,
iconImage: iconImage,
previewImages: previewImages,
content: $0.content,
techStacks: Array($0.techStacks),
mainTask: $0.mainTask,
startAt: $0.startAt,
endAt: $0.isInProgress ? nil : $0.endAt,
relatedLinks: relatedLinks
)
}
delegate?.completeToInputProjectInfo(input: projectInfoObjects)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,8 @@ extension InputProjectInfoModel: InputProjectInfoActionProtocol {
func updateIsPresentedToast(isPresented: Bool) {
self.isPresentedToast = isPresented
}

func updateErrorFieldSet(set: [Set<InputProjectInfoErrorField>]) {
self.projectErrorSetList = set
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ extension ProjectInfo {
}

enum InputProjectInfoErrorField: Hashable {
case icon
case name
case content
case mainTask
case techstaks
case date
}

protocol InputProjectInfoStateProtocol {
Expand Down Expand Up @@ -78,4 +80,5 @@ protocol InputProjectInfoActionProtocol: AnyObject {
func updateIsPresentedEndAtDatePicker(isPresented: Bool)
func updateIsPresentedTechStackAppend(isPresented: Bool)
func updateIsPresentedToast(isPresented: Bool)
func updateErrorFieldSet(set: [Set<InputProjectInfoErrorField>])
}
Loading