Skip to content

Commit

Permalink
fix: 🐛 simultaneous gesture is not triggered in voice over
Browse files Browse the repository at this point in the history
  • Loading branch information
billzhou0223 committed Sep 25, 2023
1 parent 08d3757 commit e72034f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
31 changes: 7 additions & 24 deletions Sources/FioriSwiftUICore/Utils/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import SwiftUI

extension View {
func onSimultaneousTapGesture(count: Int = 1, perform action: @escaping () -> Void) -> some View {
self.simultaneousGesture(TapGesture(count: count).onEnded {
self.accessibilitySimultaneousGesture(TapGesture(count: count).onEnded {
action()
})
}

// In order to fix an issue where the simultaneous gesture is not activated in voice over.
func accessibilitySimultaneousGesture<T>(_ gesture: T, including mask: GestureMask = .all) -> some View where T: Gesture {
simultaneousGesture(gesture, including: mask)
.accessibilityElement()
}
}

extension View {
Expand All @@ -16,27 +22,4 @@ extension View {
Alert(title: configuration.title, message: configuration.message_, primaryButton: .default(configuration.action.label_, action: configuration.action.didSelect ?? {}), secondaryButton: .cancel(configuration.secondaryAction.label_, action: configuration.secondaryAction.didSelect ?? {}))
}
}

// Cause problem generating xcframework in SAPFiori
// @ViewBuilder
// func alert(configuration: AlertConfiguration, isPresented: Binding<Bool>) -> some View {
// #if swift(>=5.5)
// if #available(iOS 15, macOS 12, *) {
// self.alert(configuration.title, isPresented: isPresented) {
// Button(action: configuration.action.didSelect ?? {}, label: { configuration.action.label })
// Button(role: .cancel, action: configuration.secondaryAction.didSelect ?? {}, label: { configuration.secondaryAction.label })
// } message: {
// configuration.message
// }
// } else {
// self.alert(isPresented: isPresented) {
// Alert(title: configuration.title, message: configuration.message_, primaryButton: .default(configuration.action.label_, action: configuration.action.didSelect ?? {}), secondaryButton: .cancel(configuration.secondaryAction.label_, action: configuration.secondaryAction.didSelect ?? {}))
// }
// }
// #else
// self.alert(isPresented: isPresented) {
// Alert(title: configuration.title, message: configuration.message_, primaryButton: .default(configuration.action.label_, action: configuration.action.didSelect ?? {}), secondaryButton: .cancel(configuration.secondaryAction.label_, action: configuration.secondaryAction.didSelect ?? {}))
// }
// #endif
// }
}
10 changes: 5 additions & 5 deletions Sources/FioriSwiftUICore/Views/SignatureCaptureView+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extension SignatureCaptureView: View {
.padding(.bottom, 11)
Spacer()
cancelAction
.simultaneousGesture(
.accessibilitySimultaneousGesture(
TapGesture()
.onEnded { _ in
clear()
Expand Down Expand Up @@ -140,7 +140,7 @@ extension SignatureCaptureView: View {
if self.isEditing {
HStack {
clearAction
.simultaneousGesture(
.accessibilitySimultaneousGesture(
TapGesture()
.onEnded { _ in
clear()
Expand All @@ -150,7 +150,7 @@ extension SignatureCaptureView: View {
.frame(minWidth: 44, minHeight: 44)
Spacer()
saveAction
.simultaneousGesture(
.accessibilitySimultaneousGesture(
TapGesture()
.onEnded { _ in
isSaved = true
Expand All @@ -162,7 +162,7 @@ extension SignatureCaptureView: View {
.padding(.top, 8)
} else if (_signatureImage != nil && !isReenterTapped) || fullSignatureImage != nil {
restartAction
.simultaneousGesture(
.accessibilitySimultaneousGesture(
TapGesture()
.onEnded { _ in
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
Expand Down Expand Up @@ -209,7 +209,7 @@ extension SignatureCaptureView: View {
ZStack {
Color.preferredColor(.quaternaryFill).cornerRadius(10)
startAction
.simultaneousGesture(
.accessibilitySimultaneousGesture(
TapGesture()
.onEnded { _ in
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
Expand Down

0 comments on commit e72034f

Please sign in to comment.