Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Bump supported SDK to iOS 9.
Browse files Browse the repository at this point in the history
Summary: We'll investigate iOS 8 support after we cut v1.

Reviewers: O2 Material Motion, O4 Material Apple platform reviewers, #material_motion, chuga

Reviewed By: O4 Material Apple platform reviewers, chuga

Tags: #material_motion

Differential Revision: http://codereview.cc/D2878
  • Loading branch information
jverkoey committed Mar 15, 2017
1 parent a63e61a commit 6516319
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Podfile.lock
Expand Up @@ -20,7 +20,7 @@ SPEC CHECKSUMS:
CatalogByConvention: be55c2263132e4f9f59299ac8a528ee8715b3275
IndefiniteObservable: 2789d61f487d8d37fa2b9c3153cc44d4447ff744
pop: f667631a5108a2e60d9e8797c9b32ddaf2080bce
ReactiveMotion: 9dd34c7c297f308fd09cf4ad6df4ab9924b372fe
ReactiveMotion: ce310a701dbfaff6522cc58e4df00657bc120158

PODFILE CHECKSUM: 3351385be5c3c7626c357a5568b15c5faa6997ab

Expand Down
2 changes: 1 addition & 1 deletion ReactiveMotion.podspec
Expand Up @@ -6,7 +6,7 @@ Pod::Spec.new do |s|
s.license = "Apache 2.0"
s.homepage = "https://github.com/material-motion/reactive-motion-swift"
s.source = { :git => "https://github.com/material-motion/reactive-motion-swift.git", :tag => "v" + s.version.to_s }
s.platform = :ios, "8.0"
s.platform = :ios, "9.0"
s.requires_arc = true

s.source_files = "src/**/*.{swift}"
Expand Down
3 changes: 0 additions & 3 deletions examples/ContextualTransitionExample.swift
Expand Up @@ -80,7 +80,6 @@ class PhotoCollectionViewCell: UICollectionViewCell {
}
}

@available(iOS 9.0, *)
public class ContextualTransitionExampleViewController: UICollectionViewController, TransitionContextViewRetriever {

let album = PhotoAlbum()
Expand Down Expand Up @@ -154,7 +153,6 @@ public class ContextualTransitionExampleViewController: UICollectionViewControll
}
}

@available(iOS 9.0, *)
class PhotoAlbumViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {

var collectionView: UICollectionView!
Expand Down Expand Up @@ -255,7 +253,6 @@ class PhotoAlbumViewController: UIViewController, UICollectionViewDataSource, UI
}
}

