0

Scenario:

  • I have a simple picker within a form.
  • I select a picker item (with chevron) from the form row.
  • I choose an item (row) from a list of items in the result panel.
  • The result panel slides away to reveal the original panel.
  • I am NOT able to repeat this procedure.

Here's my code:

class ChosenView: ObservableObject {
    static let choices = ["Modal", "PopOver", "Circle", "CircleImage", "Scroll", "Segment", "Tab", "Multi-Line"]
    @Published
    var type = 0
}

struct ContentView: View {
    @ObservedObject var chosenView = ChosenView()
    @State private var isPresented = false

    var body: some View {
        VStack {
            NavigationView {
                Form {
                    Picker(selection: $chosenView.type, label: Text("The Panels")) {
                        ForEach(0..<ChosenView.choices.count) {
                            Text(ChosenView.choices[$0]).tag($0)
                        }
                    }
                }.navigationBarTitle(Text("Available Views"))
                    .actionSheet(isPresented: $isPresented, content: {
                        ActionSheet(title: Text("Hello"))
                    })
            }
            Section {
                Button(action: launchView) {
                    Text("Select: \(ChosenView.choices[chosenView.type])")
                }
            }
            Spacer()
        }
    }

    private func launchView() {
        isPresented = true
    }
}

enter image description here enter image description here

What am I missing?
Why can't I repeat picker selection rather than having to reboot?

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105

0 Answers0