Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- struct PlusWorkoutView: View {
- @State var addToCategoryPicker: String = ""
- @State var categories: [String] = ["Warmup", "Workout", "Cooldown", "Plyometric", "Stretch"]
- @State var workoutImage: String = "add_workout"
- @State var selectedWorkout: Bool = false
- @State var showAddCategorySheet: Bool = false
- @State var showWorkoutSheet: Bool = false
- var body: some View {
- NavigationView {
- VStack {
- HStack {
- Text("Category:").foregroundColor(.black)
- .bold()
- .padding(.leading, 10)
- Picker(selection: $addToCategoryPicker) {
- ForEach(categories, id: \.self) { category in
- Text(category)
- .tag(category)
- }
- } label: {
- Text("Categories")
- }
- Spacer()
- Button {
- showAddCategorySheet.toggle()
- } label: {
- Text("Add a category")
- .foregroundColor(.black)
- .bold()
- .padding(10)
- .background(.gray)
- .cornerRadius(10)
- .padding(.trailing, 10)
- }
- }
- .sheet(isPresented: $showAddCategorySheet) {
- AddCategory(categories: $categories)
- }
- Button {
- showWorkoutSheet.toggle()
- } label: {
- if selectedWorkout {
- Button("Change Workout") {
- showWorkoutSheet.toggle()
- }
- Image(workoutImage)
- } else {
- Image(workoutImage)
- .resizable()
- .scaledToFit()
- .frame(width: 250, height: 250, alignment: .center)
- }
- }
- }
- .fullScreenCover(isPresented: $showWorkoutSheet, content: {
- AddWorkoutSheet()
- })
- .navigationTitle("Add a Workout")
- }
- }
- }
- struct PlusWorkoutView_Previews: PreviewProvider {
- static var previews: some View {
- PlusWorkoutView()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement