|
1 | 1 | // Copyright 2018-Present Shin Yamamoto. All rights reserved. MIT license. |
2 | 2 |
|
| 3 | +#if canImport(Combine) |
3 | 4 | import Combine |
| 5 | +#endif |
4 | 6 | import UIKit |
5 | 7 | import os.log |
6 | 8 |
|
@@ -50,7 +52,13 @@ class Core: NSObject, UIGestureRecognizerDelegate { |
50 | 52 | } |
51 | 53 | } |
52 | 54 | } |
53 | | - private(set) var statePublisher: CurrentValueSubject<FloatingPanelState, Never> = .init(.hidden) |
| 55 | + |
| 56 | + @available(iOS 13.0, *) |
| 57 | + private(set) var statePublisher: CurrentValueSubject<FloatingPanelState, Never>? { |
| 58 | + get { _statePublisher as? CurrentValueSubject<FloatingPanelState, Never> } |
| 59 | + set { _statePublisher = newValue } |
| 60 | + } |
| 61 | + private var _statePublisher: Any? |
54 | 62 |
|
55 | 63 | var panGestureRecognizer: FloatingPanelPanGestureRecognizer |
56 | 64 | let panGestureDelegateRouter: FloatingPanelPanGestureRecognizer.DelegateRouter |
@@ -100,6 +108,10 @@ class Core: NSObject, UIGestureRecognizerDelegate { |
100 | 108 |
|
101 | 109 | super.init() |
102 | 110 |
|
| 111 | + if #available(iOS 13.0, *) { |
| 112 | + statePublisher = .init(.hidden) |
| 113 | + } |
| 114 | + |
103 | 115 | panGestureRecognizer.set(floatingPanel: self) |
104 | 116 | surfaceView.addGestureRecognizer(panGestureRecognizer) |
105 | 117 | panGestureRecognizer.addTarget(self, action: #selector(handle(panGesture:))) |
@@ -262,7 +274,9 @@ class Core: NSObject, UIGestureRecognizerDelegate { |
262 | 274 | layoutAdapter.activateLayout(for: target, forceLayout: true) |
263 | 275 | backdropView.alpha = getBackdropAlpha(for: target) |
264 | 276 | adjustScrollContentInsetIfNeeded() |
265 | | - statePublisher.send(target) |
| 277 | + if #available(iOS 13.0, *) { |
| 278 | + statePublisher?.send(target) |
| 279 | + } |
266 | 280 | } |
267 | 281 |
|
268 | 282 | private func getBackdropAlpha(for target: FloatingPanelState) -> CGFloat { |
|
0 commit comments