This commit is contained in:
Trey t
2023-07-09 09:52:54 -05:00
parent f81153a674
commit a2098943a8
10 changed files with 526 additions and 83 deletions

View File

@@ -43,7 +43,6 @@ struct AddExerciseView: View {
TextField("Filter", text: $searchString)
.padding()
.background(Color(uiColor: .systemBackground))
HStack {
muscleView()
@@ -57,7 +56,6 @@ struct AddExerciseView: View {
.padding(.top)
.frame(height: 44)
}
.background(Color(uiColor: UIColor.secondarySystemBackground))
.onAppear{
if #function.hasPrefix("__preview") {
DataStore.shared.setupFakeData()
@@ -109,7 +107,6 @@ struct AddExerciseView: View {
filterExercises()
})
}
.background(Color(uiColor: .tertiarySystemBackground))
}
func filterExercises() {

View File

@@ -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: {
})
}
}

View File

@@ -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()

View 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])
}
}

View File

@@ -67,14 +67,13 @@ struct CreateWorkoutMainView: View {
}
.listRowSeparator(.hidden)
}
.background(Color(uiColor: .secondarySystemBackground))
.overlay(Group {
if($viewModel.superSets.isEmpty) {
ZStack() {
Color(uiColor: .secondarySystemBackground)
}
}
})
// .overlay(Group {
// if($viewModel.superSets.isEmpty) {
// ZStack() {
// Color(uiColor: .secondarySystemBackground)
// }
// }
// })
Divider()
@@ -106,9 +105,7 @@ struct CreateWorkoutMainView: View {
}
.frame(height: 44)
.padding(.bottom)
.background(Color(uiColor: .systemGroupedBackground))
}
.background(Color(uiColor: .systemGroupedBackground))
.sheet(isPresented: $showAddExercise) {
AddExerciseView(selectedExercise: { exercise in
let workoutExercise = CreateWorkoutExercise(exercise: exercise)

View File

@@ -44,7 +44,6 @@ struct ExternalWorkoutDetailView: View {
ExtCountdownView()
.frame(width: metrics.size.width-50, height: metrics.size.height * 0.2)
.padding([.leading, .trailing], 50)
.background(Color(uiColor: UIColor.secondarySystemBackground))
}
}
} else {

View File

@@ -39,7 +39,6 @@ struct WorkoutDetailView: View {
}
.padding()
.frame(maxWidth: .infinity)
.background(Color(uiColor: .systemBackground))
GeometryReader { metrics in
PlayerView(player: $avPlayer)
@@ -47,13 +46,11 @@ struct WorkoutDetailView: View {
.onAppear{
avPlayer.play()
}
.background(Color(uiColor: .secondarySystemBackground))
}
}
InfoView(workout: workout)
.padding(.bottom)
.background(Color(uiColor: .secondarySystemBackground))
ExerciseListView(workout: workout)
@@ -65,7 +62,6 @@ struct WorkoutDetailView: View {
.frame(height: 44)
}
.background(Color(uiColor: .secondarySystemBackground))
.sheet(item: $presentedSheet) { item in
switch item {
case .completedWorkout(let data):