Skip to content

Commit f60582d

Browse files
author
Alberto Aznar
committed
Bug fixed with scrolling
1 parent 6893601 commit f60582d

8 files changed

+68
-37
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.0"
10+
s.version = "0.2.1"
1111

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

CiaoTransitions/CiaoTransition.swift

+14-10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ open class CiaoTransition: NSObject {
2929
self.animator = style.animator(configurator: self.configurator, scaleConfigurator: self.scaleConfigurator)
3030
self.interactor = style.interactor(configurator: self.configurator)
3131
}
32+
33+
public func didScroll(_ scrollView: UIScrollView) {
34+
interactor.scrollViewDidScroll(scrollView)
35+
}
3236
}
3337

3438
/// PUSH & POP
@@ -114,14 +118,14 @@ extension CiaoTransition: UIViewControllerTransitioningDelegate {
114118
}
115119
}
116120

117-
extension CiaoTransition: UIScrollViewDelegate {
118-
119-
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
120-
interactor.scrollViewDidScroll(scrollView)
121-
}
122-
123-
public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
124-
interactor.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
125-
}
126-
}
121+
//extension CiaoTransition: UIScrollViewDelegate {
122+
//
123+
// public func scrollViewDidScroll(_ scrollView: UIScrollView) {
124+
//
125+
// }
126+
//
127+
// public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
128+
// interactor.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
129+
// }
130+
//}
127131

