133 lines
4.9 KiB
Swift
133 lines
4.9 KiB
Swift
//
|
|
// HomeView.swift
|
|
// FitnessApp
|
|
//
|
|
// Created by Matt Bruce on 12/20/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct HomeView: View {
|
|
@State var viewModel: HomeViewModel = .init()
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
ScrollView(showsIndicators: false) {
|
|
VStack(alignment: .leading) {
|
|
Text("Wecome")
|
|
.font(.largeTitle)
|
|
.padding()
|
|
|
|
HStack {
|
|
Spacer()
|
|
|
|
VStack(alignment: .leading) {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("Calories")
|
|
.font(.callout)
|
|
.bold()
|
|
.foregroundColor(.red)
|
|
|
|
Text("\(viewModel.calories)")
|
|
.bold()
|
|
}.padding(.bottom)
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("Exercise")
|
|
.font(.callout)
|
|
.bold()
|
|
.foregroundColor(.green)
|
|
|
|
Text("\(viewModel.exercise)")
|
|
.bold()
|
|
}.padding(.bottom)
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text("Stand")
|
|
.font(.callout)
|
|
.bold()
|
|
.foregroundColor(.blue)
|
|
|
|
Text("\(viewModel.stand)")
|
|
.bold()
|
|
}
|
|
|
|
}
|
|
|
|
Spacer()
|
|
|
|
ZStack {
|
|
Spacer()
|
|
ProgressCircleView(progress: $viewModel.calories, goal: 600, color: .red)
|
|
ProgressCircleView(progress: $viewModel.exercise, goal: 600, color: .green).padding(.all, 20)
|
|
ProgressCircleView(progress: $viewModel.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)
|
|
if !viewModel.activities.isEmpty {
|
|
LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) {
|
|
ForEach(viewModel.activities , id: \.id) { activity in
|
|
ActivityCard(activity: activity)
|
|
}
|
|
}.padding(.horizontal)
|
|
}
|
|
|
|
//Recent Workouts
|
|
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(viewModel.workouts, id: \.id) { workout in
|
|
WorkoutCard(workout: workout)
|
|
}
|
|
}
|
|
.padding(.bottom)
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
HomeView()
|
|
}
|