WIP
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct SupersetExercise: Identifiable, Codable, Equatable, Hashable {
|
struct SupersetExercise: Identifiable, Codable, Equatable, Hashable {
|
||||||
var id: Int
|
var id: Int?
|
||||||
|
|
||||||
let workout: Int?
|
let workout: Int?
|
||||||
let exercise: Exercise
|
let exercise: Exercise
|
||||||
@@ -17,9 +17,9 @@ struct SupersetExercise: Identifiable, Codable, Equatable, Hashable {
|
|||||||
let duration: Int?
|
let duration: Int?
|
||||||
let durationAudio: String?
|
let durationAudio: String?
|
||||||
let weightAudio: String?
|
let weightAudio: String?
|
||||||
let createdAt: String
|
let createdAt: String?
|
||||||
let order, superset: Int
|
let order, superset: Int?
|
||||||
let uniqueID: String
|
let uniqueID: String?
|
||||||
let description: String?
|
let description: String?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ struct RegisteredUser: Codable, Hashable {
|
|||||||
let nickName: String?
|
let nickName: String?
|
||||||
let token: String?
|
let token: String?
|
||||||
let email: String?
|
let email: String?
|
||||||
|
let hasNSFWToggle: Bool?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case id
|
case id
|
||||||
@@ -21,5 +22,10 @@ struct RegisteredUser: Codable, Hashable {
|
|||||||
case image, token
|
case image, token
|
||||||
case email = "email_address"
|
case email = "email_address"
|
||||||
case nickName = "nick_name"
|
case nickName = "nick_name"
|
||||||
|
case hasNSFWToggle = "has_nsfw_toggle"
|
||||||
|
}
|
||||||
|
|
||||||
|
var NSFWValue: Bool {
|
||||||
|
return hasNSFWToggle ?? false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct Superset: Codable, Identifiable, Hashable {
|
struct Superset: Codable, Identifiable, Hashable {
|
||||||
let id: Int
|
let id: Int?
|
||||||
let exercises: [SupersetExercise]
|
let exercises: [SupersetExercise]
|
||||||
let createdAt, updatedAt, name: String?
|
let createdAt, updatedAt, name: String?
|
||||||
let rounds, order, workout: Int
|
let rounds, order, workout: Int
|
||||||
|
|||||||
@@ -28,10 +28,20 @@ class DataStore: ObservableObject {
|
|||||||
|
|
||||||
public func randomVideoFor(gender: String) -> String? {
|
public func randomVideoFor(gender: String) -> String? {
|
||||||
return allNSFWVideos?.filter({
|
return allNSFWVideos?.filter({
|
||||||
$0.genderValue == gender
|
$0.genderValue.lowercased() == gender.lowercased()
|
||||||
}).randomElement()?.videoFile ?? nil
|
}).randomElement()?.videoFile ?? nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var nsfwGenderOptions: [String]? {
|
||||||
|
let values = self.allNSFWVideos?.map({
|
||||||
|
$0.genderValue
|
||||||
|
})
|
||||||
|
if let values = values {
|
||||||
|
return Array(Set(values))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
public var workoutsUniqueUsers: [RegisteredUser]? {
|
public var workoutsUniqueUsers: [RegisteredUser]? {
|
||||||
guard let workouts = allWorkouts else {
|
guard let workouts = allWorkouts else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -102,3 +102,8 @@ class AllNSFWVideosFetchable: Fetchable {
|
|||||||
typealias Response = [NSFWVideo]
|
typealias Response = [NSFWVideo]
|
||||||
var endPoint: String = "/videos/nsfw_videos/"
|
var endPoint: String = "/videos/nsfw_videos/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RefreshUserInfoFetcable: Fetchable {
|
||||||
|
typealias Response = RegisteredUser
|
||||||
|
var endPoint: String = "/registered_user/refresh/"
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,25 @@ class UserStore: ObservableObject {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func refreshUserData() {
|
||||||
|
RefreshUserInfoFetcable().fetch(completion: { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let registeredUser):
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
if let data = try? JSONEncoder().encode(registeredUser) {
|
||||||
|
UserDefaults.standard.set(data, forKey: UserStore.userDefaultsRegisteredUserKey)
|
||||||
|
}
|
||||||
|
if let data = UserDefaults.standard.data(forKey: UserStore.userDefaultsRegisteredUserKey),
|
||||||
|
let model = try? JSONDecoder().decode(RegisteredUser.self, from: data) {
|
||||||
|
self.registeredUser = model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .failure(let failure):
|
||||||
|
fatalError()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func logout() {
|
func logout() {
|
||||||
self.registeredUser = nil
|
self.registeredUser = nil
|
||||||
UserDefaults.standard.set(nil, forKey: UserStore.userDefaultsRegisteredUserKey)
|
UserDefaults.standard.set(nil, forKey: UserStore.userDefaultsRegisteredUserKey)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct AccountView: View {
|
|||||||
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
||||||
@AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never
|
@AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never
|
||||||
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
||||||
|
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
@@ -64,26 +65,41 @@ struct AccountView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Divider()
|
Divider()
|
||||||
Group {
|
|
||||||
Text("Phone THOT Style:")
|
if userStore.registeredUser?.NSFWValue ?? false {
|
||||||
Picker("Phone THOT Style:", selection: $phoneThotStyle) {
|
Group {
|
||||||
ForEach(ThotStyle.allCases, id: \.self) { style in
|
Text("Phone THOT Style:")
|
||||||
Text(style.stringValue())
|
Picker("Phone THOT Style:", selection: $phoneThotStyle) {
|
||||||
.tag(phoneThotStyle.rawValue)
|
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 {
|
Group {
|
||||||
@@ -96,16 +112,30 @@ struct AccountView: View {
|
|||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Button("Logout", action: {
|
HStack {
|
||||||
userStore.logout()
|
Button("Logout", action: {
|
||||||
})
|
userStore.logout()
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
})
|
||||||
.frame(height: 44)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.foregroundColor(.white)
|
.frame(height: 44)
|
||||||
.background(.red)
|
.foregroundColor(.white)
|
||||||
.cornerRadius(8)
|
.background(.red)
|
||||||
.padding()
|
.cornerRadius(8)
|
||||||
.frame(maxWidth: .infinity)
|
.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()
|
.padding()
|
||||||
.sheet(isPresented: $showCompletedWorkouts) {
|
.sheet(isPresented: $showCompletedWorkouts) {
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ struct CreateExerciseActionsView: View {
|
|||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
|
superset.deleteExerciseForChosenSuperset(exercise: workoutExercise)
|
||||||
|
viewModel.increaseRandomNumberForUpdating()
|
||||||
viewModel.objectWillChange.send()
|
viewModel.objectWillChange.send()
|
||||||
}) {
|
}) {
|
||||||
Image(systemName: "trash.fill")
|
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()
|
let id = UUID()
|
||||||
@Published var exercises = [CreateWorkoutExercise]()
|
@Published var exercises = [CreateWorkoutExercise]()
|
||||||
@Published var numberOfRounds = 0
|
@Published var numberOfRounds = 0
|
||||||
@@ -85,8 +89,14 @@ class WorkoutViewModel: ObservableObject {
|
|||||||
@Published var superSets = [CreateWorkoutSuperSet]()
|
@Published var superSets = [CreateWorkoutSuperSet]()
|
||||||
@Published var title = String()
|
@Published var title = String()
|
||||||
@Published var description = String()
|
@Published var description = String()
|
||||||
|
@Published var randomValueForUpdatingValue = 0
|
||||||
|
|
||||||
|
func increaseRandomNumberForUpdating() {
|
||||||
|
randomValueForUpdatingValue += 1
|
||||||
|
}
|
||||||
|
|
||||||
func addNewSuperset() {
|
func addNewSuperset() {
|
||||||
|
increaseRandomNumberForUpdating()
|
||||||
superSets.append(CreateWorkoutSuperSet())
|
superSets.append(CreateWorkoutSuperSet())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +105,7 @@ class WorkoutViewModel: ObservableObject {
|
|||||||
$0.id == superset.id
|
$0.id == superset.id
|
||||||
}) {
|
}) {
|
||||||
superSets.remove(at: idx)
|
superSets.remove(at: idx)
|
||||||
|
increaseRandomNumberForUpdating()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,49 +24,61 @@ struct CreateWorkoutMainView: View {
|
|||||||
.padding()
|
.padding()
|
||||||
.frame(height: 55)
|
.frame(height: 55)
|
||||||
.textFieldStyle(OvalTextFieldStyle())
|
.textFieldStyle(OvalTextFieldStyle())
|
||||||
|
ScrollViewReader { proxy in
|
||||||
List() {
|
List() {
|
||||||
ForEach($viewModel.superSets, id: \.id) { superset in
|
ForEach($viewModel.superSets, id: \.id) { superset in
|
||||||
Section {
|
Section {
|
||||||
ForEach(superset.exercises, id: \.id) { exercise in
|
ForEach(superset.exercises, id: \.id) { exercise in
|
||||||
HStack {
|
HStack {
|
||||||
VStack {
|
VStack {
|
||||||
Text(exercise.wrappedValue.exercise.name)
|
Text(exercise.wrappedValue.exercise.name)
|
||||||
.font(.title2)
|
.font(.title2)
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
if exercise.wrappedValue.exercise.side.count > 0 {
|
if exercise.wrappedValue.exercise.side.count > 0 {
|
||||||
Text(exercise.wrappedValue.exercise.side)
|
Text(exercise.wrappedValue.exercise.side)
|
||||||
.font(.title3)
|
.font(.title3)
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.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 {
|
// .overlay(Group {
|
||||||
// if($viewModel.superSets.isEmpty) {
|
// if($viewModel.superSets.isEmpty) {
|
||||||
@@ -137,6 +149,7 @@ struct CreateWorkoutMainView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewModel.increaseRandomNumberForUpdating()
|
||||||
viewModel.objectWillChange.send()
|
viewModel.objectWillChange.send()
|
||||||
selectedCreateWorkoutSuperSet = nil
|
selectedCreateWorkoutSuperSet = nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ struct CreateWorkoutSupersetActionsView: View {
|
|||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
viewModel.delete(superset: workoutSuperSet)
|
viewModel.delete(superset: workoutSuperSet)
|
||||||
|
viewModel.increaseRandomNumberForUpdating()
|
||||||
viewModel.objectWillChange.send()
|
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")!)
|
@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.extThotStyle) private var extThotStyle: ThotStyle = .never
|
||||||
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
@AppStorage(Constants.extShowBothVideos) private var extShowBothVideos: Bool = false
|
||||||
|
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
@@ -77,6 +78,7 @@ struct ExternalWorkoutDetailView: View {
|
|||||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: extThotStyle,
|
thotStyle: extThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -86,6 +88,7 @@ struct ExternalWorkoutDetailView: View {
|
|||||||
if extShowBothVideos {
|
if extShowBothVideos {
|
||||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -100,6 +103,7 @@ struct ExternalWorkoutDetailView: View {
|
|||||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: extThotStyle,
|
thotStyle: extThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -109,6 +113,7 @@ struct ExternalWorkoutDetailView: View {
|
|||||||
if extShowBothVideos {
|
if extShowBothVideos {
|
||||||
if let smallVideoURL = VideoURLCreator.videoURL(
|
if let smallVideoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: videoURL),
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
|
|||||||
@@ -90,28 +90,32 @@ class VideoURLCreator {
|
|||||||
return otherVideoStyle
|
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?
|
var urlString: String?
|
||||||
|
|
||||||
switch thotStyle {
|
if UserStore.shared.registeredUser?.NSFWValue ?? false {
|
||||||
case .always:
|
switch thotStyle {
|
||||||
urlString = DataStore.shared.randomVideoFor(gender: "female")
|
case .always:
|
||||||
case .never:
|
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
|
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,
|
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")!)
|
@State var avPlayer = AVPlayer(url: URL(string: "https://dev.werkout.fitness/media/exercise_videos/2_Dumbbell_Lateral_Lunges.mp4")!)
|
||||||
var workout: Workout
|
var workout: Workout
|
||||||
@Binding var showExecersizeInfo: Bool
|
@Binding var showExecersizeInfo: Bool
|
||||||
|
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||||
|
|
||||||
@State var videoExercise: Exercise? {
|
@State var videoExercise: Exercise? {
|
||||||
didSet {
|
didSet {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: phoneThotStyle,
|
thotStyle: phoneThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: self.videoExercise?.videoURL,
|
defaultVideoURLStr: self.videoExercise?.videoURL,
|
||||||
exerciseName: self.videoExercise?.name,
|
exerciseName: self.videoExercise?.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ struct WorkoutDetailView: View {
|
|||||||
@StateObject var bridgeModule = BridgeModule.shared
|
@StateObject var bridgeModule = BridgeModule.shared
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
@AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never
|
||||||
|
@AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female"
|
||||||
|
|
||||||
enum Sheet: Identifiable {
|
enum Sheet: Identifiable {
|
||||||
case completedWorkout([String: Any])
|
case completedWorkout([String: Any])
|
||||||
var id: String { return UUID().uuidString }
|
var id: String { return UUID().uuidString }
|
||||||
@@ -55,6 +56,7 @@ struct WorkoutDetailView: View {
|
|||||||
let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise,
|
let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise,
|
||||||
let otherVideoURL = VideoURLCreator.videoURL(
|
let otherVideoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: assetURL),
|
thotStyle: VideoURLCreator.otherVideoType(forVideoURL: assetURL),
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -118,6 +120,7 @@ struct WorkoutDetailView: View {
|
|||||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: phoneThotStyle,
|
thotStyle: phoneThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -130,6 +133,7 @@ struct WorkoutDetailView: View {
|
|||||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: phoneThotStyle,
|
thotStyle: phoneThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
@@ -142,6 +146,7 @@ struct WorkoutDetailView: View {
|
|||||||
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
if let currentExtercise = bridgeModule.currentExerciseInfo.currentExercise {
|
||||||
if let videoURL = VideoURLCreator.videoURL(
|
if let videoURL = VideoURLCreator.videoURL(
|
||||||
thotStyle: phoneThotStyle,
|
thotStyle: phoneThotStyle,
|
||||||
|
gender: thotGenderOption,
|
||||||
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
defaultVideoURLStr: currentExtercise.exercise.videoURL,
|
||||||
exerciseName: currentExtercise.exercise.name,
|
exerciseName: currentExtercise.exercise.name,
|
||||||
workout: bridgeModule.currentExerciseInfo.workout) {
|
workout: bridgeModule.currentExerciseInfo.workout) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ struct Constants {
|
|||||||
static let phoneThotStyle = "phoneThotStyle"
|
static let phoneThotStyle = "phoneThotStyle"
|
||||||
static let extThotStyle = "extThotStyle"
|
static let extThotStyle = "extThotStyle"
|
||||||
static let extShowBothVideos = "extShowBothVideos"
|
static let extShowBothVideos = "extShowBothVideos"
|
||||||
|
static let thotGenderOption = "thotGenderOption"
|
||||||
}
|
}
|
||||||
|
|
||||||
@main
|
@main
|
||||||
|
|||||||
Reference in New Issue
Block a user