@available(iOS 9.0, *)
private class PushBackTransition: Transition {

required init() {}
Expand Down
1 change: 0 additions & 1 deletion examples/DragSourceExample.swift
Expand Up @@ -17,7 +17,6 @@
import UIKit
import ReactiveMotion

@available(iOS 9.0, *)
public class DragSourceExampleViewController: UIViewController {

var runtime: MotionRuntime!
Expand Down
3 changes: 0 additions & 3 deletions examples/FabTransitionExample.swift
Expand Up @@ -17,7 +17,6 @@
import UIKit
import ReactiveMotion

@available(iOS 9.0, *)
public class FabTransitionExampleViewController: UIViewController, TransitionContextViewRetriever {

var actionButton: UIButton!
Expand Down Expand Up @@ -53,7 +52,6 @@ public class FabTransitionExampleViewController: UIViewController, TransitionCon
}
}

@available(iOS 9.0, *)
private class ModalViewController: UIViewController, UITableViewDataSource {

override func viewDidLoad() {
Expand Down Expand Up @@ -84,7 +82,6 @@ private class ModalViewController: UIViewController, UITableViewDataSource {

let floodFillOvershootRatio: CGFloat = 1.2

@available(iOS 9.0, *)
private class CircularRevealTransition: Transition {

// TODO: Support for transient views.
Expand Down
3 changes: 0 additions & 3 deletions examples/InteractivePushBackTransitionExample.swift
Expand Up @@ -17,7 +17,6 @@
import UIKit
import ReactiveMotion

@available(iOS 9.0, *)
public class InteractivePushBackTransitionExampleViewController: UIViewController {

override public func viewDidLoad() {
Expand All @@ -34,7 +33,6 @@ public class InteractivePushBackTransitionExampleViewController: UIViewControlle
}
}

@available(iOS 9.0, *)
private class ModalViewController: UIViewController {

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
Expand All @@ -58,7 +56,6 @@ private class ModalViewController: UIViewController {
}
}

@available(iOS 9.0, *)
private class PushBackTransition: Transition {

required init() {}
Expand Down
7 changes: 1 addition & 6 deletions examples/ModalDialogExample.swift
Expand Up @@ -42,11 +42,7 @@ class ModalDialogViewController: UIViewController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

if #available(iOS 9.0, *) {
transitionController.transitionType = ModalDialogTransition.self
} else {
// Fallback on earlier versions
}
transitionController.transitionType = ModalDialogTransition.self

modalPresentationStyle = .overCurrentContext
}
Expand All @@ -70,7 +66,6 @@ class ModalDialogViewController: UIViewController {
}
}

@available(iOS 9.0, *)
class ModalDialogTransition: SelfDismissingTransition {

required init() {}
Expand Down
3 changes: 0 additions & 3 deletions examples/PushBackTransitionExample.swift
Expand Up @@ -17,7 +17,6 @@
import UIKit
import ReactiveMotion

@available(iOS 9.0, *)
public class PushBackTransitionExampleViewController: UIViewController {

override public func viewDidLoad() {
Expand All @@ -34,7 +33,6 @@ public class PushBackTransitionExampleViewController: UIViewController {
}
}

@available(iOS 9.0, *)
private class ModalViewController: UIViewController {

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
Expand All @@ -60,7 +58,6 @@ private class ModalViewController: UIViewController {
}
}

@available(iOS 9.0, *)
private class PushBackTransition: Transition {

required init() {}
Expand Down
3 changes: 0 additions & 3 deletions examples/StickerPickerExample.swift
Expand Up @@ -17,7 +17,6 @@
import Foundation
import ReactiveMotion

@available(iOS 9.0, *)
public class StickerPickerExampleViewController: UIViewController, StickerListViewControllerDelegate {

var runtime: MotionRuntime!
Expand Down Expand Up @@ -121,7 +120,6 @@ private class StickerCollectionViewCell: UICollectionViewCell {
}
}

@available(iOS 9.0, *)
private class StickerListViewController: UICollectionViewController {

let album = StickerAlbum()
Expand Down Expand Up @@ -189,7 +187,6 @@ private protocol StickerListViewControllerDelegate: NSObjectProtocol {
func didPickSticker(_ sticker: Sticker)
}

@available(iOS 9.0, *)
private class ModalTransition: Transition {

required init() {}
Expand Down
4 changes: 2 additions & 2 deletions examples/apps/Catalog/Catalog.xcodeproj/project.pbxproj
Expand Up @@ -629,7 +629,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -669,7 +669,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
6 changes: 0 additions & 6 deletions examples/apps/Catalog/Catalog/TableOfContents.swift
Expand Up @@ -38,7 +38,6 @@ extension DirectlyManipulableExampleViewController {
class func catalogBreadcrumbs() -> [String] { return ["Directly manipulable"] }
}

@available(iOS 9.0, *)
extension DragSourceExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Drag source"]
Expand All @@ -63,28 +62,24 @@ extension ModalDialogExampleViewController {
}
}

@available(iOS 9.0, *)
extension ContextualTransitionExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Contextual transition"]
}
}

@available(iOS 9.0, *)
extension FabTransitionExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["FAB transition"]
}
}

@available(iOS 9.0, *)
extension PushBackTransitionExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Push back transition"]
}
}

@available(iOS 9.0, *)
extension InteractivePushBackTransitionExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Push back transition (interactive)"]
Expand All @@ -97,7 +92,6 @@ extension SwipeExampleViewController {
}
}

@available(iOS 9.0, *)
extension StickerPickerExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Sticker picker"]
Expand Down
63 changes: 29 additions & 34 deletions src/reactivetypes/ReactiveCALayer.swift
Expand Up @@ -194,26 +194,24 @@ public func createCoreAnimationProperty<T>(_ name: String, initialValue: T, exte
basicAnimation.isAdditive = true
}

