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) .background(Color.themePrimary)
.foregroundColor(Color.themeTextMessageMain) .foregroundColor(Color.themeTextMessageMain)
.cornerRadius(32) .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: default:
Text("Go to Buy") Text("Go to Buy")
.font(Typography.font(for: .body)) .font(Typography.font(for: .body))

View File

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

View File

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