wake-ios/wake/View/Welcome/SplashView.swift
2025-08-21 19:39:05 +08:00

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