// // 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.. 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() }