81 lines
3.4 KiB
Swift
81 lines
3.4 KiB
Swift
import SwiftUI
|
|
import SwiftData
|
|
import AVKit
|
|
|
|
extension Notification.Name {
|
|
static let navigateToMediaViewer = Notification.Name("navigateToMediaViewer")
|
|
}
|
|
|
|
// MARK: - 主视图
|
|
struct BlindBoxView: View {
|
|
@State private var showLottieAnimation = true // 控制Lottie动画显示
|
|
|
|
// MARK: - 主体视图
|
|
var body: some View {
|
|
ZStack {
|
|
// 全局背景颜色背景色
|
|
Color.themeTextWhiteSecondary.ignoresSafeArea()
|
|
|
|
// 主内容区域
|
|
VStack {
|
|
VStack(spacing: 20) {
|
|
// 标题
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text("Hi! Click And")
|
|
Text("Open Your First Box~")
|
|
}
|
|
.font(Typography.font(for: .smallLargeTitle))
|
|
.fontWeight(.bold)
|
|
.foregroundColor(Color.themeTextMessageMain)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(.horizontal)
|
|
// 盲盒
|
|
// 添加SVG背景图片
|
|
ZStack {
|
|
// 1. 背景SVG
|
|
SVGImage(svgName: "BlindBg")
|
|
.frame(
|
|
width: UIScreen.main.bounds.width * 1.8,
|
|
height: UIScreen.main.bounds.height * 0.85
|
|
)
|
|
.position(x: UIScreen.main.bounds.width / 2,
|
|
y: UIScreen.main.bounds.height * 0.325)
|
|
|
|
LottieView(name: "loading", loopMode: .loop)
|
|
.frame(width: 200, height: 200)
|
|
.position(x: UIScreen.main.bounds.width / 2,
|
|
y: UIScreen.main.bounds.height * 0.325)
|
|
.onAppear {
|
|
// Load image from URL asynchronously
|
|
if let url = URL(string: "https://cdn.fairclip.cn/files/7348219809961742336/c5ca6151-91d3-483e-b7e7-c37f2cb69dc0.png") {
|
|
URLSession.shared.dataTask(with: url) { data, response, error in
|
|
if let data = data, let image = UIImage(data: data) {
|
|
let media = MediaType.image(image)
|
|
DispatchQueue.main.async {
|
|
// Navigate to the outcome view using router
|
|
Router.shared.navigate(to: .blindOutcome(media: media))
|
|
}
|
|
}
|
|
}.resume()
|
|
}
|
|
}
|
|
}
|
|
.frame(
|
|
maxWidth: .infinity,
|
|
maxHeight: UIScreen.main.bounds.height * 0.65
|
|
)
|
|
.clipped()
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
.background(Color.themeTextWhiteSecondary)
|
|
.edgesIgnoringSafeArea(.all)
|
|
}
|
|
}
|
|
.navigationBarBackButtonHidden(true)
|
|
}
|
|
}
|
|
// MARK: - 预览
|
|
#Preview {
|
|
BlindBoxView()
|
|
}
|