From ff99b8581968744129ccb155f60dee50e6b703e8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 20 Dec 2024 13:43:36 -0600 Subject: [PATCH] added Fitnetss Activity Signed-off-by: Matt Bruce --- FitnessApp/ActivityCard.swift | 55 +++++++++++++++++++ FitnessApp/{ => Home}/HomeView.swift | 34 +++++++++++- .../{ => Home}/ProgressCircleView.swift | 0 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 FitnessApp/ActivityCard.swift rename FitnessApp/{ => Home}/HomeView.swift (61%) rename FitnessApp/{ => Home}/ProgressCircleView.swift (100%) diff --git a/FitnessApp/ActivityCard.swift b/FitnessApp/ActivityCard.swift new file mode 100644 index 0000000..65702ea --- /dev/null +++ b/FitnessApp/ActivityCard.swift @@ -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")) +} diff --git a/FitnessApp/HomeView.swift b/FitnessApp/Home/HomeView.swift similarity index 61% rename from FitnessApp/HomeView.swift rename to FitnessApp/Home/HomeView.swift index 17f787e..2667ee3 100644 --- a/FitnessApp/HomeView.swift +++ b/FitnessApp/Home/HomeView.swift @@ -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) + } + } + } } diff --git a/FitnessApp/ProgressCircleView.swift b/FitnessApp/Home/ProgressCircleView.swift similarity index 100% rename from FitnessApp/ProgressCircleView.swift rename to FitnessApp/Home/ProgressCircleView.swift