-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc00773
Showing
21 changed files
with
1,207 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
GrowSteps.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
GrowSteps.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+35.5 KB
...codeproj/project.xcworkspace/xcuserdata/Sydney.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
56 changes: 56 additions & 0 deletions
56
GrowSteps.xcodeproj/xcuserdata/Sydney.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
14 changes: 14 additions & 0 deletions
14
GrowSteps.xcodeproj/xcuserdata/Sydney.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
GrowSteps/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
98
GrowSteps/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
Oops, something went wrong.