Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rhea's changes to photo upload feature, made sheet for photo upload w… #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GetMoovin/PhotoUpload/PhotoUpload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import ImageSource
import GetMoovinSharedContext
import GetMoovinStepCountModule
import SwiftUI
import GetMoovinStepCountModule

Expand Down
56 changes: 53 additions & 3 deletions GetMoovin/TodaysGoal/StepCountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ struct SheetView: View {
Image(uiImage: $0) // swiftlint:disable:this accessibility_label_for_image
}
}
var stepsLeft: Int {
(userInformation.stepGoal ?? 1000) - (stepCountDataSource.todaysSteps ?? 1000)
}

var stepGoal: Int {
let selectedGoalAnswer = Int(userSelectedGoal) ?? 1000
Expand All @@ -42,7 +45,7 @@ struct SheetView: View {
_ = Int(userSelectedGoal) ?? 1000
return max(0, stepGoal - (stepCountDataSource.todaysSteps ?? 0))
}

var body: some View {
NavigationStack {
ImageSource(image: $image)
Expand Down Expand Up @@ -75,7 +78,54 @@ struct StepCountView: View {

@State var todaysSteps: Int?
@State var showingSheet = false

var stepsLeft: Int {
(userInformation.stepGoal ?? 1000) - (stepCountDataSource.todaysSteps ?? 1000)
}
var stepGoal: Int {
(userInformation.stepGoal ?? 1000)
}

var body: some View {
// this doesnt change anything
VStack {
Text("Your current goal is: \(stepGoal) steps/day")
.padding()
if stepsLeft <= 0 {
Text("Congrats! You've met your daily goal")
if stepsLeft < 0 {
Text("Wow, today you exceeded your goal by \(abs(stepsLeft))")
}
Button("Take your photo") {
showingSheet.toggle()
}
.foregroundColor(.white)
.font(.title)
.padding()
.background(.blue)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.sheet(isPresented: $showingSheet) {
SheetView()
}
} else {
Text("You still need \(stepsLeft) steps to reach your goal!")
}
VStack {
DailyProgressCircle(todaysSteps: $todaysSteps)
.padding()
}

.refreshable {
loadStepCount()
}
.onAppear {
loadStepCount()
}
.onChange(of: scenePhase) { _ in
loadStepCount()
}


var stepGoal: Int {
let selectedGoalAnswer = Int(userSelectedGoal) ?? 1000
return selectedGoalAnswer
Expand Down Expand Up @@ -180,8 +230,7 @@ struct StepCountView: View {
}
}
}



#if DEBUG
struct StepCountView_Previews: PreviewProvider {
static var previews: some View {
Expand All @@ -190,3 +239,4 @@ struct StepCountView: View {
}
}
#endif