From 9b0287f038ffe2081ba12d9d0a740143fa084a8d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 20 Dec 2024 13:19:36 -0600 Subject: [PATCH] initial start screen Signed-off-by: Matt Bruce --- FitnessApp/ContentView.swift | 2 +- FitnessApp/FitnessTabView.swift | 42 +++++++++++++++ FitnessApp/HistoricDataView.swift | 18 +++++++ FitnessApp/HomeView.swift | 82 +++++++++++++++++++++++++++++ FitnessApp/ProfileView.swift | 17 ++++++ FitnessApp/ProgressCircleView.swift | 31 +++++++++++ 6 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 FitnessApp/FitnessTabView.swift create mode 100644 FitnessApp/HistoricDataView.swift create mode 100644 FitnessApp/HomeView.swift create mode 100644 FitnessApp/ProfileView.swift create mode 100644 FitnessApp/ProgressCircleView.swift diff --git a/FitnessApp/ContentView.swift b/FitnessApp/ContentView.swift index a24f10f..cbc5a37 100644 --- a/FitnessApp/ContentView.swift +++ b/FitnessApp/ContentView.swift @@ -13,7 +13,7 @@ struct ContentView: View { Image(systemName: "globe") .imageScale(.large) .foregroundStyle(.tint) - Text("Hello, world!") + Text("Fitness App!") } .padding() } diff --git a/FitnessApp/FitnessTabView.swift b/FitnessApp/FitnessTabView.swift new file mode 100644 index 0000000..5cfa5a1 --- /dev/null +++ b/FitnessApp/FitnessTabView.swift @@ -0,0 +1,42 @@ +// +// FitnessTabView.swift +// FitnessApp +// +// Created by Matt Bruce on 12/20/24. +// + +import SwiftUI + +struct FitnessTabView: View { + @State var selectedTab = "Home" + + init() { + let appearace = UITabBarAppearance() + appearace.configureWithOpaqueBackground() + appearace.stackedLayoutAppearance.selected.iconColor = .green + appearace.stackedLayoutAppearance.selected.titleTextAttributes = + [.foregroundColor: UIColor.label] + UITabBar.appearance().scrollEdgeAppearance = appearace + } + + var body: some View { + TabView(selection: $selectedTab) { + HomeView() + .tag("Home") + .tabItem { + Image(systemName: "house") + Text("Home") + } + HistoricDataView() + .tag("Historic") + .tabItem { + Image(systemName: "chart.line.uptrend.xyaxis") + Text("Historic") + } + } + } +} + +#Preview { + FitnessTabView() +} diff --git a/FitnessApp/HistoricDataView.swift b/FitnessApp/HistoricDataView.swift new file mode 100644 index 0000000..195e551 --- /dev/null +++ b/FitnessApp/HistoricDataView.swift @@ -0,0 +1,18 @@ +// +// HistoricDataView.swift +// FitnessApp +// +// Created by Matt Bruce on 12/20/24. +// + +import SwiftUI + +struct HistoricDataView: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +#Preview { + HistoricDataView() +} diff --git a/FitnessApp/HomeView.swift b/FitnessApp/HomeView.swift new file mode 100644 index 0000000..17f787e --- /dev/null +++ b/FitnessApp/HomeView.swift @@ -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() +} diff --git a/FitnessApp/ProfileView.swift b/FitnessApp/ProfileView.swift new file mode 100644 index 0000000..3ade684 --- /dev/null +++ b/FitnessApp/ProfileView.swift @@ -0,0 +1,17 @@ +// +// ProfileView.swift +// FitnessApp +// +// Created by Matt Bruce on 12/20/24. +// +import SwiftUI + +struct ProfileView: View { + var body: some View { + Text("Profile") + } +} + +#Preview { + HomeView() +} diff --git a/FitnessApp/ProgressCircleView.swift b/FitnessApp/ProgressCircleView.swift new file mode 100644 index 0000000..f171812 --- /dev/null +++ b/FitnessApp/ProgressCircleView.swift @@ -0,0 +1,31 @@ +// +// ProgressCircle.swift +// FitnessApp +// +// Created by Matt Bruce on 12/20/24. +// +import SwiftUI + +struct ProgressCircleView: View { + @Binding var progress: Int + var goal: Int + var color: Color + private let width: CGFloat = 20 + + var body: some View { + ZStack { + Circle() + .stroke(color.opacity(0.3), lineWidth: width) + + Circle() + .trim(from: 0, to: CGFloat(progress) / CGFloat(goal)) + .stroke(color, style: StrokeStyle(lineWidth: 20, lineCap: .round)) + .rotationEffect(Angle(degrees: -90)) + .shadow(radius: 5) + } + } +} + +#Preview { + ProgressCircleView(progress: .constant(100), goal: 200, color: .gray) +}