84 lines
2.2 KiB
Swift
84 lines
2.2 KiB
Swift
//
|
|
// Onboarding.swift
|
|
// WorkoutsPlus
|
|
//
|
|
// Created by Felix Förtsch on 04.09.24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
|
|
// TODO: Inspiration holen von https://github.com/SvenTiigi/WhatsNewKit
|
|
struct Onboarding: View {
|
|
@Default(\.isFirstAppStart) var isFirstAppStart
|
|
@Default(\.isOnboarding) var isOnboarding
|
|
@Default(\.userId) var userId
|
|
|
|
@State private var currentPage = 0
|
|
let totalPages = 3
|
|
|
|
var body: some View {
|
|
VStack {
|
|
TabView(selection: $currentPage) {
|
|
ForEach(0..<totalPages, id: \.self) { index in
|
|
VStack {
|
|
Spacer()
|
|
|
|
Image(systemName: "scribble.variable")
|
|
.resizable()
|
|
.scaledToFit()
|
|
.frame(width: 150, height: 150)
|
|
.foregroundColor(.blue)
|
|
|
|
Text("userID: \(userId)")
|
|
.font(.largeTitle)
|
|
.fontWeight(.bold)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.top, 40)
|
|
|
|
Text("Erfahren Sie, wie MyApp Ihnen helfen kann, produktiver zu sein.")
|
|
.font(.title3)
|
|
.foregroundColor(.gray)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.horizontal, 40)
|
|
.padding(.top, 20)
|
|
|
|
Spacer()
|
|
|
|
HStack {
|
|
if currentPage > 0 {
|
|
Button("Zurück") {
|
|
currentPage -= 1
|
|
}
|
|
.padding(.horizontal, 40)
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Button(currentPage == totalPages - 1 ? "Los geht's!" : "Weiter") {
|
|
if currentPage < totalPages - 1 {
|
|
currentPage += 1
|
|
} else {
|
|
if (isFirstAppStart) {
|
|
userId = UUID().uuidString
|
|
}
|
|
isFirstAppStart = false
|
|
isOnboarding = false
|
|
}
|
|
}
|
|
.padding(.horizontal, 40)
|
|
}
|
|
.padding(.bottom, 40)
|
|
}
|
|
.tag(index)
|
|
}
|
|
}
|
|
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
Onboarding()
|
|
}
|