working on onboarding

got animations and stuff on the onboarding
This commit is contained in:
neon443
2025-08-27 20:32:52 +01:00
parent 9cab6baea4
commit cf96b0e505
3 changed files with 91 additions and 4 deletions

View File

@@ -0,0 +1,52 @@
//
// WelcomeChunk.swift
// ShhShell
//
// Created by neon443 on 27/08/2025.
//
import SwiftUI
struct WelcomeChunk: View {
@State var symbol: String
@State var title: String
@State var para: String
@State var timeTarget: TimeInterval = 0
@State private var spawnDate: Date = .now
var body: some View {
TimelineView(.animation) { tl in
let time = tl.date.timeIntervalSince(spawnDate)
HStack {
if time > timeTarget {
Image(systemName: symbol)
.resizable().scaledToFit()
.frame(width: 50)
}
VStack(alignment: .leading) {
if time > timeTarget+1 {
Text(title)
.bold()
.font(.headline)
Text(para)
.foregroundStyle(.gray)
.multilineTextAlignment(.leading)
}
}
Spacer()
}
.animation(.spring, value: time)
.frame(maxWidth: .infinity)
.padding(.horizontal, 50)
}
}
}
#Preview {
WelcomeChunk(
symbol: "trash",
title: "The Trash",
para: "Here's to the crazy ones."
)
}

View File

@@ -8,11 +8,42 @@
import SwiftUI
struct WelcomeView: View {
var body: some View {
Text("Welcome")
}
@State private var spawnDate: Date = .now
var body: some View {
TimelineView(.animation) { tl in
let time = tl.date.timeIntervalSince(spawnDate)
#if DEBUG
Button("reset") { spawnDate = .now }
Text("\(time)")
.frame(width: 150, alignment: .leading)
#endif
VStack {
Text("Welcome")
.monospaced()
.font(.largeTitle)
.bold()
if time > 1 {
Image("regular")
.resizable().scaledToFit()
.frame(width: 100)
.clipShape(RoundedRectangle(cornerRadius: 22))
.shadow(color: .white, radius: 6)
.transition(.scale)
.padding(.bottom)
}
if time > 1 {
WelcomeChunk(symbol: "hare.fill", title: "Blazing fast", para: "hi", timeTarget: 1)
}
}
.animation(.spring, value: time)
.preferredColorScheme(.dark)
}
}
}
#Preview {
WelcomeView()
WelcomeView()
}