Skip to content

Commit d64793d

Browse files
committed
[Chore] #219 - 이력서 기간 입력 오류 수정
1 parent 5e43342 commit d64793d

5 files changed

Lines changed: 46 additions & 29 deletions

File tree

CERTI-iOS/Presentation/Resume/Components/PeriodInputComponent.swift

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ struct PeriodInputComponent: View {
5252
DatePicker("", selection: Binding<Date>(
5353
get: { startDate ?? Date() },
5454
set: {
55-
startDate = $0
56-
if let end = endDate, $0 > end {
57-
endDate = $0
55+
let selected = $0
56+
startDate = selected
57+
startAt = formatDateToString(selected)
58+
59+
if let end = endDate, selected > end {
60+
endDate = selected
61+
endAt = formatDateToString(selected)
5862
}
63+
64+
isFilled = startDate != nil && endDate != nil
5965
}
6066
), displayedComponents: .date)
6167
.datePickerStyle(.graphical)
@@ -82,10 +88,16 @@ struct PeriodInputComponent: View {
8288
DatePicker("", selection: Binding<Date>(
8389
get: { endDate ?? Date() },
8490
set: {
85-
endDate = $0
86-
if let start = startDate, $0 < start {
87-
startDate = $0
91+
let selected = $0
92+
endDate = selected
93+
endAt = formatDateToString(selected)
94+
95+
if let start = startDate, selected < start {
96+
startDate = selected
97+
startAt = formatDateToString(selected)
8898
}
99+
100+
isFilled = startDate != nil && endDate != nil
89101
}
90102
), displayedComponents: .date)
91103
.datePickerStyle(.graphical)
@@ -110,15 +122,13 @@ struct PeriodInputComponent: View {
110122
}
111123
}
112124
.onAppear {
113-
if startDate == nil, !startAt.isEmpty {
114-
startDate = Date.stringToDate(startAt)
115-
}
116-
117-
if endDate == nil, !endAt.isEmpty {
118-
endDate = Date.stringToDate(endAt)
119-
}
120-
121-
isFilled = startDate != nil && endDate != nil
125+
datesBind()
126+
}
127+
.onChange(of: startAt) { _ in
128+
datesBind()
129+
}
130+
.onChange(of: endAt) { _ in
131+
datesBind()
122132
}
123133
}
124134

@@ -135,6 +145,12 @@ struct PeriodInputComponent: View {
135145
formatter.locale = Locale(identifier: "ko_KR")
136146
return formatter.string(from: date)
137147
}
148+
149+
private func datesBind() {
150+
startDate = startAt.isEmpty ? nil : Date.stringToDate(startAt)
151+
endDate = endAt.isEmpty ? nil : Date.stringToDate(endAt)
152+
isFilled = startDate != nil && endDate != nil
153+
}
138154
}
139155

140156
extension PeriodInputComponent {

CERTI-iOS/Presentation/Resume/Components/ResumeActivityListComponent.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct ResumeActivityListComponent: View {
1616
VStack(alignment: .leading, spacing: 0) {
1717
let periodText = "\(model.startAt.toYearMonth()) ~ \(model.endAt.toYearMonth())"
1818

19-
Text(periodText) .applyCertiFont(.caption_regular_12)
19+
Text(periodText)
20+
.applyCertiFont(.caption_regular_12)
2021
.foregroundStyle(.grayscale500)
2122
.frame(height: 18)
2223

@@ -26,8 +27,8 @@ struct ResumeActivityListComponent: View {
2627
.frame(height: 18)
2728
.padding(.top, 12)
2829
}
29-
.frame(width: 104, height: 48)
30-
30+
.frame(width: 108, height: 48)
31+
3132
VStack(alignment: .leading, spacing: 0) {
3233
Text(model.place)
3334
.applyCertiFont(.body_semibold_16)

CERTI-iOS/Presentation/Resume/Components/ResumeCareerListComponent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ResumeCareerListComponent: View {
2727
.frame(height: 18)
2828
.padding(.top, 12)
2929
}
30-
.frame(width: 104, height: 48)
30+
.frame(width: 108, height: 48)
3131

3232
VStack(alignment: .leading, spacing: 0) {
3333
Text(model.place)

CERTI-iOS/Presentation/Resume/View/MyActivityWriteView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ struct MyActivityWriteView: View {
4646
.padding(.top, 40)
4747
}
4848
}
49-
.onAppear{
50-
switch mode {
51-
case .add:
52-
viewModel.clearActivityWriteModel()
53-
case .edit(let activityId):
49+
.onAppear {
50+
if case let .edit(activityId) = mode {
5451
viewModel.prepareActivityEdit(activityId: activityId)
5552
}
5653
}
54+
.onDisappear {
55+
viewModel.clearActivityWriteModel()
56+
}
5757
.navigationBarBackButtonHidden()
5858
.scrollIndicators(.hidden)
5959
.scrollDismissesKeyboard(.immediately)

CERTI-iOS/Presentation/Resume/View/MyCareerWriteView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ struct MyCareerWriteView: View {
4646
.padding(.top, 40)
4747
}
4848
}
49-
.onAppear{
50-
switch mode {
51-
case .add:
52-
viewModel.clearCareerWriteModel()
53-
case .edit(let careerId):
49+
.onAppear {
50+
if case let .edit(careerId) = mode {
5451
viewModel.prepareCareerEdit(careerId: careerId)
5552
}
5653
}
54+
.onDisappear {
55+
viewModel.clearCareerWriteModel()
56+
}
5757
.scrollIndicators(.hidden)
5858
.navigationBarBackButtonHidden()
5959
.scrollDismissesKeyboard(.immediately)

0 commit comments

Comments
 (0)