Skip to content

Commit c6054ac

Browse files
committed
Added onboarding with transition demos
1 parent 25c7c79 commit c6054ac

File tree

17 files changed

+401
-27
lines changed

17 files changed

+401
-27
lines changed

demo/IntroductionToCoreImage.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
17A9345929697BFF004EE3CA /* OnboardingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 17A9345729697BFF004EE3CA /* OnboardingViewController.xib */; };
11+
17A9345A29697BFF004EE3CA /* OnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A9345829697BFF004EE3CA /* OnboardingViewController.swift */; };
12+
17A9345C29697C09004EE3CA /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A9345B29697C09004EE3CA /* Coordinator.swift */; };
13+
17A9345E296983E9004EE3CA /* CIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17A9345D296983E9004EE3CA /* CIImage+Extension.swift */; };
1014
17DF3B362965FD3400FA0E23 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF3B2C2965FD3400FA0E23 /* AboutViewController.swift */; };
1115
17DF3B372965FD3400FA0E23 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17DF3B2D2965FD3400FA0E23 /* AppDelegate.swift */; };
1216
17DF3B392965FD3400FA0E23 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 17DF3B302965FD3400FA0E23 /* Assets.xcassets */; };
@@ -16,6 +20,10 @@
1620
/* End PBXBuildFile section */
1721

1822
/* Begin PBXFileReference section */
23+
17A9345729697BFF004EE3CA /* OnboardingViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OnboardingViewController.xib; sourceTree = "<group>"; };
24+
17A9345829697BFF004EE3CA /* OnboardingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingViewController.swift; sourceTree = "<group>"; };
25+
17A9345B29697C09004EE3CA /* Coordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = "<group>"; };
26+
17A9345D296983E9004EE3CA /* CIImage+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CIImage+Extension.swift"; sourceTree = "<group>"; };
1927
17DF3B142965FCF900FA0E23 /* IntroductionToCoreImage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IntroductionToCoreImage.app; sourceTree = BUILT_PRODUCTS_DIR; };
2028
17DF3B2C2965FD3400FA0E23 /* AboutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
2129
17DF3B2D2965FD3400FA0E23 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -37,6 +45,15 @@
3745
/* End PBXFrameworksBuildPhase section */
3846

3947
/* Begin PBXGroup section */
48+
17A9345629697BFF004EE3CA /* OnboardingViewController */ = {
49+
isa = PBXGroup;
50+
children = (
51+
17A9345829697BFF004EE3CA /* OnboardingViewController.swift */,
52+
17A9345729697BFF004EE3CA /* OnboardingViewController.xib */,
53+
);
54+
path = OnboardingViewController;
55+
sourceTree = "<group>";
56+
};
4057
17DF3B0B2965FCF900FA0E23 = {
4158
isa = PBXGroup;
4259
children = (
@@ -57,9 +74,12 @@
5774
17DF3B2B2965FD3400FA0E23 /* Sources */ = {
5875
isa = PBXGroup;
5976
children = (
77+
17A9345629697BFF004EE3CA /* OnboardingViewController */,
6078
17DF3B3D2965FEFC00FA0E23 /* AboutViewController */,
6179
17DF3B2D2965FD3400FA0E23 /* AppDelegate.swift */,
80+
17A9345B29697C09004EE3CA /* Coordinator.swift */,
6281
17DF3B4029662EE600FA0E23 /* UIView+Snapshot.swift */,
82+
17A9345D296983E9004EE3CA /* CIImage+Extension.swift */,
6383
);
6484
path = Sources;
6585
sourceTree = "<group>";
@@ -144,6 +164,7 @@
144164
17DF3B392965FD3400FA0E23 /* Assets.xcassets in Resources */,
145165
17DF3B3F296627F100FA0E23 /* AboutViewController.xib in Resources */,
146166
17DF3B3A2965FD3400FA0E23 /* LaunchScreen.storyboard in Resources */,
167+
17A9345929697BFF004EE3CA /* OnboardingViewController.xib in Resources */,
147168
);
148169
runOnlyForDeploymentPostprocessing = 0;
149170
};
@@ -156,7 +177,10 @@
156177
files = (
157178
17DF3B372965FD3400FA0E23 /* AppDelegate.swift in Sources */,
158179
17DF3B362965FD3400FA0E23 /* AboutViewController.swift in Sources */,
180+
17A9345C29697C09004EE3CA /* Coordinator.swift in Sources */,
181+
17A9345E296983E9004EE3CA /* CIImage+Extension.swift in Sources */,
159182
17DF3B4129662EE600FA0E23 /* UIView+Snapshot.swift in Sources */,
183+
17A9345A29697BFF004EE3CA /* OnboardingViewController.swift in Sources */,
160184
);
161185
runOnlyForDeploymentPostprocessing = 0;
162186
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "onboarding-image-1.jpeg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "joel-vodell-8Ogfqvw15Rg-unsplash.jpg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "onboarding-image-3.jpg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Loading
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "onboarding-image-4.jpg",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}
Loading

