From 6ec98d8bcde0c98712f4c467cab549f679643d1b Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 31 Dec 2025 14:50:52 -0600 Subject: [PATCH] updated launch screen, remove this if apple doesn't like it. Signed-off-by: Matt Bruce --- Baccarat/Baccarat/BaccaratApp.swift | 9 ++- Baccarat/Baccarat/LaunchScreen.storyboard | 28 +------- Blackjack/Blackjack/BlackjackApp.swift | 9 +-- Blackjack/Blackjack/LaunchScreen.storyboard | 34 ++-------- .../Views/Branding/AppLaunchView.swift | 64 +++++++++++++++++++ 5 files changed, 78 insertions(+), 66 deletions(-) create mode 100644 CasinoKit/Sources/CasinoKit/Views/Branding/AppLaunchView.swift diff --git a/Baccarat/Baccarat/BaccaratApp.swift b/Baccarat/Baccarat/BaccaratApp.swift index 882c35a..4850f15 100644 --- a/Baccarat/Baccarat/BaccaratApp.swift +++ b/Baccarat/Baccarat/BaccaratApp.swift @@ -5,16 +5,15 @@ // Created by Matt Bruce on 12/16/25. // import SwiftUI +import CasinoKit @main struct BaccaratApp: App { var body: some Scene { WindowGroup { -// #if DEBUG -// IconGeneratorView() -// #else - ContentView() // your real app root -// #endif + AppLaunchView(config: .baccarat) { + ContentView() + } } } } diff --git a/Baccarat/Baccarat/LaunchScreen.storyboard b/Baccarat/Baccarat/LaunchScreen.storyboard index 05f7d66..1edb369 100644 --- a/Baccarat/Baccarat/LaunchScreen.storyboard +++ b/Baccarat/Baccarat/LaunchScreen.storyboard @@ -1,10 +1,9 @@ - + - @@ -14,31 +13,8 @@ - - - - - - - - - - - + diff --git a/Blackjack/Blackjack/BlackjackApp.swift b/Blackjack/Blackjack/BlackjackApp.swift index 72d00d3..13ab216 100644 --- a/Blackjack/Blackjack/BlackjackApp.swift +++ b/Blackjack/Blackjack/BlackjackApp.swift @@ -18,12 +18,9 @@ struct BlackjackApp: App { var body: some Scene { WindowGroup { - // #if DEBUG - // IconGeneratorView() - // #else - ContentView() // your real app root - // #endif + AppLaunchView(config: .blackjack) { + ContentView() + } } } } - diff --git a/Blackjack/Blackjack/LaunchScreen.storyboard b/Blackjack/Blackjack/LaunchScreen.storyboard index e4e6d48..aa40a5e 100644 --- a/Blackjack/Blackjack/LaunchScreen.storyboard +++ b/Blackjack/Blackjack/LaunchScreen.storyboard @@ -1,49 +1,25 @@ - - + + - + - - - - - - - - - - - - + - + diff --git a/CasinoKit/Sources/CasinoKit/Views/Branding/AppLaunchView.swift b/CasinoKit/Sources/CasinoKit/Views/Branding/AppLaunchView.swift new file mode 100644 index 0000000..2eb2395 --- /dev/null +++ b/CasinoKit/Sources/CasinoKit/Views/Branding/AppLaunchView.swift @@ -0,0 +1,64 @@ +// +// AppLaunchView.swift +// CasinoKit +// +// A wrapper view that shows an animated launch screen before transitioning +// to the main app content. Use this to create seamless animated launches. +// + +import SwiftUI + +/// A wrapper that shows an animated launch screen before the main content. +/// +/// Usage: +/// ```swift +/// AppLaunchView(config: .baccarat) { +/// ContentView() +/// } +/// ``` +public struct AppLaunchView: View { + let config: LaunchScreenConfig + let content: () -> Content + + @State private var showLaunchScreen = true + + /// Creates a launch wrapper. + /// - Parameters: + /// - config: The launch screen configuration. + /// - content: The main app content to show after the launch animation. + public init( + config: LaunchScreenConfig, + @ViewBuilder content: @escaping () -> Content + ) { + self.config = config + self.content = content + } + + public var body: some View { + ZStack { + // Main content (always rendered underneath) + content() + + // Launch screen overlay + if showLaunchScreen { + LaunchScreenView(config: config) + .transition(.opacity) + .zIndex(1) + } + } + .task { + // Wait for launch animation to complete, then fade out + try? await Task.sleep(for: .seconds(2.0)) + withAnimation(.easeOut(duration: 0.5)) { + showLaunchScreen = false + } + } + } +} + +#Preview { + AppLaunchView(config: .example) { + Text("Main App Content") + .font(.largeTitle) + } +}