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

Update to Swift 5 #12

Open
wants to merge 4 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
Binary file added .DS_Store
Binary file not shown.
Binary file added Example/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Example/YapAnimatorExample-iOS/Resources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
31 changes: 20 additions & 11 deletions Example/YapAnimatorExample-iOS/Resources/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--First-->
<scene sceneID="hNz-n2-bh7">
<objects>
<viewController id="9pv-A4-QxB" customClass="FirstViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="9pv-A4-QxB" customClass="FirstViewController" customModule="YapAnimatorExample_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ia1-K6-d13"/>
<viewControllerLayoutGuide type="bottom" id="4ug-Mw-9AY"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="First View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="128.5" y="427.5" width="157.5" height="41.5"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<rect key="frame" x="110" y="477" width="194.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand All @@ -46,24 +50,26 @@
<!--Second-->
<scene sceneID="wg7-f3-ORb">
<objects>
<viewController id="8rJ-Kc-sve" customClass="SecondViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="8rJ-Kc-sve" customClass="SecondViewController" customModule="YapAnimatorExample_iOS" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="L7p-HK-0SC"/>
<viewControllerLayoutGuide type="bottom" id="Djb-ko-YwX"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="QS5-Rx-YEW">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Second View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="zEq-FU-wV5">
<rect key="frame" x="102.5" y="427.5" width="209.5" height="41.5"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name="Helvetica" family="Helvetica" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
<rect key="frame" x="99.5" y="477" width="215" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down Expand Up @@ -104,5 +110,8 @@
<resources>
<image name="first" width="30" height="30"/>
<image name="second" width="30" height="30"/>
<systemColor name="darkTextColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- YapAnimator (1.2.0)
- YapAnimator (1.3.1)

DEPENDENCIES:
- YapAnimator (from `./`)

EXTERNAL SOURCES:
YapAnimator:
:path: ./
:path: "./"

SPEC CHECKSUMS:
YapAnimator: 6b682c9587b66163239a27a0ea6e0cf7b9f181a5
YapAnimator: 0fcf1aac258baf286a5a227f1de64edef5e20f02

PODFILE CHECKSUM: b39ff26ae2dc1d34f8cd981143f287258736a213

COCOAPODS: 1.2.1
COCOAPODS: 1.10.1
2 changes: 1 addition & 1 deletion Source/AnimatableLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public class YapAnimatedLayer {
self.delegate?.setValue(animator.current.value, forKeyPath: "transform.scale")
}
})

public lazy var frame: YapAnimator<CGRect> = YapAnimator(initialValue: self.delegate!.frame, willBegin: { [unowned self] in
self.delegate?.frame ?? CGRect.zero
}, eachFrame: { [unowned self] animator in
Expand Down
32 changes: 18 additions & 14 deletions Source/YapAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ fileprivate extension YapAnimator {
}

func lerp(start: [Double], end: [Double], percent: Double) -> [Double] {
return zip(start, end).flatMap { lerp(start: $0.0, end: $0.1, percent: percent) }
return zip(start, end).compactMap { lerp(start: $0.0, end: $0.1, percent: percent) }
}

func criticalFriction() -> Double {
Expand All @@ -308,19 +308,23 @@ fileprivate extension YapAnimator {
self.observer = Engine.sharedInstance
}

func bouncy(offset: T, tension: Double, friction: Double) -> AccelerationFnType {

return { state in
T.composed(from: zip(offset.components, state.velocity.components)
.flatMap { $0.0 != 0.0 ? (-tension * $0.0) - (friction * $0.1) : 0.0 })
}
}
func bouncy(offset: T, tension: Double, friction: Double) -> AccelerationFnType {
return { state in
T.composed(from: zip(offset.components, state.velocity.components)
.compactMap {
if $0.0 != 0.0 {
return (-tension * $0.0) - (friction * $0.1)
}
return 0.0
})
}
}

func decay(forces: T, resistance: Double, dT: CFTimeInterval) -> AccelerationFnType {

return { state in
T.composed(from: zip(forces.components, state.velocity.components)
.flatMap { ($0.0 / dT) - $0.1 * resistance })
.compactMap { ($0.0 / dT) - $0.1 * resistance })
}
}

Expand All @@ -341,11 +345,11 @@ fileprivate extension YapAnimator {
// MARK: - Everything else

func +<T>(lhs: T, rhs: T) -> T where T: Animatable {
return T.composed(from: zip(lhs.components, rhs.components).flatMap { $0.0 + $0.1 })
return T.composed(from: zip(lhs.components, rhs.components).compactMap { $0.0 + $0.1 })
}

func -<T>(lhs: T, rhs: T) -> T where T: Animatable {
return T.composed(from: zip(lhs.components, rhs.components).flatMap { $0.0 - $0.1 })
return T.composed(from: zip(lhs.components, rhs.components).compactMap { $0.0 - $0.1 })
}

fileprivate enum YapAnimatorState {
Expand All @@ -368,7 +372,7 @@ public struct PhysicsState<T> where T: Animatable {
public var velocity: T
}

fileprivate protocol YapAnimatorCommonInterface: class {
fileprivate protocol YapAnimatorCommonInterface: AnyObject {

var state: YapAnimatorState { get set }

Expand Down Expand Up @@ -441,7 +445,7 @@ fileprivate final class DisplayLink: NSObject {
#elseif os(iOS) || os(tvOS)

displayLink = CADisplayLink(target: self, selector: #selector(step(with:)))
displayLink?.add(to: .current, forMode: .commonModes)
displayLink?.add(to: .current, forMode: RunLoop.Mode.common)

#endif
}
Expand Down Expand Up @@ -529,7 +533,7 @@ extension Engine: YapAnimatorObserver {
}
}

fileprivate protocol YapAnimatorObserver: class {
fileprivate protocol YapAnimatorObserver: AnyObject {

func didChangeState(animator: YapAnimatorCommonInterface)
}
2 changes: 1 addition & 1 deletion YapAnimator.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "YapAnimator"
s.version = "1.2.0"
s.version = "1.3.2"
s.summary = "Yap Studios Animation Framework"
s.homepage = "http://yapstudios.com/"
s.license = "BSD"
Expand Down
Loading