Skip to content

Commit 5dd2fff

Browse files
authored
Merge pull request #114 from DSM-PICK/feature/(#111)-chore_error
🔗 :: (#111) 오토 레이아웃 및 Auth 에러 처리
2 parents d804fba + e58dcc0 commit 5dd2fff

14 files changed

Lines changed: 149 additions & 118 deletions

File tree

Projects/Domain/BaseDomain/Sources/Base/BaseRemoteDataSource.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ open class BaseRemoteDataSource<API: PiCKAPI> {
3838
return self.refreshTokenAndRetry(api: api, originalError: moyaError)
3939
}
4040

41-
throw api.errorMap?[code] ??
42-
PiCKError.error(
43-
message: (try? moyaError.response?
44-
.mapJSON() as? NSDictionary)?["message"] as? String ?? "",
45-
errorBody: [:]
46-
)
41+
let serverMessage = (try? moyaError.response?
42+
.mapJSON() as? NSDictionary)?["message"] as? String ?? ""
43+
44+
if !serverMessage.isEmpty {
45+
throw PiCKError.error(message: serverMessage, errorBody: [:])
46+
}
47+
48+
throw api.errorMap?[code] ?? PiCKError.error(message: "오류가 발생했습니다.", errorBody: [:])
4749
}
4850
.eraseToAnyPublisher()
4951
}

Projects/Feature/AllTabFeature/Sources/Component/AllTabMenuList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public struct AllTabMenuList: View {
4949
action: onSelfStudyCheckTap
5050
),
5151
MenuItemModel(
52-
icon: PiCKImage.classRoomMove, // admin classroomMove 아이콘 추가 필요
52+
icon: PiCKImage.moveClass,
5353
title: "교실 이동 현황",
5454
action: onClassroomMoveListTap
5555
),

