Repository: marty-suzuki/HoverConversion Branch: master Commit: 2dc49fd6a002 Files: 36 Total size: 118.7 KB Directory structure: gitextract_6qxoyk_h/ ├── .gitignore ├── .swift-version ├── HoverConversion/ │ ├── HCContentViewController.swift │ ├── HCDefaultAnimatedTransitioning.swift │ ├── HCNavigationController.swift │ ├── HCNavigationView.swift │ ├── HCNextHeaderView.swift │ ├── HCPagingViewController.swift │ ├── HCRootAnimatedTransitioning.swift │ ├── HCRootViewController.swift │ ├── HCViewContentable.swift │ ├── NSIndexPath+Row.swift │ ├── UIScrollView+BottomBounceSize.swift │ └── UITableViewCell+Screenshot.swift ├── HoverConversion.podspec ├── HoverConversionSample/ │ ├── HoverConversionSample/ │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets/ │ │ │ └── AppIcon.appiconset/ │ │ │ └── Contents.json │ │ ├── Base.lproj/ │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Cell/ │ │ │ ├── HomeTableViewCell.swift │ │ │ └── HomeTableViewCell.xib │ │ ├── Info.plist │ │ ├── Manager/ │ │ │ └── TwitterManager.swift │ │ ├── Request/ │ │ │ ├── StatusesUserTimelineRequest.swift │ │ │ ├── TWTRAPIClient+Extra.swift │ │ │ ├── TWTRRequestable.swift │ │ │ └── UsersLookUpRequest.swift │ │ ├── View/ │ │ │ └── NextHeaderView.swift │ │ └── ViewController/ │ │ ├── HomeViewController.swift │ │ └── UserTimelineViewController.swift │ ├── HoverConversionSample.xcodeproj/ │ │ ├── project.pbxproj │ │ └── project.xcworkspace/ │ │ └── contents.xcworkspacedata │ ├── HoverConversionSample.xcworkspace/ │ │ └── contents.xcworkspacedata │ └── Podfile ├── LICENSE └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore # OS X .DS_Store ## Build generated build/ DerivedData/ ## Various settings *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata/ ## Other *.moved-aside *.xcuserstate ## Obj-C/Swift specific *.hmap *.ipa *.dSYM.zip *.dSYM ## Playgrounds timeline.xctimeline playground.xcworkspace # Swift Package Manager # # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ .build/ # CocoaPods # # We recommend against adding the Pods directory to your .gitignore. However # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # Pods/ # Carthage # # Add this line if you want to avoid checking in source code from Carthage dependencies. # Carthage/Checkouts Carthage/Build # fastlane # # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md fastlane/report.xml fastlane/Preview.html fastlane/screenshots fastlane/test_output ================================================ FILE: .swift-version ================================================ 3.0 ================================================ FILE: HoverConversion/HCContentViewController.swift ================================================ // // HCContentViewController.swift // HoverConversion // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit public protocol HCContentViewControllerScrollDelegate: class { func contentViewController(_ viewController: HCContentViewController, scrollViewWillBeginDragging scrollView: UIScrollView) func contentViewController(_ viewController: HCContentViewController, scrollViewDidScroll scrollView: UIScrollView) func contentViewController(_ viewController: HCContentViewController, scrollViewDidEndDragging scrollView: UIScrollView, willDecelerate decelerate: Bool) func contentViewController(_ viewController: HCContentViewController, handlePanGesture gesture: UIPanGestureRecognizer) } public struct PagableHandler { public enum Direction { case prev, next } private var values: [Direction : Bool] = [ .prev : true, .next : true ] public subscript(direction: Direction) -> Bool { get { return values[direction] ?? false } set { values[direction] = newValue } } } open class HCContentViewController: UIViewController, HCViewContentable { open var tableView: UITableView! = UITableView() open var navigatoinContainerView: UIView! = UIView() open var navigationView: HCNavigationView! = HCNavigationView(buttonPosition: .left) let cellImageView = UIImageView(frame: .zero) open weak var scrollDelegate: HCContentViewControllerScrollDelegate? open var canPaging: PagableHandler = PagableHandler() open override var title: String? { didSet { navigationView?.titleLabel.text = title } } override open func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. automaticallyAdjustsScrollViewInsets = false addViews() tableView.delegate = self view.addSubview(cellImageView) let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(HCContentViewController.handleNavigatoinContainerViewPanGesture(_:))) navigatoinContainerView.addGestureRecognizer(panGestureRecognizer) } override open func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } open func navigationView(_ navigationView: HCNavigationView, didTapLeftButton button: UIButton) { _ = navigationController?.popViewController(animated: true) } func handleNavigatoinContainerViewPanGesture(_ gesture: UIPanGestureRecognizer) { scrollDelegate?.contentViewController(self, handlePanGesture: gesture) } } extension HCContentViewController: UITableViewDelegate { public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { scrollDelegate?.contentViewController(self, scrollViewWillBeginDragging: scrollView) } public func scrollViewDidScroll(_ scrollView: UIScrollView) { scrollDelegate?.contentViewController(self, scrollViewDidScroll: scrollView) } public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { scrollDelegate?.contentViewController(self, scrollViewDidEndDragging: scrollView, willDecelerate: decelerate) } } ================================================ FILE: HoverConversion/HCDefaultAnimatedTransitioning.swift ================================================ // // HCDefaultAnimatedTransitioning.swift // HoverConversion // // Created by Taiki Suzuki on 2016/09/11. // Copyright © 2016年 marty-suzuki. All rights reserved. // // import UIKit class HCDefaultAnimatedTransitioning: NSObject, UIViewControllerAnimatedTransitioning { fileprivate struct Const { static let defaultDuration: TimeInterval = 0.25 static let rootDuration: TimeInterval = 0.4 static let scaling: CGFloat = 0.95 } let operation: UINavigationControllerOperation fileprivate let alphaView = UIView() init(operation: UINavigationControllerOperation) { self.operation = operation super.init() } @objc func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { guard let toVC = transitionContext?.viewController(forKey: UITransitionContextViewControllerKey.to), let fromVC = transitionContext?.viewController(forKey: UITransitionContextViewControllerKey.from) else { return 0 } switch (fromVC, toVC) { case (_ as HCPagingViewController, _ as HCRootViewController): return Const.rootDuration case (_ as HCRootViewController, _ as HCPagingViewController): return Const.rootDuration default: return Const.defaultDuration } } // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. @objc func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { guard let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to), let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) else { transitionContext.completeTransition(true) return } let containerView = transitionContext.containerView containerView.backgroundColor = .black alphaView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5) alphaView.frame = containerView.bounds switch operation { case .pop: popAnimation(transitionContext, toVC: toVC, fromVC: fromVC, containerView: containerView) case .push: pushAnimation(transitionContext, toVC: toVC, fromVC: fromVC, containerView: containerView) case .none: transitionContext.completeTransition(true) } } fileprivate func popAnimation(_ transitionContext: UIViewControllerContextTransitioning, toVC: UIViewController, fromVC: UIViewController, containerView: UIView) { containerView.insertSubview(toVC.view, belowSubview: fromVC.view) containerView.insertSubview(alphaView, belowSubview: fromVC.view) if let pagingVC = fromVC as? HCPagingViewController, let rootVC = toVC as? HCRootViewController { let indexPath = pagingVC.currentIndexPath //pagingVC.homeViewTalkContainerView.backgroundColor = .whiteColor() if rootVC.tableView?.cellForRow(at: indexPath as IndexPath) == nil { //rootVC.tableView?.scrollToRowAtIndexPath(indexPath, atScrollPosition: pagingVC.scrollDirection, animated: false) } rootVC.tableView?.selectRow(at: indexPath as IndexPath, animated: false, scrollPosition: .none) } alphaView.alpha = 1 toVC.view.frame = containerView.bounds toVC.view.transform = CGAffineTransform(scaleX: Const.scaling, y: Const.scaling) UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: .curveLinear, animations: { toVC.view.transform = CGAffineTransform.identity fromVC.view.frame.origin.x = containerView.bounds.size.width self.alphaView.alpha = 0 }) { finished in let canceled = transitionContext.transitionWasCancelled if canceled { toVC.view.removeFromSuperview() } else { fromVC.view.removeFromSuperview() } toVC.view.transform = CGAffineTransform.identity self.alphaView.removeFromSuperview() if let pagingVC = fromVC as? HCPagingViewController, let rootVC = toVC as? HCRootViewController { let indexPath = pagingVC.currentIndexPath rootVC.tableView?.deselectRow(at: indexPath as IndexPath, animated: true) } transitionContext.completeTransition(!canceled) } } fileprivate func pushAnimation(_ transitionContext: UIViewControllerContextTransitioning, toVC: UIViewController, fromVC: UIViewController, containerView: UIView) { containerView.addSubview(alphaView) containerView.addSubview(toVC.view) toVC.view.frame = containerView.bounds toVC.view.frame.origin.x = containerView.bounds.size.width alphaView.alpha = 0 UIView.animate(withDuration: transitionDuration(using: transitionContext), delay: 0, options: .curveLinear, animations: { fromVC.view.transform = CGAffineTransform(scaleX: Const.scaling, y: Const.scaling) self.alphaView.alpha = 1 toVC.view.frame.origin.x = 0 }) { finished in let canceled = transitionContext.transitionWasCancelled if canceled { toVC.view.removeFromSuperview() } self.alphaView.removeFromSuperview() fromVC.view.transform = CGAffineTransform.identity transitionContext.completeTransition(!canceled) } } } ================================================ FILE: HoverConversion/HCNavigationController.swift ================================================ // // HCNavigationController.swift // // Created by Taiki Suzuki on 2016/09/11. // Copyright © 2016年 marty-suzuki. All rights reserved. // // import UIKit open class HCNavigationController: UINavigationController { fileprivate struct Const { fileprivate static let queueLabel = "jp.marty-suzuki.HoverConversion.SynchronizationQueue" static let synchronizationQueue = DispatchQueue(label: queueLabel, attributes: []) static func performBlock(_ block: @escaping () -> ()) { synchronizationQueue.async { DispatchQueue.main.sync(execute: block) } } } enum SwipeType { case edge, pan, none var threshold: CGFloat { switch self { case .edge: return 0.3 case .pan: return 0.01 case .none: return 0 } } } fileprivate let interactiveTransition = UIPercentDrivenInteractiveTransition() let interactiveEdgePanGestureRecognizer = UIScreenEdgePanGestureRecognizer() let interactivePanGestureRecognizer = UIPanGestureRecognizer() fileprivate var isPaning = false override open func viewDidLoad() { super.viewDidLoad() delegate = self interactivePopGestureRecognizer?.isEnabled = false interactiveEdgePanGestureRecognizer.edges = .left interactiveEdgePanGestureRecognizer.addTarget(self, action: #selector(HCNavigationController.handleInteractiveEdgePanGesture(_:))) interactiveEdgePanGestureRecognizer.delegate = self view.addGestureRecognizer(interactiveEdgePanGestureRecognizer) interactivePanGestureRecognizer.addTarget(self, action: #selector(HCNavigationController.handleInteractivePanGesture(_:))) interactivePanGestureRecognizer.delegate = self view.addGestureRecognizer(interactivePanGestureRecognizer) } func interactiveEdgePanGestureRecognizerMakesToFail(gesture: UIGestureRecognizer) { gesture.require(toFail: interactiveEdgePanGestureRecognizer) } func interactivePanGestureRecognizerMakesToFail(gesture: UIGestureRecognizer) { gesture.require(toFail: interactivePanGestureRecognizer) } func handleInteractiveEdgePanGesture(_ edgePanGestureRecognizer: UIScreenEdgePanGestureRecognizer) { handlePanGesture(edgePanGestureRecognizer, swipeType: .edge) } func handleInteractivePanGesture(_ panGestureRecognizer: UIPanGestureRecognizer) { handlePanGesture(panGestureRecognizer, swipeType: .pan) } fileprivate func handlePanGesture(_ gesture: UIPanGestureRecognizer, swipeType: SwipeType) { let translation = gesture.translation(in: view) let velocity = gesture.velocity(in: view) let percentage = min(1, max(0, translation.x / view.bounds.size.width)) switch gesture.state { case .began: Const.performBlock { if self.viewControllers.count < 2 { return } self.isPaning = true self.popViewController(animated: true) } case .changed: Const.performBlock { self.interactiveTransition.update(percentage) } case .ended, .failed, .possible, .cancelled: Const.performBlock { self.isPaning = false if 0 < velocity.x && swipeType.threshold < percentage { self.interactiveTransition.finish() } else { self.interactiveTransition.cancel() } } } } } extension HCNavigationController: UINavigationControllerDelegate { public func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { return isPaning ? interactiveTransition : nil } public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { //TODO: initial frame switch (fromVC, toVC, isPaning) { case (_ as HCRootViewController, _ as HCPagingViewController, _): return HCRootAnimatedTransitioning(operation: operation) case (_ as HCPagingViewController, _ as HCRootViewController, false): return HCRootAnimatedTransitioning(operation: operation) default: return HCDefaultAnimatedTransitioning(operation: operation) } } } extension HCNavigationController: UIGestureRecognizerDelegate { public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { if let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer , gestureRecognizer === interactivePanGestureRecognizer && gestureRecognizer.velocity(in: navigationController?.view).x < 0 { return false } return true } public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool { if gestureRecognizer === interactivePanGestureRecognizer && otherGestureRecognizer === interactiveEdgePanGestureRecognizer { return true } return false } } ================================================ FILE: HoverConversion/HCNavigationView.swift ================================================ // // HCNavigationView.swift // HoverConversion // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import MisterFusion public protocol HCNavigationViewDelegate: class { func navigationView(_ navigationView: HCNavigationView, didTapLeftButton button: UIButton) func navigationView(_ navigationView: HCNavigationView, didTapRightButton button: UIButton) } open class HCNavigationView: UIView { public struct ButtonPosition: OptionSet { static let right = ButtonPosition(rawValue: 1 << 0) static let left = ButtonPosition(rawValue: 1 << 1) public let rawValue: UInt public init(rawValue: UInt) { self.rawValue = rawValue } } open static let height: CGFloat = 64 open var leftButton: UIButton? open let titleLabel: UILabel = { let label = UILabel(frame: .zero) label.textAlignment = .center label.font = UIFont.boldSystemFont(ofSize: 16) return label }() open var rightButton: UIButton? weak var delegate: HCNavigationViewDelegate? public convenience init() { self.init(buttonPosition: []) } public init(buttonPosition: ButtonPosition) { super.init(frame: .zero) if buttonPosition.contains(.left) { let leftButton = UIButton(type: .custom) addLayoutSubview(leftButton, andConstraints: leftButton.left, leftButton.bottom, leftButton.width |==| leftButton.height, leftButton.height |==| 44 ) leftButton.setTitle("‹", for: UIControlState()) leftButton.titleLabel?.font = .systemFont(ofSize: 40) leftButton.addTarget(self, action: #selector(HCNavigationView.didTouchDown(_:)), for: .touchDown) leftButton.addTarget(self, action: #selector(HCNavigationView.didTouchDragExit(_:)), for: .touchDragExit) leftButton.addTarget(self, action: #selector(HCNavigationView.didTouchDragEnter(_:)), for: .touchDragEnter) leftButton.addTarget(self, action: #selector(HCNavigationView.didTouchUpInside(_:)), for: .touchUpInside) self.leftButton = leftButton } if buttonPosition.contains(.right) { let rightButton = UIButton(type: .custom) addLayoutSubview(rightButton, andConstraints: rightButton.right, rightButton.bottom, rightButton.width |==| rightButton.height, rightButton.height |==| 44 ) rightButton.addTarget(self, action: #selector(HCNavigationView.didTouchDown(_:)), for: .touchDown) rightButton.addTarget(self, action: #selector(HCNavigationView.didTouchDragExit(_:)), for: .touchDragExit) rightButton.addTarget(self, action: #selector(HCNavigationView.didTouchDragEnter(_:)), for: .touchDragEnter) rightButton.addTarget(self, action: #selector(HCNavigationView.didTouchUpInside(_:)), for: .touchUpInside) self.rightButton = rightButton } var constraints: [MisterFusion] = [] if let leftButton = leftButton { constraints += [leftButton.right |==| titleLabel.left] } else { constraints += [titleLabel.left |+| 44] } if let rightButton = rightButton { constraints += [rightButton.left |==| titleLabel.right] } else { constraints += [titleLabel.right |-| 44] } constraints += [ titleLabel.height |==| 44, titleLabel.bottom ] addLayoutSubview(titleLabel, andConstraints: constraints) } required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } func didTouchUpInside(_ sender: UIButton) { sender.alpha = 1 if sender == leftButton { delegate?.navigationView(self, didTapLeftButton: sender) } else if sender == rightButton { delegate?.navigationView(self, didTapRightButton: sender) } } func didTouchDown(_ sender: UIButton) { sender.alpha = 0.5 } func didTouchDragExit(_ sender: UIButton) { sender.alpha = 0.5 } func didTouchDragEnter(_ sender: UIButton) { sender.alpha = 1 } } ================================================ FILE: HoverConversion/HCNextHeaderView.swift ================================================ // // HCNextHeaderView.swift // HoverConversion // // Created by Taiki Suzuki on 2016/09/13. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit open class HCNextHeaderView: UIView {} ================================================ FILE: HoverConversion/HCPagingViewController.swift ================================================ // // HCPagingViewController.swift // HoverConversion // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import MisterFusion fileprivate func < (lhs: T?, rhs: T?) -> Bool { switch (lhs, rhs) { case let (l?, r?): return l < r case (nil, _?): return true default: return false } } fileprivate func >= (lhs: T?, rhs: T?) -> Bool { switch (lhs, rhs) { case let (l?, r?): return l >= r default: return !(lhs < rhs) } } public enum HCPagingPosition: Int { case upper = 1, center = 0, lower = 2 } public protocol HCPagingViewControllerDataSource : class { func pagingViewController(_ viewController: HCPagingViewController, viewControllerFor indexPath: IndexPath) -> HCContentViewController? func pagingViewController(_ viewController: HCPagingViewController, nextHeaderViewFor indexPath: IndexPath) -> HCNextHeaderView? } open class HCPagingViewController: UIViewController { fileprivate struct Const { static let fireDistance: CGFloat = 180 static let bottomTotalSpace = HCNavigationView.height static let nextAnimationDuration: TimeInterval = 0.4 static let previousAnimationDuration: TimeInterval = 0.3 static fileprivate func calculateRudderBanding(_ distance: CGFloat, constant: CGFloat, dimension: CGFloat) -> CGFloat { return (1 - (1 / ((distance * constant / dimension) + 1))) * dimension } } open fileprivate(set) var viewControllers: [HCPagingPosition : HCContentViewController?] = [ .upper : nil, .center : nil, .lower : nil ] let containerViews: [HCPagingPosition : UIView] = [ .upper : UIView(), .center : UIView(), .lower : UIView() ] fileprivate var containerViewsAdded: Bool = false var currentIndexPath: IndexPath open fileprivate(set) var isPaging: Bool = false fileprivate var isDragging: Bool = false fileprivate var isPanning = false fileprivate var beginningContentOffset: CGPoint = .zero fileprivate(set) var scrollDirection: UITableViewScrollPosition = .none fileprivate var _alphaView: UIView? fileprivate var alphaView: UIView { let alphaView: UIView if let _alphaView = _alphaView { alphaView = _alphaView } else { alphaView = createAlphaViewAndAddSubview(containerViews[.center]) _alphaView = alphaView } return alphaView } fileprivate var nextHeaderView: HCNextHeaderView? open weak var dataSource: HCPagingViewControllerDataSource? { didSet { addContainerViews() setupViewControllers() } } public init(indexPath: IndexPath) { self.currentIndexPath = indexPath super.init(nibName: nil, bundle: nil) } required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override open func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. automaticallyAdjustsScrollViewInsets = false addContainerViews() } open override var preferredStatusBarStyle : UIStatusBarStyle { return viewController(.center)?.preferredStatusBarStyle ?? .default } fileprivate func createAlphaViewAndAddSubview(_ view: UIView?) -> UIView { let alphaView = UIView() alphaView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6) view?.addLayoutSubview(alphaView, andConstraints: alphaView.top, alphaView.left, alphaView.bottom, alphaView.right ) alphaView.isUserInteractionEnabled = false alphaView.alpha = 0 return alphaView } fileprivate func clearAlphaView() { _alphaView?.removeFromSuperview() _alphaView = nil } fileprivate func clearNextHeaderView() { nextHeaderView?.removeFromSuperview() nextHeaderView = nil } fileprivate func setScrollsTop() { viewControllers.forEach { $0.1?.tableView?.scrollsToTop = $0.0 == .center } } fileprivate func viewController(_ position: HCPagingPosition) -> HCContentViewController? { guard let nullableViewController = viewControllers[position] else { return nil } return nullableViewController } fileprivate func setupViewControllers() { setupViewController(indexPath: currentIndexPath.rowPlus(-1), position: .upper) setupViewController(indexPath: currentIndexPath, position: .center) setupViewController(indexPath: currentIndexPath.rowPlus(1), position: .lower) setScrollsTop() let tableView = viewController(.center)?.tableView if let _ = viewController(.lower) { tableView?.contentInset.bottom = Const.bottomTotalSpace tableView?.scrollIndicatorInsets.bottom = Const.bottomTotalSpace } else { tableView?.contentInset.bottom = 0 tableView?.scrollIndicatorInsets.bottom = 0 } setNeedsStatusBarAppearanceUpdate() } fileprivate func setupViewController(indexPath: IndexPath, position: HCPagingPosition) { if (indexPath as NSIndexPath).row < 0 || (indexPath as NSIndexPath).section < 0 { return } guard let vc = dataSource?.pagingViewController(self, viewControllerFor: indexPath) else { return } addViewController(vc, to: position) } fileprivate func addViewController(_ viewController: HCContentViewController, to position: HCPagingPosition) { viewController.scrollDelegate = self addView(viewController.view, to: position) addChildViewController(viewController) viewController.didMove(toParentViewController: self) viewControllers[position] = viewController } fileprivate func addView(_ view: UIView, to position: HCPagingPosition) { guard let containerView = containerViews[position] else { return } containerView.addLayoutSubview(view, andConstraints: view.top, view.right, view.left, view.bottom ) } fileprivate func addContainerViews() { if containerViewsAdded { return } containerViewsAdded = true containerViews.sorted { $0.0.rawValue < $1.0.rawValue }.forEach { let misterFusion: MisterFusion switch $0.0 { case .upper: misterFusion = $0.1.bottom |==| view.top case .center: misterFusion = $0.1.top case .lower: misterFusion = $0.1.top |==| view.bottom } view.addLayoutSubview($0.1, andConstraints: misterFusion, $0.1.height, $0.1.left, $0.1.right ) } } override open func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func moveToNext(_ scrollView: UIScrollView, offset: CGPoint) { guard let _ = viewController(.lower) , viewController(.center)?.canPaging[.next] == true else { return } scrollDirection = .bottom let value = offset.y - (scrollView.contentSize.height - scrollView.bounds.size.height) let headerHeight = HCNavigationView.height isPaging = true scrollView.setContentOffset(scrollView.contentOffset, animated: false) let relativeDuration = TimeInterval(0.25) let lowerViewController = viewController(.lower) let centerViewController = viewController(.center) UIView.animateKeyframes(withDuration: Const.nextAnimationDuration, delay: 0, options: UIViewKeyframeAnimationOptions(), animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1.0 - relativeDuration) { lowerViewController?.view.frame.origin.y = -self.view.bounds.size.height + headerHeight centerViewController?.view.frame.origin.y = -self.view.bounds.size.height + value + headerHeight centerViewController?.navigationView?.frame.origin.y = self.view.bounds.size.height - value - headerHeight self.nextHeaderView?.alpha = 0 } UIView.addKeyframe(withRelativeStartTime: 1.0 - relativeDuration, relativeDuration: relativeDuration) { lowerViewController?.view.frame.origin.y = -self.view.bounds.size.height centerViewController?.view.frame.origin.y = -self.view.bounds.size.height + value } }) { _ in let upperViewController = self.viewController(.upper) upperViewController?.view.removeFromSuperview() centerViewController?.view.removeFromSuperview() lowerViewController?.view.removeFromSuperview() if let lowerView = lowerViewController?.view { self.addView(lowerView, to: .center) } if let centerView = centerViewController?.view { self.addView(centerView, to: .upper) } centerViewController?.scrollDelegate = nil upperViewController?.willMove(toParentViewController: self) upperViewController?.removeFromParentViewController() let nextCenterVC = lowerViewController let nextUpperVC = centerViewController self.viewControllers[.center] = nextCenterVC self.viewControllers[.upper] = nextUpperVC self.viewControllers[.lower] = nil self.currentIndexPath = self.currentIndexPath.rowPlus(1) if let newViewController = self.dataSource?.pagingViewController(self, viewControllerFor: self.currentIndexPath.rowPlus(1)) { self.addViewController(newViewController, to: .lower) self.viewControllers[.lower] = newViewController nextCenterVC?.tableView.contentInset.bottom = Const.bottomTotalSpace nextCenterVC?.tableView.scrollIndicatorInsets.bottom = Const.bottomTotalSpace } else { nextCenterVC?.tableView.contentInset.bottom = 0 nextCenterVC?.tableView.scrollIndicatorInsets.bottom = 0 } nextCenterVC?.scrollDelegate = self if nextUpperVC?.tableView?.contentOffset.y >= scrollView.contentSize.height - scrollView.bounds.size.height { if scrollView.contentSize.height > scrollView.bounds.size.height { nextUpperVC?.tableView?.setContentOffset(CGPoint(x: 0, y: scrollView.contentSize.height - scrollView.bounds.size.height), animated: false) } else { nextUpperVC?.tableView?.setContentOffset(.zero, animated: false) } } nextUpperVC?.tableView?.reloadData() self.setNeedsStatusBarAppearanceUpdate() self.setScrollsTop() self.clearAlphaView() self.clearNextHeaderView() self.isPaging = false } } func moveToPrevious(_ scrollView: UIScrollView, offset: CGPoint) { guard let _ = viewController(.upper) , viewController(.center)?.canPaging[.prev] == true else { return } scrollDirection = .top isPaging = true scrollView.setContentOffset(scrollView.contentOffset, animated: false) let upperViewController = viewController(.upper) let centerViewController = viewController(.center) UIView.animate(withDuration: Const.previousAnimationDuration, delay: 0, options: .curveLinear, animations: { upperViewController?.view.frame.origin.y = self.view.bounds.size.height centerViewController?.view.frame.origin.y = self.view.bounds.size.height + offset.y }) { finished in let lowerViewController = self.viewController(.lower) upperViewController?.view.removeFromSuperview() centerViewController?.view.removeFromSuperview() lowerViewController?.view.removeFromSuperview() if let upperView = upperViewController?.view { self.addView(upperView, to: .center) } if let centerView = centerViewController?.view { self.addView(centerView, to: .lower) } centerViewController?.scrollDelegate = nil lowerViewController?.willMove(toParentViewController: self) lowerViewController?.removeFromParentViewController() let nextCenterVC = upperViewController let nextLowerVC = centerViewController self.viewControllers[.center] = nextCenterVC self.viewControllers[.lower] = nextLowerVC self.viewControllers[.upper] = nil self.currentIndexPath = self.currentIndexPath.rowPlus(-1) if let newViewController = self.dataSource?.pagingViewController(self, viewControllerFor: self.currentIndexPath.rowPlus(-1)) { self.addViewController(newViewController, to: .upper) self.viewControllers[.upper] = newViewController } if let _ = nextLowerVC { nextCenterVC?.tableView.contentInset.bottom = Const.bottomTotalSpace nextCenterVC?.tableView.scrollIndicatorInsets.bottom = Const.bottomTotalSpace } else { nextCenterVC?.tableView.contentInset.bottom = 0 nextCenterVC?.tableView.scrollIndicatorInsets.bottom = 0 } nextCenterVC?.scrollDelegate = self nextLowerVC?.tableView?.reloadData() self.setNeedsStatusBarAppearanceUpdate() self.setScrollsTop() self.clearAlphaView() self.clearNextHeaderView() self.isPaging = false } } } extension HCPagingViewController: HCContentViewControllerScrollDelegate { public func contentViewController(_ viewController: HCContentViewController, scrollViewDidScroll scrollView: UIScrollView) { if isPanning { return } guard viewController == self.viewController(.center) else { return } let offset = scrollView.contentOffset let contentSize = scrollView.contentSize let scrollViewSize = scrollView.bounds.size if contentSize.height - scrollViewSize.height <= offset.y { guard let lowerViewController = self.viewController(.lower) else { return } let delta = offset.y - (contentSize.height - scrollViewSize.height) lowerViewController.view.frame.origin.y = min(0, -delta) let value: CGFloat = scrollView.bottomBounceSize if value > Const.bottomTotalSpace { let alpha = min(1, max(0, (value - Const.bottomTotalSpace) / Const.fireDistance)) alphaView.alpha = alpha } if let _ = self.nextHeaderView { } else if let view = self.viewController(.lower)?.view, let nhv = dataSource?.pagingViewController(self, nextHeaderViewFor: currentIndexPath.rowPlus(1)) { view.addLayoutSubview(nhv, andConstraints: nhv.top, nhv.right, nhv.left, nhv.height |==| HCNavigationView.height ) self.nextHeaderView = nhv } } else if offset.y < 0 { guard let upperViewController = self.viewController(.upper), let centerViewController = self.viewController(.center) else { return } let delta = max(0, -offset.y) if (currentIndexPath as NSIndexPath).row > 0 { let alpha = min(1, max(0, -offset.y / Const.fireDistance)) alphaView.alpha = alpha } clearNextHeaderView() upperViewController.view.frame.origin.y = delta centerViewController.navigationView.frame.origin.y = delta } else { viewControllers[.lower]??.view.frame.origin.y = 0 viewControllers[.upper]??.view.frame.origin.y = 0 viewControllers[.center]??.navigationView.frame.origin.y = 0 clearAlphaView() clearNextHeaderView() } if isDragging { return } if scrollView.contentSize.height > scrollView.bounds.size.height { if offset.y < -Const.fireDistance { moveToPrevious(scrollView, offset: offset) } else if offset.y > (scrollView.contentSize.height + Const.fireDistance) - scrollView.bounds.size.height { moveToNext(scrollView, offset: offset) } } else { if offset.y < -Const.fireDistance { moveToPrevious(scrollView, offset: offset) } else if offset.y > Const.fireDistance { moveToNext(scrollView, offset: CGPoint(x: offset.x, y: offset.y + (scrollView.contentSize.height - scrollView.bounds.size.height))) } } } public func contentViewController(_ viewController: HCContentViewController, scrollViewWillBeginDragging scrollView: UIScrollView) { guard viewController == self.viewController(.center) else { return } isDragging = true } public func contentViewController(_ viewController: HCContentViewController, scrollViewDidEndDragging scrollView: UIScrollView, willDecelerate decelerate: Bool) { guard viewController == self.viewController(.center) else { return } isDragging = false } public func contentViewController(_ viewController: HCContentViewController, handlePanGesture gesture: UIPanGestureRecognizer) { guard let centerViewController = self.viewController(.center) , centerViewController == viewController && (currentIndexPath as NSIndexPath).row > 0 && viewController.canPaging[.prev] else { return } let translation = gesture.translation(in: view) let velocity = gesture.velocity(in: view) let tableView = viewController.tableView switch gesture.state { case .began: isPanning = true beginningContentOffset = (tableView?.contentOffset)! case .changed: let position = max(0, translation.y) let rudderBanding = Const.calculateRudderBanding(position, constant: 0.55, dimension: view.frame.size.height) let headerPosition = max(0, rudderBanding) if viewController.navigationView.frame.origin.y != headerPosition { viewController.navigationView.frame.origin.y = headerPosition } let tableViewOffset = beginningContentOffset.y - max(0, rudderBanding) tableView?.setContentOffset(CGPoint(x: 0, y: tableViewOffset), animated: false) self.viewController(.upper)?.view.frame.origin.y = headerPosition alphaView.alpha = min(1, (rudderBanding / Const.fireDistance)) case .cancelled, .ended: if velocity.y > 0 && translation.y > Const.fireDistance && (currentIndexPath as NSIndexPath).row > 0 { isPanning = false let rudderBanding = Const.calculateRudderBanding(max(0, translation.y), constant: 0.55, dimension: view.frame.size.height) moveToPrevious(tableView!, offset: CGPoint(x: 0, y: -rudderBanding)) } else { UIView.animate(withDuration: 0.25, animations: { viewController.navigationView.frame.origin.y = 0 self.viewController(.upper)?.view.frame.origin.y = 0 tableView?.setContentOffset(self.beginningContentOffset, animated: false) self.alphaView.alpha = 0 }, completion: { finished in self.beginningContentOffset = .zero self.isPanning = false }) } case .failed, .possible: break } } } ================================================ FILE: HoverConversion/HCRootAnimatedTransitioning.swift ================================================ // // HCRootAnimatedTransitioning.swift // // Created by Taiki Suzuki on 2016/09/11. // Copyright © 2016年 marty-suzuki. All rights reserved. // // import UIKit class HCRootAnimatedTransitioning: NSObject, UIViewControllerAnimatedTransitioning { fileprivate struct Const { static let duration: TimeInterval = 0.3 static let scaling: CGFloat = 0.95 } let operation: UINavigationControllerOperation fileprivate let alphaView = UIView() init(operation: UINavigationControllerOperation) { self.operation = operation super.init() } @objc func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return Const.duration } // This method can only be a nop if the transition is interactive and not a percentDriven interactive transition. @objc func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { guard let toVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to), let fromVC = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) else { transitionContext.completeTransition(true) return } let containerView = transitionContext.containerView containerView.backgroundColor = .black alphaView.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5) alphaView.frame = containerView.bounds switch operation { case .pop: popAnimation(transitionContext, toVC: toVC, fromVC: fromVC, containerView: containerView) case .push: pushAnimation(transitionContext, toVC: toVC, fromVC: fromVC, containerView: containerView) case .none: transitionContext.completeTransition(true) break } } fileprivate func popAnimation(_ transitionContext: UIViewControllerContextTransitioning, toVC: UIViewController, fromVC: UIViewController, containerView: UIView) { containerView.insertSubview(toVC.view, belowSubview: fromVC.view) containerView.insertSubview(alphaView, belowSubview: fromVC.view) var initialFrame: CGRect? if let rootVC = toVC as? HCRootViewController, let pagingVC = fromVC as? HCPagingViewController { let indexPath = pagingVC.currentIndexPath if rootVC.tableView?.cellForRow(at: indexPath as IndexPath) == nil { rootVC.tableView?.scrollToRow(at: indexPath as IndexPath, at: pagingVC.scrollDirection, animated: false) } if let cell = rootVC.tableView?.cellForRow(at: indexPath as IndexPath) { if let nullableVC = pagingVC.viewControllers[.center], let centeVC = nullableVC { centeVC.cellImageView.frame = cell.bounds centeVC.cellImageView.image = cell.screenshot() } if let superview = rootVC.view, let point = cell.superview?.convert(cell.frame.origin, to: superview) { var selectedCellFrame: CGRect = .zero selectedCellFrame.origin = point selectedCellFrame.size = cell.bounds.size initialFrame = selectedCellFrame } } rootVC.tableView?.selectRow(at: indexPath as IndexPath, animated: true, scrollPosition: .none) } fromVC.view.clipsToBounds = true alphaView.alpha = 1 toVC.view.transform = CGAffineTransform(scaleX: Const.scaling, y: Const.scaling) UIView.animateKeyframes(withDuration: transitionDuration(using: transitionContext) , delay: 0, options: UIViewKeyframeAnimationOptions(), animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.25) { (fromVC as? HCPagingViewController)?.viewControllers[.center]??.cellImageView.alpha = 1 } UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.25) { (fromVC as? HCPagingViewController)?.containerViews[.center]?.alpha = 0 } UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1) { if let initialFrame = initialFrame { fromVC.view.frame = initialFrame } fromVC.view.layoutIfNeeded() toVC.view.transform = CGAffineTransform.identity self.alphaView.alpha = 0 } }) { finished in let canceled = transitionContext.transitionWasCancelled if canceled { toVC.view.removeFromSuperview() } else { fromVC.view.removeFromSuperview() fromVC.view.clipsToBounds = false } toVC.view.transform = CGAffineTransform.identity self.alphaView.removeFromSuperview() if let pagingVC = fromVC as? HCPagingViewController, let rootVC = toVC as? HCRootViewController { let indexPath = pagingVC.currentIndexPath rootVC.tableView?.deselectRow(at: indexPath as IndexPath, animated: true) } transitionContext.completeTransition(!canceled) } } fileprivate func pushAnimation(_ transitionContext: UIViewControllerContextTransitioning, toVC: UIViewController, fromVC: UIViewController, containerView: UIView) { containerView.addSubview(alphaView) containerView.addSubview(toVC.view) toVC.view.clipsToBounds = true var earlyAlphaAnimation = false if let rootVC = fromVC as? HCRootViewController, let pagingVC = toVC as? HCPagingViewController { let indexPath = pagingVC.currentIndexPath if let cell = rootVC.tableView?.cellForRow(at: indexPath as IndexPath) { if let nullableVC = pagingVC.viewControllers[.center], let centeVC = nullableVC { centeVC.cellImageView.frame = cell.bounds centeVC.cellImageView.image = cell.screenshot() } if let superview = rootVC.view, let point = cell.superview?.convert(cell.frame.origin, to: superview) { var selectedCellFrame: CGRect = .zero selectedCellFrame.origin = point selectedCellFrame.size = cell.bounds.size toVC.view.frame = selectedCellFrame } if let superview = rootVC.view, let point = cell.superview?.convert(cell.frame.origin, to: superview) , point.y < containerView.bounds.size.height / 3 { earlyAlphaAnimation = true } } } alphaView.alpha = 0 let relativeStartTime = earlyAlphaAnimation ? 0 : 0.25 UIView.animateKeyframes(withDuration: transitionDuration(using: transitionContext), delay: 0, options: UIViewKeyframeAnimationOptions(), animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1) { toVC.view.frame = containerView.bounds fromVC.view.transform = CGAffineTransform(scaleX: Const.scaling, y: Const.scaling) self.alphaView.alpha = 1 } UIView.addKeyframe(withRelativeStartTime: relativeStartTime, relativeDuration: 0.5) { (toVC as? HCPagingViewController)?.viewControllers[.center]??.cellImageView.alpha = 0 } }) { finished in let canceled = transitionContext.transitionWasCancelled if canceled { toVC.view.removeFromSuperview() toVC.view.clipsToBounds = false } self.alphaView.removeFromSuperview() fromVC.view.transform = CGAffineTransform.identity transitionContext.completeTransition(!canceled) } } } ================================================ FILE: HoverConversion/HCRootViewController.swift ================================================ // // HCRootViewController.swift // HoverConversion // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit open class HCRootViewController: UIViewController, HCViewControllable { open var tableView: UITableView! = UITableView() open var navigatoinContainerView: UIView! = UIView() open var navigationView: HCNavigationView! = HCNavigationView() open override var title: String? { didSet { navigationView?.titleLabel.text = title } } override open func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. addViews() automaticallyAdjustsScrollViewInsets = false navigationController?.setNavigationBarHidden(true, animated: false) } override open func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } ================================================ FILE: HoverConversion/HCViewContentable.swift ================================================ // // HCViewContentable.swift // HoverConversion // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import MisterFusion public protocol HCViewControllable: HCNavigationViewDelegate { var navigationView: HCNavigationView! { get set } var navigatoinContainerView: UIView! { get set } var tableView: UITableView! { get set } func addViews() } extension HCViewControllable where Self: UIViewController { public func addViews() { navigationView.delegate = self view.addLayoutSubview(navigatoinContainerView, andConstraints: navigatoinContainerView.top, navigatoinContainerView.right, navigatoinContainerView.left, navigatoinContainerView.height |==| HCNavigationView.height ) navigatoinContainerView.addLayoutSubview(navigationView, andConstraints: navigationView.top, navigationView.right, navigationView.left, navigationView.bottom ) view.addLayoutSubview(tableView, andConstraints: tableView.top |==| navigatoinContainerView.bottom, tableView.right, tableView.left, tableView.bottom ) view.bringSubview(toFront: navigatoinContainerView) } public func navigationView(_ navigationView: HCNavigationView, didTapLeftButton button: UIButton) {} public func navigationView(_ navigationView: HCNavigationView, didTapRightButton button: UIButton) {} } public protocol HCViewContentable: HCViewControllable { weak var scrollDelegate: HCContentViewControllerScrollDelegate? { get set } } ================================================ FILE: HoverConversion/NSIndexPath+Row.swift ================================================ // // NSIndexPath+Row.swift // HoverConversion // // Created by Taiki Suzuki on 2016/09/11. // Copyright © 2016年 marty-suzuki. All rights reserved. // // import Foundation extension IndexPath { func rowPlus(_ value: Int) -> IndexPath { return IndexPath(row: row + value, section: section) } } ================================================ FILE: HoverConversion/UIScrollView+BottomBounceSize.swift ================================================ // // UIScrollView+BottomBounceSize.swift // HoverConversion // // Created by Taiki Suzuki on 2016/09/12. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit extension UIScrollView { var bottomBounceSize: CGFloat { if bounds.size.height < contentSize.height { return contentOffset.y - (contentSize.height - bounds.size.height) } else { return contentOffset.y } } } ================================================ FILE: HoverConversion/UITableViewCell+Screenshot.swift ================================================ // // UITableViewCell+Screenshot.swift // HoverConversion // // Created by Taiki Suzuki on 2016/09/08. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit extension UITableViewCell { func screenshot(_ scale: CGFloat = UIScreen.main.scale) -> UIImage? { UIGraphicsBeginImageContextWithOptions(bounds.size, false, scale) drawHierarchy(in: self.bounds, afterScreenUpdates: true) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image } } ================================================ FILE: HoverConversion.podspec ================================================ # # Be sure to run `pod lib lint HoverConversion.podspec' to ensure this is a # valid spec before submitting. # # Any lines starting with a # are optional, but their use is encouraged # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| s.name = 'HoverConversion' s.version = '0.3.1' s.summary = 'HoverConversion realized vertical paging. UIViewController will be paging when reaching top or bottom of UITableView content.' # This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? # * Try to keep it short, snappy and to the point. # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! # s.description = <<-DESC # TODO: Add long description of the pod here. # DESC s.homepage = 'https://github.com/marty-suzuki/HoverConversion' # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'marty-suzuki' => 's1180183@gmail.com' } s.source = { :git => 'https://github.com/marty-suzuki/HoverConversion.git', :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/marty_suzuki' s.ios.deployment_target = '8.0' s.source_files = 'HoverConversion/*.{swift}' # s.resource_bundles = { # 'HoverConversion' => ['HoverConversion/Assets/*.png'] # } # s.public_header_files = 'Pod/Classes/**/*.h' s.frameworks = 'UIKit' s.dependency 'MisterFusion', '~> 2.0.0' # s.dependency 'AFNetworking', '~> 2.3' end ================================================ FILE: HoverConversionSample/HoverConversionSample/AppDelegate.swift ================================================ // // AppDelegate.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import Fabric import TwitterKit import TouchVisualizer @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. Fabric.with([Twitter.self]) Visualizer.start() 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. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. Visualizer.stop() } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. Visualizer.start() } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. Visualizer.start() } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. Visualizer.stop() } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Assets.xcassets/AppIcon.appiconset/Contents.json ================================================ { "images" : [ { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, { "idiom" : "iphone", "size" : "29x29", "scale" : "3x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, { "idiom" : "iphone", "size" : "40x40", "scale" : "3x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "2x" }, { "idiom" : "iphone", "size" : "60x60", "scale" : "3x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "1x" }, { "idiom" : "ipad", "size" : "29x29", "scale" : "2x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "1x" }, { "idiom" : "ipad", "size" : "40x40", "scale" : "2x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "1x" }, { "idiom" : "ipad", "size" : "76x76", "scale" : "2x" }, { "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Base.lproj/LaunchScreen.storyboard ================================================ ================================================ FILE: HoverConversionSample/HoverConversionSample/Base.lproj/Main.storyboard ================================================ ================================================ FILE: HoverConversionSample/HoverConversionSample/Cell/HomeTableViewCell.swift ================================================ // // HomeTableViewCell.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/09/04. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import TwitterKit class HomeTableViewCell: UITableViewCell, IconImageViewLoadable { static let Height: CGFloat = 80 @IBOutlet weak var iconImageView: UIImageView! @IBOutlet weak var userNameLabel: UILabel! @IBOutlet weak var screenNameLabel: UILabel! @IBOutlet weak var latestTweetLabel: UILabel! @IBOutlet weak var timestampLabel: UILabel! var userValue: (TWTRUser, TWTRTweet)? { didSet { guard let value = userValue else { return } let user = value.0 if let url = URL(string: user.profileImageLargeURL) { loadImage(url) } userNameLabel.text = user.name screenNameLabel.text = "@" + user.screenName let tweet = value.1 latestTweetLabel.text = tweet.text timestampLabel.text = tweet.createdAt.description } } override func awakeFromNib() { super.awakeFromNib() // Initialization code iconImageView.layer.cornerRadius = iconImageView.bounds.size.height / 2 iconImageView.layer.borderWidth = 1 iconImageView.layer.borderColor = UIColor.lightGray.cgColor iconImageView.layer.masksToBounds = true } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Cell/HomeTableViewCell.xib ================================================ ================================================ FILE: HoverConversionSample/HoverConversionSample/Info.plist ================================================ CFBundleDevelopmentRegion en CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName $(PRODUCT_NAME) CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1 Fabric APIKey 17f9b693790022f676a0812ed5b69bf3f93d01ff Kits KitInfo consumerKey Tqg8V7zKdLsQyEl5V01o80kLj consumerSecret cMRzcgG08gsYahpLf6RAltA91WvFAQJvGRJ5wi2OK9U5JkYmKi KitName Twitter LSRequiresIPhoneOS UILaunchStoryboardName LaunchScreen UIMainStoryboardFile Main UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight ================================================ FILE: HoverConversionSample/HoverConversionSample/Manager/TwitterManager.swift ================================================ // // TwitterManager.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/09/03. // Copyright © 2016年 marty-suzuki. All rights reserved. // import Foundation import TwitterKit class TwitterManager { fileprivate let screenNames: [String] = [ "tim_cook", "SwiftLang", "BacktotheFuture", "realmikefox", "marty_suzuki" ] fileprivate(set) var tweets: [String : [TWTRTweet]] = [:] fileprivate(set) var users: [TWTRUser] = [] fileprivate lazy var client = TWTRAPIClient() func sortUsers() { let result = users.flatMap { user -> (TWTRUser, TWTRTweet)? in guard let tweet = tweets[user.screenName]?.first else { return nil } return (user, tweet) } let sortedResult = result.sorted { $0.0.1.createdAt.timeIntervalSince1970 > $0.1.1.createdAt.timeIntervalSince1970 } users = sortedResult.flatMap { $0.0 } } func fetchUsersTimeline(_ completion: @escaping (() -> ())) { let group = DispatchGroup() screenNames.forEach { group.enter() fetchUserTimeline(screenName: $0) { group.leave() } } group.notify(queue: DispatchQueue.main) { completion() } } func fetchUserTimeline(screenName: String, completion: @escaping (() -> ())) { let request = StatusesUserTimelineRequest(screenName: screenName, maxId: nil, count: 1) client.sendTwitterRequest(request) { [weak self] in switch $0.result { case .success(let tweets): guard let userTweets = self?.tweets[screenName] else { self?.tweets[screenName] = tweets completion() return } self?.tweets[screenName] = Array([userTweets, tweets].joined()) case .failure(let error): print(error) } completion() } } func fetchUsers(_ completion: @escaping (() -> ())) { let request = UsersLookUpRequest(screenNames: screenNames) client.sendTwitterRequest(request) { [weak self] in switch $0.result { case .success(let users): self?.users = users case .failure(let error): print(error) } completion() } } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Request/StatusesUserTimelineRequest.swift ================================================ // // StatusesUserTimelineRequest.swift // HoverConversionSample // // Created by 鈴木大貴 on 2016/09/08. // Copyright © 2016年 szk-atmosphere. All rights reserved. // import Foundation import TwitterKit struct StatusesUserTimelineRequest: TWTRGetRequestable { typealias ResponseType = [TWTRTweet] typealias ParseResultType = [[String : NSObject]] let path: String = "/1.1/statuses/user_timeline.json" let screenName: String let maxId: String? let count: Int? var parameters: [AnyHashable: Any]? { var parameters: [AnyHashable: Any] = [ "screen_name" : screenName ] if let maxId = maxId { parameters["max_id"] = maxId } if let count = count { parameters["count"] = String(count) } return parameters } static func decode(_ data: Data) -> TWTRResult { switch UsersLookUpRequest.parseData(data) { case .success(let parsedData): return .success(parsedData.flatMap { TWTRTweet(jsonDictionary: $0) }) case .failure(let error): return .failure(error) } } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Request/TWTRAPIClient+Extra.swift ================================================ // // TWTRAPIClient+Extra.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/09/04. // Copyright © 2016年 marty-suzuki. All rights reserved. // import Foundation import TwitterKit enum TWTRResult { case success(T) case failure(NSError) } struct TWTRResponse { let request: URLRequest? let response: HTTPURLResponse? let data: Data? let result: TWTRResult } enum TWTRHTTPMethod: String { case GET = "GET" } extension TWTRAPIClient { func sendTwitterRequest(_ request: T, completion: @escaping (TWTRResponse) -> ()) { guard let URL = request.URL else { let error = NSError(domain: TWTRAPIErrorDomain, code: -9999, userInfo: nil) completion(TWTRResponse(request: nil, response: nil, data: nil, result: .failure(error))) return } let absoluteString = URL.absoluteString var error: NSError? let request = urlRequest(withMethod: request.method.rawValue, url: absoluteString, parameters: request.parameters, error: &error) if let error = error { completion(TWTRResponse(request: request, response: nil, data: nil, result: .failure(error))) return } sendTwitterRequest(request) { let result: TWTRResult if let error = $0.2 { result = .failure(error as NSError) } else if let data = $0.1 { switch T.decode(data) { case .success(let decodeData): result = .success(decodeData) case .failure(let error): result = .failure(error) } } else { result = .failure(NSError(domain: TWTRAPIErrorDomain, code: -9999, userInfo: nil)) } completion(TWTRResponse(request: request, response: $0.0 as? HTTPURLResponse, data: $0.1, result: result)) } } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Request/TWTRRequestable.swift ================================================ // // TWTRRequestable.swift // HoverConversionSample // // Created by 鈴木大貴 on 2016/09/08. // Copyright © 2016年 szk-atmosphere. All rights reserved. // import Foundation import TwitterKit protocol TWTRRequestable { associatedtype ResponseType associatedtype ParseResultType var method: TWTRHTTPMethod { get } var baseURL: Foundation.URL? { get } var path: String { get } var URL: Foundation.URL? { get } var parameters: [AnyHashable: Any]? { get } static func parseData(_ data: Data) -> TWTRResult static func decode(_ data: Data) -> TWTRResult } extension TWTRRequestable { var baseURL: Foundation.URL? { return Foundation.URL(string: "https://api.twitter.com") } var URL: Foundation.URL? { return Foundation.URL(string: path, relativeTo: baseURL) } static func parseData(_ data: Data) -> TWTRResult { do { let anyObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) guard let object = anyObject as? ParseResultType else { return .failure(NSError(domain: TWTRAPIErrorDomain, code: -9999, userInfo: nil)) } return .success(object) } catch let error as NSError { return .failure(error) } } } protocol TWTRGetRequestable: TWTRRequestable {} extension TWTRGetRequestable { var method: TWTRHTTPMethod { return .GET } } ================================================ FILE: HoverConversionSample/HoverConversionSample/Request/UsersLookUpRequest.swift ================================================ // // UsersLookUpRequest.swift // HoverConversionSample // // Created by 鈴木大貴 on 2016/09/08. // Copyright © 2016年 szk-atmosphere. All rights reserved. // import Foundation import TwitterKit struct UsersLookUpRequest: TWTRGetRequestable { typealias ResponseType = [TWTRUser] typealias ParseResultType = [[String : NSObject]] let path: String = "/1.1/users/lookup.json" let screenNames: [String] var parameters: [AnyHashable: Any]? { let screenNameValue: String = screenNames.joined(separator: ",") let parameters: [AnyHashable: Any] = [ "screen_name" : screenNameValue, "include_entities" : "true" ] return parameters } static func decode(_ data: Data) -> TWTRResult { switch UsersLookUpRequest.parseData(data) { case .success(let parsedData): return .success(parsedData.flatMap { TWTRUser(jsonDictionary: $0) }) case .failure(let error): return .failure(error) } } } ================================================ FILE: HoverConversionSample/HoverConversionSample/View/NextHeaderView.swift ================================================ // // NextHeaderView.swift // HoverConversionSample // // Created by 鈴木大貴 on 2016/09/13. // Copyright © 2016年 szk-atmosphere. All rights reserved. // import UIKit import HoverConversion import TwitterKit import MisterFusion protocol IconImageViewLoadable { var iconImageView: UIImageView! { get } func loadImage(_ url: URL) } extension IconImageViewLoadable { func loadImage(_ url: URL) { DispatchQueue.global().async { guard let data = try? Data(contentsOf: url) else { return } DispatchQueue.main.async { guard let image = UIImage(data: data) else { return } self.iconImageView.image = image } } } } class NextHeaderView: HCNextHeaderView, IconImageViewLoadable { var user: TWTRUser? { didSet { guard let user = user else { return } setupViews() titleLabel.numberOfLines = 2 let attributedText = NSMutableAttributedString() attributedText.append(NSAttributedString(string: user.name + "\n", attributes: [ NSFontAttributeName : UIFont.boldSystemFont(ofSize: 18), NSForegroundColorAttributeName : UIColor.white ])) attributedText.append(NSAttributedString(string: "@" + user.screenName, attributes: [ NSFontAttributeName : UIFont.systemFont(ofSize: 16), NSForegroundColorAttributeName : UIColor(white: 1, alpha: 0.6) ])) titleLabel.attributedText = attributedText guard let url = URL(string: user.profileImageLargeURL) else { return } loadImage(url) } } let iconImageView: UIImageView! = UIImageView(frame: .zero) let titleLabel: UILabel = UILabel(frame: .zero) init() { super.init(frame: .zero) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func layoutSubviews() { super.layoutSubviews() iconImageView.layer.cornerRadius = iconImageView.bounds.size.height / 2 } fileprivate func setupViews() { addLayoutSubview(iconImageView, andConstraints: iconImageView.top |+| 8, iconImageView.left |+| 8, iconImageView.bottom |-| 8, iconImageView.width |==| iconImageView.height ) iconImageView.layer.borderWidth = 1 iconImageView.layer.borderColor = UIColor.lightGray.cgColor iconImageView.layer.masksToBounds = true addLayoutSubview(titleLabel, andConstraints: titleLabel.top |+| 4, titleLabel.right |-| 4, titleLabel.left |==| iconImageView.right |+| 16, titleLabel.bottom |-| 4 ) backgroundColor = UIColor(red: 0.25, green: 0.25, blue: 0.25, alpha: 1) } } ================================================ FILE: HoverConversionSample/HoverConversionSample/ViewController/HomeViewController.swift ================================================ // // HomeViewController.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/07/18. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import HoverConversion import TwitterKit class HomeViewController: HCRootViewController { let twitterManager = TwitterManager() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. navigationView.backgroundColor = UIColor(red: 85 / 255, green: 172 / 255, blue: 238 / 255, alpha: 1) navigationView.titleLabel.textColor = .white tableView.delegate = self tableView.dataSource = self tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell") tableView.register(UINib(nibName: "HomeTableViewCell", bundle: nil), forCellReuseIdentifier: "HomeTableViewCell") title = "Following List" } override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let group = DispatchGroup() group.enter() twitterManager.fetchUsersTimeline { group.leave() } group.enter() twitterManager.fetchUsers { group.leave() } group.notify(queue: DispatchQueue.main) { self.twitterManager.sortUsers() self.tableView.reloadData() } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } fileprivate func showPagingViewContoller(indexPath: IndexPath) { let vc = HCPagingViewController(indexPath: indexPath) vc.dataSource = self navigationController?.pushViewController(vc, animated: true) } } extension HomeViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if twitterManager.tweets.count == twitterManager.users.count { return twitterManager.users.count } return 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let user = twitterManager.users[(indexPath as NSIndexPath).row] guard let tweet = twitterManager.tweets[user.screenName]?.first else { return tableView.dequeueReusableCell(withIdentifier: "UITableViewCell")! } let cell = tableView.dequeueReusableCell(withIdentifier: "HomeTableViewCell") as! HomeTableViewCell cell.userValue = (user, tweet) return cell } } extension HomeViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return HomeTableViewCell.Height } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: false) showPagingViewContoller(indexPath: indexPath) } } extension HomeViewController: HCPagingViewControllerDataSource { func pagingViewController(_ viewController: HCPagingViewController, viewControllerFor indexPath: IndexPath) -> HCContentViewController? { guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil } let vc = UserTimelineViewController() vc.user = twitterManager.users[indexPath.row] return vc } func pagingViewController(_ viewController: HCPagingViewController, nextHeaderViewFor indexPath: IndexPath) -> HCNextHeaderView? { guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil } let view = NextHeaderView() view.user = twitterManager.users[indexPath.row] return view } } ================================================ FILE: HoverConversionSample/HoverConversionSample/ViewController/UserTimelineViewController.swift ================================================ // // UserTimelineViewController.swift // HoverConversionSample // // Created by Taiki Suzuki on 2016/09/05. // Copyright © 2016年 marty-suzuki. All rights reserved. // import UIKit import HoverConversion import TwitterKit class UserTimelineViewController: HCContentViewController { var user: TWTRUser? fileprivate var tweets: [TWTRTweet] = [] fileprivate var hasNext = true fileprivate let client = TWTRAPIClient() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. navigationView.backgroundColor = UIColor(red: 85 / 255, green: 172 / 255, blue: 238 / 255, alpha: 1) if let user = user { navigationView.titleLabel.numberOfLines = 2 let attributedText = NSMutableAttributedString() attributedText.append(NSAttributedString(string: user.name + "\n", attributes: [ NSFontAttributeName : UIFont.boldSystemFont(ofSize: 14), NSForegroundColorAttributeName : UIColor.white ])) attributedText.append(NSAttributedString(string: "@" + user.screenName, attributes: [ NSFontAttributeName : UIFont.systemFont(ofSize: 12), NSForegroundColorAttributeName : UIColor(white: 1, alpha: 0.6) ])) navigationView.titleLabel.attributedText = attributedText } tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell") tableView.register(TWTRTweetTableViewCell.self, forCellReuseIdentifier: "TWTRTweetTableViewCell") tableView.dataSource = self loadTweets() } override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } fileprivate func loadTweets() { guard let user = user , hasNext else { return } let oldestTweetId = tweets.first?.tweetID let request = StatusesUserTimelineRequest(screenName: user.screenName, maxId: oldestTweetId, count: nil) client.sendTwitterRequest(request) { [weak self] in switch $0.result { case .success(let tweets): if tweets.count < 1 { self?.hasNext = false return } let filterdTweets = tweets.filter { $0.tweetID != oldestTweetId } let sortedTweets = filterdTweets.sorted { $0.0.createdAt.timeIntervalSince1970 < $0.1.createdAt.timeIntervalSince1970 } guard let storedTweets = self?.tweets else { return } self?.tweets = sortedTweets + storedTweets self?.tableView.reloadData() if let tweets = self?.tweets { let indexPath = IndexPath(row: tweets.count - 2, section: 0) self?.tableView.scrollToRow(at: indexPath, at: .bottom, animated: false) } case .failure(let error): print(error) self?.hasNext = false } } } } extension UserTimelineViewController { func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: IndexPath) -> CGFloat { guard (indexPath as NSIndexPath).row < tweets.count else { return 0 } let tweet = tweets[(indexPath as NSIndexPath).row] let width = UIScreen.main.bounds.size.width return TWTRTweetTableViewCell.height(for: tweet, style: .compact, width: width, showingActions: false) } func tableView(_ tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: IndexPath) { if (indexPath as NSIndexPath).row < 1 { //loadTweets() } } } extension UserTimelineViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return tweets.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: "TWTRTweetTableViewCell") as? TWTRTweetTableViewCell else { return tableView.dequeueReusableCell(withIdentifier: "UITableViewCell")! } cell.configure(with: tweets[(indexPath as NSIndexPath).row]) return cell } } ================================================ FILE: HoverConversionSample/HoverConversionSample.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 376AB1C31D8705C8001A8CD7 /* NextHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376AB1C21D8705C8001A8CD7 /* NextHeaderView.swift */; }; 376B9FC61D7C72B90009CC07 /* UserTimelineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376B9FC51D7C72B90009CC07 /* UserTimelineViewController.swift */; }; 376B9FC91D80752B0009CC07 /* TWTRAPIClient+Extra.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376B9FC81D80752B0009CC07 /* TWTRAPIClient+Extra.swift */; }; 376B9FCB1D80755A0009CC07 /* UsersLookUpRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376B9FCA1D80755A0009CC07 /* UsersLookUpRequest.swift */; }; 376B9FCD1D8076A10009CC07 /* TWTRRequestable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376B9FCC1D8076A10009CC07 /* TWTRRequestable.swift */; }; 376B9FCF1D808B250009CC07 /* StatusesUserTimelineRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 376B9FCE1D808B250009CC07 /* StatusesUserTimelineRequest.swift */; }; 377008E71D3BDAC7007606E8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 377008E61D3BDAC7007606E8 /* AppDelegate.swift */; }; 377008EC1D3BDAC7007606E8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 377008EA1D3BDAC7007606E8 /* Main.storyboard */; }; 377008EE1D3BDAC7007606E8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 377008ED1D3BDAC7007606E8 /* Assets.xcassets */; }; 377008F11D3BDAC7007606E8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 377008EF1D3BDAC7007606E8 /* LaunchScreen.storyboard */; }; 3799D0D81D7B462400CD339B /* TwitterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3799D0D31D7B462400CD339B /* TwitterManager.swift */; }; 3799D0DA1D7B462400CD339B /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3799D0D71D7B462400CD339B /* HomeViewController.swift */; }; 3799D0DD1D7B468600CD339B /* HomeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3799D0DB1D7B468600CD339B /* HomeTableViewCell.swift */; }; 3799D0DE1D7B468600CD339B /* HomeTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3799D0DC1D7B468600CD339B /* HomeTableViewCell.xib */; }; A19CAA499B1B6C5C98BAF960 /* Pods_HoverConversionSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 989C93E9FFF664FC7F5DAC59 /* Pods_HoverConversionSample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 178E9201DDD007E86236711A /* Pods-HoverConversionSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HoverConversionSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-HoverConversionSample/Pods-HoverConversionSample.debug.xcconfig"; sourceTree = ""; }; 376AB1C21D8705C8001A8CD7 /* NextHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NextHeaderView.swift; sourceTree = ""; }; 376B9FC51D7C72B90009CC07 /* UserTimelineViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserTimelineViewController.swift; sourceTree = ""; }; 376B9FC81D80752B0009CC07 /* TWTRAPIClient+Extra.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TWTRAPIClient+Extra.swift"; sourceTree = ""; }; 376B9FCA1D80755A0009CC07 /* UsersLookUpRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UsersLookUpRequest.swift; sourceTree = ""; }; 376B9FCC1D8076A10009CC07 /* TWTRRequestable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TWTRRequestable.swift; sourceTree = ""; }; 376B9FCE1D808B250009CC07 /* StatusesUserTimelineRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusesUserTimelineRequest.swift; sourceTree = ""; }; 377008E31D3BDAC6007606E8 /* HoverConversionSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HoverConversionSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 377008E61D3BDAC7007606E8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 377008EB1D3BDAC7007606E8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 377008ED1D3BDAC7007606E8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 377008F01D3BDAC7007606E8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 377008F21D3BDAC7007606E8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3799D0D31D7B462400CD339B /* TwitterManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwitterManager.swift; sourceTree = ""; }; 3799D0D71D7B462400CD339B /* HomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = ""; }; 3799D0DB1D7B468600CD339B /* HomeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeTableViewCell.swift; sourceTree = ""; }; 3799D0DC1D7B468600CD339B /* HomeTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomeTableViewCell.xib; sourceTree = ""; }; 989C93E9FFF664FC7F5DAC59 /* Pods_HoverConversionSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HoverConversionSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BCBB46B066D4D58B7568C17F /* Pods-HoverConversionSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HoverConversionSample.release.xcconfig"; path = "Pods/Target Support Files/Pods-HoverConversionSample/Pods-HoverConversionSample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 377008E01D3BDAC6007606E8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( A19CAA499B1B6C5C98BAF960 /* Pods_HoverConversionSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 376B9FC71D80752B0009CC07 /* Request */ = { isa = PBXGroup; children = ( 376B9FC81D80752B0009CC07 /* TWTRAPIClient+Extra.swift */, 376B9FCC1D8076A10009CC07 /* TWTRRequestable.swift */, 376B9FCA1D80755A0009CC07 /* UsersLookUpRequest.swift */, 376B9FCE1D808B250009CC07 /* StatusesUserTimelineRequest.swift */, ); path = Request; sourceTree = ""; }; 377008DA1D3BDAC6007606E8 = { isa = PBXGroup; children = ( 377008E51D3BDAC7007606E8 /* HoverConversionSample */, 377008E41D3BDAC6007606E8 /* Products */, 77C3C9ACBF70123F6F82AA62 /* Pods */, 3BDC8B7EA0C8D8C60EA01922 /* Frameworks */, ); sourceTree = ""; }; 377008E41D3BDAC6007606E8 /* Products */ = { isa = PBXGroup; children = ( 377008E31D3BDAC6007606E8 /* HoverConversionSample.app */, ); name = Products; sourceTree = ""; }; 377008E51D3BDAC7007606E8 /* HoverConversionSample */ = { isa = PBXGroup; children = ( 377008E61D3BDAC7007606E8 /* AppDelegate.swift */, 377008EA1D3BDAC7007606E8 /* Main.storyboard */, 3799D0D11D7B462400CD339B /* Cell */, 3799D0D21D7B462400CD339B /* Manager */, 376B9FC71D80752B0009CC07 /* Request */, 3799D0D51D7B462400CD339B /* View */, 3799D0D61D7B462400CD339B /* ViewController */, 377008ED1D3BDAC7007606E8 /* Assets.xcassets */, 377008EF1D3BDAC7007606E8 /* LaunchScreen.storyboard */, 377008F21D3BDAC7007606E8 /* Info.plist */, ); path = HoverConversionSample; sourceTree = ""; }; 3799D0D11D7B462400CD339B /* Cell */ = { isa = PBXGroup; children = ( 3799D0DB1D7B468600CD339B /* HomeTableViewCell.swift */, 3799D0DC1D7B468600CD339B /* HomeTableViewCell.xib */, ); path = Cell; sourceTree = ""; }; 3799D0D21D7B462400CD339B /* Manager */ = { isa = PBXGroup; children = ( 3799D0D31D7B462400CD339B /* TwitterManager.swift */, ); path = Manager; sourceTree = ""; }; 3799D0D51D7B462400CD339B /* View */ = { isa = PBXGroup; children = ( 376AB1C21D8705C8001A8CD7 /* NextHeaderView.swift */, ); path = View; sourceTree = ""; }; 3799D0D61D7B462400CD339B /* ViewController */ = { isa = PBXGroup; children = ( 3799D0D71D7B462400CD339B /* HomeViewController.swift */, 376B9FC51D7C72B90009CC07 /* UserTimelineViewController.swift */, ); path = ViewController; sourceTree = ""; }; 3BDC8B7EA0C8D8C60EA01922 /* Frameworks */ = { isa = PBXGroup; children = ( 989C93E9FFF664FC7F5DAC59 /* Pods_HoverConversionSample.framework */, ); name = Frameworks; sourceTree = ""; }; 77C3C9ACBF70123F6F82AA62 /* Pods */ = { isa = PBXGroup; children = ( 178E9201DDD007E86236711A /* Pods-HoverConversionSample.debug.xcconfig */, BCBB46B066D4D58B7568C17F /* Pods-HoverConversionSample.release.xcconfig */, ); name = Pods; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 377008E21D3BDAC6007606E8 /* HoverConversionSample */ = { isa = PBXNativeTarget; buildConfigurationList = 377008F51D3BDAC7007606E8 /* Build configuration list for PBXNativeTarget "HoverConversionSample" */; buildPhases = ( 60CE7C4347D44804863A8C57 /* [CP] Check Pods Manifest.lock */, 377008DF1D3BDAC6007606E8 /* Sources */, 377008E01D3BDAC6007606E8 /* Frameworks */, 377008E11D3BDAC6007606E8 /* Resources */, 3799D0CC1D7AB6B300CD339B /* ShellScript */, E091ECB7B854A4215F480250 /* [CP] Embed Pods Frameworks */, 90CB03264FD0C6DD77F59633 /* [CP] Copy Pods Resources */, ); buildRules = ( ); dependencies = ( ); name = HoverConversionSample; productName = HoverConversionSample; productReference = 377008E31D3BDAC6007606E8 /* HoverConversionSample.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 377008DB1D3BDAC6007606E8 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; LastUpgradeCheck = 0800; ORGANIZATIONNAME = "szk-atmosphere"; TargetAttributes = { 377008E21D3BDAC6007606E8 = { CreatedOnToolsVersion = 7.3.1; LastSwiftMigration = 0800; }; }; }; buildConfigurationList = 377008DE1D3BDAC6007606E8 /* Build configuration list for PBXProject "HoverConversionSample" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); mainGroup = 377008DA1D3BDAC6007606E8; productRefGroup = 377008E41D3BDAC6007606E8 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 377008E21D3BDAC6007606E8 /* HoverConversionSample */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 377008E11D3BDAC6007606E8 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 377008F11D3BDAC7007606E8 /* LaunchScreen.storyboard in Resources */, 377008EE1D3BDAC7007606E8 /* Assets.xcassets in Resources */, 3799D0DE1D7B468600CD339B /* HomeTableViewCell.xib in Resources */, 377008EC1D3BDAC7007606E8 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 3799D0CC1D7AB6B300CD339B /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Fabric/run\" 17f9b693790022f676a0812ed5b69bf3f93d01ff e63261495fad4e59db4746e04a9bedd867c4ef814a71a5d3fd4d6e5478288a20"; }; 60CE7C4347D44804863A8C57 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 90CB03264FD0C6DD77F59633 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HoverConversionSample/Pods-HoverConversionSample-resources.sh\"\n"; showEnvVarsInLog = 0; }; E091ECB7B854A4215F480250 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-HoverConversionSample/Pods-HoverConversionSample-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 377008DF1D3BDAC6007606E8 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 376B9FCF1D808B250009CC07 /* StatusesUserTimelineRequest.swift in Sources */, 376B9FC61D7C72B90009CC07 /* UserTimelineViewController.swift in Sources */, 376AB1C31D8705C8001A8CD7 /* NextHeaderView.swift in Sources */, 376B9FC91D80752B0009CC07 /* TWTRAPIClient+Extra.swift in Sources */, 3799D0DD1D7B468600CD339B /* HomeTableViewCell.swift in Sources */, 3799D0DA1D7B462400CD339B /* HomeViewController.swift in Sources */, 376B9FCB1D80755A0009CC07 /* UsersLookUpRequest.swift in Sources */, 377008E71D3BDAC7007606E8 /* AppDelegate.swift in Sources */, 376B9FCD1D8076A10009CC07 /* TWTRRequestable.swift in Sources */, 3799D0D81D7B462400CD339B /* TwitterManager.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ 377008EA1D3BDAC7007606E8 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( 377008EB1D3BDAC7007606E8 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; 377008EF1D3BDAC7007606E8 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( 377008F01D3BDAC7007606E8 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ 377008F31D3BDAC7007606E8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; 377008F41D3BDAC7007606E8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 9.3; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; name = Release; }; 377008F61D3BDAC7007606E8 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = 178E9201DDD007E86236711A /* Pods-HoverConversionSample.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = HoverConversionSample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "szk-atmosphere.HoverConversionSample"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Debug; }; 377008F71D3BDAC7007606E8 /* Release */ = { isa = XCBuildConfiguration; baseConfigurationReference = BCBB46B066D4D58B7568C17F /* Pods-HoverConversionSample.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = HoverConversionSample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "szk-atmosphere.HoverConversionSample"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 377008DE1D3BDAC6007606E8 /* Build configuration list for PBXProject "HoverConversionSample" */ = { isa = XCConfigurationList; buildConfigurations = ( 377008F31D3BDAC7007606E8 /* Debug */, 377008F41D3BDAC7007606E8 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; 377008F51D3BDAC7007606E8 /* Build configuration list for PBXNativeTarget "HoverConversionSample" */ = { isa = XCConfigurationList; buildConfigurations = ( 377008F61D3BDAC7007606E8 /* Debug */, 377008F71D3BDAC7007606E8 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; rootObject = 377008DB1D3BDAC6007606E8 /* Project object */; } ================================================ FILE: HoverConversionSample/HoverConversionSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: HoverConversionSample/HoverConversionSample.xcworkspace/contents.xcworkspacedata ================================================ ================================================ FILE: HoverConversionSample/Podfile ================================================ # Uncomment this line to define a global platform for your project platform :ios, '8.0' # Uncomment this line if you're using Swift use_frameworks! target 'HoverConversionSample' do pod 'HoverConversion', :path => '../' pod 'Fabric' pod 'TwitterKit' pod 'TwitterCore' pod 'TouchVisualizer', '~>2.0.1' end ================================================ FILE: LICENSE ================================================ Copyright (c) 2016 szk-atmosphere 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. ================================================ FILE: README.md ================================================ # HoverConversion [![Platform](http://img.shields.io/badge/platform-ios-blue.svg?style=flat )](https://developer.apple.com/iphone/index.action) [![Language](http://img.shields.io/badge/language-swift-brightgreen.svg?style=flat )](https://developer.apple.com/swift) [![Version](https://img.shields.io/cocoapods/v/HoverConversion.svg?style=flat)](http://cocoapods.org/pods/HoverConversion) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![License](https://img.shields.io/cocoapods/l/HoverConversion.svg?style=flat)](http://cocoapods.org/pods/HoverConversion) [ManiacDev.com](https://maniacdev.com/) referred. [https://maniacdev.com/2016/09/hoverconversion-a-swift-ui-component-for-navigating-between-multiple-table-views](https://maniacdev.com/2016/09/hoverconversion-a-swift-ui-component-for-navigating-between-multiple-table-views) ![](./Images/sample1.gif) ![](./Images/sample2.gif) HoverConversion realized vertical paging with UITableView. UIViewController will be paging when reaching top or bottom of UITableView's contentOffset. ## Featrue - [x] Vertical paging with UITableView - [x] Seamless transitioning - [x] Transitioning with navigationView pan gesture - [x] Selected cell that related to UIViewController is highlighting - [x] Support Swift2.3 - [x] Support Swift3 To run the example project, clone the repo, and run `pod install` from the Example directory first. ## Installation HoverConversion is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: ```ruby pod "HoverConversion" ``` ## Usage If you install from cocoapods, You have to write `import HoverConversion`. #### Storyboard or Xib ![](./Images/storyboard.png) Set custom class of `UINavigationController` to `HCNavigationController`. In addition, set module to `HoverConversion`. And set `HCRootViewController` as `navigationController`'s first viewController. #### Code Set `HCNavigationController` as `self.window.rootViewController`. And set `HCRootViewController` as `navigationController`'s first viewController. #### HCPagingViewController If you want to show vertical contents, please use `HCPagingViewController`. ```swift let vc = HCPagingViewController(indexPath: indexPath) vc.dataSource = self navigationController?.pushViewController(vc, animated: true) ``` #### HCContentViewController A content included in `HCPagingViewController` is `HCContentViewController`. Return `HCContentViewController` (or subclass) with this delegate method. ```swift extension ViewController: HCPagingViewControllerDataSource { func pagingViewController(viewController: HCPagingViewController, viewControllerFor indexPath: NSIndexPath) -> HCContentViewController? { guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil } let vc = UserTimelineViewController() vc.user = twitterManager.users[indexPath.row] return vc } } ``` #### HCNextHeaderView ![](./Images/next_header.png) Return `HCNextHeaderView` (or subclass) with this delegate method. ```swift extension ViewController: HCPagingViewControllerDataSource { func pagingViewController(viewController: HCPagingViewController, nextHeaderViewFor indexPath: NSIndexPath) -> HCNextHeaderView? { guard 0 <= indexPath.row && indexPath.row < twitterManager.users.count else { return nil } let view = NextHeaderView() view.user = twitterManager.users[indexPath.row] return view } } ``` #### Stop transitioning If you want to load more contents from server and want to stop transitioning, you can use `canPaging` in `HCContentViewController`. ```swift //Stop transitioning to previous ViewController canPaging[.prev] = false //Default true //Stop transitioning to next ViewController canPaging[.next] = false //Default true ``` ## Requirements - Xcode 7.3 or greater - iOS 8.0 or greater - [MisterFusion](https://github.com/marty-suzuki/MisterFusion) - Swift DSL for AutoLayout ## Special Thanks Those OSS are used in sample project! - [TouchVisualizer](https://github.com/morizotter/TouchVisualizer) (Created by [@morizotter](https://github.com/morizotter)) - [TwitterKit](https://docs.fabric.io/apple/twitter/overview.html#) ## Author marty-suzuki, s1180183@gmail.com ## License HoverConversion is available under the MIT license. See the LICENSE file for more info.