0

I have a simple view in swiftui

struct AddTodoView: View {

  // MARK: - PROPERTIES

  @Environment(\.presentationMode) var presentationMode

  @State private var name: String = ""
  @State private var priority: String = "Normal"

  let priorities = ["High", "Normal", "Low"]

  var body: some View {
    NavigationView {
        
        VStack {
            Form {
                // MARK: - TODO NAME
                TextField("Todo", text: $name)
                
                // MARK: - TODO PRIORITY
                Picker("Priority", selection: $priority) {
                    ForEach(priorities, id: \.self) {
                        Text($0)
                    }
                }.pickerStyle(SegmentedPickerStyle())
                // MARK: - SAVE BUTTON
                Button(action: {
                    print("save a new todo item")
                }) {
                    Text("Save")
                }
                
            } //: FORM
            Spacer()
        } //: VSTACK
        
        
        
        .navigationBarTitle("New Todo", displayMode: .inline)
        .navigationBarItems(trailing:
                                Button(action: {
            self.presentationMode.wrappedValue.dismiss()
        }) {
            Image(systemName: "xmark")
        }
        )
        
    } // : NAVIGATION
  }
}

looks like normal, but I am experimenting a visual issue I have a extra space in the left and right side as in the image

enter image description here

I would like to get without these spaces

flanker
  • 3,840
  • 1
  • 12
  • 20
aws will
  • 45
  • 1
  • 5

1 Answers1

1

you may replace Form with List, and you will get the same behavior.

by default you have the option .listStyle(.insetGrouped) but you can check with this option, you must get the expected result

List { }
.listStyle(.grouped)
Camilo Andres
  • 196
  • 1
  • 12