diff --git a/FitnessApp/ActivityCard.swift b/FitnessApp/Home/ActivityCard.swift similarity index 100% rename from FitnessApp/ActivityCard.swift rename to FitnessApp/Home/ActivityCard.swift diff --git a/FitnessApp/Home/HomeView.swift b/FitnessApp/Home/HomeView.swift index 461dffe..55086e1 100644 --- a/FitnessApp/Home/HomeView.swift +++ b/FitnessApp/Home/HomeView.swift @@ -19,89 +19,124 @@ struct HomeView: View { Activity(id: 3, title: "Today Steps", subtitle: "50,000 steps", image: "figure.run", tintColor: .red, amount: "104,812") ] + var mockWorkouts = [ + Workout(id: 0, title: "Running", image: "figure.run", tintColor: .green, duration: "1 hrs", date: "Aug 3", calories: "100 kcal"), + Workout(id: 1, title: "Strength Training", image: "figure.run", tintColor: .purple, duration: "1.5 hrs", date: "Aug 3", calories: "130 kcal"), + Workout(id: 2, title: "Walking", image: "figure.run", tintColor: .blue, duration: ".5 hrs", date: "Aug 3", calories: "250 kcal"), + Workout(id: 3, title: "Bike", image: "figure.run", tintColor: .red, duration: "2 hrs", date: "Aug 29", calories: "500 kcal") + ] + var body: some View { - ScrollView(showsIndicators: false) { - VStack(alignment: .leading) { - Text("Wecome") - .font(.largeTitle) - .padding() - - HStack { - Spacer() + NavigationStack { + ScrollView(showsIndicators: false) { + VStack(alignment: .leading) { + Text("Wecome") + .font(.largeTitle) + .padding() - VStack { - VStack(alignment: .leading, spacing: 8) { - Text("Calories") - .font(.callout) - .bold() - .foregroundColor(.red) - - Text("123 kcal") - .bold() - }.padding(.bottom) - - VStack { - Text("Active") - .font(.callout) - .bold() - .foregroundColor(.green) - - Text("52 mins") - .bold() - }.padding(.bottom) - - - VStack { - Text("Stand") - .font(.callout) - .bold() - .foregroundColor(.blue) - - Text("8 hrs") - .bold() - } - - } - - Spacer() - - ZStack { + HStack { Spacer() - ProgressCircleView(progress: $calories, goal: 600, color: .red) - ProgressCircleView(progress: $active, goal: 600, color: .green).padding(.all, 20) - ProgressCircleView(progress: $stand, goal: 600, color: .blue).padding(.all, 40) + + VStack { + VStack(alignment: .leading, spacing: 8) { + Text("Calories") + .font(.callout) + .bold() + .foregroundColor(.red) + + Text("123 kcal") + .bold() + }.padding(.bottom) + + VStack { + Text("Active") + .font(.callout) + .bold() + .foregroundColor(.green) + + Text("52 mins") + .bold() + }.padding(.bottom) + + + VStack { + Text("Stand") + .font(.callout) + .bold() + .foregroundColor(.blue) + + Text("8 hrs") + .bold() + } + + } + + Spacer() + + ZStack { + Spacer() + ProgressCircleView(progress: $calories, goal: 600, color: .red) + ProgressCircleView(progress: $active, goal: 600, color: .green).padding(.all, 20) + ProgressCircleView(progress: $stand, goal: 600, color: .blue).padding(.all, 40) + } + .padding(.horizontal) + + Spacer() + } + .padding() + + //Fitness Activity + HStack { + Text("Fitness Activity") + .font(.title2) + + Spacer() + + Button { + print("Show More") + } label: { + Text("Show More") + .padding(.all, 10) + .foregroundColor(.white) + .background(.blue) + .cornerRadius(20) + } } .padding(.horizontal) - Spacer() - } - .padding() - - //Fitness Activity - HStack { - Text("Fitness Activity") - .font(.title2) + LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) { + ForEach(mockActivities, id: \.id) { activity in + ActivityCard(activity: activity) + } + }.padding(.horizontal) - Spacer() - Button { - print("Show More") - } label: { - Text("Show More") - .padding(.all, 10) - .foregroundColor(.white) - .background(.blue) - .cornerRadius(20) + //Fitness Activity + HStack { + Text("Recent Workouts") + .font(.title2) + + Spacer() + + NavigationLink(destination: EmptyView()) { + Text("Show More") + .padding(.all, 10) + .foregroundColor(.white) + .background(.blue) + .cornerRadius(20) + + } } + .padding(.horizontal) + .padding(.top) + LazyVStack{ + ForEach(mockWorkouts, id: \.id) { workout in + WorkoutCard(workout: workout) + } + } + .padding(.bottom) + } - .padding(.horizontal) - - LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) { - ForEach(mockActivities, id: \.id) { activity in - ActivityCard(activity: activity) - } - }.padding(.horizontal) - } } diff --git a/FitnessApp/Home/WorkoutCard.swift b/FitnessApp/Home/WorkoutCard.swift new file mode 100644 index 0000000..5c1722c --- /dev/null +++ b/FitnessApp/Home/WorkoutCard.swift @@ -0,0 +1,54 @@ +// +// WorkoutCard.swift +// FitnessApp +// +// Created by Matt Bruce on 12/20/24. +// + +import SwiftUI + +struct Workout { + let id: Int + let title: String + let image: String + let tintColor: Color + let duration: String + let date: String + let calories: String +} + + +struct WorkoutCard: View { + @State var workout: Workout + + var body: some View { + HStack { + Image(systemName: workout.image) + .resizable() + .scaledToFit() + .frame(width: 48, height: 48) + .foregroundColor(workout.tintColor) + .padding() + .background(.gray.opacity(0.1)) + .cornerRadius(10) + + VStack (spacing: 16) { + HStack { + Text(workout.title).font(.title3).bold() + Spacer() + Text(workout.duration) + } + + HStack { + Text(workout.date) + Spacer() + Text(workout.calories) + } + } + }.padding(.horizontal) + } +} + +#Preview { + WorkoutCard(workout: .init(id: 0, title: "Running", image: "figure.run", tintColor: .green, duration: "1 hour", date: "Aug 3", calories: "100 kcal")) +}