Screen layout positioning in Swift

Hello everyone,

I’m just trying to position these times and check boxes side by side as shown in the attachment. So far no matter what I try, it only lists. There are more fixed times for example 10:00am all the way to 6:30pm. The user picks the times that they are NOT available. This is a sample of the code below. The check boxes work fine, it’s just the screen layout I’m having issues with.

Any advice will be appreciated.

.....................................

import SwiftUI

struct ContentView: View {

@State private var wakeup = Date.now

@State private var isCheckedOption900 = false

@State private var isCheckedOption930 = false

var body: some View {

Text("Select unavailable Dates/Times")

      

DatePicker("Please enter a date", selection: $wakeup)

    .labelsHidden()

   }


    Form{

        Section("Enter Blockout times") {
         

            Toggle(isOn: $isCheckedOption900) {

                Text("9:00am")

             }

        .toggleStyle(CheckboxToggleStyle())

             
            Toggle(isOn: $isCheckedOption930) {

                Text("9:30am")

            

}

            .toggleStyle(CheckboxToggleStyle())

           }

something went wrong with formatting the code in your post, so it is a difficult to reproduce. I'm not sure what you're trying to get at here - you can wrap the two check boxes in an HStack, they will then appear side by side

HStack {
  Toggle(isOn: $isCheckedOption900) {
   Text("9:00am")
  }
  .toggleStyle(CheckboxToggleStyle())
                    
Toggle(isOn: $isCheckedOption930) {
   Text("9:30am")
 }
}

Please, when you post code, say for which platform (your code doesn't work on iOS).

If you have check boxes for every half hour from 9am till 6:30pm, they're probably not going to fit across one screen anyway, if you don't want a fixed-size window, maybe you want to think about using some other container.

Screen layout positioning in Swift
 
 
Q