demo/Sources/AboutViewController/AboutViewController.swift

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ViewController.swift
2+
// AboutViewController.swift
33
// IntroductionToCoreImage
44
//
55
// Created by Florian Denis on 04/01/2023.
@@ -10,32 +10,29 @@ import CoreImage.CIFilterBuiltins
1010
import MetalKit
1111
import UIKit
1212

13-
extension CIImage {
14-
func applyingFilter<T: CIFilter>(_ filter: T, _ configurationBlock: ((T) -> Void)? = nil) -> CIImage {
15-
filter.setValue(self, forKey: kCIInputImageKey)
16-
configurationBlock?(filter)
17-
return filter.outputImage ?? self
18-
}
19-
}
20-
21-
2213
class AboutViewController: UIViewController {
14+
public var nextPressedHandler: (() -> Void)?
15+
2316
private var snapshotImage: CIImage?
2417
private var gestureLocation: CGPoint?
2518

2619
private var processedImage: CIImage? {
27-
// snapshotImage?
28-
// .applyingFilter(CIFilter.bumpDistortion()) {
29-
// $0.center = self.gestureLocation ?? .zero
30-
// $0.radius = 300
31-
// $0.scale = 0.3 + Float(1 + cos(CACurrentMediaTime())) / 3
32-
// }
33-
snapshotImage?
20+
guard
21+
let center = self.gestureLocation,
22+
let snapshot = snapshotImage
23+
else { return nil }
24+
25+
return snapshot
3426
.applyingFilter(CIFilter.twirlDistortion()) {
35-
$0.center = self.gestureLocation ?? .zero
27+
$0.center = center
3628
$0.radius = 300
3729
$0.angle = .pi / 2
3830
}
31+
.applyingFilter(CIFilter.bumpDistortion()) {
32+
$0.center = center
33+
$0.radius = 300
34+
$0.scale = Float(1 + cos(CACurrentMediaTime())) / 5
35+
}
3936
}
4037

4138
@IBAction private func panGestureRecognized(_ gesture: UIPanGestureRecognizer) {
@@ -51,7 +48,6 @@ class AboutViewController: UIViewController {
5148
.applying(CGAffineTransform(translationX: 0, y: view.bounds.height))
5249
.applying(CGAffineTransform(scaleX: scale, y: scale))
5350

54-
5551
if [.cancelled, .ended].contains(gesture.state) {
5652
snapshotImage = nil
5753
mtkView.isPaused = true
@@ -81,6 +77,12 @@ class AboutViewController: UIViewController {
8177
mtkView.delegate = self
8278
mtkView.framebufferOnly = false
8379
}
80+
81+
// MARK: -
82+
83+
@IBAction private func nextPressed() {
84+
nextPressedHandler?()
85+
}
8486
}
8587

8688
extension AboutViewController: MTKViewDelegate {

0 commit comments

Comments
 (0)