From 2a19a48b733c8cf23373488a7543aaca3e554bd6 Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Sat, 3 Oct 2026 15:13:06 +0800 Subject: [PATCH 1/6] fix: coordinate video detail tab pan with native back navigation --- .github/workflows/verify-ios.yml | 27 +++++ .../Components/VideoDetailTabPanGesture.swift | 106 ++++++++++++++++++ .../Views/VideoDetail/VideoDetailPage.swift | 40 +++---- 3 files changed, 150 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/verify-ios.yml create mode 100644 PiliPod/Components/VideoDetailTabPanGesture.swift diff --git a/.github/workflows/verify-ios.yml b/.github/workflows/verify-ios.yml new file mode 100644 index 0000000..924dc54 --- /dev/null +++ b/.github/workflows/verify-ios.yml @@ -0,0 +1,27 @@ +name: Verify iOS build + +on: + push: + branches: ['codex/video-detail-back-gesture'] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '26.6' + - name: Build for iOS Simulator + run: >- + xcodebuild build + -project PiliPod.xcodeproj + -scheme PiliPod + -configuration Debug + -destination 'generic/platform=iOS Simulator' + CODE_SIGNING_ALLOWED=NO diff --git a/PiliPod/Components/VideoDetailTabPanGesture.swift b/PiliPod/Components/VideoDetailTabPanGesture.swift new file mode 100644 index 0000000..8e9ce38 --- /dev/null +++ b/PiliPod/Components/VideoDetailTabPanGesture.swift @@ -0,0 +1,106 @@ +import SwiftUI +import UIKit + +/// Directional tab paging that yields unrelated drags to scrolling and navigation. +struct VideoDetailTabPanGesture: UIGestureRecognizerRepresentable { + let isEnabled: Bool + let isIntro: Bool + let leadingExclusionWidth: CGFloat + let onChanged: (CGFloat) -> Void + let onEnded: (CGFloat?) -> Void + + func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { + Coordinator(gesture: self, converter: converter) + } + + func makeUIGestureRecognizer(context: Context) -> UIPanGestureRecognizer { + let recognizer = UIPanGestureRecognizer() + recognizer.maximumNumberOfTouches = 1 + recognizer.delegate = context.coordinator + return recognizer + } + + func updateUIGestureRecognizer(_ recognizer: UIPanGestureRecognizer, context: Context) { + context.coordinator.gesture = self + context.coordinator.converter = context.converter + recognizer.isEnabled = isEnabled + } + + func handleUIGestureRecognizerAction(_ recognizer: UIPanGestureRecognizer, context: Context) { + let translation = context.converter.localTranslation?.x ?? recognizer.translation(in: recognizer.view).x + switch recognizer.state { + case .began, .changed: + onChanged(translation) + case .ended: + onEnded(translation) + case .cancelled, .failed: + onEnded(nil) + default: + break + } + } + + final class Coordinator: NSObject, UIGestureRecognizerDelegate { + var gesture: VideoDetailTabPanGesture + var converter: CoordinateSpaceConverter + + init(gesture: VideoDetailTabPanGesture, converter: CoordinateSpaceConverter) { + self.gesture = gesture + self.converter = converter + } + + func gestureRecognizer(_ recognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { + // Check the actual touch-down position, before the pan moves. + gesture.isEnabled && converter.localLocation.x > gesture.leadingExclusionWidth + } + + func gestureRecognizerShouldBegin(_ recognizer: UIGestureRecognizer) -> Bool { + guard gesture.isEnabled, let pan = recognizer as? UIPanGestureRecognizer else { return false } + let velocity = pan.velocity(in: pan.view) + guard abs(velocity.x) > abs(velocity.y) else { return false } + // In the intro, a rightward pan belongs to native back navigation. + return gesture.isIntro ? velocity.x < 0 : velocity.x > 0 + } + + func gestureRecognizer( + _ recognizer: UIGestureRecognizer, + shouldRecognizeSimultaneouslyWith other: UIGestureRecognizer + ) -> Bool { + // Vertical scrolling remains responsive while UIKit decides direction. + guard let scrollView = other.view as? UIScrollView else { return false } + return other === scrollView.panGestureRecognizer + } + + func gestureRecognizer( + _ recognizer: UIGestureRecognizer, + shouldBeRequiredToFailBy other: UIGestureRecognizer + ) -> Bool { + // Content-back waits for this directional pan to fail. On the intro + // a rightward pan fails immediately; on comments it pages to intro. + guard #available(iOS 26.0, *), let navigation = navigationController(for: recognizer.view) else { + return false + } + return other === navigation.interactiveContentPopGestureRecognizer + } + + func gestureRecognizer( + _ recognizer: UIGestureRecognizer, + shouldRequireFailureOf other: UIGestureRecognizer + ) -> Bool { + guard let navigation = navigationController(for: recognizer.view) else { return false } + return other === navigation.interactivePopGestureRecognizer + } + + private func navigationController(for view: UIView?) -> UINavigationController? { + var responder: UIResponder? = view + while let current = responder { + if let controller = current as? UIViewController, + let navigation = controller.navigationController { + return navigation + } + responder = current.next + } + return nil + } + } +} diff --git a/PiliPod/Views/VideoDetail/VideoDetailPage.swift b/PiliPod/Views/VideoDetail/VideoDetailPage.swift index 722b461..af1d057 100644 --- a/PiliPod/Views/VideoDetail/VideoDetailPage.swift +++ b/PiliPod/Views/VideoDetail/VideoDetailPage.swift @@ -1987,7 +1987,7 @@ private struct TabPager: View { @ViewBuilder let introContent: () -> IntroContent @ViewBuilder let commentsContent: () -> CommentsContent - @GestureState private var dragTranslation: CGFloat = 0 + @State private var dragTranslation: CGFloat = 0 private var currentIndex: CGFloat { switch selectedTab { @@ -2008,14 +2008,13 @@ private struct TabPager: View { .frame(width: width) .frame(maxHeight: .infinity, alignment: .top) } + .offset(x: -currentIndex * width + dragOffset) .frame(width: width, alignment: .leading) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) - .offset(x: -currentIndex * width + dragOffset) .animation(.interactiveSpring(response: 0.32, dampingFraction: 0.86), value: selectedTab) .contentShape(Rectangle()) - // A transparent overlay here would intercept ScrollView and button - // touches. Keep the pager gesture simultaneous with the content - // instead, and leave the edge strip inert in the gesture callbacks. + // Reject unrelated pans before recognition, rather than ignoring their + // callbacks after a SwiftUI DragGesture has already claimed the touch. .simultaneousGesture(pagerGesture) .clipped() } @@ -2025,27 +2024,21 @@ private struct TabPager: View { return dragTranslation } - private var pagerGesture: some Gesture { - DragGesture(minimumDistance: 12) - .updating($dragTranslation) { value, state, _ in - guard isSwipeEnabled else { return } - guard value.startLocation.x > leadingSwipeExclusionWidth else { return } - guard abs(value.translation.width) > abs(value.translation.height) else { return } - - let translation = value.translation.width + private var pagerGesture: VideoDetailTabPanGesture { + VideoDetailTabPanGesture( + isEnabled: isSwipeEnabled, + isIntro: selectedTab == .intro, + leadingExclusionWidth: leadingSwipeExclusionWidth, + onChanged: { translation in if selectedTab == .intro { - state = max(-width, min(0, translation)) + dragTranslation = max(-width, min(0, translation)) } else { - state = max(0, min(width, translation)) + dragTranslation = max(0, min(width, translation)) } - } - .onEnded { value in - guard isSwipeEnabled else { return } - guard value.startLocation.x > leadingSwipeExclusionWidth else { return } - let dx = value.translation.width - let dy = value.translation.height - guard abs(dx) > abs(dy) else { return } - + }, + onEnded: { dx in + defer { dragTranslation = 0 } + guard isSwipeEnabled, let dx else { return } let threshold = width * 0.2 switch selectedTab { case .intro: @@ -2056,6 +2049,7 @@ private struct TabPager: View { selectedTab = .intro } } + ) } } From 5031064d4f6909c0b88b0741ef09812a2205c53d Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Sat, 3 Oct 2026 15:19:19 +0800 Subject: [PATCH 2/6] fix: attach UIKit tab recognizer through supported SwiftUI gesture API --- PiliPod/Views/VideoDetail/VideoDetailPage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PiliPod/Views/VideoDetail/VideoDetailPage.swift b/PiliPod/Views/VideoDetail/VideoDetailPage.swift index af1d057..5a33eea 100644 --- a/PiliPod/Views/VideoDetail/VideoDetailPage.swift +++ b/PiliPod/Views/VideoDetail/VideoDetailPage.swift @@ -2015,7 +2015,7 @@ private struct TabPager: View { .contentShape(Rectangle()) // Reject unrelated pans before recognition, rather than ignoring their // callbacks after a SwiftUI DragGesture has already claimed the touch. - .simultaneousGesture(pagerGesture) + .gesture(pagerGesture) .clipped() } From 8bdb7c5860d2e016f84fce878225b5162d786c8c Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Sat, 3 Oct 2026 15:29:50 +0800 Subject: [PATCH 3/6] ci: upload unsigned IPA for back gesture verification --- .github/workflows/verify-ios.yml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/verify-ios.yml b/.github/workflows/verify-ios.yml index 924dc54..d14f6a8 100644 --- a/.github/workflows/verify-ios.yml +++ b/.github/workflows/verify-ios.yml @@ -25,3 +25,37 @@ jobs: -configuration Debug -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO + + ipa: + if: github.ref == 'refs/heads/codex/video-detail-back-gesture' + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '26.6' + - name: Archive unsigned iOS app + run: >- + xcodebuild archive + -project PiliPod.xcodeproj + -scheme PiliPod + -configuration Release + -destination 'generic/platform=iOS' + -archivePath build/PiliPod.xcarchive + CODE_SIGNING_ALLOWED=NO + CODE_SIGNING_REQUIRED=NO + CODE_SIGN_IDENTITY="" + PROVISIONING_PROFILE_SPECIFIER="" + - name: Package IPA + run: | + mkdir -p build/Payload + cp -R build/PiliPod.xcarchive/Products/Applications/PiliPod.app build/Payload/ + cd build + zip -qr PiliPod-back-gesture.ipa Payload + - name: Upload IPA + uses: actions/upload-artifact@v4 + with: + name: PiliPod-back-gesture-unsigned-IPA + path: build/PiliPod-back-gesture.ipa + retention-days: 14 + if-no-files-found: error From 30924cf7a989ec3d24970c56871522c58d4a1499 Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Sat, 3 Oct 2026 16:04:26 +0800 Subject: [PATCH 4/6] fix: let like button holds yield to edge navigation and scrolling --- .../VideoTripleLikePressGesture.swift | 76 +++++++++++++++++++ .../Views/VideoDetail/VideoDetailPage.swift | 50 ++++++------ 2 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 PiliPod/Components/VideoTripleLikePressGesture.swift diff --git a/PiliPod/Components/VideoTripleLikePressGesture.swift b/PiliPod/Components/VideoTripleLikePressGesture.swift new file mode 100644 index 0000000..850bdfb --- /dev/null +++ b/PiliPod/Components/VideoTripleLikePressGesture.swift @@ -0,0 +1,76 @@ +import SwiftUI +import UIKit + +/// A stationary hold, rather than a zero-distance drag that competes with pans. +struct VideoTripleLikePressGesture: UIGestureRecognizerRepresentable { + let isEnabled: Bool + let onStarted: () -> Void + let onFinished: () -> Void + + func makeCoordinator(converter: CoordinateSpaceConverter) -> Coordinator { + Coordinator(gesture: self) + } + + func makeUIGestureRecognizer(context: Context) -> UILongPressGestureRecognizer { + let recognizer = UILongPressGestureRecognizer() + recognizer.minimumPressDuration = 0.5 + recognizer.allowableMovement = 10 + recognizer.numberOfTouchesRequired = 1 + recognizer.delegate = context.coordinator + return recognizer + } + + func updateUIGestureRecognizer(_ recognizer: UILongPressGestureRecognizer, context: Context) { + context.coordinator.gesture = self + recognizer.isEnabled = isEnabled + } + + func handleUIGestureRecognizerAction(_ recognizer: UILongPressGestureRecognizer, context: Context) { + let coordinator = context.coordinator + switch recognizer.state { + case .began: + coordinator.isHolding = true + onStarted() + case .changed: + // UIKit's allowableMovement guards recognition. Also cancel movement + // during charging, using window coordinates unaffected by animation. + guard let start = coordinator.startLocation else { return } + let location = recognizer.location(in: recognizer.view?.window) + if hypot(location.x - start.x, location.y - start.y) > recognizer.allowableMovement { + coordinator.finish() + recognizer.isEnabled = false + recognizer.isEnabled = isEnabled + } + case .ended, .cancelled, .failed: + coordinator.finish() + default: + break + } + } + + final class Coordinator: NSObject, UIGestureRecognizerDelegate { + var gesture: VideoTripleLikePressGesture + var startLocation: CGPoint? + var isHolding = false + + init(gesture: VideoTripleLikePressGesture) { + self.gesture = gesture + } + + func gestureRecognizer(_ recognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { + guard gesture.isEnabled, let window = touch.window else { return false } + let location = touch.location(in: window) + // Reserve both physical edges for system navigation gestures. + guard location.x > window.bounds.minX + 32, + location.x < window.bounds.maxX - 32 else { return false } + startLocation = location + return true + } + + func finish() { + guard isHolding else { return } + isHolding = false + gesture.onFinished() + } + } +} diff --git a/PiliPod/Views/VideoDetail/VideoDetailPage.swift b/PiliPod/Views/VideoDetail/VideoDetailPage.swift index 5a33eea..b54a925 100644 --- a/PiliPod/Views/VideoDetail/VideoDetailPage.swift +++ b/PiliPod/Views/VideoDetail/VideoDetailPage.swift @@ -2218,18 +2218,15 @@ struct VideoActionBar: View { let pressID = UUID() activeTriplePressID = pressID isTripleTouching = true - hasTripleChargeStarted = false + hasTripleCompleted = false + hasTripleChargeStarted = true + isTripleCharging = true + withAnimation(.easeIn(duration: 1.4)) { + tripleChargeProgress = 1 + } + tripleChargeHaptics.start() triplePressTask = Task { @MainActor in - guard await waitForTriplePress(milliseconds: 500) else { return } - guard isTripleTouching, activeTriplePressID == pressID else { return } - - hasTripleChargeStarted = true - isTripleCharging = true - withAnimation(.easeIn(duration: 1.4)) { - tripleChargeProgress = 1 - } - tripleChargeHaptics.start() - + // UIKit already recognized a stationary 0.5-second long press. guard await waitForTriplePress(milliseconds: 1_400) else { return } guard isTripleTouching, activeTriplePressID == pressID else { return } @@ -2268,7 +2265,6 @@ struct VideoActionBar: View { return } - let shouldHandleAsTap = !hasTripleChargeStarted let shouldRestore = hasTripleChargeStarted && !hasTripleCompleted isTripleTouching = false @@ -2290,10 +2286,6 @@ struct VideoActionBar: View { tripleCompletionScale = 1 } } - - if shouldHandleAsTap { - onToggleLike() - } } private func cancelTriplePress() { @@ -2302,6 +2294,12 @@ struct VideoActionBar: View { triplePressTask?.cancel() triplePressTask = nil tripleChargeHaptics.stop() + isTripleCharging = false + isTripleCompletionAnimating = false + hasTripleChargeStarted = false + hasTripleCompleted = false + tripleChargeProgress = 0 + tripleCompletionScale = 1 } private func requestTripleLike() { @@ -2379,17 +2377,15 @@ private struct VideoTripleLikeButton: View { completionScale: completionScale ) ) - .gesture( - DragGesture(minimumDistance: 0) - .onChanged { _ in - guard !isDisabled else { return } - onPressStarted() - } - .onEnded { _ in - guard !isDisabled else { return } - onPressEnded() - } - ) + .onTapGesture { + guard !isDisabled else { return } + onTap() + } + .gesture(VideoTripleLikePressGesture( + isEnabled: !isDisabled, + onStarted: onPressStarted, + onFinished: onPressEnded + )) .opacity(isDisabled ? 0.6 : 1) } } From d7084d02aba76891808a049e71f6659a1cec5228 Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Sat, 3 Oct 2026 16:33:15 +0800 Subject: [PATCH 5/6] fix: unblock detail tab paging and exercise native gestures in UI tests --- .github/workflows/verify-ios.yml | 36 ++++++++--- .../Components/VideoDetailTabPanGesture.swift | 14 ++--- PiliPod/PiliPodApp.swift | 8 +++ .../Views/VideoDetail/VideoDetailPage.swift | 61 +++++++++++++++++++ .../VideoDetailGestureUITests.swift | 52 ++++++++++++++++ 5 files changed, 153 insertions(+), 18 deletions(-) create mode 100644 PiliPodUITests/VideoDetailGestureUITests.swift diff --git a/.github/workflows/verify-ios.yml b/.github/workflows/verify-ios.yml index d14f6a8..4ec277a 100644 --- a/.github/workflows/verify-ios.yml +++ b/.github/workflows/verify-ios.yml @@ -17,14 +17,34 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: '26.6' - - name: Build for iOS Simulator - run: >- - xcodebuild build - -project PiliPod.xcodeproj - -scheme PiliPod - -configuration Debug - -destination 'generic/platform=iOS Simulator' - CODE_SIGNING_ALLOWED=NO + - name: Test detail gestures on iOS Simulator + run: | + SIMULATOR_ID=$(xcrun simctl list devices available -j | python3 -c ' + import json, sys + devices = json.load(sys.stdin)["devices"] + for runtime in sorted(devices, reverse=True): + if "iOS" in runtime: + for device in devices[runtime]: + if device["name"].startswith("iPhone"): + print(device["udid"]) + sys.exit(0) + sys.exit("No available iPhone simulator")') + xcodebuild test \ + -project PiliPod.xcodeproj \ + -scheme PiliPod \ + -configuration Debug \ + -destination "platform=iOS Simulator,id=$SIMULATOR_ID" \ + -only-testing:PiliPodUITests/VideoDetailGestureUITests \ + -parallel-testing-enabled NO \ + -resultBundlePath build/GestureTests.xcresult \ + CODE_SIGNING_ALLOWED=NO + - name: Upload gesture test results + if: always() + uses: actions/upload-artifact@v4 + with: + name: Video-detail-gesture-test-results + path: build/GestureTests.xcresult + retention-days: 14 ipa: if: github.ref == 'refs/heads/codex/video-detail-back-gesture' diff --git a/PiliPod/Components/VideoDetailTabPanGesture.swift b/PiliPod/Components/VideoDetailTabPanGesture.swift index 8e9ce38..8171e4c 100644 --- a/PiliPod/Components/VideoDetailTabPanGesture.swift +++ b/PiliPod/Components/VideoDetailTabPanGesture.swift @@ -50,8 +50,10 @@ struct VideoDetailTabPanGesture: UIGestureRecognizerRepresentable { } func gestureRecognizer(_ recognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { - // Check the actual touch-down position, before the pan moves. - gesture.isEnabled && converter.localLocation.x > gesture.leadingExclusionWidth + // Use the touch itself: the converter's current location need not + // have been updated when UIKit asks whether to receive a new touch. + guard gesture.isEnabled, let window = touch.window else { return false } + return touch.location(in: window).x > window.bounds.minX + gesture.leadingExclusionWidth } func gestureRecognizerShouldBegin(_ recognizer: UIGestureRecognizer) -> Bool { @@ -83,14 +85,6 @@ struct VideoDetailTabPanGesture: UIGestureRecognizerRepresentable { return other === navigation.interactiveContentPopGestureRecognizer } - func gestureRecognizer( - _ recognizer: UIGestureRecognizer, - shouldRequireFailureOf other: UIGestureRecognizer - ) -> Bool { - guard let navigation = navigationController(for: recognizer.view) else { return false } - return other === navigation.interactivePopGestureRecognizer - } - private func navigationController(for view: UIView?) -> UINavigationController? { var responder: UIResponder? = view while let current = responder { diff --git a/PiliPod/PiliPodApp.swift b/PiliPod/PiliPodApp.swift index b9d2c50..91d1532 100644 --- a/PiliPod/PiliPodApp.swift +++ b/PiliPod/PiliPodApp.swift @@ -65,7 +65,15 @@ struct PiliPodApp: App { var body: some Scene { WindowGroup { +#if DEBUG + if ProcessInfo.processInfo.arguments.contains("--uitest-video-detail-gestures") { + VideoDetailGestureTestRoot() + } else { + MainTabView() + } +#else MainTabView() +#endif } } } diff --git a/PiliPod/Views/VideoDetail/VideoDetailPage.swift b/PiliPod/Views/VideoDetail/VideoDetailPage.swift index b54a925..ca2ba95 100644 --- a/PiliPod/Views/VideoDetail/VideoDetailPage.swift +++ b/PiliPod/Views/VideoDetail/VideoDetailPage.swift @@ -2053,6 +2053,67 @@ private struct TabPager: View { } } +#if DEBUG +/// Network-free UI test surface using the production pager and navigation setup. +struct VideoDetailGestureTestRoot: View { + @State private var isPresented = false + @Namespace private var namespace + + var body: some View { + NavigationStack { + Button("Open detail") { isPresented = true } + .accessibilityIdentifier("gesture.open") + .matchedTransitionSource(id: "gesture.detail", in: namespace) + .navigationDestination(isPresented: $isPresented) { + VideoDetailGestureTestContent() + .navigationTransition(.zoom(sourceID: "gesture.detail", in: namespace)) + } + } + } +} + +private struct VideoDetailGestureTestContent: View { + @State private var selectedTab: VideoDetailPage.VideoDetailTab = .intro + + var body: some View { + GeometryReader { geometry in + VStack(spacing: 0) { + Color.black.frame(height: 160) + Text(selectedTab.rawValue) + .accessibilityIdentifier(selectedTab == .intro ? "gesture.tab.intro" : "gesture.tab.comments") + .frame(height: 44) + TabPager( + selectedTab: $selectedTab, + width: geometry.size.width, + isSwipeEnabled: true, + leadingSwipeExclusionWidth: 32, + introContent: { + ScrollView { + VStack { + ForEach(0..<80) { index in + Text("Intro row \(index)") + .frame(maxWidth: .infinity, minHeight: 48) + .accessibilityIdentifier("gesture.intro.\(index)") + } + } + } + }, + commentsContent: { + List(0..<80, id: \.self) { index in + Text("Comment row \(index)") + } + .listStyle(.plain) + } + ) + } + } + .background(NavigationPopGestureEnabler()) + .navigationBarBackButtonHidden(true) + .toolbar(.hidden, for: .navigationBar) + } +} +#endif + #if canImport(UIKit) struct SystemVolumeController { private let volumeView: MPVolumeView diff --git a/PiliPodUITests/VideoDetailGestureUITests.swift b/PiliPodUITests/VideoDetailGestureUITests.swift new file mode 100644 index 0000000..6ece461 --- /dev/null +++ b/PiliPodUITests/VideoDetailGestureUITests.swift @@ -0,0 +1,52 @@ +import XCTest + +final class VideoDetailGestureUITests: XCTestCase { + override func setUpWithError() throws { + continueAfterFailure = false + } + + @MainActor + private func openDetail() -> XCUIApplication { + let app = XCUIApplication() + app.launchArguments = ["--uitest-video-detail-gestures"] + app.launch() + app.buttons["gesture.open"].tap() + XCTAssertTrue(app.staticTexts["gesture.tab.intro"].waitForExistence(timeout: 5)) + return app + } + + @MainActor + func testTabSwipesAndContentBack() { + let app = openDetail() + let left = app.coordinate(withNormalizedOffset: CGVector(dx: 0.15, dy: 0.65)) + let right = app.coordinate(withNormalizedOffset: CGVector(dx: 0.85, dy: 0.65)) + right.press(forDuration: 0.05, thenDragTo: left) + XCTAssertTrue(app.staticTexts["gesture.tab.comments"].waitForExistence(timeout: 5)) + left.press(forDuration: 0.05, thenDragTo: right) + XCTAssertTrue(app.staticTexts["gesture.tab.intro"].waitForExistence(timeout: 5)) + let backStart = app.coordinate(withNormalizedOffset: CGVector(dx: 0.25, dy: 0.65)) + let backEnd = app.coordinate(withNormalizedOffset: CGVector(dx: 0.95, dy: 0.68)) + backStart.press(forDuration: 0.05, thenDragTo: backEnd) + XCTAssertTrue(app.buttons["gesture.open"].waitForExistence(timeout: 5)) + XCTAssertFalse(app.staticTexts["gesture.tab.intro"].exists) + } + + @MainActor + func testEdgeBack() { + let app = openDetail() + let start = app.coordinate(withNormalizedOffset: CGVector(dx: 0.01, dy: 0.65)) + let end = app.coordinate(withNormalizedOffset: CGVector(dx: 0.9, dy: 0.65)) + start.press(forDuration: 0.05, thenDragTo: end) + XCTAssertTrue(app.buttons["gesture.open"].waitForExistence(timeout: 5)) + XCTAssertFalse(app.staticTexts["gesture.tab.intro"].exists) + } + + @MainActor + func testVerticalScrollDoesNotSwitchTabs() { + let app = openDetail() + XCTAssertTrue(app.staticTexts["gesture.intro.0"].isHittable) + app.swipeUp() + XCTAssertTrue(app.staticTexts["gesture.tab.intro"].exists) + XCTAssertFalse(app.staticTexts["gesture.intro.0"].isHittable) + } +} From 1ab3fad3827a3d7a49de4b0c93aade8afea73fff Mon Sep 17 00:00:00 2001 From: NZJ-Jimmy Date: Mon, 5 Oct 2026 11:40:18 +0800 Subject: [PATCH 6/6] chore: record integration of PR #5 [skip ci]