Skip to content

Commit 175368e

Browse files
author
Alberto Aznar
committed
Enable and disable gestures
1 parent f60582d commit 175368e

File tree

8 files changed

+58
-8
lines changed

8 files changed

+58
-8
lines changed

CiaoTransitions.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ s.ios.deployment_target = '11'
77
s.name = "CiaoTransitions"
88
s.summary = "With Ciao you can make fancy custom transitions. Use it in your iOS projects to make push and modal transitions between view controllers"
99
s.requires_arc = true
10-
s.version = "0.2.1"
10+
s.version = "0.2.2"
1111

1212
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
1313

CiaoTransitions/CiaoTransition.swift

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ open class CiaoTransition: NSObject {
3333
public func didScroll(_ scrollView: UIScrollView) {
3434
interactor.scrollViewDidScroll(scrollView)
3535
}
36+
37+
/// Enable gesture interactive transitions on dismiss
38+
public func enable() {
39+
interactor.enableGestures()
40+
}
41+
42+
/// Disable gesture interactive transitions on dismiss
43+
public func disable() {
44+
interactor.disableGestures()
45+
}
3646
}
3747

3848
/// PUSH & POP

CiaoTransitions/Interactor/BasicInteractor.swift

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public class BasicInteractor: Interactor {
2828
}
2929
}
3030

31+
public override func enableGestures() {
32+
dismissalPanGesture.delegate = self
33+
dismissalScreenEdgePanGesture.delegate = self
34+
}
35+
3136
private func dismissView() {
3237
if isNavigationEnabled {
3338
navigationController?.popViewController(animated: true)

CiaoTransitions/Interactor/Interactor.swift

+9
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ public class Interactor: UIPercentDrivenInteractiveTransition {
5959
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
6060

6161
}
62+
63+
public func disableGestures() {
64+
dismissalPanGesture.delegate = nil
65+
dismissalScreenEdgePanGesture.delegate = nil
66+
}
67+
68+
public func enableGestures() {
69+
70+
}
6271
}
6372

6473
extension Interactor: UIGestureRecognizerDelegate {

Example/CiaoTransitions/Controllers/AppStore/AppStoreCardsViewController.swift

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AppStoreCardsViewController: UIViewController {
3636
collectionView.delegate = self
3737
collectionView.clipsToBounds = false
3838
collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
39+
collectionView.contentInsetAdjustmentBehavior = .never
3940

4041
CardCollectionViewCell.register(nibFor: collectionView)
4142
TodayHeaderReusableView.register(nibFor: collectionView, kind: UICollectionView.elementKindSectionHeader)

Example/CiaoTransitions/Controllers/Items/Routing/ItemsRouting.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ extension ItemsRouting: ItemsRoutingInterface {
8181
}
8282
presentViewController?.transitioningDelegate = transition
8383

84-
switch item {
85-
case .push:
86-
viewController?.navigationController?.delegate = transition
87-
viewController?.navigationController?.pushViewController(presentViewController!, animated: true)
88-
case .modal:
84+
// switch item {
85+
// case .push:
86+
// viewController?.navigationController?.delegate = transition
87+
// viewController?.navigationController?.pushViewController(presentViewController!, animated: true)
88+
// case .modal:
8989
viewController?.present(presentViewController!, animated: true, completion: nil)
90-
}
90+
// }
9191

9292

9393
}

Example/CiaoTransitions/Controllers/Items/View/ItemsViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ extension ItemsViewController: ItemsViewInterface {
3838
collectionView.dataSource = protocols
3939
collectionView.delegate = protocols
4040
collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
41+
collectionView.contentInsetAdjustmentBehavior = .never
4142
}
42-
4343
}

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ func presentDetailView() {
139139
}
140140
```
141141

142+
#### Example modal with Navigation Controller
143+
```swift
144+
func presentDetailView() {
145+
let ciaoTransition = CiaoTransition(style: .vertical)
146+
let detailViewController = DetailViewController()
147+
detailViewController.ciaoTransition = ciaoTransition
148+
149+
let navigationController = UINavigationController(rootViewController: detailViewController)
150+
navigationController.transitioningDelegate = ciaoTransition
151+
152+
present(navigationController, animated: true, completion: nil)
153+
}
154+
```
155+
142156
## Configuration
143157

144158
### CiaoConfigurator
@@ -249,6 +263,17 @@ CiaoTransitionStyle.scaleImage
249263
CiaoTransitionStyle.appStore
250264
```
251265

266+
## Extra
267+
Additionally you can enable or disable dismiss gesture transitions whenever you want.
268+
269+
```swift
270+
// Enable gesture interactive transitions on dismiss
271+
ciaoTransition.enable()
272+
273+
// Disable gesture interactive transitions on dismiss
274+
ciaoTransition.disable()
275+
```
276+
252277
## Author
253278

254279
Alberto Aznar, info@alberdev.com

0 commit comments

Comments
 (0)