Projects/Feature/ClassroomMoveListFeature/Sources/Scene/ClassroomMoveListView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public struct ClassroomMoveListView: View {
125125
.navigationTitle("교실 이동 현황")
126126
.navigationBarTitleDisplayMode(.inline)
127127
.navigationBarBackButtonHidden(true)
128+
.toolbar(.hidden, for: .tabBar)
128129
.toolbar {
129130
ToolbarItem(placement: .navigationBarLeading) {
130131
Button {

Projects/Feature/OutListFeature/Sources/Scene/OutListView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public struct OutListView: View {
185185
.navigationTitle("외출자 목록")
186186
.navigationBarTitleDisplayMode(.inline)
187187
.navigationBarBackButtonHidden(true)
188+
.toolbar(.hidden, for: .tabBar)
188189
.toolbar {
189190
ToolbarItem(placement: .navigationBarLeading) {
190191
Button {

Projects/Feature/OutingHistoryFeature/Sources/Component/OutingHistoryCell.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ struct OutingHistoryCell: View {
88
var body: some View {
99
VStack(alignment: .leading, spacing: 12) {
1010
Text("\(data.grade)\(data.classNum)\(String(format: "%02d", data.num)) \(data.userName)")
11-
.pickText(type: .subTitle1, textColor: .Normal.black)
11+
.pickText(type: .subTitle2, textColor: .Normal.black)
1212

1313
HStack(spacing: 12) {
1414
HStack(spacing: 8) {
1515
Text("조기귀가")
16-
.pickText(type: .label1, textColor: .Normal.white)
16+
.pickText(type: .body1, textColor: .Normal.white)
1717
.frame(width: 68, height: 28)
1818
.background(Color.Primary.primary300)
1919
.cornerRadius(8)
2020

2121
Text("\(data.earlyReturnCnt)")
22-
.pickText(type: .caption1, textColor: .Normal.black)
22+
.pickText(type: .body1, textColor: .Normal.black)
2323
}
2424

2525
HStack(spacing: 8) {
2626
Text("외출")
27-
.pickText(type: .label1, textColor: .Normal.white)
27+
.pickText(type: .body1, textColor: .Normal.white)
2828
.frame(width: 64, height: 28)
2929
.background(Color.Primary.primary500)
3030
.cornerRadius(8)
3131

3232
Text("\(data.applicationCnt)")
33-
.pickText(type: .caption1, textColor: .Normal.black)
33+
.pickText(type: .body1, textColor: .Normal.black)
3434
}
3535
}
3636
}

Projects/Feature/OutingHistoryFeature/Sources/Scene/OutingHistoryView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public struct OutingHistoryView: View {
7373
.navigationTitle("이전 외출 기록")
7474
.navigationBarTitleDisplayMode(.inline)
7575
.navigationBarBackButtonHidden(true)
76+
.toolbar(.hidden, for: .tabBar)
7677
.toolbar {
7778
ToolbarItem(placement: .navigationBarLeading) {
7879
Button {

Projects/Feature/SchoolMealFeature/Sources/Cell/SchoolMealCellView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,28 @@ struct SchoolMealCellView: View {
99
var body: some View {
1010
HStack(spacing: 0) {
1111
Spacer()
12+
1213
VStack(spacing: 16) {
1314
Text(mealTime)
1415
.pickText(type: .subTitle1, textColor: .Primary.primary700)
1516

1617
if !menu.isEmpty {
1718
Text(kcal)
1819
.pickText(type: .caption2, textColor: .Normal.white)
19-
.frame(width: 75, height: 22)
20+
.padding(.horizontal, 12)
21+
.padding(.vertical, 4)
2022
.background(Color.Primary.primary500)
2123
.cornerRadius(12)
2224
}
2325
}
24-
.frame(width: 140)
2526

2627
Spacer()
2728

2829
Text(menu.isEmpty ? "급식이 없습니다" : menu.joined(separator: "\n"))
2930
.pickText(type: .label1, textColor: .Normal.black)
3031
.multilineTextAlignment(.leading)
31-
.frame(width: 200)
32+
.frame(width: 120)
33+
3234
Spacer()
3335
}
3436
.frame(maxWidth: .infinity, minHeight: 140)

Projects/Feature/SelfStudyCheck/Sources/Scene/SelfStudyCheckView.swift

Lines changed: 62 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,6 @@ public struct SelfStudyCheckView: View {
1616
self.store = store
1717
}
1818

19-
private func statusColor(_ status: String) -> Color {
20-
switch status {
21-
case "출석":
22-
return .Primary.primary300
23-
case "현체":
24-
return .Gray.gray300
25-
case "이동":
26-
return .Gray.gray800
27-
case "외출":
28-
return .Primary.primary500
29-
case "무단":
30-
return .Error.error
31-
case "귀가", "결과":
32-
return .Gray.gray600
33-
case "취업중":
34-
return .Primary.primary500
35-
default:
36-
return .Gray.gray600
37-
}
38-
}
39-
40-
private func indicatorOffset(for period: SelfStudyCheckReducer.Period) -> CGFloat {
41-
let allCases = SelfStudyCheckReducer.Period.allCases
42-
guard let selectedIndex = allCases.firstIndex(of: period) else { return 0 }
43-
let buttonWidth: CGFloat = 114
44-
let spacing: CGFloat = 8
45-
let horizontalPadding: CGFloat = 24
46-
47-
return horizontalPadding + CGFloat(selectedIndex) * (buttonWidth + spacing)
48-
}
49-
5019
public var body: some View {
5120
WithViewStore(store, observe: { $0 }) { viewStore in
5221
ZStack {
@@ -66,34 +35,16 @@ public struct SelfStudyCheckView: View {
6635
.padding(.top, 16)
6736

6837
HStack(spacing: 0) {
69-
HStack(spacing: 16) {
70-
Text(Date().koreanMonthDayString)
71-
.pickText(type: .label1, textColor: .Normal.black)
72-
73-
Text("출결")
74-
.pickText(type: .label1, textColor: .Normal.black)
75-
}
76-
.padding(.leading, 24)
38+
Text(Date().koreanMonthDayString + " 출결")
39+
.pickText(type: .heading4, textColor: .Normal.black)
40+
.padding(.leading, 24)
7741

7842
Spacer()
7943

80-
Button {
81-
tempSelectedGrade = "\(viewStore.selectedGrade)"
82-
tempSelectedClass = "\(viewStore.selectedClass)"
83-
isClassBottomSheetPresented = true
84-
} label: {
85-
HStack(spacing: 8) {
86-
Text("\(viewStore.selectedGrade)학년 \(viewStore.selectedClass)")
87-
.pickText(type: .body1, textColor: .Gray.gray800)
88-
89-
Image(systemName: "chevron.down")
90-
.foregroundColor(.Gray.gray600)
91-
.font(.system(size: 12))
92-
}
93-
.frame(width: 103, height: 34)
94-
.background(Color.Gray.gray50)
95-
.cornerRadius(8)
96-
}
44+
ClassroomFilterButton(
45+
selectedClassroom: "\(viewStore.selectedGrade)학년 \(viewStore.selectedClass)",
46+
onTap: { isClassBottomSheetPresented = true }
47+
)
9748
.padding(.trailing, 24)
9849
}
9950
.padding(.top, 20)
@@ -105,33 +56,28 @@ public struct SelfStudyCheckView: View {
10556
.padding(.top, 20)
10657
.padding(.horizontal, 24)
10758

108-
VStack(alignment: .leading, spacing: 0) {
109-
ScrollView(.horizontal, showsIndicators: false) {
110-
HStack(spacing: 8) {
111-
ForEach(SelfStudyCheckReducer.Period.allCases, id: \.self) { period in
112-
Button {
113-
viewStore.send(.selectPeriod(period), animation: .spring())
114-
} label: {
115-
Text(period.title)
116-
.pickText(
117-
type: .body1,
118-
textColor: viewStore.selectedPeriod == period ? .Primary.primary500 : .Gray.gray600
119-
)
120-
.frame(width: 114, height: 32)
121-
.background(Color.clear)
122-
.cornerRadius(8)
123-
}
124-
}
59+
HStack(spacing: 8) {
60+
ForEach(SelfStudyCheckReducer.Period.allCases, id: \.self) { period in
61+
Button {
62+
viewStore.send(.selectPeriod(period), animation: .spring())
63+
} label: {
64+
Text(period.title)
65+
.pickText(
66+
type: .body1,
67+
textColor: viewStore.selectedPeriod == period ? .Primary.primary500 : .Gray.gray600
68+
)
69+
.frame(maxWidth: .infinity)
70+
.frame(height: 32)
71+
.background(
72+
viewStore.selectedPeriod == period
73+
? Color.Primary.primary50
74+
: Color.clear
75+
)
76+
.cornerRadius(8)
12577
}
126-
.padding(.horizontal, 24)
12778
}
128-
129-
Rectangle()
130-
.fill(Color.Primary.primary500)
131-
.frame(width: 114, height: 1)
132-
.offset(x: indicatorOffset(for: viewStore.selectedPeriod))
133-
.animation(.spring(), value: viewStore.selectedPeriod)
13479
}
80+
.padding(.horizontal, 24)
13581
.padding(.top, 16)
13682

13783
ScrollView {
@@ -146,15 +92,10 @@ public struct SelfStudyCheckView: View {
14692
}
14793
.frame(maxWidth: .infinity, minHeight: UIScreen.main.bounds.height - 400)
14894
} else {
149-
VStack(spacing: 20) {
95+
VStack(spacing: 16) {
15096
ForEach(viewStore.studentItems) { item in
15197
HStack(spacing: 0) {
152-
Text("\(item.grade)\(item.classNum)\(String(format: "%02d", item.num))")
153-
.pickText(type: .body1, textColor: .Normal.black)
154-
155-
Text(" ")
156-
157-
Text(item.userName)
98+
Text("\(item.grade)\(item.classNum)\(String(format: "%02d", item.num)) \(item.userName)")
15899
.pickText(type: .subTitle3, textColor: .Normal.black)
159100

160101
Spacer()
@@ -164,7 +105,7 @@ public struct SelfStudyCheckView: View {
164105
isStatusBottomSheetPresented = true
165106
} label: {
166107
Text(item.status)
167-
.pickText(type: .body3, textColor: .Normal.white)
108+
.pickText(type: .body1, textColor: .Normal.white)
168109
.frame(width: 55, height: 29)
169110
.background(statusColor(item.status))
170111
.cornerRadius(8)
@@ -177,7 +118,6 @@ public struct SelfStudyCheckView: View {
177118
.cornerRadius(12)
178119
}
179120
}
180-
.padding(.top, 20)
181121
.padding(.horizontal, 24)
182122
}
183123
}
@@ -237,3 +177,36 @@ public struct SelfStudyCheckView: View {
237177
}
238178
}
239179
}
180+
181+
extension SelfStudyCheckView {
182+
private func statusColor(_ status: String) -> Color {
183+
switch status {
184+
case "출석":
185+
return .Primary.primary300
186+
case "현체":
187+
return .Gray.gray300
188+
case "이동":
189+
return .Gray.gray800
190+
case "외출":
191+
return .Primary.primary500
192+
case "무단":
193+
return .Error.error
194+
case "귀가", "결과":
195+
return .Gray.gray600
196+
case "취업중":
197+
return .Primary.primary500
198+
default:
199+
return .Gray.gray600
200+
}
201+
}
202+
203+
private func indicatorOffset(for period: SelfStudyCheckReducer.Period) -> CGFloat {
204+
let allCases = SelfStudyCheckReducer.Period.allCases
205+
guard let selectedIndex = allCases.firstIndex(of: period) else { return 0 }
206+
let buttonWidth: CGFloat = 114
207+
let spacing: CGFloat = 8
208+
let horizontalPadding: CGFloat = 24
209+
210+
return horizontalPadding + CGFloat(selectedIndex) * (buttonWidth + spacing)
211+
}
212+
}

Projects/Feature/SigninFeature/Sources/Scene/SigninView.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ struct SigninView: View {
2929
}
3030
}
3131
.navigationBarHidden(true)
32+
.errorToast(
33+
message: viewStore.errorMessage ?? "에러발생!",
34+
isPresented: viewStore.binding(
35+
get: { $0.errorMessage != nil },
36+
send: .clearError
37+
)
38+
)
3239
}
3340
}
3441

0 commit comments

Comments
 (0)