Compare commits
No commits in common. "1df20c79cbb8d845a6788fa915b8e5bdc7ec1af7" and "9b0287f038ffe2081ba12d9d0a740143fa084a8d" have entirely different histories.
1df20c79cb
...
9b0287f038
@ -1,16 +0,0 @@
|
|||||||
//
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
//
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
//
|
|
||||||
// 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")
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
//
|
|
||||||
// ActivityCard.swift
|
|
||||||
// FitnessApp
|
|
||||||
//
|
|
||||||
// Created by Matt Bruce on 12/20/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ActivityCard: View {
|
|
||||||
@State var activity: Activity
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ZStack {
|
|
||||||
Color(uiColor: .systemGray6).cornerRadius(15)
|
|
||||||
|
|
||||||
VStack {
|
|
||||||
HStack(alignment: .top) {
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
Text(activity.title)
|
|
||||||
Text(activity.subtitle).font(.caption)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
Image(systemName: activity.image)
|
|
||||||
.foregroundColor(activity.tintColor)
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(activity.amount)
|
|
||||||
.font(.title)
|
|
||||||
.bold()
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview {
|
|
||||||
ActivityCard(activity: .init(id: 1,
|
|
||||||
title: "Test",
|
|
||||||
subtitle: "Goal 10,000",
|
|
||||||
image: "walk",
|
|
||||||
tintColor: .green,
|
|
||||||
amount: "9,000"))
|
|
||||||
}
|
|
||||||
@ -1,132 +0,0 @@
|
|||||||
//
|
|
||||||
// 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 {
|
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
|
||||||
Text("Calories")
|
|
||||||
.font(.callout)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(.red)
|
|
||||||
|
|
||||||
Text("\(viewModel.calories)")
|
|
||||||
.bold()
|
|
||||||
}.padding(.bottom)
|
|
||||||
|
|
||||||
VStack {
|
|
||||||
Text("Active")
|
|
||||||
.font(.callout)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(.green)
|
|
||||||
|
|
||||||
Text("\(viewModel.active)")
|
|
||||||
.bold()
|
|
||||||
}.padding(.bottom)
|
|
||||||
|
|
||||||
|
|
||||||
VStack {
|
|
||||||
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.active, 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)
|
|
||||||
|
|
||||||
LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) {
|
|
||||||
ForEach(viewModel.mockActivities , 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.mockWorkouts, id: \.id) { workout in
|
|
||||||
WorkoutCard(workout: workout)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.padding(.bottom)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Preview {
|
|
||||||
HomeView()
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
//
|
|
||||||
// WorkoutCard.swift
|
|
||||||
// FitnessApp
|
|
||||||
//
|
|
||||||
// Created by Matt Bruce on 12/20/24.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
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"))
|
|
||||||
}
|
|
||||||
82
FitnessApp/HomeView.swift
Normal file
82
FitnessApp/HomeView.swift
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
//
|
||||||
|
// HomeView.swift
|
||||||
|
// FitnessApp
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 12/20/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct HomeView: View {
|
||||||
|
@State var calories: Int = 123
|
||||||
|
@State var active: Int = 205
|
||||||
|
@State var stand: Int = 80
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ScrollView(showsIndicators: false) {
|
||||||
|
VStack {
|
||||||
|
Text("Wecome")
|
||||||
|
.font(.largeTitle)
|
||||||
|
.padding()
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
HomeView()
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user