added Fitnetss Activity

Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
Matt Bruce 2024-12-20 13:43:36 -06:00
parent 9b0287f038
commit ff99b85819
3 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,55 @@
//
// ActivityCard.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
}
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"))
}

View File

@ -12,9 +12,16 @@ struct HomeView: View {
@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 body: some View {
ScrollView(showsIndicators: false) {
VStack {
VStack(alignment: .leading) {
Text("Wecome")
.font(.largeTitle)
.padding()
@ -71,6 +78,31 @@ struct HomeView: View {
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)
}
}
LazyVGrid(columns: Array(repeating: GridItem(spacing: 20), count: 2)) {
ForEach(mockActivities, id: \.id) { activity in
ActivityCard(activity: activity)
}
}
}
}