[ad_1]
I’ve a segmentedControl (Picker) with two segments:
struct Container: View {
@State personal var selectedSegment: Section = .sequence
var physique: some View {
VStack {
Picker("", choice: $selectedSegment) {
ForEach(Section.allCases, id: .self) {
Textual content($0.rawValue)
}
}
.pickerStyle(.segmented)
.padding()
Spacer()
SegmentView(phase: selectedSegment)
Spacer()
}
}
}
struct SegmentView: View {
var phase: Section
var physique: some View {
swap phase {
case .first:
FirstView()
case .options:
FeaturesView()
}
}
}
In one of many segments I present a listing:
struct FeaturesView: View {
personal var options: [Feature]
var physique: some View {
VStack {
Record(options) { function in
FeatureRow(function: function)
.onTapGesture {
// swap to different phase and move in `function`
}
}
.listStyle(PlainListStyle())
}
}
}
What I’m making an attempt to do is when the consumer faucets on one of many rows, swap to FirstView and move within the function.
How do I do that is SwiftUI ?
Perhaps through the use of a Notification ?
[ad_2]
