I have an app written using SwiftUI that uses a ZStack with a DragGesture handler. That handler doesn't get called on some phones on some versions of iOS. For example, iPhone 10, 12 & se work as I expect on iOS 15.x, but on iPhone 12 on iOS 16.3.1 & iPhone 13 on iOS 16.5, the gesture handler is not called. I've used .onEnded & .updating, but the problem persists. Code is as follows
ZStack {
Color.detailScreenBackground
.ignoresSafeArea()
VStack(spacing: 20) {
viewModel.image()
.resizable()
.scaledToFit()
.frame(width: 88, height: 88)
.clipShape(Circle())
.overlay(Circle().stroke(Color.gray))
.padding(.top)
Text(viewModel.name)
.font(.system(size: 40))
.fontWeight(.semibold)
viewModel.connectionStateView()
VStack(alignment: .leading, spacing: 20) {
HStack {
Text("Model")
Spacer()
Text(viewModel.model)
}
.padding([.leading, .top, .trailing])
Divider()
HStack {
Text("Serial number")
Spacer()
Text(viewModel.serialNumber)
}
.padding([.leading, .bottom, .trailing])
}
.background(Color.white)
.cornerRadius(cornerRadius)
VStack(alignment: .leading, spacing: 10) {
firmwareView()
.background(Color.white)
.cornerRadius(cornerRadius)
Text(viewModel.webPortalInstructionText)
.font(.caption)
.padding(.leading)
}
Button(action: {
router.push {
DeviceSettingsViewFactory().viewFor(lock: viewModel.lock, tenantLogicController: tenantLogicController, router: router)
}
}) {
HStack {
Text(viewModel.settingsText)
.padding()
Spacer()
DisclosureIndicatorView()
.padding()
}
}
.background(Color.white)
.cornerRadius(cornerRadius)
.disabled(viewModel.connectionState != .connected || settingsTapped )
.foregroundColor(viewModel.connectionState == .connected ? .text : .disabledGray)
Spacer()
syncButtonView(lock: viewModel.lock)
}
.padding([.leading, .trailing])
}
.gesture(DragGesture(minimumDistance: 200, coordinateSpace: .global)
.updating($dragOffset, body: { value, _, _ in
// Swipe right
if value.location.x > value.startLocation.x {
disconnectAndGoBack()
}
}))
Am I doing something fundamentally wrong?
Thanks