Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SPM #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BlowinSwiper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -311,7 +311,7 @@
PRODUCT_BUNDLE_IDENTIFIER = TakumaHoriuchi.BlowinSwiper;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
36 changes: 33 additions & 3 deletions BlowinSwiper/BlowinSwiper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ public final class BlowinSwiper: NSObject {
private var isInteractivePop = false
private var isDecideBack = false
private var isOnceGestureBegan = true
private var deferredDelegate: UINavigationControllerDelegate?

public init(navigationController: UINavigationController?) {
super.init()
self.navigationController = navigationController
self.deferredDelegate = navigationController?.delegate

let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:)))
panGesture.delegate = self
Expand Down Expand Up @@ -102,22 +104,50 @@ extension BlowinSwiper: UIGestureRecognizerDelegate {
}

extension BlowinSwiper: UINavigationControllerDelegate {
public func navigationController(_ navigationController: UINavigationController,
willShow viewController: UIViewController,
animated: Bool) {
deferredDelegate?.navigationController?(navigationController, willShow: viewController, animated: animated)
}

public func navigationController(_ navigationController: UINavigationController,
didShow viewController: UIViewController,
animated: Bool) {
deferredDelegate?.navigationController?(navigationController, didShow: viewController, animated: animated)
}

public func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
animationControllerFor operation: UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
let deferredValue = deferredDelegate?.navigationController?(
navigationController, animationControllerFor: operation, from: fromVC, to: toVC
)
switch operation {
case .pop:
return PopAnimatedTransitioning(isInteractivePop: isInteractivePop)

default:
return nil
return deferredValue
}
}

public func navigationController(_ navigationController: UINavigationController,
interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
return isInteractivePop ? percentDriven : nil
return isInteractivePop
? percentDriven
: deferredDelegate?.navigationController?(navigationController, interactionControllerFor: animationController)
}

public func navigationControllerSupportedInterfaceOrientations(
_ navigationController: UINavigationController
) -> UIInterfaceOrientationMask {
return deferredDelegate?.navigationControllerSupportedInterfaceOrientations?(navigationController) ?? [.all]
}

public func navigationControllerPreferredInterfaceOrientationForPresentation(
_ navigationController: UINavigationController
) -> UIInterfaceOrientation {
return deferredDelegate?.navigationControllerPreferredInterfaceOrientationForPresentation?(navigationController) ?? .unknown
}
}
24 changes: 24 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "BlowinSwiper",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "BlowinSwiper",
targets: ["BlowinSwiper"]
),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "BlowinSwiper",
dependencies: [],
path: "BlowinSwiper"
),
]
)