WIP
This commit is contained in:
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
struct AccountView: View {
|
||||
@State var completedWorkouts: [CompletedWorkout]?
|
||||
@ObservedObject var userStore = UserStore.shared
|
||||
@State var showCompletedWorkouts: Bool = false
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
@@ -44,8 +45,19 @@ struct AccountView: View {
|
||||
Text("Last workout:")
|
||||
Text(lastWorkout.workoutStartTime)
|
||||
}
|
||||
|
||||
Button("View All Workouts", action: {
|
||||
showCompletedWorkouts = true
|
||||
})
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.frame(height: 44)
|
||||
.foregroundColor(.blue)
|
||||
.background(.yellow)
|
||||
.cornerRadius(8)
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@@ -62,11 +74,17 @@ struct AccountView: View {
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
.padding()
|
||||
.sheet(isPresented: $showCompletedWorkouts) {
|
||||
if let history = completedWorkouts {
|
||||
WorkoutHistoryView(completedWorkouts: history)
|
||||
}
|
||||
}
|
||||
.onAppear{
|
||||
if completedWorkouts == nil {
|
||||
fetchCompletedWorkouts()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func fetchCompletedWorkouts() {
|
||||
@@ -83,7 +101,7 @@ struct AccountView: View {
|
||||
|
||||
struct AccountView_Previews: PreviewProvider {
|
||||
static let userStore = UserStore.shared
|
||||
static let completedWorkouts = PreviewWorkout.parseCompletedWorkouts()
|
||||
static let completedWorkouts = PreviewData.parseCompletedWorkouts()
|
||||
|
||||
static var previews: some View {
|
||||
AccountView(completedWorkouts: completedWorkouts)
|
||||
|
||||
Reference in New Issue
Block a user