feat: 动画

This commit is contained in:
jinyaqiu 2025-09-01 16:33:46 +08:00
parent 08a82386da
commit 982c32cfdb

View File

@ -293,6 +293,7 @@ struct BlindBoxView: View {
@State private var aspectRatio: CGFloat = 1.0 @State private var aspectRatio: CGFloat = 1.0
@State private var isPortrait: Bool = false @State private var isPortrait: Bool = false
@State private var displayImage: UIImage? @State private var displayImage: UIImage?
@State private var showMedia = false
// - // -
@Query private var login: [Login] @Query private var login: [Login]
@ -868,22 +869,39 @@ struct BlindBoxView: View {
ZStack { ZStack {
GIFView(name: "BlindOpen") GIFView(name: "BlindOpen")
.frame(width: 300, height: 300) .frame(width: 300, height: 300)
.scaleEffect(scale)
.opacity(showMedia ? 0 : 1) // GIF
.onAppear { .onAppear {
print("开始播放开启动画") print("开始播放开启动画")
// // 1
self.scale = 1.0
// 2.5 // 1
DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
// withAnimation(.spring(response: 1.0, dampingFraction: 0.7)) {
if mediaType == .video { //
loadVideo() self.scale = max(
} else if mediaType == .image { UIScreen.main.bounds.width / 300,
loadImage() UIScreen.main.bounds.height / 300
} ) * 1.2
// //
withAnimation(.easeInOut(duration: 0.5)) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.startScalingAnimation() withAnimation(.spring(response: 0.8, dampingFraction: 0.7)) {
self.scale = 1.0
//
self.showScalingOverlay = true
if mediaType == .video {
loadVideo()
} else if mediaType == .image {
loadImage()
}
// GIF
self.showMedia = true
}
}
} }
} }
} }
@ -899,7 +917,8 @@ struct BlindBoxView: View {
.compositingGroup() .compositingGroup()
.padding() .padding()
} }
if !showScalingOverlay { //
if !showScalingOverlay && !showMedia {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
// blindGeneratedescription // blindGeneratedescription
Text(blindGenerate?.videoGenerateTime ?? "hhsdshjsjdhn") Text(blindGenerate?.videoGenerateTime ?? "hhsdshjsjdhn")