This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MotionAggregator is active: true | |
Child is active: true | |
tween(duration: 5.0, values: UIExtendedSRGBColorSpace 1 0 0 1, UIExtendedSRGBColorSpace 1 0 1 1, UIExtendedSRGBColorSpace 1 0 0 1) | |
-> <CAKeyframeAnimation:0x608000223060; keyPath = backgroundColor; values = ( | |
"<CGColor 0x6000000a8340> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 0 1 )", | |
"<CGColor 0x6000000a8640> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 1 1 )", | |
"<CGColor 0x6000000a8340> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 0 1 )" | |
); duration = 5> '6591F5BE-E262-447D-A04B-6967BAF32095' to CALayer::0x60000003e940.backgroundColor | |
springTo(destination: 400.0, source: UIView::0x7f90b59143c0, property: centerY) | |
-> 333.5 to UIView::0x7f90b59143c0.centerY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let tween = Tween<CGFloat>( | |
duration: 0.3, | |
values: [0, 5], | |
timeline: timeline | |
) | |
runtime.addPlan(tween, | |
to: layer, | |
property: tweenPropertyOf(layer).position) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright 2016-present The Material Motion Authors. All Rights Reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public typealias MaterialRestableStream<T> = (stream: MaterialStream<T>, atRest: MaterialStream<Bool>) | |
public func drag(_ pan: UIPanGestureRecognizer) -> MaterialRestableStream<CGPoint> { | |
return (MaterialStream<CGPoint>(named: #function) { observer in | |
let dragObserver = DragObserver { | |
observer.next(pan.location(in: pan.view!.superview!)) | |
} | |
pan.addTarget(dragObserver, action: #selector(DragObserver.didPan)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MaterialRestableStream<T>: MaterialStream<T> { | |
public var atRest = true { | |
didSet { | |
if atRest != oldValue { | |
for listener in listeners { | |
(listener as! AnyObserver<Bool>).next(atRest) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Observer { | |
associatedtype Value | |
func next(_ value: Value) -> Void | |
} | |
class Subscription { | |
init(_ unsubscribe: (() -> Void)? = nil) { | |
_unsubscribe = unsubscribe | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func rubberBand(value: CGFloat, min: CGFloat, max: CGFloat, bandLength: CGFloat) -> CGFloat { | |
if value >= min && value <= max { | |
// While we're within range we don't rubber band the value. | |
return value | |
} | |
if bandLength <= 0 { | |
// The rubber band doesn't exist, return the minimum value so that we stay put. | |
return min |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func willBeginTransition(_ transition: Transition) { | |
self.transition = transition | |
runtime = StreamRuntime(runtime: transition.runtime) | |
if transition.foreViewController.preferredContentSize != .zero { | |
drawerSize = transition.foreViewController.preferredContentSize | |
} else { | |
drawerSize = transition.foreViewController.view.bounds.size | |
} | |
if transition.direction == .forward { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var transition: Transition! | |
func willBeginTransition(_ transition: Transition) { | |
self.transition = transition | |
runtime = StreamRuntime(runtime: transition.runtime) | |
if transition.foreViewController.preferredContentSize != .zero { | |
drawerSize = transition.foreViewController.preferredContentSize | |
} else { | |
drawerSize = transition.foreViewController.view.bounds.size | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
An Observable emits values to its subscribed observers. | |
A minimal implementation based upon the reactivex specification: | |
http://reactivex.io/documentation/observable.html | |
*/ | |
public class Observable<Value> { | |
/** Add a new observer. The provided instance will receive all values provided to onNext. */ | |
public func subscribe(_ observer: @escaping (Value) -> Void) -> Observable<Value> { | |
observers.append(observer) |