if #available(iOS 9.0, *) {
// Core Animation springs do not support multi-dimensional velocity, so we bear the burden
// of decomposing multi-dimensional springs here.
if let springAnimation = animation as? CASpringAnimation
, springAnimation.isAdditive
, let initialVelocity = info.initialVelocity as? CGPoint
, let delta = springAnimation.fromValue as? CGPoint {
let decomposed = decompose(springAnimation: springAnimation,
delta: delta,
initialVelocity: initialVelocity)

CATransaction.begin()
CATransaction.setCompletionBlock(info.onCompletion)
layer.add(decomposed.0, forKey: info.key + ".x")
layer.add(decomposed.1, forKey: info.key + ".y")
CATransaction.commit()

strongReactiveLayer.decomposedKeys.insert(info.key)
return
}
// Core Animation springs do not support multi-dimensional velocity, so we bear the burden
// of decomposing multi-dimensional springs here.
if let springAnimation = animation as? CASpringAnimation
, springAnimation.isAdditive
, let initialVelocity = info.initialVelocity as? CGPoint
, let delta = springAnimation.fromValue as? CGPoint {
let decomposed = decompose(springAnimation: springAnimation,
delta: delta,
initialVelocity: initialVelocity)

CATransaction.begin()
CATransaction.setCompletionBlock(info.onCompletion)
layer.add(decomposed.0, forKey: info.key + ".x")
layer.add(decomposed.1, forKey: info.key + ".y")
CATransaction.commit()

strongReactiveLayer.decomposedKeys.insert(info.key)
return
}

if let initialVelocity = info.initialVelocity {
Expand Down Expand Up @@ -272,7 +270,6 @@ public class ReactiveCAShapeLayer: ReactiveCALayer {
}
}

@available(iOS 9.0, *)
private func decompose(springAnimation: CASpringAnimation, delta: CGPoint, initialVelocity: CGPoint) -> (CASpringAnimation, CASpringAnimation) {
let xAnimation = springAnimation.copy() as! CASpringAnimation
let yAnimation = springAnimation.copy() as! CASpringAnimation
Expand All @@ -295,19 +292,17 @@ private func decompose(springAnimation: CASpringAnimation, delta: CGPoint, initi
}

private func applyInitialVelocity(_ initialVelocity: Any, to animation: CAPropertyAnimation) {
if #available(iOS 9.0, *) {
if let springAnimation = animation as? CASpringAnimation, springAnimation.isAdditive {
// Additive animations have a toValue of 0 and a fromValue of negative delta (where the model
// value came from).
guard let initialVelocity = initialVelocity as? CGFloat, let delta = springAnimation.fromValue as? CGFloat else {
// Unsupported velocity type.
return
}
if delta != 0 {
// CASpringAnimation's initialVelocity is proportional to the distance to travel, i.e. our
// delta.
springAnimation.initialVelocity = initialVelocity / -delta
}
if let springAnimation = animation as? CASpringAnimation, springAnimation.isAdditive {
// Additive animations have a toValue of 0 and a fromValue of negative delta (where the model
// value came from).
guard let initialVelocity = initialVelocity as? CGFloat, let delta = springAnimation.fromValue as? CGFloat else {
// Unsupported velocity type.
return
}
if delta != 0 {
// CASpringAnimation's initialVelocity is proportional to the distance to travel, i.e. our
// delta.
springAnimation.initialVelocity = initialVelocity / -delta
}
}
}
1 change: 0 additions & 1 deletion src/systems/coreAnimationSpringToStream.swift
Expand Up @@ -21,7 +21,6 @@ import Foundation
Only works with Subtractable types due to use of additive animations.
*/
@available(iOS 9.0, *)
public func coreAnimation<T>(_ spring: SpringShadow<T>) -> (MotionObservable<T>) where T: Subtractable, T: Zeroable, T: Equatable {
let initialVelocityStream = spring.initialVelocity.asStream()
return MotionObservable(Metadata("Core Animation Spring", args: [spring.enabled, spring.state, spring.initialValue, spring.initialVelocity, spring.destination, spring.tension, spring.friction, spring.mass, spring.suggestedDuration, spring.threshold])) { observer in
Expand Down

0 comments on commit 6516319

Please sign in to comment.