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
3 changes: 3 additions & 0 deletions Application/App/Sources/App/DevLogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ struct DevLogApp: App {

init() {
AppGraph.shared.preparePresentationDependencies()
#if DEBUG
TouchIndicator.install()
#endif
}

var body: some Scene {
Expand Down
71 changes: 71 additions & 0 deletions Application/App/Sources/App/TouchIndicator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// TouchIndicator.swift
// DevLog
//
// Created by opfic on 11/27/26.
//

#if DEBUG
import ObjectiveC
import UIKit

// 녹화 영상에 터치 위치를 남기는 Debug 빌드 전용 표시
// 실행 인자 `-showsTouches YES`로 켬
enum TouchIndicator {
@MainActor fileprivate static var dots: [ObjectIdentifier: UIView] = [:]

static func install() {
guard UserDefaults.standard.bool(forKey: "showsTouches"),
let original = class_getInstanceMethod(UIWindow.self, #selector(UIWindow.sendEvent(_:))),
let replacement = class_getInstanceMethod(
UIWindow.self,
#selector(UIWindow.touchIndicatorSendEvent(_:))
) else { return }

method_exchangeImplementations(original, replacement)
}
}

private extension UIWindow {
// 구현을 맞바꾼 뒤라 이 호출이 원래 sendEvent 실행
@objc func touchIndicatorSendEvent(_ event: UIEvent) {
touchIndicatorSendEvent(event)
guard event.type == .touches, let touches = event.allTouches else { return }

for touch in touches {
let key = ObjectIdentifier(touch)
let point = touch.location(in: self)

switch touch.phase {
case .began:
let dot = UIView(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
dot.isUserInteractionEnabled = false
dot.layer.cornerRadius = 22
dot.backgroundColor = UIColor.systemGray.withAlphaComponent(0.45)
dot.layer.borderColor = UIColor.white.withAlphaComponent(0.9).cgColor
dot.layer.borderWidth = 2
dot.layer.zPosition = 10_000
dot.center = point
addSubview(dot)
TouchIndicator.dots[key] = dot
case .moved, .stationary:
if let dot = TouchIndicator.dots[key] {
bringSubviewToFront(dot)
dot.center = point
}
case .ended, .cancelled:
if let dot = TouchIndicator.dots.removeValue(forKey: key) {
dot.center = point
UIView.animate(withDuration: 0.35, delay: 0.15) {
dot.alpha = 0
} completion: { _ in
dot.removeFromSuperview()
}
}
default:
break
}
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ private final class NavigationPopGestureController: UIViewController, UICoordina
@MainActor
final class Coordinator: NSObject, UIGestureRecognizerDelegate {
private weak var recognizer: UIGestureRecognizer?
// 화면 가장자리가 아닌 곳에서 밀어도 이전 화면으로 돌아가는 제스처
private weak var contentRecognizer: UIGestureRecognizer?
private weak var controller: UINavigationController?
private weak var delegate: (any UIGestureRecognizerDelegate)?
private weak var contentDelegate: (any UIGestureRecognizerDelegate)?
private var isObserving = false
weak var owner: UIViewController?
var completion: () -> Void
Expand All @@ -172,28 +175,46 @@ private final class NavigationPopGestureController: UIViewController, UICoordina
guard let controller,
let gesture = controller.interactivePopGestureRecognizer else { return }

if recognizer !== gesture {
// 시스템 막대를 숨긴 화면은 시스템이 이 제스처도 막아 가장자리 제스처와 함께 넘겨받음
var content: UIGestureRecognizer?
if #available(iOS 26.0, *) {
content = controller.interactiveContentPopGestureRecognizer
}

if recognizer !== gesture || contentRecognizer !== content {
restore()
recognizer = gesture
delegate = gesture.delegate
gesture.addTarget(self, action: #selector(handlePopGesture(_:)))
contentRecognizer = content
contentDelegate = content?.delegate
content?.addTarget(self, action: #selector(handlePopGesture(_:)))
}

self.controller = controller
gesture.delegate = self
gesture.isEnabled = 1 < controller.viewControllers.count
content?.delegate = self
}

func restore() {
guard let recognizer else { return }

recognizer.removeTarget(self, action: #selector(handlePopGesture(_:)))
if recognizer.delegate === self {
recognizer.delegate = delegate
if let recognizer {
recognizer.removeTarget(self, action: #selector(handlePopGesture(_:)))
if recognizer.delegate === self {
recognizer.delegate = delegate
}
}
if let contentRecognizer {
contentRecognizer.removeTarget(self, action: #selector(handlePopGesture(_:)))
if contentRecognizer.delegate === self {
contentRecognizer.delegate = contentDelegate
}
}
self.recognizer = nil
recognizer = nil
contentRecognizer = nil
controller = nil
delegate = nil
contentDelegate = nil
isObserving = false
}

Expand All @@ -202,6 +223,8 @@ private final class NavigationPopGestureController: UIViewController, UICoordina
1 < controller.viewControllers.count,
controller.transitionCoordinator == nil else { return false }
guard !popsImmediately else {
// 사이드바가 있는 창은 화면 가장자리에서 밀 때만 바로 돌아감
guard recognizer !== contentRecognizer else { return false }
controller.popViewController(animated: false)
completion()
return false
Expand Down