From 1e3dcb4e1624470203eba1b51bc66fa0077d46c5 Mon Sep 17 00:00:00 2001 From: Stephen <158498287+0-Blu@users.noreply.github.com> Date: Thu, 27 Mar 2025 14:39:49 -0400 Subject: [PATCH] 5 Second Loading --- StikJIT/StikJITApp.swift | 69 +++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 0891180..af38f76 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -10,21 +10,33 @@ import em_proxy @main struct HeartbeatApp: App { + @State private var isLoading = true + var body: some Scene { WindowGroup { - MainTabView() - .onAppear { - startProxy() - startHeartbeatInBackground() - } + if isLoading { + LoadingView() + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 5) { + withAnimation(.easeInOut(duration: 1.0)) { + isLoading = false + } + } + startProxy() + startHeartbeatInBackground() + } + } else { + MainTabView() + } } } - + func startHeartbeatInBackground() { DispatchQueue.global(qos: .background).async { startHeartbeat() } } + func startProxy() { let port = 51820 let bindAddr = "127.0.0.1:\(port)" @@ -35,12 +47,53 @@ struct HeartbeatApp: App { DispatchQueue.main.async { if result == 0 { print("DEBUG: em_proxy started successfully on port \(port)") - print("DEBUG: em_proxy started successfully on port \(port).") } else { print("DEBUG: Failed to start em_proxy") - print("DEBUG: Failed to start em_proxy.") } } } } } + +struct LoadingView: View { + @State private var animate = false + + var body: some View { + ZStack { + LinearGradient(gradient: Gradient(colors: [Color.black, Color.black]), + startPoint: .topLeading, + endPoint: .bottomTrailing) + .ignoresSafeArea() + + VStack { + ZStack { + Circle() + .stroke(lineWidth: 8) + .foregroundColor(Color.white.opacity(0.3)) + .frame(width: 80, height: 80) + + Circle() + .trim(from: 0, to: 0.7) + .stroke(AngularGradient( + gradient: Gradient(colors: [Color.white.opacity(0.8), Color.white.opacity(0.3)]), + center: .center + ), style: StrokeStyle(lineWidth: 6, lineCap: .round)) + .rotationEffect(.degrees(animate ? 360 : 0)) + .frame(width: 80, height: 80) + .animation(Animation.linear(duration: 1.2).repeatForever(autoreverses: false), value: animate) + } + .shadow(color: .white.opacity(0.5), radius: 10, x: 0, y: 0) + .onAppear { + animate = true + } + + Text("Loading...") + .font(.system(size: 20, weight: .medium, design: .rounded)) + .foregroundColor(.white.opacity(0.8)) + .padding(.top, 20) + .opacity(animate ? 1.0 : 0.5) + .animation(Animation.easeInOut(duration: 1.5).repeatForever(autoreverses: true), value: animate) + } + } + } +}