Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/verify-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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: 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'
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
100 changes: 100 additions & 0 deletions PiliPod/Components/VideoDetailTabPanGesture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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 {
// 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 {
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
}

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
}
}
}
76 changes: 76 additions & 0 deletions PiliPod/Components/VideoTripleLikePressGesture.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
8 changes: 8 additions & 0 deletions PiliPod/PiliPodApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Loading