Files
workoutsplus/WorkoutsPlus/ContentView.swift

123 lines
3.4 KiB
Swift

//
// ContentView.swift
// WorkoutsPlus
//
// Created by Felix Förtsch on 13.08.24.
//
import SwiftUI
import SwiftData
struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@Default(\.isOnboarding) var isOnboarding
@Default(\.isWorkingOut) var isWorkingOut
var body: some View {
NavigationStack {
List {
Section {
VStack {
HStack {
Image(systemName: "person.crop.circle.badge.plus")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 50, height: 50)
.padding(.horizontal)
.foregroundStyle(.blue)
VStack(alignment: .leading) {
Text("Felix Förtsch")
.font(.title)
.fontWeight(.bold)
Text("You got this!")
.font(.headline)
.foregroundStyle(.secondary)
}
}
.padding(.vertical, 5)
// TODO: Food Log (Foto + Kalender + Macros
// TODO: Goal page
// ActivityLog()
// .frame(height: 200)
}
}
Section {
NavigationLink(destination: ActiveWorkoutSession()) {
if (isWorkingOut) {
HStack {
Label("Back to Session", systemImage: "memories")
.symbolEffect(.rotate)
Text("35 min")
.font(.subheadline)
.foregroundStyle(.secondary)
}
} else {
Label("Start Workout Session", systemImage: "play")
}
}
NavigationLink(destination: WorkoutLog()) {
Label("Workout Log", systemImage: "calendar.badge.clock")
}
}
Section {
NavigationLink(destination: WorkoutLibrary()) {
Label("Workouts", systemImage: "figure.run.square.stack")
}
NavigationLink(destination: ExerciseLibrary()) {
Label("Exercises", systemImage: "figure.run")
}
}
Section {
NavigationLink(destination: Settings()) {
Label("Settings", systemImage: "gear")
}
}
Section(header: Text("Debug")) {
NavigationLink(destination: DebugList()) {
Label("Debug", systemImage: "hammer")
}
}
}
.navigationBarTitleDisplayMode(.large)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
HStack {
ZStack {
Image(systemName: "hexagon.fill")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 35, height: 35)
.foregroundStyle(systemColors.randomElement()!)
Image(systemName: fitnessIcons.randomElement()!)
.foregroundStyle(.white)
}
Text("Workout+")
.font(.title)
.fontWeight(.bold)
}
}
}
}
.sheet(isPresented: $isOnboarding) { Onboarding() }
}
}
#Preview("No Workout Session") {
ContentView()
.onAppear {
Defaults.shared.isWorkingOut = false
}
.modelContainer(SampleData.shared.modelContainer)
}
#Preview("With Active Workout Session") {
ContentView()
.onAppear {
Defaults.shared.isWorkingOut = true
}
.modelContainer(SampleData.shared.modelContainer)
}