reaaaranged
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
cb8f3f7204
commit
1df20c79cb
16
FitnessApp/Home/Models/Activity.swift
Normal file
16
FitnessApp/Home/Models/Activity.swift
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Activity.swift
|
||||||
|
// FitnessApp
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 12/20/24.
|
||||||
|
//
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct Activity {
|
||||||
|
let id: Int
|
||||||
|
let title: String
|
||||||
|
let subtitle: String
|
||||||
|
let image: String
|
||||||
|
let tintColor: Color
|
||||||
|
let amount: String
|
||||||
|
}
|
||||||
17
FitnessApp/Home/Models/Workout.swift
Normal file
17
FitnessApp/Home/Models/Workout.swift
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Workout.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
|
||||||
|
}
|
||||||
30
FitnessApp/Home/ViewModels/HomeViewModel.swift
Normal file
30
FitnessApp/Home/ViewModels/HomeViewModel.swift
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// HomeViewModel.swift
|
||||||
|
// FitnessApp
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 12/20/24.
|
||||||
|
//
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
@Observable
|
||||||
|
class HomeViewModel {
|
||||||
|
var activities: [Activity] = []
|
||||||
|
var workouts: [Workout] = []
|
||||||
|
var calories: Int = 123
|
||||||
|
var active: Int = 205
|
||||||
|
var stand: Int = 80
|
||||||
|
|
||||||
|
var mockActivities = [
|
||||||
|
Activity(id: 0, title: "Today Steps", subtitle: "10,000 steps", image: "figure.walk", tintColor: .green, amount: "9,812"),
|
||||||
|
Activity(id: 1, title: "Today Steps", subtitle: "1,000 steps", image: "figure.walk", tintColor: .blue, amount: "812"),
|
||||||
|
Activity(id: 2, title: "Today Steps", subtitle: "12,000 steps", image: "figure.walk", tintColor: .purple, amount: "9,0000"),
|
||||||
|
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")
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -7,15 +7,6 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct Activity {
|
|
||||||
let id: Int
|
|
||||||
let title: String
|
|
||||||
let subtitle: String
|
|
||||||
let image: String
|
|
||||||
let tintColor: Color
|
|
||||||
let amount: String
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ActivityCard: View {
|
struct ActivityCard: View {
|
||||||
@State var activity: Activity
|
@State var activity: Activity
|
||||||
|
|
||||||
@ -8,24 +8,8 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HomeView: View {
|
struct HomeView: View {
|
||||||
@State var calories: Int = 123
|
@State var viewModel: HomeViewModel = .init()
|
||||||
@State var active: Int = 205
|
|
||||||
@State var stand: Int = 80
|
|
||||||
|
|
||||||
var mockActivities = [
|
|
||||||
Activity(id: 0, title: "Today Steps", subtitle: "10,000 steps", image: "figure.walk", tintColor: .green, amount: "9,812"),
|
|
||||||
Activity(id: 1, title: "Today Steps", subtitle: "1,000 steps", image: "figure.walk", tintColor: .blue, amount: "812"),
|
|
||||||
Activity(id: 2, title: "Today Steps", subtitle: "12,000 steps", image: "figure.walk", tintColor: .purple, amount: "9,0000"),
|
|
||||||
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 {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
@ -44,7 +28,7 @@ struct HomeView: View {
|
|||||||
.bold()
|
.bold()
|
||||||
.foregroundColor(.red)
|
.foregroundColor(.red)
|
||||||
|
|
||||||
Text("123 kcal")
|
Text("\(viewModel.calories)")
|
||||||
.bold()
|
.bold()
|
||||||
}.padding(.bottom)
|
}.padding(.bottom)
|
||||||
|
|
||||||
@ -54,7 +38,7 @@ struct HomeView: View {
|
|||||||
.bold()
|
.bold()
|
||||||
.foregroundColor(.green)
|
.foregroundColor(.green)
|
||||||
|
|
||||||
Text("52 mins")
|
Text("\(viewModel.active)")
|
||||||
.bold()
|
.bold()
|
||||||
}.padding(.bottom)
|
}.padding(.bottom)
|
||||||
|
|
||||||
@ -65,7 +49,7 @@ struct HomeView: View {
|
|||||||
.bold()
|
.bold()
|
||||||
.foregroundColor(.blue)
|
.foregroundColor(.blue)
|
||||||
|
|
||||||
Text("8 hrs")
|
Text("\(viewModel.stand)")
|
||||||
.bold()
|
.bold()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +59,9 @@ struct HomeView: View {
|
|||||||
|
|
||||||
ZStack {
|
ZStack {
|
||||||
Spacer()
|
Spacer()
|
||||||
ProgressCircleView(progress: $calories, goal: 600, color: .red)
|
ProgressCircleView(progress: $viewModel.calories, goal: 600, color: .red)
|
||||||
ProgressCircleView(progress: $active, goal: 600, color: .green).padding(.all, 20)
|
ProgressCircleView(progress: $viewModel.active, goal: 600, color: .green).padding(.all, 20)
|
||||||
ProgressCircleView(progress: $stand, goal: 600, color: .blue).padding(.all, 40)
|
ProgressCircleView(progress: $viewModel.stand, goal: 600, color: .blue).padding(.all, 40)
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
@ -105,13 +89,13 @@ struct HomeView: View {
|
|||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) {
|
LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) {
|
||||||
ForEach(mockActivities, id: \.id) { activity in
|
ForEach(viewModel.mockActivities , id: \.id) { activity in
|
||||||
ActivityCard(activity: activity)
|
ActivityCard(activity: activity)
|
||||||
}
|
}
|
||||||
}.padding(.horizontal)
|
}.padding(.horizontal)
|
||||||
|
|
||||||
|
|
||||||
//Fitness Activity
|
//Recent Workouts
|
||||||
HStack {
|
HStack {
|
||||||
Text("Recent Workouts")
|
Text("Recent Workouts")
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
@ -130,7 +114,7 @@ struct HomeView: View {
|
|||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.padding(.top)
|
.padding(.top)
|
||||||
LazyVStack{
|
LazyVStack{
|
||||||
ForEach(mockWorkouts, id: \.id) { workout in
|
ForEach(viewModel.mockWorkouts, id: \.id) { workout in
|
||||||
WorkoutCard(workout: workout)
|
WorkoutCard(workout: workout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,17 +7,6 @@
|
|||||||
|
|
||||||
import SwiftUI
|
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 {
|
struct WorkoutCard: View {
|
||||||
@State var workout: Workout
|
@State var workout: Workout
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user