Skip to content

Commit

Permalink
adding to git
Browse files Browse the repository at this point in the history
  • Loading branch information
squid-ney committed Jul 25, 2022
0 parents commit dc00773
Show file tree
Hide file tree
Showing 21 changed files with 1,207 additions and 0 deletions.
617 changes: 617 additions & 0 deletions GrowSteps.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "74914ABE-B105-4A20-A405-959B6A06CF54"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "516D9617-3446-40DB-861E-0EA35D02D359"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "GrowSteps/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "82"
endingLineNumber = "82"
landmarkName = "unknown"
landmarkType = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B46DE0C0-C532-4F24-8818-9702017389F7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "GrowSteps/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8F0BF506-7314-4B81-A438-B302C4910D74"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "GrowSteps/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "71"
endingLineNumber = "71"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>GrowSteps.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
11 changes: 11 additions & 0 deletions GrowSteps/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
98 changes: 98 additions & 0 deletions GrowSteps/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions GrowSteps/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
88 changes: 88 additions & 0 deletions GrowSteps/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//
// ContentView.swift
// GrowSteps
//
// Created by Sydney Achinger on 1/26/22.
//

import SwiftUI
import HealthKit

struct ContentView: View {

@State private var progress = 10.0

@State private var stepCount: Double?

@State private var healthStatus: Color?

private var stepGoal = 5000.00


private var healthStore: HealthStore?

init() {
healthStore = HealthStore()
}

private func getHealthStatus(steps: Double){
let ratio = steps/stepGoal
if(ratio < 0.5){
healthStatus = Color.red
}
if(ratio >= 0.5){
healthStatus = Color.gray
}
if(ratio >= 1.0){
healthStatus = Color.green
}
}

private func updateUIFromStatistics( _ statisticsCollection: HKStatisticsCollection){

statisticsCollection.enumerateStatistics(from: Date(), to: Date()) { statistics, stop in
stepCount = statistics.sumQuantity()?.doubleValue(for: .count()) ?? 0.0
getHealthStatus(steps: stepCount ?? 0.0)

}

}

var body: some View {
VStack{
HStack{
ProgressView(value: stepCount ?? 0.0, total: stepGoal)
.padding(.top, 50)
//.rotationEffect(Angle(degrees: -90.0))

}
Spacer()
HealthAvatar(healthStatus: healthStatus ?? Color.clear)
Text(String(stepCount ?? 0.0)+" steps")
.font(.body)
.padding()
}
.onAppear(perform: {
if let healthStore = healthStore {
healthStore.requestAuthorization { (success) in
if success {
healthStore.calculateSteps { statisticsCollection in
if let statisticsCollection = statisticsCollection {
updateUIFromStatistics(statisticsCollection)
}

}
}
}
}
})

}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.preferredColorScheme(.light)
}
}
10 changes: 10 additions & 0 deletions GrowSteps/GrowSteps.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.healthkit</key>
<true/>
<key>com.apple.developer.healthkit.access</key>
<array/>
</dict>
</plist>
17 changes: 17 additions & 0 deletions GrowSteps/GrowStepsApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// GrowStepsApp.swift
// GrowSteps
//
// Created by Sydney Achinger on 1/26/22.
//

import SwiftUI

@main
struct GrowStepsApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
30 changes: 30 additions & 0 deletions GrowSteps/HealthAvatar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// HealthAvatar.swift
// GrowSteps
//
// Created by Sydney Achinger on 2/22/22.
//

import SwiftUI

struct HealthAvatar: View {
let healthStatus: Color

// let statusColorPairs = [
// "low": Color.red,
// "good": Color.gray,
// "great": Color.green
// ]

var body: some View {
Rectangle()
.fill(healthStatus)
.frame(width: 200, height: 200)
}
}

struct HealthAvatar_Previews: PreviewProvider {
static var previews: some View {
HealthAvatar(healthStatus: Color.clear)
}
}
Loading

0 comments on commit dc00773

Please sign in to comment.