Можно ли остаться нативным .onTapgesture
для Picker
, поэтому он остается реактивным при нажатии на втором сегменте, но также, например, на изменение var
при изменении выбранного сегмента? Спасибо
import SwiftUI
import CoreLocation
struct MapView: View {
@State private var selectedSegment = 0
@State private var center = false
var body: some View {
ZStack{
VStack{
Picker("", selection: $selectedSegment) {
ForEach(0 ..< locations.count) { index in
Text(self.locations[index].title).tag(index)
}
}
.pickerStyle(SegmentedPickerStyle())
.shadow(radius: 7)
.padding(.init(top: 0, leading: 5, bottom: 0, trailing: 5))
.onTapGesture {
if self.center { //this is the action I need to perform
self.center = false // when selectedSegment changes
}
}