diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift index ab4f89e..684b127 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshExtensions.swift @@ -1,28 +1,28 @@ /* - -The MIT License (MIT) - -Copyright (c) 2015 Danil Gontovnik - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ + + The MIT License (MIT) + + Copyright (c) 2015 Danil Gontovnik + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + */ import UIKit import ObjectiveC @@ -82,16 +82,16 @@ public extension NSObject { public extension UIScrollView { // MARK: - Vars - + fileprivate struct dg_associatedKeys { static var pullToRefreshView = "pullToRefreshView" } - + fileprivate var pullToRefreshView: DGElasticPullToRefreshView? { get { return objc_getAssociatedObject(self, &dg_associatedKeys.pullToRefreshView) as? DGElasticPullToRefreshView } - + set { objc_setAssociatedObject(self, &dg_associatedKeys.pullToRefreshView, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) } @@ -102,13 +102,13 @@ public extension UIScrollView { public func dg_addPullToRefreshWithActionHandler(_ actionHandler: @escaping () -> Void, loadingView: DGElasticPullToRefreshLoadingView?) { isMultipleTouchEnabled = false panGestureRecognizer.maximumNumberOfTouches = 1 - + let pullToRefreshView = DGElasticPullToRefreshView() self.pullToRefreshView = pullToRefreshView pullToRefreshView.actionHandler = actionHandler pullToRefreshView.loadingView = loadingView addSubview(pullToRefreshView) - + pullToRefreshView.observing = true } @@ -157,8 +157,8 @@ public extension UIPanGestureRecognizer { // MARK: - // MARK: (UIGestureRecognizerState) Extension -public extension UIGestureRecognizerState { - func dg_isAnyOf(_ values: [UIGestureRecognizerState]) -> Bool { +public extension UIGestureRecognizer.State { + func dg_isAnyOf(_ values: [UIGestureRecognizer.State]) -> Bool { return values.contains(where: { $0 == self }) } } diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift index c510baf..bd6ee49 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshLoadingViewCircle.swift @@ -1,28 +1,28 @@ /* - -The MIT License (MIT) - -Copyright (c) 2015 Danil Gontovnik - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ + + The MIT License (MIT) + + Copyright (c) 2015 Danil Gontovnik + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + */ import UIKit @@ -58,7 +58,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin transform = CATransform3DRotate(transform, CGFloat(-90.0).toRadians(), 0.0, 0.0, 1.0) return transform }() - + // MARK: - // MARK: Constructors @@ -72,7 +72,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin shapeLayer.anchorPoint = CGPoint(x: 0.5, y: 0.5) layer.addSublayer(shapeLayer) } - + required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -103,7 +103,7 @@ open class DGElasticPullToRefreshLoadingViewCircle: DGElasticPullToRefreshLoadin rotationAnimation.duration = 1.0 rotationAnimation.repeatCount = Float.infinity rotationAnimation.isRemovedOnCompletion = false - rotationAnimation.fillMode = kCAFillModeForwards + rotationAnimation.fillMode = CAMediaTimingFillMode.forwards shapeLayer.add(rotationAnimation, forKey: kRotationAnimation) } diff --git a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift index d393eaf..e9acf9f 100644 --- a/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift +++ b/DGElasticPullToRefresh/DGElasticPullToRefreshView.swift @@ -1,32 +1,32 @@ /* - -The MIT License (MIT) - -Copyright (c) 2015 Danil Gontovnik - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -*/ + + The MIT License (MIT) + + Copyright (c) 2015 Danil Gontovnik + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + */ import UIKit -// MARK: - +// MARK: - Swift 5 updates. // MARK: DGElasticPullToRefreshState public @@ -124,7 +124,7 @@ open class DGElasticPullToRefreshView: UIView { super.init(frame: CGRect.zero) displayLink = CADisplayLink(target: self, selector: #selector(DGElasticPullToRefreshView.displayLinkTick)) - displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes) + displayLink.add(to: RunLoop.main, forMode:.default) displayLink.isPaused = true shapeLayer.backgroundColor = UIColor.clear.cgColor @@ -141,30 +141,30 @@ open class DGElasticPullToRefreshView: UIView { addSubview(r2ControlPointView) addSubview(r3ControlPointView) - NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(DGElasticPullToRefreshView.applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil) } - + required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } // MARK: - - + /** - Has to be called when the receiver is no longer required. Otherwise the main loop holds a reference to the receiver which in turn will prevent the receiver from being deallocated. - */ + Has to be called when the receiver is no longer required. Otherwise the main loop holds a reference to the receiver which in turn will prevent the receiver from being deallocated. + */ func disassociateDisplayLink() { displayLink?.invalidate() } - + deinit { observing = false NotificationCenter.default.removeObserver(self) } - + // MARK: - // MARK: Observer - + override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { if keyPath == DGElasticPullToRefreshConstants.KeyPaths.ContentOffset { if let newContentOffset = change?[NSKeyValueChangeKey.newKey], let scrollView = scrollView() { @@ -189,11 +189,11 @@ open class DGElasticPullToRefreshView: UIView { } } } - + // MARK: - // MARK: Notifications - func applicationWillEnterForeground() { + @objc func applicationWillEnterForeground() { if state == .loading { layoutSubviews() } @@ -334,7 +334,7 @@ open class DGElasticPullToRefreshView: UIView { scrollView.isScrollEnabled = true } self?.state = .loading - }) + }) bounceAnimationHelperView.center = CGPoint(x: 0.0, y: originalContentInsetTop + currentHeight()) UIView.animate(withDuration: duration * 0.4, animations: { [weak self] in @@ -355,13 +355,13 @@ open class DGElasticPullToRefreshView: UIView { displayLink.isPaused = true } - func displayLinkTick() { + @objc func displayLinkTick() { let width = bounds.width var height: CGFloat = 0.0 if state == .animatingBounce { guard let scrollView = scrollView() else { return } - + scrollView.contentInset.top = bounceAnimationHelperView.dg_center(isAnimating()).y scrollView.contentOffset.y = -scrollView.contentInset.top @@ -371,7 +371,7 @@ open class DGElasticPullToRefreshView: UIView { } else if state == .animatingToStopped { height = actualContentOffsetY() } - + shapeLayer.frame = CGRect(x: 0.0, y: 0.0, width: width, height: height) shapeLayer.path = currentPath() diff --git a/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj b/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj index c778cf5..8544c6d 100644 --- a/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj +++ b/DGElasticPullToRefreshExample.xcodeproj/project.pbxproj @@ -118,7 +118,9 @@ TargetAttributes = { 05CD14641BBE8FEA00AF4030 = { CreatedOnToolsVersion = 7.0; + DevelopmentTeam = FAYEZUN5CX; LastSwiftMigration = 0800; + ProvisioningStyle = Automatic; }; }; }; @@ -127,6 +129,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -269,12 +272,16 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FAYEZUN5CX; INFOPLIST_FILE = DGElasticPullToRefreshExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample; PRODUCT_NAME = DGElasticPullToRefreshExample; - SWIFT_VERSION = 3.0; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -282,12 +289,16 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = FAYEZUN5CX; INFOPLIST_FILE = DGElasticPullToRefreshExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.gatafan.DGElasticPullToRefreshExample; PRODUCT_NAME = DGElasticPullToRefreshExample; - SWIFT_VERSION = 3.0; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcuserdata/mimi.xcuserdatad/UserInterfaceState.xcuserstate b/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcuserdata/mimi.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..ccb9b8c Binary files /dev/null and b/DGElasticPullToRefreshExample.xcodeproj/project.xcworkspace/xcuserdata/mimi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/DGElasticPullToRefreshExample.xcodeproj/xcuserdata/mimi.xcuserdatad/xcschemes/xcschememanagement.plist b/DGElasticPullToRefreshExample.xcodeproj/xcuserdata/mimi.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..5056fef --- /dev/null +++ b/DGElasticPullToRefreshExample.xcodeproj/xcuserdata/mimi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + DGElasticPullToRefreshExample.xcscheme_^#shared#^_ + + orderHint + 0 + + + +