From 43600857729d9efff046dc6673e6f94e095882c7 Mon Sep 17 00:00:00 2001 From: Ivan Vorobei Date: Wed, 9 Feb 2022 16:03:52 +0300 Subject: [PATCH] Fixed drag. --- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../xcschemes/xcschememanagement.plist | 2 +- SPIndicator.podspec | 2 +- Sources/SPIndicator/SPIndicatorView.swift | 13 ++----------- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Example Apps/SPIndicator.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example Apps/SPIndicator.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index fa65a10..90d9aad 100644 --- a/Example Apps/SPIndicator.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example Apps/SPIndicator.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ivanvorobei/SparrowKit", "state": { "branch": null, - "revision": "df2ba76dd6a27dfe721a193bb3a7888e311693d1", - "version": "3.5.1" + "revision": "f872b45a3e6aa5e2833ac8d3050a3f026d97ce0b", + "version": "3.5.2" } }, { diff --git a/Example Apps/SPIndicator.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist b/Example Apps/SPIndicator.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist index a4303f8..965138e 100644 --- a/Example Apps/SPIndicator.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Example Apps/SPIndicator.xcodeproj/xcuserdata/ivanvorobei.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ tvOS Example.xcscheme_^#shared#^_ orderHint - 3 + 2 watchOS Example.xcscheme_^#shared#^_ diff --git a/SPIndicator.podspec b/SPIndicator.podspec index b093d97..e49ac1d 100644 --- a/SPIndicator.podspec +++ b/SPIndicator.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'SPIndicator' - s.version = '1.6.3' + s.version = '1.6.4' s.summary = 'Floating indicator, mimicrate to indicator which appear when silent mode switched. Can be present from top and bottom.' s.homepage = 'https://github.com/ivanvorobei/SPIndicator' s.source = { :git => 'https://github.com/ivanvorobei/SPIndicator.git', :tag => s.version } diff --git a/Sources/SPIndicator/SPIndicatorView.swift b/Sources/SPIndicator/SPIndicatorView.swift index 47cc418..82e3b47 100644 --- a/Sources/SPIndicator/SPIndicatorView.swift +++ b/Sources/SPIndicator/SPIndicatorView.swift @@ -205,7 +205,6 @@ open class SPIndicatorView: UIView { present(duration: self.duration, haptic: haptic, completion: completion) } - open func present(duration: TimeInterval, haptic: SPIndicatorHaptic = .success, completion: (() -> Void)? = nil) { if self.presentWindow == nil { @@ -251,16 +250,9 @@ open class SPIndicatorView: UIView { iconView.animate() } } - - safeAreaInsetsObserver = window.observe(\.safeAreaInsets, changeHandler: { [weak self] window, _ in - guard let self = self else { return } - self.center.x = window.frame.midX - self.toPresentPosition(.visible(self.presentSide)) - }) } @objc open func dismiss() { - safeAreaInsetsObserver?.invalidate() UIView.animate(withDuration: presentAndDismissDuration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: [.beginFromCurrentState, .curveEaseIn], animations: { self.toPresentPosition(.prepare(self.presentSide)) if self.presentWithOpacity { self.alpha = 0 } @@ -280,6 +272,7 @@ open class SPIndicatorView: UIView { private var whenGestureEndShoudHide: Bool = false @objc func handlePan(_ gestureRecognizer: UIPanGestureRecognizer) { + if gestureRecognizer.state == .began || gestureRecognizer.state == .changed { self.gestureIsDragging = true let translation = gestureRecognizer.translation(in: self) @@ -364,7 +357,7 @@ open class SPIndicatorView: UIView { return CGAffineTransform.identity.translatedBy(x: 0, y: position) case .bottom: let height = window.frame.height - var bottomSafeAreaInsets = window.safeAreaInsets.bottom + var bottomSafeAreaInsets = window.safeAreaInsets.top if bottomSafeAreaInsets < 20 { bottomSafeAreaInsets = 20 } let position = height - bottomSafeAreaInsets - 3 - self.frame.height - self.offset return CGAffineTransform.identity.translatedBy(x: 0, y: position) @@ -402,8 +395,6 @@ open class SPIndicatorView: UIView { private var spaceBetweenTitles: CGFloat = 1 private var spaceBetweenTitlesAndImage: CGFloat = 16 - private var safeAreaInsetsObserver: NSKeyValueObservation? - private var titlesCompactWidth: CGFloat { if let iconView = self.iconView { let space = iconView.frame.maxY + spaceBetweenTitlesAndImage