WIP
This commit is contained in:
@@ -38,41 +38,20 @@ struct AllWorkoutsListView: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(filteredWorkouts, id:\.name) { workout in
|
||||
Section {
|
||||
VStack {
|
||||
Text(workout.name)
|
||||
.font(.title2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(workout.description ?? "")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
if let muscles = workout.muscles,
|
||||
muscles.joined(separator: ", ").count > 0{
|
||||
Divider()
|
||||
Text(muscles.joined(separator: ", "))
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 20) {
|
||||
ForEach(filteredWorkouts, id:\.id) { workout in
|
||||
WorkoutOverviewView(workout: workout)
|
||||
.padding([.leading, .trailing])
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
selectedWorkout(workout)
|
||||
}
|
||||
|
||||
if let equipment = workout.equipment,
|
||||
equipment.joined(separator: ", ").count > 0 {
|
||||
Divider()
|
||||
Text(equipment.joined(separator: ", "))
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
selectedWorkout(workout)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.refreshable {
|
||||
refresh()
|
||||
refresh()
|
||||
}
|
||||
|
||||
TextField("Filter" ,text: $searchString)
|
||||
@@ -81,3 +60,15 @@ struct AllWorkoutsListView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AllWorkoutsListView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AllWorkoutsListView(workouts: PreviewData.allWorkouts(),
|
||||
selectedWorkout: { workout in
|
||||
|
||||
},
|
||||
refresh: {
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,14 +80,12 @@ struct AllWorkoutsView: View {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
ProgressView("Updating")
|
||||
}
|
||||
}.onAppear{
|
||||
// UserStore.shared.logout()
|
||||
maybeUpdateShit()
|
||||
}
|
||||
.background(Color(uiColor: .systemGroupedBackground))
|
||||
.sheet(item: $selectedWorkout) { item in
|
||||
let viewModel = WorkoutDetailViewModel(workout: item)
|
||||
WorkoutDetailView(viewModel: viewModel)
|
||||
@@ -96,12 +94,12 @@ struct AllWorkoutsView: View {
|
||||
let viewModel = WorkoutDetailViewModel(workout: item)
|
||||
WorkoutDetailView(viewModel: viewModel, showAddToCalendar: false)
|
||||
}
|
||||
.sheet(isPresented: $showLoginView) {
|
||||
LoginView(completion: {
|
||||
self.needsUpdating = true
|
||||
maybeUpdateShit()
|
||||
})
|
||||
}
|
||||
// .sheet(isPresented: $showLoginView) {
|
||||
// LoginView(completion: {
|
||||
// self.needsUpdating = true
|
||||
// maybeUpdateShit()
|
||||
// })
|
||||
// }
|
||||
.onReceive(pub) { (output) in
|
||||
self.needsUpdating = true
|
||||
maybeUpdateShit()
|
||||
|
||||
59
Werkout_ios/Views/AllWorkouts/WorkoutOverviewView.swift
Normal file
59
Werkout_ios/Views/AllWorkouts/WorkoutOverviewView.swift
Normal file
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// WorkoutOverviewView.swift
|
||||
// Werkout_ios
|
||||
//
|
||||
// Created by Trey Tartt on 7/9/23.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct WorkoutOverviewView: View {
|
||||
let workout: Workout
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
VStack {
|
||||
Text(workout.name)
|
||||
.font(.title2)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text(workout.description ?? "")
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
if let exerciseCount = workout.exercise_count {
|
||||
VStack {
|
||||
Text("\(exerciseCount)")
|
||||
.font(.body.bold())
|
||||
Text("exercises")
|
||||
.font(.footnote)
|
||||
.foregroundColor(Color(uiColor: .systemGray2))
|
||||
}
|
||||
}
|
||||
}
|
||||
if let muscles = workout.muscles,
|
||||
muscles.joined(separator: ", ").count > 0{
|
||||
Divider()
|
||||
Text(muscles.joined(separator: ", "))
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
if let equipment = workout.equipment,
|
||||
equipment.joined(separator: ", ").count > 0 {
|
||||
Divider()
|
||||
Text(equipment.joined(separator: ", "))
|
||||
.font(.footnote)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.background(Color(uiColor: .secondarySystemBackground))
|
||||
.cornerRadius(15)
|
||||
}
|
||||
}
|
||||
|
||||
struct WorkoutOverviewView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
WorkoutOverviewView(workout: PreviewData.allWorkouts()[0])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user