mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
working on onboarding
got animations and stuff on the onboarding
This commit is contained in:
52
ShhShell/Views/Onboarding/WelcomeChunk.swift
Normal file
52
ShhShell/Views/Onboarding/WelcomeChunk.swift
Normal 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."
|
||||
)
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user