From 2a2c5a50feac7924aaee670487eb21f38936bb07 Mon Sep 17 00:00:00 2001 From: Sergey Slavinskiy Date: Mon, 10 Sep 2018 19:16:53 +0300 Subject: [PATCH] support ios 8 --- ExampleApp/AppDelegate.swift | 8 ++++---- .../Custom Footer/TableFooterExample.xib | 8 +++----- .../Table Example/TableViewController.swift | 2 +- FlowKit.xcodeproj/project.pbxproj | 4 ++-- FlowKitManager.podspec | 2 +- .../Collection/CollectionAdapter+Events.swift | 16 ++++++++++++++-- .../FlowKit/Collection/CollectionDirector.swift | 2 ++ .../Collection/FlowCollectionDirector.swift | 2 ++ 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ExampleApp/AppDelegate.swift b/ExampleApp/AppDelegate.swift index d2a7c3b..d862d7d 100644 --- a/ExampleApp/AppDelegate.swift +++ b/ExampleApp/AppDelegate.swift @@ -14,10 +14,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + // Override point for customization after application launch. + return true + } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. diff --git a/ExampleApp/Table Example/Custom Footer/TableFooterExample.xib b/ExampleApp/Table Example/Custom Footer/TableFooterExample.xib index 7cd27c8..e938a7c 100644 --- a/ExampleApp/Table Example/Custom Footer/TableFooterExample.xib +++ b/ExampleApp/Table Example/Custom Footer/TableFooterExample.xib @@ -1,11 +1,10 @@ - + - @@ -25,12 +24,11 @@ - - + + - diff --git a/ExampleApp/Table Example/TableViewController.swift b/ExampleApp/Table Example/TableViewController.swift index 33d9f75..f23e18f 100644 --- a/ExampleApp/Table Example/TableViewController.swift +++ b/ExampleApp/Table Example/TableViewController.swift @@ -79,7 +79,7 @@ public class ArticleAdapter: TableAdapter { ctx.cell?.subtitleLabel?.text = ctx.model.text } self.on.tap = { ctx in - ctx.cell?.accessoryType = UITableViewCell.AccessoryType.checkmark + ctx.cell?.accessoryType = UITableViewCellAccessoryType.checkmark print("Tapped on article \(ctx.model.modelID)") return .deselectAnimated } diff --git a/FlowKit.xcodeproj/project.pbxproj b/FlowKit.xcodeproj/project.pbxproj index 73a900b..3f3d923 100644 --- a/FlowKit.xcodeproj/project.pbxproj +++ b/FlowKit.xcodeproj/project.pbxproj @@ -670,7 +670,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Configs/FlowKit.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.FlowKit.FlowKit-iOS"; @@ -693,7 +693,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Configs/FlowKit.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.FlowKit.FlowKit-iOS"; PRODUCT_NAME = FlowKit; diff --git a/FlowKitManager.podspec b/FlowKitManager.podspec index 84eadd9..7bbddd3 100644 --- a/FlowKitManager.podspec +++ b/FlowKitManager.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Daniele Margutti" => "me@danielemargutti.com" } s.social_media_url = "https://twitter.com/danielemargutti" - s.ios.deployment_target = "9.0" + s.ios.deployment_target = "8.0" s.source = { :git => "https://github.com/malcommac/FlowKit.git", :tag => s.version.to_s } s.source_files = "Sources/**/*" s.frameworks = "Foundation" diff --git a/Sources/FlowKit/Collection/CollectionAdapter+Events.swift b/Sources/FlowKit/Collection/CollectionAdapter+Events.swift index bcb673f..4491903 100644 --- a/Sources/FlowKit/Collection/CollectionAdapter+Events.swift +++ b/Sources/FlowKit/Collection/CollectionAdapter+Events.swift @@ -86,8 +86,20 @@ public extension CollectionDirector { var layoutDidChange: ((_ old: UICollectionViewLayout, _ new: UICollectionViewLayout) -> UICollectionViewTransitionLayout?)? = nil var targetOffset: ((_ proposedContentOffset: CGPoint) -> CGPoint)? = nil var moveItemPath: ((_ originalIndexPath: IndexPath, _ proposedIndexPath: IndexPath) -> IndexPath)? = nil - var shouldUpdateFocus: ((_ context: UICollectionViewFocusUpdateContext) -> Bool)? = nil - var didUpdateFocus: ((_ context: UICollectionViewFocusUpdateContext, _ coordinator: UIFocusAnimationCoordinator) -> Void)? = nil + + private var _shouldUpdateFocus: ((_ context: AnyObject) -> Bool)? = nil + @available(iOS 9.0, *) + var shouldUpdateFocus: ((_ context: UICollectionViewFocusUpdateContext) -> Bool)? { + get { return _shouldUpdateFocus } + set { _shouldUpdateFocus = newValue as? ((AnyObject) -> Bool) } + } + + private var _didUpdateFocus: ((_ context: AnyObject, _ coordinator: AnyObject) -> Void)? = nil + @available(iOS 9.0, *) + var didUpdateFocus: ((_ context: UICollectionViewFocusUpdateContext, _ coordinator: UIFocusAnimationCoordinator) -> Void)? { + get { return _didUpdateFocus } + set { _didUpdateFocus = newValue as? ((AnyObject, AnyObject) -> Void) } + } var willDisplayHeader : ((HeaderFooterEvent) -> Void)? = nil var willDisplayFooter : ((HeaderFooterEvent) -> Void)? = nil diff --git a/Sources/FlowKit/Collection/CollectionDirector.swift b/Sources/FlowKit/Collection/CollectionDirector.swift index ccbe34d..0a3bf4b 100644 --- a/Sources/FlowKit/Collection/CollectionDirector.swift +++ b/Sources/FlowKit/Collection/CollectionDirector.swift @@ -485,6 +485,7 @@ public extension CollectionDirector { return ((adapter.dispatch(.shouldSpringLoad, context: InternalContext.init(model, indexPath, nil, collectionView)) as? Bool) ?? true) } + @available(iOS 9.0, *) public func collectionView(_ collectionView: UICollectionView, shouldUpdateFocusIn context: UICollectionViewFocusUpdateContext) -> Bool { guard let update = self.on.shouldUpdateFocus?(context) else { return true @@ -492,6 +493,7 @@ public extension CollectionDirector { return update } + @available(iOS 9.0, *) public func collectionView(_ collectionView: UICollectionView, didUpdateFocusIn context: UICollectionViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) { self.on.didUpdateFocus?(context,coordinator) } diff --git a/Sources/FlowKit/Collection/FlowCollectionDirector.swift b/Sources/FlowKit/Collection/FlowCollectionDirector.swift index 366298e..d43b002 100644 --- a/Sources/FlowKit/Collection/FlowCollectionDirector.swift +++ b/Sources/FlowKit/Collection/FlowCollectionDirector.swift @@ -61,6 +61,7 @@ open class FlowCollectionDirector: CollectionDirector, UICollectionViewDelegateF /// Each new header view that scrolls to the top of the screen pushes the previously pinned header view offscreen. /// /// The default value of this property is `false`. + @available(iOS 9.0, *) public var stickyHeaders: Bool { set { self.layout?.sectionHeadersPinToVisibleBounds = newValue } get { return (self.layout?.sectionHeadersPinToVisibleBounds ?? false) } @@ -71,6 +72,7 @@ open class FlowCollectionDirector: CollectionDirector, UICollectionViewDelegateF /// Each new footer view that scrolls to the bottom of the screen pushes the previously pinned footer view offscreen. /// /// The default value of this property is `false`. + @available(iOS 9.0, *) public var stickyFooters: Bool { set { self.layout?.sectionFootersPinToVisibleBounds = newValue } get { return (self.layout?.sectionFootersPinToVisibleBounds ?? false) }