import SwiftUI struct RootView: View { @StateObject private var model = WebModel() @State private var showSplash = true var body: some View { ZStack { Ka.bg.ignoresSafeArea() WebView(model: model) .ignoresSafeArea(.container, edges: .bottom) .opacity(model.loaded ? 1 : 0) // barre de progression fine en haut pendant le chargement if !model.loaded && !model.failed { VStack(spacing: 0) { GeometryReader { geo in Rectangle() .fill(Ka.orange) .frame(width: geo.size.width * max(0.04, model.progress), height: 3) .animation(.easeOut(duration: 0.25), value: model.progress) } .frame(height: 3) Spacer() } } if showSplash { splash.transition(.opacity) } if model.failed { offline } } .onChange(of: model.loaded) { loaded in if loaded { DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { withAnimation(.easeInOut(duration: 0.4)) { showSplash = false } } } } } private var splash: some View { ZStack { Ka.bg.ignoresSafeArea() VStack(spacing: 18) { KaMark(size: 92) Text("Admin-Ka") .font(.system(size: 26, weight: .heavy, design: .rounded)) .foregroundColor(Ka.ink) Text("Console Claude Code · Groupe KA") .font(.system(size: 13, weight: .semibold, design: .rounded)) .foregroundColor(Ka.muted) if !model.failed { ProgressView().tint(Ka.orange).padding(.top, 6) } } } } private var offline: some View { ZStack { Ka.bg.ignoresSafeArea() VStack(spacing: 16) { KaMark(size: 72) Text("Hors ligne") .font(.system(size: 22, weight: .heavy, design: .rounded)) .foregroundColor(Ka.ink) Text("Impossible de joindre administration-ka.com") .font(.system(size: 14, weight: .medium, design: .rounded)) .foregroundColor(Ka.muted) .multilineTextAlignment(.center) .padding(.horizontal, 40) Button { showSplash = true model.reload() } label: { Text("Réessayer") .font(.system(size: 16, weight: .heavy, design: .rounded)) .foregroundColor(Ka.ink) .padding(.horizontal, 26).padding(.vertical, 13) .background( Capsule().fill(Ka.orange) .overlay(Capsule().strokeBorder(Ka.ink, lineWidth: 2)) ) .shadow(color: Ka.ink, radius: 0, x: 3, y: 3) } .padding(.top, 6) } } } }