Skip to content

Commit

Permalink
fix: iOS 18 Toggle tap gesture (#98)
Browse files Browse the repository at this point in the history
* fix: added priority for toggle tap gesture

* fix: fixed tap and drag actions for Toggle

---------

Co-authored-by: Anton Yarmolenko <[email protected]>
  • Loading branch information
rnr and rnr committed Dec 23, 2024
1 parent 1ffadfd commit 7f8f347
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,24 @@ struct CourseVideoDownloadBarView: View {
Toggle("", isOn: .constant(viewModel.isOn))
.toggleStyle(SwitchToggleStyle(tint: Theme.Colors.toggleSwitchColor))
.padding(.trailing, 15)
.onTapGesture {
if !viewModel.isInternetAvaliable {
onNotInternetAvaliable?()
return
.highPriorityGesture(
DragGesture(minimumDistance: 20, coordinateSpace: .local).onEnded { _ in
toggleAction()
}
Task { await viewModel.onToggle() }
}
)
.highPriorityGesture(
TapGesture().onEnded {
toggleAction()
}
)
.accessibilityIdentifier("download_toggle")
}

private func toggleAction() {
if !viewModel.isInternetAvaliable {
onNotInternetAvaliable?()
return
}
Task { await viewModel.onToggle() }
}
}

0 comments on commit 7f8f347

Please sign in to comment.