92 lines
3.4 KiB
Swift
92 lines
3.4 KiB
Swift
import SwiftUI
|
|
|
|
struct SplashView: View {
|
|
@State private var isAnimating = false
|
|
@State private var showLogin = false
|
|
@EnvironmentObject private var authState: AuthState
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
ZStack {
|
|
// 背景渐变
|
|
LinearGradient(
|
|
gradient: Gradient(colors: [
|
|
Theme.Colors.primary, // Primary color with some transparency
|
|
Theme.Colors.primaryDark, // Darker shade of the primary color
|
|
]),
|
|
startPoint: .topLeading,
|
|
endPoint: .bottomTrailing
|
|
)
|
|
.edgesIgnoringSafeArea(.all)
|
|
VStack(spacing: 50) {
|
|
Spacer()
|
|
// 欢迎文字动画
|
|
Text("Welcome")
|
|
.font(.system(size: 40, weight: .bold, design: .rounded))
|
|
.foregroundColor(.primary)
|
|
.scaleEffect(isAnimating ? 1.1 : 0.9)
|
|
.opacity(isAnimating ? 1 : 0.3)
|
|
.animation(
|
|
.easeInOut(duration: 1.5)
|
|
.repeatForever(autoreverses: true),
|
|
value: isAnimating
|
|
)
|
|
|
|
// 动画图标
|
|
Image(systemName: "moon.stars.fill")
|
|
.font(.system(size: 120))
|
|
.foregroundColor(.accentColor)
|
|
.rotationEffect(.degrees(isAnimating ? 360 : 0))
|
|
.scaleEffect(isAnimating ? 1.2 : 0.8)
|
|
.animation(
|
|
.easeInOut(duration: 2)
|
|
.repeatForever(autoreverses: true),
|
|
value: isAnimating
|
|
)
|
|
|
|
Spacer()
|
|
|
|
// 圆形按钮
|
|
Button(action: {
|
|
withAnimation {
|
|
showLogin = true
|
|
}
|
|
}) {
|
|
Image(systemName: "arrow.right")
|
|
.font(.title)
|
|
.foregroundColor(.white)
|
|
.frame(width: 140, height: 140)
|
|
.background(
|
|
Circle()
|
|
.fill(Color.accentColor.opacity(0.7)) // 80% opacity
|
|
.shadow(radius: 10)
|
|
)
|
|
}
|
|
.padding(.bottom, 40)
|
|
.background(
|
|
NavigationLink(destination: LoginView().environmentObject(authState), isActive: $showLogin) {
|
|
EmptyView()
|
|
}
|
|
.hidden()
|
|
)
|
|
Spacer()
|
|
}
|
|
.padding()
|
|
}
|
|
.onAppear {
|
|
isAnimating = true
|
|
}
|
|
}
|
|
.navigationViewStyle(StackNavigationViewStyle())
|
|
}
|
|
}
|
|
|
|
// 预览
|
|
#if DEBUG
|
|
struct SplashView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SplashView()
|
|
.environmentObject(AuthState.shared)
|
|
}
|
|
}
|
|
#endif |