feat: 优化开启时按钮状态

This commit is contained in:
Junhui Chen 2025-09-12 14:46:15 +08:00
parent d62e8373f8
commit c4c33158fd
3 changed files with 41 additions and 3 deletions

View File

@ -37,6 +37,15 @@ struct BlindBoxActionButton: View {
.background(Color.themePrimary)
.foregroundColor(Color.themeTextMessageMain)
.cornerRadius(32)
case .opening:
Text("Ready")
.font(Typography.font(for: .body))
.fontWeight(.bold)
.frame(maxWidth: .infinity)
.padding()
.background(Color.themePrimary)
.foregroundColor(Color.themeTextMessageMain)
.cornerRadius(32)
default:
Text("Go to Buy")
.font(Typography.font(for: .body))

View File

@ -22,6 +22,8 @@ struct BlindBoxView: View {
@State private var showLogin = false
// ViewModel countdownText
@State private var animationPhase: BlindBoxAnimationPhase = .none
//
@State private var isOpening: Bool = false
// -
@Query private var login: [Login]
@ -55,6 +57,8 @@ struct BlindBoxView: View {
viewModel.player?.pause()
viewModel.player?.replaceCurrentItem(with: nil)
viewModel.player = nil
//
isOpening = false
NotificationCenter.default.removeObserver(
self,
@ -153,6 +157,8 @@ struct BlindBoxView: View {
maxWidth: .infinity,
maxHeight: UIScreen.main.bounds.height * 0.65
)
//
.zIndex(animationPhase == .opening ? 1 : 0)
// TODO
@ -161,12 +167,23 @@ struct BlindBoxView: View {
phase: animationPhase,
countdownText: viewModel.countdownText,
onOpen: {
openBlindBoxAndUpdateState(navigateAfterOpen: true)
//
guard !isOpening else { return }
isOpening = true
// onOpeningCompleted
openBlindBoxAndUpdateState(navigateAfterOpen: false)
},
onGoToBuy: {
Router.shared.navigate(to: .mediaUpload)
}
)
.disabled(isOpening)
//
.opacity(animationPhase == .opening ? 0 : 1)
//
.animation(.easeInOut(duration: 0.2), value: animationPhase)
//
.allowsHitTesting(animationPhase != .opening)
.padding(.horizontal)
}
}
@ -259,6 +276,8 @@ struct BlindBoxView: View {
}
} catch {
print("❌ 开启盲盒失败: \(error)")
//
isOpening = false
}
}
}
@ -289,6 +308,8 @@ struct BlindBoxView: View {
goToFeedback: false
)
)
//
isOpening = false
return
}
} else if mediaType == .image {
@ -310,11 +331,15 @@ struct BlindBoxView: View {
goToFeedback: true
)
)
//
isOpening = false
return
}
}
// 便
print("⚠️ navigateToOutcome: 媒体尚未准备好videoURL=\(viewModel.videoURL), image=\(String(describing: viewModel.displayImage))")
//
isOpening = false
}
}
}

View File

@ -115,13 +115,17 @@ struct BlindOutcomeView: View {
.background(Color.themePrimary)
.cornerRadius(26)
}
//
.opacity(showIPListModal ? 0 : 1)
.animation(.easeInOut(duration: 0.2), value: showIPListModal)
.allowsHitTesting(!showIPListModal)
.padding(.horizontal)
}
.padding(.bottom, 20)
}
}
// .navigationBarHidden(true)
// .navigationBarBackButtonHidden(true)
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
.overlay(
JoinModal(isPresented: $showIPListModal, onClose: { onContinue() })
)