Skip to content

Commit 7a6117d

Browse files
committed
chore :: [#111] 버그제보 토스트 처리 변경
1 parent f366ccb commit 7a6117d

2 files changed

Lines changed: 49 additions & 25 deletions

File tree

Projects/Feature/BugReport/Sources/BugReportReducer.swift

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ComposableArchitecture
2+
import PiCK_iOS_DesignSystem
23
import Foundation
34
import PhotosUI
45
import SwiftUI
@@ -21,7 +22,10 @@ public struct BugReportReducer: Reducer {
2122
public var bugDescription: String = ""
2223
public var selectedImages: [Data] = []
2324
public var isSubmitting: Bool = false
24-
public var showSuccessAlert: Bool = false
25+
public var showAlert: Bool = false
26+
public var alertSuccessType: SuccessType = .success
27+
public var alertMessage: String = ""
28+
public var shouldDismiss: Bool = false
2529
public var isSubmitButtonEnabled: Bool = false
2630

2731
public init() {}
@@ -35,7 +39,7 @@ public struct BugReportReducer: Reducer {
3539
case submitButtonTapped
3640
case uploadImagesResponse(TaskResult<[String]>)
3741
case submitBugReportResponse(TaskResult<Void>)
38-
case dismissSuccessAlert
42+
case dismissAlert
3943
case updateSubmitButtonState
4044
}
4145

@@ -101,24 +105,33 @@ public struct BugReportReducer: Reducer {
101105
))
102106
}
103107

104-
case let .uploadImagesResponse(.failure(error)):
108+
case .uploadImagesResponse(.failure):
105109
state.isSubmitting = false
110+
state.alertSuccessType = .fail
111+
state.alertMessage = "이미지 업로드를 실패했어요"
112+
state.showAlert = true
106113
return .none
107114

108115
case .submitBugReportResponse(.success):
109116
state.isSubmitting = false
110-
state.showSuccessAlert = true
117+
state.alertSuccessType = .success
118+
state.alertMessage = "버그 제보가 완료되었습니다"
119+
state.showAlert = true
120+
state.shouldDismiss = true
111121
state.bugLocation = ""
112122
state.bugDescription = ""
113123
state.selectedImages = []
114124
return .none
115125

116-
case let .submitBugReportResponse(.failure(error)):
126+
case .submitBugReportResponse(.failure):
117127
state.isSubmitting = false
128+
state.alertSuccessType = .fail
129+
state.alertMessage = "버그 제보를 실패했어요"
130+
state.showAlert = true
118131
return .none
119132

120-
case .dismissSuccessAlert:
121-
state.showSuccessAlert = false
133+
case .dismissAlert:
134+
state.showAlert = false
122135
return .none
123136

124137
case .updateSubmitButtonState:

Projects/Feature/BugReport/Sources/Scene/BugReportView.swift

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,38 @@ public struct BugReportView: View {
1515

1616
public var body: some View {
1717
WithViewStore(store, observe: { $0 }) { viewStore in
18-
VStack(spacing: 0) {
19-
customNavigationBar
18+
ZStack {
19+
VStack(spacing: 0) {
20+
customNavigationBar
2021

21-
ScrollView {
22-
formContent(viewStore: viewStore)
23-
}
22+
ScrollView {
23+
formContent(viewStore: viewStore)
24+
}
2425

25-
submitButton(viewStore: viewStore)
26-
}
27-
.background(Color.Background.background)
28-
.navigationBarHidden(true)
29-
.toolbar(.hidden, for: .tabBar)
30-
.alert("제보 완료", isPresented: viewStore.binding(
31-
get: \.showSuccessAlert,
32-
send: .dismissSuccessAlert
33-
)) {
34-
Button("확인") {
35-
dismiss()
26+
submitButton(viewStore: viewStore)
27+
}
28+
.background(Color.Background.background)
29+
.navigationBarHidden(true)
30+
.toolbar(.hidden, for: .tabBar)
31+
32+
if viewStore.showAlert {
33+
VStack {
34+
Spacer()
35+
PiCKDisappearAlert(
36+
successType: viewStore.alertSuccessType,
37+
message: viewStore.alertMessage
38+
)
39+
.onDisappear {
40+
viewStore.send(.dismissAlert)
41+
if viewStore.shouldDismiss {
42+
dismiss()
43+
}
44+
}
45+
.padding(.bottom, 40)
46+
}
47+
.transition(.move(edge: .bottom).combined(with: .opacity))
48+
.zIndex(999)
3649
}
37-
} message: {
38-
Text("버그 제보가 성공적으로 완료되었습니다.")
3950
}
4051
}
4152
}

0 commit comments

Comments
 (0)