fix(detail): 콘텐츠/시리즈 상세 로딩 실패 시 자동 복귀를 적용한다
This commit is contained in:
@@ -21,6 +21,8 @@ struct ContentDetailView: View {
|
||||
@State private var isShowCommentListView = false
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
@State private var creatorId: Int = 0
|
||||
@State private var didTriggerAutoBackOnLoadFailure: Bool = false
|
||||
@State private var isViewVisible: Bool = false
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
@@ -28,11 +30,7 @@ struct ContentDetailView: View {
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 0) {
|
||||
Button {
|
||||
if presentationMode.wrappedValue.isPresented {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
} else {
|
||||
AppState.shared.back()
|
||||
}
|
||||
goBack()
|
||||
} label: {
|
||||
Image("ic_back")
|
||||
.resizable()
|
||||
@@ -217,9 +215,26 @@ struct ContentDetailView: View {
|
||||
.navigationTitle("")
|
||||
.navigationBarBackButtonHidden()
|
||||
.onAppear {
|
||||
isViewVisible = true
|
||||
didTriggerAutoBackOnLoadFailure = false
|
||||
viewModel.contentId = contentId
|
||||
AppState.shared.pushAudioContentId = 0
|
||||
}
|
||||
.onDisappear {
|
||||
isViewVisible = false
|
||||
}
|
||||
.onChange(of: viewModel.isShowPopup) { isShowing in
|
||||
guard isShowing else { return }
|
||||
guard viewModel.audioContent == nil else { return }
|
||||
guard !didTriggerAutoBackOnLoadFailure else { return }
|
||||
|
||||
didTriggerAutoBackOnLoadFailure = true
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
guard isViewVisible else { return }
|
||||
goBack()
|
||||
}
|
||||
}
|
||||
|
||||
if let audioContent = viewModel.audioContent, isShowOrderView {
|
||||
VStack(spacing: 0) {
|
||||
@@ -423,7 +438,7 @@ struct ContentDetailView: View {
|
||||
.padding(.vertical, 13.3)
|
||||
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.background(Color(hex: "3bb9f1"))
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.center)
|
||||
.cornerRadius(20)
|
||||
@@ -434,4 +449,12 @@ struct ContentDetailView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func goBack() {
|
||||
if presentationMode.wrappedValue.isPresented {
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
} else {
|
||||
AppState.shared.back()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user