Example/CiaoTransitions/Controllers/AppStore/AppStoreCardsViewController.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import CiaoTransitions
1212
class AppStoreCardsViewController: UIViewController {
1313

1414
@IBOutlet weak var collectionView: UICollectionView!
15+
var ciaoTransition: CiaoTransition?
1516

1617
var cards = [[
1718
CardContentView.ViewModel(image: UIImage(named: "Image1"), title: "Best latest\nphotos sample 1", subtitle: "FEATURED IMAGES"),
@@ -103,9 +104,6 @@ extension AppStoreCardsViewController: UICollectionViewDataSource, UICollectionV
103104
header.viewModel = TodayHeaderReusableView.ViewModel(title: "Today", subtitle: "APPSTORE CARDS TRANSITION", image: UIImage(named: "Profile"))
104105
return header
105106
}
106-
}
107-
108-
extension AppStoreCardsViewController: UICollectionViewDelegate {
109107

110108
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
111109

@@ -131,3 +129,11 @@ extension AppStoreCardsViewController: UICollectionViewDelegate {
131129
present(presentViewController, animated: true, completion: nil)
132130
}
133131
}
132+
133+
extension AppStoreCardsViewController: UIScrollViewDelegate {
134+
135+
func scrollViewDidScroll(_ scrollView: UIScrollView) {
136+
ciaoTransition?.didScroll(scrollView)
137+
}
138+
}
139+

Example/CiaoTransitions/Controllers/Detail/AppStoreCardDetailViewController.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import UIKit
1010
import CiaoTransitions
1111

12-
class AppStoreCardDetailViewController: UIViewController {
12+
class AppStoreCardDetailViewController: UIViewController, UIScrollViewDelegate {
1313

1414
@IBOutlet weak var scrollView: UIScrollView!
1515
@IBOutlet weak var cardContentView: CardContentView!
@@ -22,6 +22,10 @@ class AppStoreCardDetailViewController: UIViewController {
2222
super.viewDidLoad()
2323
view.clipsToBounds = true
2424
cardContentView.viewModel = viewModel
25-
scrollView.delegate = ciaoTransition
25+
scrollView.delegate = self
26+
}
27+
28+
func scrollViewDidScroll(_ scrollView: UIScrollView) {
29+
ciaoTransition?.didScroll(scrollView)
2630
}
2731
}

Example/CiaoTransitions/Controllers/Detail/AppStoreCardDetailViewController.xib

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
89
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
910
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1011
</dependencies>
@@ -19,14 +20,14 @@
1920
</placeholder>
2021
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
2122
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="nrq-2g-nW4">
22-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
23+
<rect key="frame" x="0.0" y="0.0" width="375" height="994"/>
2324
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2425
<subviews>
2526
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nKp-Rh-3Iv">
26-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
27+
<rect key="frame" x="0.0" y="0.0" width="375" height="994"/>
2728
<subviews>
2829
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Scs-Vr-84v">
29-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
30+
<rect key="frame" x="0.0" y="0.0" width="375" height="994"/>
3031
<subviews>
3132
<view tag="100" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="she-Df-Y1g" customClass="CardContentView" customModule="CiaoTransitions_Example" customModuleProvider="target">
3233
<rect key="frame" x="0.0" y="0.0" width="375" height="350"/>
@@ -36,11 +37,19 @@
3637
</constraints>
3738
</view>
3839
<label opaque="NO" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Rte-LT-cFZ">
39-
<rect key="frame" x="8" y="358" width="359" height="184"/>
40-
<string key="text">Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
40+
<rect key="frame" x="8" y="358" width="359" height="585"/>
41+
<mutableString key="text">Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
4142

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
4243

43-
Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
44+
Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
45+

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
46+
47+
Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
48+
49+
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua.
50+

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
51+
52+
Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</mutableString>
4453
<fontDescription key="fontDescription" type="system" pointSize="14"/>
4554
<color key="textColor" red="0.23137254900000001" green="0.2156862745" blue="0.21960784310000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4655
<nil key="highlightedColor"/>
@@ -74,8 +83,9 @@ Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deseru
7483
<constraint firstItem="nKp-Rh-3Iv" firstAttribute="top" secondItem="nrq-2g-nW4" secondAttribute="top" id="n7y-o7-Glk"/>
7584
<constraint firstItem="nKp-Rh-3Iv" firstAttribute="trailing" secondItem="atI-P0-WL4" secondAttribute="trailing" id="uJW-S5-EbU"/>
7685
</constraints>
86+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
7787
<viewLayoutGuide key="safeArea" id="atI-P0-WL4"/>
78-
<point key="canvasLocation" x="33.5" y="53.5"/>
88+
<point key="canvasLocation" x="32.799999999999997" y="199.70014992503749"/>
7989
</view>
8090
</objects>
8191
</document>

Example/CiaoTransitions/Controllers/Detail/ScrollFadeViewController.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
import UIKit
1010
import CiaoTransitions
1111

12-
class ScrollFadeViewController: UIViewController {
12+
class ScrollFadeViewController: UIViewController, UIScrollViewDelegate {
1313

1414
@IBOutlet weak var scrollView: UIScrollView!
1515
var ciaoTransition: CiaoTransition?
1616

1717
override func viewDidLoad() {
1818
super.viewDidLoad()
19-
scrollView.delegate = ciaoTransition
19+
scrollView.delegate = self
2020
}
2121

22-
// func scrollViewDidScroll(_ scrollView: UIScrollView) {
23-
// transition?.didScroll(scrollView: scrollView)
24-
// }
22+
func scrollViewDidScroll(_ scrollView: UIScrollView) {
23+
ciaoTransition?.didScroll(scrollView)
24+
}
2525
}
2626

2727

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ extension ItemsRouting: ItemsRoutingInterface {
6363
case .appStore:
6464

6565
configurator.lateralTranslationEnabled = true
66-
configurator.dragDownEnabled = false
67-
configurator.dragLateralEnabled = true
66+
configurator.dragDownEnabled = true
67+
configurator.dragLateralEnabled = false
6868
presentViewController = AppStoreCardsViewController()
6969
}
7070

7171
if style == .appStore {
72-
style = .lateral
72+
style = .vertical
7373
}
7474
transition = CiaoTransition(style: style, configurator: configurator, scaleConfigurator: scaleConfigurator)
7575

7676
if let presentViewController = presentViewController as? ScrollFadeViewController {
7777
presentViewController.ciaoTransition = transition
7878
}
79+
if let presentViewController = presentViewController as? AppStoreCardsViewController {
80+
presentViewController.ciaoTransition = transition
81+
}
7982
presentViewController?.transitioningDelegate = transition
8083

8184
switch item {

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,27 @@ In the example you will see some custom transitions that can be used in your pro
6565

6666
### 1. Add CiaoTransition to your presented view controller
6767

68-
Add `CiaoTransition` to your presented view controller. This is neccessary to save your retain your transition for dismissed interaction. Also you could need it if have some scroll view. In this case, you should set scroll view delegate to your `CiaoTransition`
68+
Add `CiaoTransition` to your presented view controller. This is neccessary to save your retain your transition for dismissed interaction. Also you could need it if have some scroll view. In this case, you should call `didScroll` method when the view is scrolled
6969

7070
```swift
71-
class DetailViewController: CiaoBaseViewController {
71+
class DetailViewController: CiaoBaseViewController, UIScrollViewDelegate {
7272

7373
@IBOutlet weak var scrollView: UIScrollView!
7474

7575
var ciaoTransition: CiaoTransition?
7676

7777
override func viewDidLoad() {
7878
super.viewDidLoad()
79-
scrollView.delegate = ciaoTransition
79+
scrollView.delegate = self
80+
}
81+
82+
func scrollViewDidScroll(_ scrollView: UIScrollView) {
83+
ciaoTransition?.didScroll(scrollView)
8084
}
8185
}
8286
```
8387

84-
> Important: If the view have some **Scroll View**, you must set his delegate to your transition object once view is loaded. This is needed by `CiaoTransition` to manage interactive transitions.
88+
> Important: If the view have some **Scroll View**, you must implement UIScrollViewDelegate protocol and call `didScroll` method when the view is scrolled. This is needed by `CiaoTransition` to manage interactive transitions.
8589
8690
### 2. Instace CiaoTransition with your values
8791

0 commit comments

Comments
 (0)