diff --git a/Werkout_ios.xcodeproj/project.pbxproj b/Werkout_ios.xcodeproj/project.pbxproj index 950f868..f863a26 100644 --- a/Werkout_ios.xcodeproj/project.pbxproj +++ b/Werkout_ios.xcodeproj/project.pbxproj @@ -39,6 +39,11 @@ 1CAF4D8A2A5132F900B00E50 /* PlannedWorkout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF4D892A5132F900B00E50 /* PlannedWorkout.swift */; }; 1CAF4D8C2A51339200B00E50 /* PlannedWorkouts.json in Resources */ = {isa = PBXBuildFile; fileRef = 1CAF4D8B2A51339200B00E50 /* PlannedWorkouts.json */; }; 1CAF4D952A52180600B00E50 /* PlanWorkoutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CAF4D942A52180600B00E50 /* PlanWorkoutView.swift */; }; + 1CC092ED2C1FAC730004E1E6 /* Logoutview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092EC2C1FAC730004E1E6 /* Logoutview.swift */; }; + 1CC092EF2C1FACFC0004E1E6 /* NameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092EE2C1FACFC0004E1E6 /* NameView.swift */; }; + 1CC092F12C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092F02C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift */; }; + 1CC092F32C1FADDA0004E1E6 /* ThotPreferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092F22C1FADDA0004E1E6 /* ThotPreferenceView.swift */; }; + 1CC092F52C1FAE7B0004E1E6 /* ShowNextUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CC092F42C1FAE7B0004E1E6 /* ShowNextUpView.swift */; }; 1CD0C6632A5AF62900970E52 /* WorkoutOverviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */; }; 1CD0C6672A5CA19600970E52 /* BaseURLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6662A5CA19600970E52 /* BaseURLs.swift */; }; 1CD0C6682A5CA1A200970E52 /* BaseURLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CD0C6662A5CA19600970E52 /* BaseURLs.swift */; }; @@ -158,6 +163,11 @@ 1CAF4D892A5132F900B00E50 /* PlannedWorkout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlannedWorkout.swift; sourceTree = ""; }; 1CAF4D8B2A51339200B00E50 /* PlannedWorkouts.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = PlannedWorkouts.json; sourceTree = ""; }; 1CAF4D942A52180600B00E50 /* PlanWorkoutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanWorkoutView.swift; sourceTree = ""; }; + 1CC092EC2C1FAC730004E1E6 /* Logoutview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logoutview.swift; sourceTree = ""; }; + 1CC092EE2C1FACFC0004E1E6 /* NameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameView.swift; sourceTree = ""; }; + 1CC092F02C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletedWorkoutsView.swift; sourceTree = ""; }; + 1CC092F22C1FADDA0004E1E6 /* ThotPreferenceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThotPreferenceView.swift; sourceTree = ""; }; + 1CC092F42C1FAE7B0004E1E6 /* ShowNextUpView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowNextUpView.swift; sourceTree = ""; }; 1CD0C6622A5AF62900970E52 /* WorkoutOverviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkoutOverviewView.swift; sourceTree = ""; }; 1CD0C6662A5CA19600970E52 /* BaseURLs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseURLs.swift; sourceTree = ""; }; 1CD0C66B2A5E4EA100970E52 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; @@ -250,6 +260,18 @@ name = Frameworks; sourceTree = ""; }; + 1CC092EB2C1FAC2A0004E1E6 /* subview */ = { + isa = PBXGroup; + children = ( + 1CC092EC2C1FAC730004E1E6 /* Logoutview.swift */, + 1CC092EE2C1FACFC0004E1E6 /* NameView.swift */, + 1CC092F02C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift */, + 1CC092F22C1FADDA0004E1E6 /* ThotPreferenceView.swift */, + 1CC092F42C1FAE7B0004E1E6 /* ShowNextUpView.swift */, + ); + path = subview; + sourceTree = ""; + }; 1CF65A192A3972840042FFBD = { isa = PBXGroup; children = ( @@ -287,6 +309,7 @@ 1CF65A802A412AA30042FFBD /* DataStore.swift */, 1CF65AB92A4894430042FFBD /* UserStore.swift */, 1C6BF28E2A56602B00450FD7 /* Keychain.swift */, + 1CC092EB2C1FAC2A0004E1E6 /* subview */, 1CF65A3F2A3973840042FFBD /* Views */, 1CF65A3E2A39737D0042FFBD /* APIModels */, 1CF65A3D2A3973760042FFBD /* Network */, @@ -592,6 +615,7 @@ 1CF65A3C2A3972CE0042FFBD /* ExternalWorkoutDetailView.swift in Sources */, 1CF65A632A3BF6A30042FFBD /* AllWorkoutsView.swift in Sources */, 1CF65A692A3C018F0042FFBD /* AccountView.swift in Sources */, + 1CC092EF2C1FACFC0004E1E6 /* NameView.swift in Sources */, 1CF65A4E2A39FF200042FFBD /* WorkoutDetailViewModel.swift in Sources */, 1CF65A472A39FB6C0042FFBD /* RegisteredUser.swift in Sources */, 1CF65AB32A452F360042FFBD /* WatchPackageModel.swift in Sources */, @@ -601,11 +625,13 @@ 1CF65A852A43E8060042FFBD /* CompletedWorkout.swift in Sources */, 1CF65A6E2A3F60480042FFBD /* CreateViewModels.swift in Sources */, 1CF65A4C2A39FDA20042FFBD /* WorkoutDetailView.swift in Sources */, + 1CC092F12C1FAD1E0004E1E6 /* CompletedWorkoutsView.swift in Sources */, 1C4AFF182A65CD290027710B /* Superset.swift in Sources */, 1CF65A8E2A44B78B0042FFBD /* CompletedWorkoutView.swift in Sources */, 1CF65A432A39FB410042FFBD /* Workout.swift in Sources */, 1CF65A502A3A1EA90042FFBD /* BridgeModule.swift in Sources */, 1CF65A592A3BF4B60042FFBD /* Muscle.swift in Sources */, + 1CC092F32C1FADDA0004E1E6 /* ThotPreferenceView.swift in Sources */, 1C4AFF1E2A7579410027710B /* NSFWVideo.swift in Sources */, 1C5190D02A589D5F00885849 /* AllWorkoutsListView.swift in Sources */, 1C5190CA2A589CEC00885849 /* ExerciseListView.swift in Sources */, @@ -621,12 +647,14 @@ 1C485C8A2A492BB400A6F896 /* LoginView.swift in Sources */, 1C4AFF1B2A65FB190027710B /* CurrentWorkoutInfo.swift in Sources */, 1CF65A732A3F60D20042FFBD /* CreateExerciseActionsView.swift in Sources */, + 1CC092ED2C1FAC730004E1E6 /* Logoutview.swift in Sources */, 1CF65A832A42347D0042FFBD /* Extensions.swift in Sources */, 1CF65A282A3972840042FFBD /* Persistence.swift in Sources */, 1CF65ABA2A4894430042FFBD /* UserStore.swift in Sources */, 1C485C8C2A49D65600A6F896 /* WorkoutHistoryView.swift in Sources */, 1CAF4D952A52180600B00E50 /* PlanWorkoutView.swift in Sources */, 1C5190C62A589CC100885849 /* ActionsView.swift in Sources */, + 1CC092F52C1FAE7B0004E1E6 /* ShowNextUpView.swift in Sources */, 1CF65A5B2A3BF4BE0042FFBD /* Equipment.swift in Sources */, 1C4AFF152A60F25F0027710B /* ThotStyle.swift in Sources */, 1C5190C82A589CDA00885849 /* CurrentWorkoutElapsedTimeView.swift in Sources */, diff --git a/Werkout_ios/Views/AccountView/AccountView.swift b/Werkout_ios/Views/AccountView/AccountView.swift index f7e5b57..50e1df4 100644 --- a/Werkout_ios/Views/AccountView/AccountView.swift +++ b/Werkout_ios/Views/AccountView/AccountView.swift @@ -9,168 +9,37 @@ import Foundation import SwiftUI struct AccountView: View { - @State var completedWorkouts: [CompletedWorkout]? @ObservedObject var userStore = UserStore.shared - @State var showCompletedWorkouts: Bool = false - @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never - @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never - @AppStorage(Constants.extShowNextVideo) private var extShowNextVideo: Bool = false - @AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female" + var body: some View { VStack(alignment: .leading) { - if let registeredUser = userStore.registeredUser { - if let nickName = registeredUser.nickName { - Text(nickName) - .font(.title) - } - - HStack { - Text(registeredUser.firstName ?? "-") - Text(registeredUser.lastName ?? "-") - } - - if let email = registeredUser.email { - Text(email) - } - } + NameView() + + CompletedWorkoutsView() - if let completedWorkouts = completedWorkouts { - VStack(alignment: .leading) { - Divider() - Text("Workout History:") - HStack { - Text("Number of workouts:") - Text("\(completedWorkouts.count)") - } - - if let lastWorkout = completedWorkouts.last { - HStack { - Text("Last workout:") - Text(lastWorkout.workoutStartTime) - } - - Button("View All Workouts", action: { - showCompletedWorkouts = true - }) - .frame(maxWidth: .infinity, alignment: .center) - .frame(height: 44) - .foregroundColor(.blue) - .background(.yellow) - .cornerRadius(8) - .padding() - .frame(maxWidth: .infinity) - } - - } - } Divider() - 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) - } - } - } + ThotPreferenceView() - Group { - Divider() - - Toggle(isOn: $extShowNextVideo, label: { - Text("Show next up video") - }) - } + ShowNextUpView() Spacer() - 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) - } + Logoutview() } .padding() - .sheet(isPresented: $showCompletedWorkouts) { - if let history = completedWorkouts { - WorkoutHistoryView(completedWorkouts: history) - } - } - .onAppear{ - if completedWorkouts == nil { - fetchCompletedWorkouts() - } - } - - } - - func fetchCompletedWorkouts() { - CompletedWorkoutFetchable().fetch(completion: { result in - switch result { - case .success(let model): - completedWorkouts = model - case .failure(let failure): - fatalError(failure.localizedDescription) - } - }) } } -struct AccountView_Previews: PreviewProvider { - static let userStore = UserStore.shared - static let completedWorkouts = PreviewData.parseCompletedWorkouts() - - static var previews: some View { - AccountView(completedWorkouts: completedWorkouts) - .onAppear{ - userStore.setFakeUser() - } - } -} +//struct AccountView_Previews: PreviewProvider { +// static let userStore = UserStore.shared +// static let completedWorkouts = PreviewData.parseCompletedWorkouts() +// +// static var previews: some View { +// AccountView(completedWorkouts: completedWorkouts) +// .onAppear{ +// userStore.setFakeUser() +// } +// } +//} diff --git a/Werkout_ios/subview/CompletedWorkoutsView.swift b/Werkout_ios/subview/CompletedWorkoutsView.swift new file mode 100644 index 0000000..13ede37 --- /dev/null +++ b/Werkout_ios/subview/CompletedWorkoutsView.swift @@ -0,0 +1,68 @@ +// +// CompletedWorkoutsView.swift +// Werkout_ios +// +// Created by Trey Tartt on 6/16/24. +// + +import SwiftUI + +struct CompletedWorkoutsView: View { + @State var completedWorkouts: [CompletedWorkout]? + @State var showCompletedWorkouts: Bool = false + + var body: some View { + if let completedWorkouts = completedWorkouts { + VStack(alignment: .leading) { + Divider() + Text("Workout History:") + HStack { + Text("Number of workouts:") + Text("\(completedWorkouts.count)") + } + + if let lastWorkout = completedWorkouts.last { + HStack { + Text("Last workout:") + Text(lastWorkout.workoutStartTime) + } + + Button("View All Workouts", action: { + showCompletedWorkouts = true + }) + .frame(maxWidth: .infinity, alignment: .center) + .frame(height: 44) + .foregroundColor(.blue) + .background(.yellow) + .cornerRadius(8) + .padding() + .frame(maxWidth: .infinity) + } + + } + .onAppear{ + fetchCompletedWorkouts() + } + .sheet(isPresented: $showCompletedWorkouts) { + if completedWorkouts.count > 0 { + WorkoutHistoryView(completedWorkouts: completedWorkouts) + } + } + } + } + + func fetchCompletedWorkouts() { + CompletedWorkoutFetchable().fetch(completion: { result in + switch result { + case .success(let model): + completedWorkouts = model + case .failure(let failure): + fatalError(failure.localizedDescription) + } + }) + } +} + +#Preview { + CompletedWorkoutsView() +} diff --git a/Werkout_ios/subview/Logoutview.swift b/Werkout_ios/subview/Logoutview.swift new file mode 100644 index 0000000..a8a8a66 --- /dev/null +++ b/Werkout_ios/subview/Logoutview.swift @@ -0,0 +1,43 @@ +// +// Logoutview.swift +// Werkout_ios +// +// Created by Trey Tartt on 6/16/24. +// + +import SwiftUI + +struct Logoutview: View { + @ObservedObject var userStore = UserStore.shared + + var body: some View { + 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) + } + } +} + +#Preview { + Logoutview() +} diff --git a/Werkout_ios/subview/NameView.swift b/Werkout_ios/subview/NameView.swift new file mode 100644 index 0000000..af56112 --- /dev/null +++ b/Werkout_ios/subview/NameView.swift @@ -0,0 +1,34 @@ +// +// NameView.swift +// Werkout_ios +// +// Created by Trey Tartt on 6/16/24. +// + +import SwiftUI + +struct NameView: View { + @ObservedObject var userStore = UserStore.shared + + var body: some View { + if let registeredUser = userStore.registeredUser { + if let nickName = registeredUser.nickName { + Text(nickName) + .font(.title) + } + + HStack { + Text(registeredUser.firstName ?? "-") + Text(registeredUser.lastName ?? "-") + } + + if let email = registeredUser.email { + Text(email) + } + } + } +} + +#Preview { + NameView() +} diff --git a/Werkout_ios/subview/ShowNextUpView.swift b/Werkout_ios/subview/ShowNextUpView.swift new file mode 100644 index 0000000..32d8465 --- /dev/null +++ b/Werkout_ios/subview/ShowNextUpView.swift @@ -0,0 +1,22 @@ +// +// ShowNextUpView.swift +// Werkout_ios +// +// Created by Trey Tartt on 6/16/24. +// + +import SwiftUI + +struct ShowNextUpView: View { + @AppStorage(Constants.extShowNextVideo) private var extShowNextVideo: Bool = false + + var body: some View { + Toggle(isOn: $extShowNextVideo, label: { + Text("Show next up video") + }) + } +} + +#Preview { + ShowNextUpView() +} diff --git a/Werkout_ios/subview/ThotPreferenceView.swift b/Werkout_ios/subview/ThotPreferenceView.swift new file mode 100644 index 0000000..0563bf9 --- /dev/null +++ b/Werkout_ios/subview/ThotPreferenceView.swift @@ -0,0 +1,57 @@ +// +// ThosPreferenceView.swift +// Werkout_ios +// +// Created by Trey Tartt on 6/16/24. +// + +import SwiftUI + +struct ThotPreferenceView: View { + @ObservedObject var userStore = UserStore.shared + @AppStorage(Constants.phoneThotStyle) private var phoneThotStyle: ThotStyle = .never + @AppStorage(Constants.extThotStyle) private var extThotStyle: ThotStyle = .never + @AppStorage(Constants.thotGenderOption) private var thotGenderOption: String = "female" + + var body: some View { + 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) + } + } + } + } +} + +#Preview { + ThotPreferenceView() +}