From 7f8f347db6fa18a9f4e2c9b385f2a190841cd213 Mon Sep 17 00:00:00 2001 From: Anton Yarmolenko Date: Thu, 21 Nov 2024 16:58:44 +0100 Subject: [PATCH] fix: iOS 18 Toggle tap gesture (#98) * fix: added priority for toggle tap gesture * fix: fixed tap and drag actions for Toggle --------- Co-authored-by: Anton Yarmolenko <37253+rnr@users.noreply.github.com> --- .../CourseVideoDownloadBarView.swift | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarView.swift b/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarView.swift index 8af9257e4..fa41436a1 100644 --- a/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarView.swift +++ b/Course/Course/Presentation/Subviews/CourseVideoDownloadBarView/CourseVideoDownloadBarView.swift @@ -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() } + } }