Skip to content

Commit 7124594

Browse files
authored
Merge pull request #113 from DDakal/Develop
v1.2.2 hotfix
2 parents 50e7af3 + 3ee7ab3 commit 7124594

File tree

2 files changed

+49
-27
lines changed

2 files changed

+49
-27
lines changed

DancingMarker/DancingMarker/Extensions/View+.swift

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,55 @@
77

88
import SwiftUI
99

10-
struct SwipeBackModifier: UIViewControllerRepresentable {
10+
struct EnableSwipeBack: ViewModifier {
11+
func body(content: Content) -> some View {
12+
content
13+
.background(EnableSwipeBackRepresentable())
14+
}
15+
}
16+
17+
private struct EnableSwipeBackRepresentable: UIViewControllerRepresentable {
1118
func makeUIViewController(context: Context) -> UIViewController {
12-
let viewController = UIViewController()
19+
let controller = UIViewController()
1320
DispatchQueue.main.async {
14-
if let navController = viewController.navigationController {
15-
navController.interactivePopGestureRecognizer?.delegate = context.coordinator
16-
navController.interactivePopGestureRecognizer?.isEnabled = true
21+
if let nav = controller.parentNavigationController {
22+
nav.interactivePopGestureRecognizer?.delegate = context.coordinator
23+
nav.interactivePopGestureRecognizer?.isEnabled = true
1724
}
1825
}
19-
return viewController
26+
return controller
2027
}
21-
22-
func updateUIViewController(_ uiViewController: UIViewController, context: Context) { }
23-
28+
29+
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
30+
2431
func makeCoordinator() -> Coordinator {
2532
Coordinator()
2633
}
27-
34+
2835
class Coordinator: NSObject, UIGestureRecognizerDelegate {
2936
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
37+
// 뒤로가기 제스처가 항상 동작하도록 허용
3038
return true
3139
}
32-
33-
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
34-
return otherGestureRecognizer is UIPanGestureRecognizer &&
35-
!(gestureRecognizer is UIScreenEdgePanGestureRecognizer)
40+
}
41+
}
42+
43+
// UINavigationController를 안전하게 찾는 extension
44+
private extension UIViewController {
45+
var parentNavigationController: UINavigationController? {
46+
var parentVC = self.parent
47+
while parentVC != nil {
48+
if let nav = parentVC as? UINavigationController {
49+
return nav
50+
}
51+
parentVC = parentVC?.parent
3652
}
53+
return nil
3754
}
3855
}
3956

4057
extension View {
4158
func enableSwipeBack() -> some View {
42-
self.background(SwipeBackModifier())
59+
self.modifier(EnableSwipeBack())
4360
}
4461
}

DancingMarker/DancingMarker/View/Playing/PlayingView.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,23 @@ struct PlayingView: View {
108108
.frame(width: geometry.size.width * CGFloat(playerModel.progress), height: geometry.size.height)
109109
}
110110
.cornerRadius(12)
111-
.background(Color.red.opacity(0.2))
112-
.gesture(DragGesture(minimumDistance: 0)
113-
.onChanged({ value in
114-
DispatchQueue.main.async {
115-
let newProgress = min(max(0, Double(value.location.x / geometry.size.width)), 1.0)
116-
playerModel.progress = newProgress
117-
let newTime = newProgress * playerModel.duration
118-
playerModel.currentTime = newTime
119-
playerModel.formattedProgress = playerModel.formattedTime(newTime)
120-
playerModel.updateAudioPlayer(with: newTime)
121-
}
122-
}))
111+
.contentShape(
112+
Rectangle()
113+
.inset(by: -6)
114+
)
115+
.highPriorityGesture(
116+
DragGesture(minimumDistance: 0)
117+
.onChanged({ value in
118+
DispatchQueue.main.async {
119+
let newProgress = min(max(0, Double(value.location.x / geometry.size.width)), 1.0)
120+
playerModel.progress = newProgress
121+
let newTime = newProgress * playerModel.duration
122+
playerModel.currentTime = newTime
123+
playerModel.formattedProgress = playerModel.formattedTime(newTime)
124+
playerModel.updateAudioPlayer(with: newTime)
125+
}
126+
})
127+
)
123128
}
124129
.frame(height: 8)
125130
.padding(.bottom, 3)

0 commit comments

Comments
 (0)