Advertisement

← poker-tutor

App/PokerTutorPhone/AdLabSplash.swift

2.0 KB Download file
import SwiftUI

/// The (Digital) Ad Lab startup screen, shared verbatim by Poker Tutor,
/// PolyTerm, and KalTerm: drop this file in, overlay `AdLabSplash(done:)`
/// at the app root, and it fades itself out. Self-contained — system serif
/// only, so it needs no bundled fonts and no other files.
struct AdLabSplash: View {
    /// Flipped when the splash has finished fading out.
    @Binding var done: Bool
    @State private var showMark = false
    @State private var fadeOut = false

    private let background = Color(red: 0.07, green: 0.07, blue: 0.08)
    private let olive = Color(red: 0.55, green: 0.58, blue: 0.35)

    var body: some View {
        ZStack {
            background.ignoresSafeArea()
            VStack(spacing: 14) {
                Text("From")
                    .font(.system(size: 12, design: .monospaced))
                    .kerning(3)
                    .textCase(.uppercase)
                    .foregroundStyle(.secondary)
                HStack(spacing: 0) {
                    Text("The ").font(.system(size: 30, weight: .bold, design: .serif))
                    Text("(Digital)")
                        .font(.system(size: 30, weight: .bold, design: .serif))
                        .italic()
                        .foregroundStyle(olive)
                    Text(" Ad Lab").font(.system(size: 30, weight: .bold, design: .serif))
                }
                .foregroundStyle(Color(red: 0.95, green: 0.94, blue: 0.90))
            }
            .opacity(showMark ? 1 : 0)
            .scaleEffect(showMark ? 1 : 0.97)
        }
        .opacity(fadeOut ? 0 : 1)
        .onAppear {
            withAnimation(.easeOut(duration: 0.5)) { showMark = true }
            DispatchQueue.main.asyncAfter(deadline: .now() + 1.4) {
                withAnimation(.easeIn(duration: 0.4)) { fadeOut = true }
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.45) { done = true }
            }
        }
        .accessibilityLabel("The Digital Ad Lab")
    }
}