Advertisement
Guest User

Untitled

a guest
Aug 28th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. import SwiftUI
  2.  
  3.  
  4. struct PlusWorkoutView: View {
  5.  
  6. @State var addToCategoryPicker: String = ""
  7. @State var categories: [String] = ["Warmup", "Workout", "Cooldown", "Plyometric", "Stretch"]
  8. @State var workoutImage: String = "add_workout"
  9. @State var selectedWorkout: Bool = false
  10. @State var showAddCategorySheet: Bool = false
  11. @State var showWorkoutSheet: Bool = false
  12.  
  13. var body: some View {
  14. NavigationView {
  15. VStack {
  16. HStack {
  17.  
  18. Text("Category:").foregroundColor(.black)
  19. .bold()
  20. .padding(.leading, 10)
  21.  
  22. Picker(selection: $addToCategoryPicker) {
  23. ForEach(categories, id: \.self) { category in
  24. Text(category)
  25. .tag(category)
  26. }
  27. } label: {
  28. Text("Categories")
  29. }
  30.  
  31. Spacer()
  32.  
  33. Button {
  34. showAddCategorySheet.toggle()
  35. } label: {
  36. Text("Add a category")
  37. .foregroundColor(.black)
  38. .bold()
  39. .padding(10)
  40. .background(.gray)
  41. .cornerRadius(10)
  42. .padding(.trailing, 10)
  43. }
  44.  
  45.  
  46. }
  47. .sheet(isPresented: $showAddCategorySheet) {
  48. AddCategory(categories: $categories)
  49. }
  50. Button {
  51. showWorkoutSheet.toggle()
  52. } label: {
  53. if selectedWorkout {
  54.  
  55. Button("Change Workout") {
  56. showWorkoutSheet.toggle()
  57. }
  58.  
  59. Image(workoutImage)
  60. } else {
  61. Image(workoutImage)
  62. .resizable()
  63. .scaledToFit()
  64. .frame(width: 250, height: 250, alignment: .center)
  65. }
  66.  
  67. }
  68.  
  69. }
  70. .fullScreenCover(isPresented: $showWorkoutSheet, content: {
  71. AddWorkoutSheet()
  72. })
  73. .navigationTitle("Add a Workout")
  74. }
  75. }
  76. }
  77.  
  78.  
  79. struct PlusWorkoutView_Previews: PreviewProvider {
  80. static var previews: some View {
  81. PlusWorkoutView()
  82. }
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement