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

v2.0.0

Latest
Compare
Choose a tag to compare
@jverkoey jverkoey released this 19 May 19:58

This major release of Material Motion focuses includes improvements to the transitioning architecture, the reactive architecture, and new features on many of the interactions.

Breaking changes

• The IndefiniteObservable dependency has been bumped to 4.0.0. View the release notes.

• The Metadata and Inspectable types have been removed from Material Motion. All related APIs have been simplified accordingly.

• The MotionRuntime.toGraphViz API has been removed. There is no replacement API.

Tossable's init(system:draggable:) has been removed. Use init(spring:draggable:) instead.

SelfDismissingTransition's willPresent(fore:dismisser:) is no longer a static method. Implement the method as an instance method instead.

Transition is now a class protocol. This means that only object-types can conform to Transition.

TransitionController's dismisser has been removed. All methods have been moved directly to the TransitionController object.

Tween's keyPositions has been removed. Use offsets instead.

MotionRuntime's interactions(for:filter:) has been removed. Use interactions(ofType:for:) instead.

New features

Reactive architecture

• Subscriptions no longer automatically unsubscribe when the Subscription object is released. Subscriptions will stay active for as long as the head of the stream is alive.

• Reactive types are now global and shared across all instances of MotionRuntime. You can use Reactive(object) to fetch a cached reactive version of a supported type.

• MotionRuntime now supports a .get for UISlider instances. This will return an Observable of the slider's value.

• New operator ignoreUntil.

• New reactive variant of operator rubberBanded(outsideOf:maxLength:).

• New operator for float types toString(format:).

• New ReactiveScrollViewDelegate API turns UIScrollViewDelegate events into observable streams.

For example, the delegate itself is an observable on the scroll view's content offset:

let delegate = ReactiveScrollViewDelegate()
scrollView.delegate = delegate
delegate.x().subscribeToValue { contentOffset in
  print(contentOffset)
}

• New ReactiveButtonTarget API for building reactive UIButtons.

MotionRuntime has a new API start(_:when:is:) for starting interactions when another interaction reaches a given state.

MotionRuntime has a new isBeingManipulated stream. This stream emits true when any Manipulable interaction becomes active and false when all Manipulable interactions come to rest.

Interactions

MotionRuntime now has a new isBeingManipulated property that indicates whether any manipulation interaction is active.

Any interaction that conforms to the new Manipulation type will affect the runtime's isBeingManipulated property.

Draggable now has a resistance property that can be used to create drag resistance beyond a draggable region.

draggable.resistance.perimeter.value = someRect

Tween has new properties for creating repeating animations: repeatCount, repeatDuration, and autoreverses.

These properties directly map to the corresponding properties in Core Animation.

TransitionTween has new initializer values delayBefore and delayAfter.

delayBefore is the delay used when transitioning forward. delayAfter is the delay used when transitioning backward.

• The gesture property for gesture-based interactions is now optional. When nil, the interaction will do nothing.

This is primarily useful when building transitions that have optional interactivity.

Transitions

• New TransitionWithFallback protocol allows transitions to swap themselves out for another transition instance.

• New TransitionWithPresentation protocol allows transitions to customize their presentation using an iOS presentation controller. See the modal dialog case study for an example of using this new functionality.

• New TransitionWithTermination protocol allows transitions to perform cleanup logic at the end of a transition.

TransitionContext's gestureRecognizers is now settable. This makes it possible to add arbitrary gesture recognizers to a transition.

Source changes

API changes

Auto-generated by running:

apidiff origin/stable release-candidate swift MaterialMotion.xcworkspace MaterialMotion

Debugging

Inspectable

removed protocol: Inspectable

Metadata

removed class: Metadata

Interactions

Draggable

new var: resistance in Draggable

modified class: Draggable

Type of change: Declaration
From: public final class Draggable : Gesturable<UIPanGestureRecognizer>, Interaction, Togglable, Stateful
To: public final class Draggable : Gesturable<UIPanGestureRecognizer>, Interaction, Togglable, Manipulation

Manipulation

new protocol: Manipulation

Rotatable

modified class: Rotatable

Type of change: Declaration
From: public final class Rotatable : Gesturable<UIRotationGestureRecognizer>, Interaction, Togglable, Stateful
To: public final class Rotatable : Gesturable<UIRotationGestureRecognizer>, Interaction, Togglable, Manipulation

Scalable

modified class: Scalable

Type of change: Declaration
From: public final class Scalable : Gesturable<UIPinchGestureRecognizer>, Interaction, Togglable, Stateful
To: public final class Scalable : Gesturable<UIPinchGestureRecognizer>, Interaction, Togglable, Manipulation

Tossable

removed method: init(system:draggable:) in Tossable

Tween

new var: offsets in Tween

new var: repeatCount in Tween

new var: repeatDuration in Tween

new var: autoreverses in Tween

removed var: keyPositions in Tween

Reactive architecture

MotionObservableConvertible

new method: ignoreUntil(_:) in MotionObservableConvertible

new method: rubberBanded(outsideOf:maxLength:) in MotionObservableConvertible

new method: toString(format:) in MotionObservableConvertible

MotionRuntime

new method: interactions(ofType:for:) in MotionRuntime

new method: start(_:when:is:) in MotionRuntime

new var: isBeingManipulated in MotionRuntime

removed method: interactions(for:filter:) in MotionRuntime

removed method: asGraphviz() in MotionRuntime

ReactiveButtonTarget

new class: ReactiveButtonTarget

new var: didHighlight in ReactiveButtonTarget

ReactiveUIView

removed class: ReactiveUIView

ReactiveCAShapeLayer

removed class: ReactiveCAShapeLayer

ReactiveScrollViewDelegate

new class: ReactiveScrollViewDelegate

Transitions

SelfDismissingTransition

new method: willPresent(fore:dismisser:) in SelfDismissingTransition

removed static method: willPresent(fore:dismisser:) in SelfDismissingTransition

Transition

removed method: init() in Transition

modified protocol: Transition

Type of change: Declaration
From: public protocol Transition
To: public protocol Transition : class

TransitionWithFallback

new protocol: TransitionWithFallback

new method: fallbackTansition(withContext:) in TransitionWithFallback

TransitionWithPresentation

new protocol: TransitionWithPresentation

new method: presentationController(forPresented:presenting:source:) in TransitionWithPresentation

new method: defaultModalPresentationStyle() in TransitionWithPresentation

TransitionWithTermination

new protocol: TransitionWithTermination

new method: didEndTransition(withContext:runtime:) in TransitionWithTermination

TransitionContext

modified var: gestureRecognizers in TransitionContext

Type of change: Declaration
From: public var gestureRecognizers: Set<UIGestureRecognizer> { get }
To: public let gestureRecognizers: Set<UIGestureRecognizer>

TransitionController

new method: disableSimultaneousRecognition(of:) in TransitionController

new var: presentationController in TransitionController

new method: topEdgeDismisserDelegate(for:) in TransitionController

new var: gestureRecognizers in TransitionController

new var: transition in TransitionController

new var: gestureDelegate in TransitionController

new method: dismissWhenGestureRecognizerBegins(_:) in TransitionController

removed var: transitionType in TransitionController

removed var: dismisser in TransitionController

Non-source changes