From 982c32cfdb083796263c90d4df8a7ec42c42ecd8 Mon Sep 17 00:00:00 2001 From: jinyaqiu Date: Mon, 1 Sep 2025 16:33:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wake/ContentView.swift | 47 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/wake/ContentView.swift b/wake/ContentView.swift index 77ea40e..ce5afd0 100644 --- a/wake/ContentView.swift +++ b/wake/ContentView.swift @@ -293,6 +293,7 @@ struct BlindBoxView: View { @State private var aspectRatio: CGFloat = 1.0 @State private var isPortrait: Bool = false @State private var displayImage: UIImage? + @State private var showMedia = false // 查询数据 - 简单查询 @Query private var login: [Login] @@ -868,22 +869,39 @@ struct BlindBoxView: View { ZStack { GIFView(name: "BlindOpen") .frame(width: 300, height: 300) + .scaleEffect(scale) + .opacity(showMedia ? 0 : 1) // 当显示媒体时隐藏GIF .onAppear { print("开始播放开启动画") - // 不在这里准备媒体,等待动画完成 + // 初始缩放为1(原始大小) + self.scale = 1.0 - // 2.5秒后开始显示媒体内容 - DispatchQueue.main.asyncAfter(deadline: .now() + 2.5) { - // 准备并显示媒体 - if mediaType == .video { - loadVideo() - } else if mediaType == .image { - loadImage() - } - - // 开始缩放动画 - withAnimation(.easeInOut(duration: 0.5)) { - self.startScalingAnimation() + // 1秒后开始全屏动画 + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + withAnimation(.spring(response: 1.0, dampingFraction: 0.7)) { + // 缩放到全屏 + self.scale = max( + UIScreen.main.bounds.width / 300, + UIScreen.main.bounds.height / 300 + ) * 1.2 + + // 全屏后稍作停留,然后缩小回原始大小 + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + 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() .padding() } - if !showScalingOverlay { + // 只在未显示媒体且未播放动画时显示文字 + if !showScalingOverlay && !showMedia { VStack(alignment: .leading, spacing: 8) { // 从变量blindGenerate中获取description Text(blindGenerate?.videoGenerateTime ?? "hhsdshjsjdhn")