WIP
This commit is contained in:
@@ -15,6 +15,7 @@ struct AccountView: View {
|
||||
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
||||
@AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never
|
||||
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
||||
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
@@ -64,26 +65,41 @@ struct AccountView: View {
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
Group {
|
||||
Text("Phone THOT Style:")
|
||||
Picker("Phone THOT Style:", selection: $phoneThotStyle) {
|
||||
ForEach(ThotStyle.allCases, id: \.self) { style in
|
||||
Text(style.stringValue())
|
||||
.tag(phoneThotStyle.rawValue)
|
||||
|
||||
if userStore.registeredUser?.NSFWValue ?? false {
|
||||
Group {
|
||||
Text("Phone THOT Style:")
|
||||
Picker("Phone THOT Style:", selection: $phoneThotStyle) {
|
||||
ForEach(ThotStyle.allCases, id: \.self) { style in
|
||||
Text(style.stringValue())
|
||||
.tag(phoneThotStyle.rawValue)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
|
||||
Divider()
|
||||
|
||||
Text("External THOT Style:")
|
||||
Picker("External THOT Style:", selection: $extThotStyle) {
|
||||
ForEach(ThotStyle.allCases, id: \.self) { style in
|
||||
Text(style.stringValue())
|
||||
.tag(extThotStyle.rawValue)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
|
||||
if let genderOptions = DataStore.shared.nsfwGenderOptions {
|
||||
Divider()
|
||||
Text("Video Gender:")
|
||||
Picker("Video Gender:", selection: $thotGenderOption) {
|
||||
ForEach(genderOptions, id: \.self) { option in
|
||||
Text(option.capitalized)
|
||||
.tag(option.lowercased())
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
|
||||
Divider()
|
||||
|
||||
Text("External THOT Style:")
|
||||
Picker("External THOT Style:", selection: $extThotStyle) {
|
||||
ForEach(ThotStyle.allCases, id: \.self) { style in
|
||||
Text(style.stringValue())
|
||||
.tag(extThotStyle.rawValue)
|
||||
}
|
||||
}
|
||||
.pickerStyle(.segmented)
|
||||
}
|
||||
|
||||
Group {
|
||||
@@ -96,16 +112,30 @@ struct AccountView: View {
|
||||
|
||||
Spacer()
|
||||
|
||||
Button("Logout", action: {
|
||||
userStore.logout()
|
||||
})
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.frame(height: 44)
|
||||
.foregroundColor(.white)
|
||||
.background(.red)
|
||||
.cornerRadius(8)
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
HStack {
|
||||
Button("Logout", action: {
|
||||
userStore.logout()
|
||||
})
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.frame(height: 44)
|
||||
.foregroundColor(.white)
|
||||
.background(.red)
|
||||
.cornerRadius(8)
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
Button(action: {
|
||||
userStore.refreshUserData()
|
||||
}, label: {
|
||||
Image(systemName: "arrow.triangle.2.circlepath")
|
||||
})
|
||||
.frame(width: 44, height: 44)
|
||||
.foregroundColor(.white)
|
||||
.background(.green)
|
||||
.cornerRadius(8)
|
||||
.padding()
|
||||
.frame(maxWidth: .infinity)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.sheet(isPresented: $showCompletedWorkouts) {
|
||||
|
||||
@@ -84,6 +84,7 @@ struct CreateExerciseActionsView: View {
|
||||
|
||||
Button(action: {
|
||||
superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
|
||||
viewModel.increaseRandomNumberForUpdating()
|
||||
viewModel.objectWillChange.send()
|
||||
}) {
|
||||
Image(systemName: "trash.fill")
|
||||
|
||||
@@ -56,7 +56,11 @@ class CreateWorkoutExercise: ObservableObject, Identifiable {
|
||||
}
|
||||
}
|
||||
|
||||
class CreateWorkoutSuperSet: ObservableObject, Identifiable {
|
||||
class CreateWorkoutSuperSet: ObservableObject, Identifiable, Equatable {
|
||||
static func == (lhs: CreateWorkoutSuperSet, rhs: CreateWorkoutSuperSet) -> Bool {
|
||||
lhs.id == rhs.id
|
||||
}
|
||||
|
||||
let id = UUID()
|
||||
@Published var exercises = [CreateWorkoutExercise]()
|
||||
@Published var numberOfRounds = 0
|
||||
@@ -85,8 +89,14 @@ class WorkoutViewModel: ObservableObject {
|
||||
@Published var superSets = [CreateWorkoutSuperSet]()
|
||||
@Published var title = String()
|
||||
@Published var description = String()
|
||||
@Published var randomValueForUpdatingValue = 0
|
||||
|
||||
func increaseRandomNumberForUpdating() {
|
||||
randomValueForUpdatingValue += 1
|
||||
}
|
||||
|
||||
func addNewSuperset() {
|
||||
increaseRandomNumberForUpdating()
|
||||
superSets.append(CreateWorkoutSuperSet())
|
||||
}
|
||||
|
||||
@@ -95,6 +105,7 @@ class WorkoutViewModel: ObservableObject {
|
||||
$0.id == superset.id
|
||||
}) {
|
||||
superSets.remove(at: idx)
|
||||
increaseRandomNumberForUpdating()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,49 +24,61 @@ struct CreateWorkoutMainView: View {
|
||||
.padding()
|
||||
.frame(height: 55)
|
||||
.textFieldStyle(OvalTextFieldStyle())
|
||||
|
||||
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.count > 0 {
|
||||
Text(exercise.wrappedValue.exercise.side)
|
||||
.font(.title3)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
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.count > 0 {
|
||||
Text(exercise.wrappedValue.exercise.side)
|
||||
.font(.title3)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
CreateExerciseActionsView(workoutExercise: exercise.wrappedValue,
|
||||
superset: superset.wrappedValue,
|
||||
viewModel: viewModel)
|
||||
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
HStack {
|
||||
Stepper("Number of rounds", onIncrement: {
|
||||
superset.wrappedValue.increaseNumberOfRounds()
|
||||
viewModel.objectWillChange.send()
|
||||
}, onDecrement: {
|
||||
superset.wrappedValue.decreaseNumberOfRounds()
|
||||
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)
|
||||
}
|
||||
Text("this is the bottom 🤷♂️")
|
||||
.id(999)
|
||||
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
.onChange(of: viewModel.randomValueForUpdatingValue, perform: { newValue in
|
||||
withAnimation {
|
||||
proxy.scrollTo(999, anchor: .bottom)
|
||||
}
|
||||
})
|
||||
}
|
||||
// .overlay(Group {
|
||||
// if($viewModel.superSets.isEmpty) {
|
||||
@@ -137,6 +149,7 @@ struct CreateWorkoutMainView: View {
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.increaseRandomNumberForUpdating()
|
||||
viewModel.objectWillChange.send()
|
||||
selectedCreateWorkoutSuperSet = nil
|
||||
})
|
||||
|
||||
@@ -30,6 +30,7 @@ struct CreateWorkoutSupersetActionsView: View {
|
||||
|
||||
Button(action: {
|
||||
viewModel.delete(superset: workoutSuperSet)
|
||||
viewModel.increaseRandomNumberForUpdating()
|
||||
viewModel.objectWillChange.send()
|
||||
|
||||
}) {
|
||||
|
||||
@@ -14,6 +14,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
@State var smallAVPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!)
|
||||
@AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never
|
||||
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
||||
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
@@ -77,6 +78,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: extThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -86,6 +88,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
if extShowBothVideos {
|
||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -100,6 +103,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: extThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -109,6 +113,7 @@ struct ExternalWorkoutDetailView: View {
|
||||
if extShowBothVideos {
|
||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
|
||||
@@ -90,28 +90,32 @@ class VideoURLCreator {
|
||||
return otherVideoStyle
|
||||
}
|
||||
|
||||
class func videoURL(thotStyle: ThotStyle, defaultVideoURLStr: String?, exerciseName: String?, workout: Workout?) -> URL? {
|
||||
class func videoURL(thotStyle: ThotStyle, gender: String, defaultVideoURLStr: String?, exerciseName: String?, workout: Workout?) -> URL? {
|
||||
var urlString: String?
|
||||
|
||||
switch thotStyle {
|
||||
case .always:
|
||||
urlString = DataStore.shared.randomVideoFor(gender: "female")
|
||||
case .never:
|
||||
if UserStore.shared.registeredUser?.NSFWValue ?? false {
|
||||
switch thotStyle {
|
||||
case .always:
|
||||
urlString = DataStore.shared.randomVideoFor(gender: gender)
|
||||
case .never:
|
||||
urlString = defaultVideoURLStr
|
||||
case .recovery:
|
||||
if exerciseName?.lowercased() == "recover" {
|
||||
urlString = DataStore.shared.randomVideoFor(gender: gender)
|
||||
} else {
|
||||
urlString = defaultVideoURLStr
|
||||
}
|
||||
case .random:
|
||||
if Bool.random() {
|
||||
urlString = DataStore.shared.randomVideoFor(gender: gender)
|
||||
} else {
|
||||
urlString = defaultVideoURLStr
|
||||
}
|
||||
case .off:
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
urlString = defaultVideoURLStr
|
||||
case .recovery:
|
||||
if exerciseName?.lowercased() == "recover" {
|
||||
urlString = DataStore.shared.randomVideoFor(gender: "female")
|
||||
} else {
|
||||
urlString = defaultVideoURLStr
|
||||
}
|
||||
case .random:
|
||||
if Bool.random() {
|
||||
urlString = DataStore.shared.randomVideoFor(gender: "female")
|
||||
} else {
|
||||
urlString = defaultVideoURLStr
|
||||
}
|
||||
case .off:
|
||||
return nil
|
||||
}
|
||||
|
||||
if let urlString = urlString,
|
||||
|
||||
@@ -14,11 +14,13 @@ struct ExerciseListView: View {
|
||||
@State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!)
|
||||
var workout: Workout
|
||||
@Binding var showExecersizeInfo: Bool
|
||||
|
||||
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||
|
||||
@State var videoExercise: Exercise? {
|
||||
didSet {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: self.videoExercise?.videoURL,
|
||||
exerciseName: self.videoExercise?.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
|
||||
@@ -15,7 +15,8 @@ struct WorkoutDetailView: View {
|
||||
@StateObject var bridgeModule = BridgeModule.shared
|
||||
@Environment(\.dismiss) var dismiss
|
||||
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
||||
|
||||
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||
|
||||
enum Sheet: Identifiable {
|
||||
case completedWorkout([String: Any])
|
||||
var id: String { return UUID().uuidString }
|
||||
@@ -55,6 +56,7 @@ struct WorkoutDetailView: View {
|
||||
let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise,
|
||||
let otherVideoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: assetURL),
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -118,6 +120,7 @@ struct WorkoutDetailView: View {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -130,6 +133,7 @@ struct WorkoutDetailView: View {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
@@ -142,6 +146,7 @@ struct WorkoutDetailView: View {
|
||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||
if let videoURL = VideoURLCreator.videoURL(
|
||||
thotStyle: phoneThotStyle,
|
||||
gender: thotGenderOption,
|
||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||
exerciseName: currentExtercise.exercise.name,
|
||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||
|
||||
Reference in New Issue
Block a user