Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2024-12-20 14:04:56 -06:00
parent d7181ae13f
commit cb8f3f7204
3 changed files with 162 additions and 73 deletions

View File

@ -19,7 +19,15 @@ 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 {
NavigationStack {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading) {
Text("Wecome")
@ -102,6 +110,33 @@ struct HomeView: View {
}
}.padding(.horizontal)
//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)
}
}
}

View File

@ -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"))
}