UI changes

This commit is contained in:
Trey t
2024-12-19 21:57:59 -06:00
parent b268a271fd
commit 85ef3d58c6
19 changed files with 268 additions and 184 deletions

View File

@@ -12,6 +12,6 @@ enum BaseURLs: String {
case dev = "https://dev.werkout.fitness"
static var currentBaseURL: String {
return BaseURLs.dev.rawValue
return BaseURLs.local.rawValue
}
}

View File

@@ -25,17 +25,19 @@ struct AllWorkoutsListView: View {
var body: some View {
VStack {
if let filteredRegisterdUser = filteredRegisterdUser {
Text((filteredRegisterdUser.firstName ?? "NA") + "'s Workouts")
VStack {
if let filteredRegisterdUser = filteredRegisterdUser {
Text((filteredRegisterdUser.firstName ?? "NA") + "'s Workouts")
}
FilterAllView(searchString: $searchString,
uniqueWorkoutUsers: $uniqueWorkoutUsers,
filteredRegisterdUser: $filteredRegisterdUser,
filteredWorkouts: $filteredWorkouts,
workouts: $workouts,
currentSort: $currentSort)
}
FilterAllView(searchString: $searchString,
uniqueWorkoutUsers: $uniqueWorkoutUsers,
filteredRegisterdUser: $filteredRegisterdUser,
filteredWorkouts: $filteredWorkouts,
workouts: $workouts,
currentSort: $currentSort)
ScrollView {
LazyVStack(spacing: 10) {
ForEach(filteredWorkouts, id:\.id) { workout in
@@ -48,6 +50,7 @@ struct AllWorkoutsListView: View {
}
}
}
.background(Color(uiColor: .systemBackground))
.refreshable {
refresh()
}

View File

@@ -63,7 +63,6 @@ struct AllWorkoutsView: View {
selectedWorkout = bridgeModule.currentWorkoutInfo.workout
})
switch selectedSegment {
case .AllWorkout:
if isUpdating {
@@ -79,6 +78,7 @@ struct AllWorkoutsView: View {
self.needsUpdating = true
maybeUpdateShit()
})
Divider()
case .MyWorkouts:
PlannedWorkoutView(workouts: UserStore.shared.plannedWorkouts,
@@ -88,7 +88,9 @@ struct AllWorkoutsView: View {
} else {
ProgressView("Updating")
}
}.onAppear{
}
.background(Color(uiColor: .systemGray5))
.onAppear{
// UserStore.shared.logout()
authorizeHealthKit()
maybeUpdateShit()

View File

@@ -67,7 +67,7 @@ struct CompletedWorkoutView: View {
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
}

View File

@@ -14,54 +14,47 @@ struct CreateExerciseActionsView: View {
var body: some View {
VStack {
HStack {
VStack {
VStack {
Text("Reps: ")
Text("\(workoutExercise.reps)")
.foregroundColor(workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(uiColor: .label))
.bold()
}
VStack {
HStack {
Text("Reps: ")
Text("\(workoutExercise.reps)")
.foregroundColor(workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(uiColor: .label))
.bold()
Stepper("", onIncrement: {
workoutExercise.increaseReps()
}, onDecrement: {
workoutExercise.decreaseReps()
})
.labelsHidden()
}
.frame(maxWidth: .infinity)
}
HStack {
Text("Weight: ")
Text("\(workoutExercise.weight)")
Divider()
Stepper("", onIncrement: {
workoutExercise.increaseWeight()
}, onDecrement: {
workoutExercise.decreaseWeight()
})
}
HStack {
Text("Duration: ")
Text("\(workoutExercise.duration)")
.foregroundColor(
workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(
uiColor: .label
)
)
.bold()
VStack{
VStack {
Text("Weight: ")
Text("\(workoutExercise.weight)")
}
Stepper("", onIncrement: {
workoutExercise.increaseWeight()
}, onDecrement: {
workoutExercise.decreaseWeight()
})
.labelsHidden()
}
.frame(maxWidth: .infinity)
Divider()
VStack{
VStack {
Text("Duration: ")
Text("\(workoutExercise.duration)")
.foregroundColor(workoutExercise.reps == 0 && workoutExercise.duration == 0 ? .red : Color(uiColor: .label))
.bold()
}
Stepper("", onIncrement: {
workoutExercise.increaseDuration()
}, onDecrement: {
workoutExercise.decreaseDuration()
})
}
Stepper("", onIncrement: {
workoutExercise.increaseDuration()
}, onDecrement: {
workoutExercise.decreaseDuration()
})
}
HStack {
@@ -73,17 +66,16 @@ struct CreateExerciseActionsView: View {
.frame(width: 88, height: 44)
.foregroundColor(.white)
.background(.blue)
.cornerRadius(10)
.cornerRadius(Constants.buttonRadius)
.buttonStyle(BorderlessButtonStyle())
Spacer()
Divider()
Spacer()
Button(action: {
superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
superset
.deleteExerciseForChosenSuperset(exercise: workoutExercise)
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
}) {
@@ -92,14 +84,13 @@ struct CreateExerciseActionsView: View {
.frame(width: 88, height: 44)
.foregroundColor(.white)
.background(.red)
.cornerRadius(10)
.cornerRadius(Constants.buttonRadius)
.buttonStyle(BorderlessButtonStyle())
Spacer()
}
Divider()
.background(.blue)
}
}
}

View File

@@ -62,6 +62,7 @@ class CreateWorkoutSuperSet: ObservableObject, Identifiable, Equatable {
}
let id = UUID()
@Published var title: String = ""
@Published var exercises = [CreateWorkoutExercise]()
@Published var numberOfRounds = 0

View File

@@ -79,7 +79,7 @@ struct CreateWorkoutItemPickerView: View {
.frame(height: 44)
.foregroundColor(.green)
.background(.white)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
Button(action: {
@@ -92,7 +92,7 @@ struct CreateWorkoutItemPickerView: View {
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
}

View File

@@ -8,71 +8,39 @@
import SwiftUI
struct CreateWorkoutMainView: View {
@ObservedObject var viewModel = WorkoutViewModel()
@State private var showAddExercise = false
@StateObject var viewModel = WorkoutViewModel()
@State var selectedCreateWorkoutSuperSet: CreateWorkoutSuperSet?
@State private var showAddExercise = false
var body: some View {
VStack {
VStack {
TextField("Title", text: $viewModel.title)
.padding(.horizontal)
.textFieldStyle(.roundedBorder)
TextField("Description", text: $viewModel.description)
.padding(.horizontal)
.textFieldStyle(.roundedBorder)
}
.padding(.bottom)
.background(Color(uiColor: .systemGray5))
TextField("Title", text: $viewModel.title)
.padding()
.frame(height: 55)
.textFieldStyle(OvalTextFieldStyle())
TextField("Description", text: $viewModel.description)
.padding()
.frame(height: 55)
.textFieldStyle(OvalTextFieldStyle())
ScrollViewReader { proxy in
List() {
ForEach($viewModel.superSets, id: \.id) { superset in
Section {
ForEach(superset.exercises, id: \.id) { exercise in
HStack {
VStack {
Text(exercise.wrappedValue.exercise.name)
.font(.title2)
.frame(maxWidth: .infinity)
if exercise.wrappedValue.exercise.side != nil && exercise.wrappedValue.exercise.side!.count > 0 {
Text(exercise.wrappedValue.exercise.side!)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .center)
}
CreateExerciseActionsView(workoutExercise: exercise.wrappedValue,
superset: superset.wrappedValue,
viewModel: viewModel)
}
}
}
HStack {
Stepper("Number of rounds", onIncrement: {
superset.wrappedValue.increaseNumberOfRounds()
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
}, onDecrement: {
superset.wrappedValue.decreaseNumberOfRounds()
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
})
Text("\(superset.wrappedValue.numberOfRounds)")
.foregroundColor(superset.numberOfRounds.wrappedValue > 0 ? .black : .red)
.bold()
}
CreateWorkoutSupersetActionsView(workoutSuperSet: superset.wrappedValue,
showAddExercise: $showAddExercise,
viewModel: viewModel,
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet)
}
CreateWorkoutSupersetView(
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet,
showAddExercise: $showAddExercise,
superset: superset,
viewModel: viewModel)
}
// after adding new exercise we have to scroll to the bottom
// where the new exercise is sooo keep this so we can scroll
// to id 999
Text("this is the bottom 🤷‍♂️")
.id(999)
.listRowSeparator(.hidden)
.listRowSeparator(.hidden)
}
.onChange(of: viewModel.randomValueForUpdatingValue, perform: { newValue in
withAnimation {
@@ -80,15 +48,41 @@ struct CreateWorkoutMainView: View {
}
})
}
// .overlay(Group {
// if($viewModel.superSets.isEmpty) {
// ZStack() {
// Color(uiColor: .secondarySystemBackground)
// }
// }
// })
Divider()
.sheet(isPresented: $showAddExercise) {
AddExerciseView(selectedExercise: { exercise in
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise)
// if left or right auto add the other side
// with a recover in between b/c its
// eaiser to delete a recover than add one
if exercise.side != nil && exercise.side!.count > 0 {
let exercises = DataStore.shared.allExercise?.filter({
$0.name == exercise.name
})
let recover = DataStore.shared.allExercise?.first(where: {
$0.name.lowercased() == "recover"
})
if let exercises = exercises, let recover = recover {
if exercises.count == 2 {
let recoverWorkoutExercise = CreateWorkoutExercise(exercise: recover)
selectedCreateWorkoutSuperSet?.exercises.append(recoverWorkoutExercise)
for LRExercise in exercises {
if LRExercise.id != exercise.id {
let otherSideExercise = CreateWorkoutExercise(exercise: LRExercise)
selectedCreateWorkoutSuperSet?.exercises.append(otherSideExercise)
}
}
}
}
}
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
selectedCreateWorkoutSuperSet = nil
})
}
HStack {
Button("Add Superset", action: {
@@ -96,9 +90,9 @@ struct CreateWorkoutMainView: View {
})
.frame(maxWidth: .infinity, alignment: .center)
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.foregroundColor(.white)
.background(.blue)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
@@ -110,50 +104,17 @@ struct CreateWorkoutMainView: View {
.frame(maxWidth: .infinity, alignment: .center)
.frame(height: 44)
.foregroundColor(.white)
.background(.blue)
.cornerRadius(8)
.background(.green)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
.disabled(viewModel.title.isEmpty)
}
.frame(height: 44)
.padding(.bottom)
}
.sheet(isPresented: $showAddExercise) {
AddExerciseView(selectedExercise: { exercise in
let workoutExercise = CreateWorkoutExercise(exercise: exercise)
selectedCreateWorkoutSuperSet?.exercises.append(workoutExercise)
// if left or right auto add the other side
// with a recover in between b/c its
// eaiser to delete a recover than add one
if exercise.side != nil && exercise.side!.count > 0 {
let exercises = DataStore.shared.allExercise?.filter({
$0.name == exercise.name
})
let recover = DataStore.shared.allExercise?.first(where: {
$0.name.lowercased() == "recover"
})
if let exercises = exercises, let recover = recover {
if exercises.count == 2 {
let recoverWorkoutExercise = CreateWorkoutExercise(exercise: recover)
selectedCreateWorkoutSuperSet?.exercises.append(recoverWorkoutExercise)
for LRExercise in exercises {
if LRExercise.id != exercise.id {
let otherSideExercise = CreateWorkoutExercise(exercise: LRExercise)
selectedCreateWorkoutSuperSet?.exercises.append(otherSideExercise)
}
}
}
}
}
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
selectedCreateWorkoutSuperSet = nil
})
Divider()
}
.background(Color(uiColor: .systemGray5))
}
}

View File

@@ -24,14 +24,12 @@ struct CreateWorkoutSupersetActionsView: View {
}
.foregroundColor(.white)
.background(.green)
.cornerRadius(10)
.frame(maxWidth: .infinity, alignment: .center)
.buttonStyle(BorderlessButtonStyle())
Button(action: {
viewModel.delete(superset: workoutSuperSet)
viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
// viewModel.delete(superset: workoutSuperSet)
// viewModel.increaseRandomNumberForUpdating()
// viewModel.objectWillChange.send()
}) {
Text("Delete superset")
@@ -39,9 +37,7 @@ struct CreateWorkoutSupersetActionsView: View {
}
.foregroundColor(.white)
.background(.red)
.cornerRadius(10)
.frame(maxWidth: .infinity, alignment: .center)
.buttonStyle(BorderlessButtonStyle())
}
}
}

View File

@@ -28,7 +28,7 @@ struct LoginView: View {
.textFieldStyle(PlainTextFieldStyle())
.padding([.horizontal], 4)
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)))
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding(.top, 25)
@@ -39,7 +39,7 @@ struct LoginView: View {
.textFieldStyle(PlainTextFieldStyle())
.padding([.horizontal], 4)
.overlay(RoundedRectangle(cornerRadius: 16).stroke(Color(uiColor: .clear))).background(Color(uiColor: .init(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)))
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
if doingNetworkShit {
ProgressView("Logging In")
@@ -55,7 +55,7 @@ struct LoginView: View {
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
.disabled(password.isEmpty || email.isEmpty)

View File

@@ -46,7 +46,7 @@ struct PlanWorkoutView: View {
.frame(height: 44)
.foregroundColor(.white)
.background(.red)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
Button(action: {
@@ -60,7 +60,7 @@ struct PlanWorkoutView: View {
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
}

View File

@@ -67,7 +67,7 @@ struct WorkoutDetailView: View {
.foregroundColor(Color("appColor"))
})
.foregroundColor(.blue)
.cornerRadius(4)
.cornerRadius(Constants.buttonRadius)
.frame(width: 160, height: 120)
.position(x: metrics.size.width - 22, y: metrics.size.height - 30)
@@ -79,7 +79,7 @@ struct WorkoutDetailView: View {
.foregroundColor(Color("appColor"))
})
.foregroundColor(.blue)
.cornerRadius(4)
.cornerRadius(Constants.buttonRadius)
.frame(width: 120, height: 120)
.position(x: 22, y: metrics.size.height - 30)
}

View File

@@ -15,6 +15,8 @@ struct Constants {
static let extThotStyle = "extThotStyle"
static let extShowNextVideo = "extShowNextVideo"
static let thotGenderOption = "thotGenderOption"
static let buttonRadius: CGFloat = 4
}
@main

View File

@@ -0,0 +1,36 @@
//
// AddSupersetView.swift
// Werkout_ios
//
// Created by Trey Tartt on 12/18/24.
//
import SwiftUI
struct AddSupersetView: View {
@Binding var createWorkoutSuperSet: CreateWorkoutSuperSet
var viewModel: WorkoutViewModel
@Binding var selectedCreateWorkoutSuperSet: CreateWorkoutSuperSet?
var body: some View {
VStack {
ForEach(createWorkoutSuperSet.exercises, id: \.id) { createWorkoutExercise in
HStack {
VStack {
Text(createWorkoutExercise.exercise.name)
.font(.title2)
.frame(maxWidth: .infinity)
if createWorkoutExercise.exercise.side != nil && createWorkoutExercise.exercise.side!.count > 0 {
Text(createWorkoutExercise.exercise.side!)
.font(.title3)
.frame(maxWidth: .infinity, alignment: .center)
}
CreateExerciseActionsView(workoutExercise: createWorkoutExercise,
superset: createWorkoutSuperSet,
viewModel: viewModel)
}
}
}
}
}
}

View File

@@ -27,11 +27,12 @@ struct AllExerciseView: View {
var body: some View {
VStack {
TextField("Filter", text: $searchString)
.padding()
.padding(.horizontal)
.textFieldStyle(.roundedBorder)
List() {
ForEach(filteredExercises, id: \.self) { exercise in
if searchString.isEmpty || (exercise.name.lowercased().contains(searchString.lowercased()) || (exercise.muscleGroups ?? "").lowercased().contains(searchString.lowercased())) {
if searchString.isEmpty || exercise.name.lowercased().contains(searchString.lowercased()) {
HStack {
VStack {
Text(exercise.name)

View File

@@ -35,7 +35,7 @@ struct CompletedWorkoutsView: View {
.frame(height: 44)
.foregroundColor(.blue)
.background(.yellow)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
}

View File

@@ -0,0 +1,79 @@
//
// CreateWorkoutSupersetView.swift
// Werkout_ios
//
// Created by Trey Tartt on 12/19/24.
//
import SwiftUI
struct CreateWorkoutSupersetView: View {
@Binding var selectedCreateWorkoutSuperSet: CreateWorkoutSuperSet?
@Binding var showAddExercise: Bool
@Binding var superset: CreateWorkoutSuperSet
@ObservedObject var viewModel: WorkoutViewModel
var body: some View {
Section(content: {
AddSupersetView(
createWorkoutSuperSet: $superset,
viewModel: viewModel,
selectedCreateWorkoutSuperSet: $selectedCreateWorkoutSuperSet)
}, header: {
VStack {
HStack {
TextField("Superset Title", text: $superset.title)
.font(.title2)
}
VStack {
HStack {
Text("Exercises: \(superset.exercises.count)")
.font(.subheadline)
.bold()
Spacer()
Button(action: {
selectedCreateWorkoutSuperSet = $superset.wrappedValue
showAddExercise.toggle()
}, label: {
Image(systemName: "dumbbell.fill")
.font(.title2)
})
Divider()
Button(action: {
viewModel.delete(superset: $superset.wrappedValue)
//viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
}, label: {
Image(systemName: "trash")
.font(.title2)
})
}
Divider()
Stepper(label: {
HStack {
Text("Rounds: ")
Text("\($superset.wrappedValue.numberOfRounds)")
.foregroundColor($superset.wrappedValue.numberOfRounds > 0 ? Color(uiColor: .label) : .red)
.bold()
}
}, onIncrement: {
$superset.wrappedValue.increaseNumberOfRounds()
//viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
}, onDecrement: {
$superset.wrappedValue.decreaseNumberOfRounds()
//viewModel.increaseRandomNumberForUpdating()
viewModel.objectWillChange.send()
})
}
}
})
}
}

View File

@@ -19,7 +19,7 @@ struct Logoutview: View {
.frame(height: 44)
.foregroundColor(.white)
.background(.red)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
@@ -31,7 +31,7 @@ struct Logoutview: View {
.frame(width: 44, height: 44)
.foregroundColor(.white)
.background(.green)
.cornerRadius(8)
.cornerRadius(Constants.buttonRadius)
.padding()
.frame(maxWidth: .infinity)
}