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

Commit

Permalink
Merge branch 'release-candidate' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Verkoeyen committed May 25, 2017
2 parents 288c580 + c9ae79b commit 8977b27
Show file tree
Hide file tree
Showing 34 changed files with 1,834 additions and 120 deletions.
4 changes: 2 additions & 2 deletions .arcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"arc.feature.start.default": "origin/develop",
"unit.xcode": {
"build": {
"workspace": "MaterialMotionTransitioning.xcworkspace",
"workspace": "Transitioning.xcworkspace",
"scheme": "UnitTests",
"configuration": "Debug",
"destination": "platform=iOS Simulator,name=iPhone 6s"
},
"coverage": {
"product": "MaterialMotionTransitioning.framework/MaterialMotionTransitioning"
"product": "Transitioning.framework/Transitioning"
},
"pre-build": "pod install"
}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ before_install:
script:
- set -o pipefail
- arcanist/bin/arc unit --everything --trace
- xcodebuild build -workspace MaterialMotionTransitioning.xcworkspace -scheme Catalog -sdk "iphonesimulator10.1" -destination "name=iPhone 6s,OS=10.1" ONLY_ACTIVE_ARCH=YES | xcpretty -c;
- xcodebuild build -workspace Transitioning.xcworkspace -scheme TransitionsCatalog -sdk "iphonesimulator10.1" -destination "name=iPhone 6s,OS=10.1" ONLY_ACTIVE_ARCH=YES | xcpretty -c;
after_success:
- bash <(curl -s https://codecov.io/bash)
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 1.0.0

Initial release.

Includes support for building simple view controller transitions and transitions that support custom presentation.

## Source changes

* [Clarify the docs for default modal presentation styles. (#4)](https://github.com/material-motion/transitioning-objc/commit/84c23e5f7c490e2a7d299cca6c4046ac4f368551) (featherless)
* [Initial implementation. (#1)](https://github.com/material-motion/transitioning-objc/commit/c1b760455779226ebc9749e06e528d25a6b444bc) (featherless)

## Non-source changes

* [Simplify the frame calculation APIs in the example. (#5)](https://github.com/material-motion/transitioning-objc/commit/8688b045594ee38204744c7c644d4cce58165ec6) (featherless)
14 changes: 7 additions & 7 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
workspace 'MaterialMotionTransitioning.xcworkspace'
workspace 'Transitioning.xcworkspace'
use_frameworks!

target "Catalog" do
target "TransitionsCatalog" do
pod 'CatalogByConvention'
pod 'MaterialMotionTransitioning', :path => './'
pod 'Transitioning', :path => './'

project 'examples/apps/Catalog/Catalog.xcodeproj'
project 'examples/apps/Catalog/TransitionsCatalog.xcodeproj'
end

target "UnitTests" do
pod 'MaterialMotionTransitioning', :path => './'
pod 'Transitioning', :path => './'

project 'examples/apps/Catalog/Catalog.xcodeproj'
project 'examples/apps/Catalog/TransitionsCatalog.xcodeproj'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = "3.0"
if target.name.start_with?("Material")
if target.name.start_with?("Transitioning")
configuration.build_settings['WARNING_CFLAGS'] ="$(inherited) -Wall -Wcast-align -Wconversion -Werror -Wextra -Wimplicit-atomic-properties -Wmissing-prototypes -Wno-sign-conversion -Wno-unused-parameter -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code"
end
end
Expand Down
10 changes: 5 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
PODS:
- CatalogByConvention (2.1.1)
- MaterialMotionTransitioning (1.0.0)
- Transitioning (1.0.0)

DEPENDENCIES:
- CatalogByConvention
- MaterialMotionTransitioning (from `./`)
- Transitioning (from `./`)

EXTERNAL SOURCES:
MaterialMotionTransitioning:
Transitioning:
:path: "./"

SPEC CHECKSUMS:
CatalogByConvention: c3a5319de04250a7cd4649127fcfca5fe3322a43
MaterialMotionTransitioning: 33406d4f24065281e3d2d171bddd794a89e32b7c
Transitioning: d2d2d0609e0acf133f7049ff5ddbe7ca16973f07

PODFILE CHECKSUM: 7343cb186774b759ce5a8ae9aa6df20737289df1
PODFILE CHECKSUM: 1949e62e9d70d554783c0bb931d6b52780775cfb

COCOAPODS: 1.2.1
226 changes: 211 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,66 @@
# Material Motion Transitioning
# Transitioning

[![Build Status](https://travis-ci.org/material-motion/material-motion-transitioning-objc.svg?branch=develop)](https://travis-ci.org/material-motion/material-motion-transitioning-objc)
[![codecov](https://codecov.io/gh/material-motion/material-motion-transitioning-objc/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-motion/material-motion-transitioning-objc)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/MaterialMotionTransitioning.svg)](https://cocoapods.org/pods/MaterialMotionTransitioning)
[![Platform](https://img.shields.io/cocoapods/p/MaterialMotionTransitioning.svg)](http://cocoadocs.org/docsets/MaterialMotionTransitioning)
[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/MaterialMotionTransitioning.svg)](http://cocoadocs.org/docsets/MaterialMotionTransitioning)
> Light-weight API for building UIViewController transitions.
[![Build Status](https://travis-ci.org/material-motion/transitioning-objc.svg?branch=develop)](https://travis-ci.org/material-motion/transitioning-objc)
[![codecov](https://codecov.io/gh/material-motion/transitioning-objc/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-motion/transitioning-objc)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Transitioning.svg)](https://cocoapods.org/pods/Transitioning)
[![Platform](https://img.shields.io/cocoapods/p/Transitioning.svg)](http://cocoadocs.org/docsets/Transitioning)
[![Docs](https://img.shields.io/cocoapods/metrics/doc-percent/Transitioning.svg)](http://cocoadocs.org/docsets/Transitioning)

This library standardizes the way transitions are built on iOS so that with a single line of code
you can pick the custom transition you want to use:

```swift
let viewController = MyViewController()
viewController.transitionController.transition = CustomTransition()
present(modalViewController, animated: true)
```

```objc
MyViewController *viewController = [[MyViewController alloc] init];
viewController.mdm_transitionController.transition = [[CustomTransition alloc] init];
[self presentViewController:viewController animated:true completion:nil];
```
The easiest way to make a transition with this library is to create a class that conforms to the
`Transition` protocol:
```swift
final class CustomTransition: NSObject, Transition {
func start(with context: TransitionContext) {
CATransaction.begin()
CATransaction.setCompletionBlock {
context.transitionDidEnd()
}
// Add animations...
CATransaction.commit()
}
}
```

```objc
@interface CustomTransition: NSObject <MDMTransition>
@end

@implementation CustomTransition

- (void)startWithContext:(id<MDMTransitionContext>)context {
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[context transitionDidEnd];
}];

// Add animations...

[CATransaction commit];
}

@end
```
## Installation
Expand All @@ -17,9 +73,9 @@
>
> gem install cocoapods
Add `MaterialMotionTransitioning` to your `Podfile`:
Add `Transitioning` to your `Podfile`:
pod 'MaterialMotionTransitioning'
pod 'Transitioning'
Then run the following command:
Expand All @@ -29,7 +85,7 @@ Then run the following command:
Import the framework:
@import MaterialMotionTransitioning;
@import Transitioning;
You will now have access to all of the APIs.
Expand All @@ -38,25 +94,165 @@ You will now have access to all of the APIs.
Check out a local copy of the repo to access the Catalog application by running the following
commands:
git clone https://github.com/material-motion/material-motion-transitioning-objc.git
cd material-motion-transitioning-objc
git clone https://github.com/material-motion/transitioning-objc.git
cd transitioning-objc
pod install
open MaterialMotionTransitioning.xcworkspace
open Transitioning.xcworkspace
## Guides
1. [Architecture](#architecture)
2. [How to ...](#how-to-...)
2. [How to create a simple transition](#how-to-create-a-simple-transition)
3. [How to customize presentation](#how-to-customize-presentation)
### Architecture
### How to ...
> Background: Transitions in iOS are customized by setting a `transitioningDelegate` on a view
> controller. When a view controller is presented, UIKit will ask the transitioning delegate for an
> animation, interaction, and presentation controller. These controllers are then expected to
> implement the transition's motion.
Transitioning provides a thin layer atop these protocols with the following advantages:
- Every view controller has its own **transition controller**. This encourages choosing the
transition based on the context.
- Transitions are represented in terms of **backward/forward** rather than from/to. When presenting,
we're moving forward. When dismissing, we're moving backward. This makes it easier to refer to
each "side" of a transition consistently.
- Transition objects can customize their behavior by conforming to more `TransitionWith*` protocols.
This protocol-oriented design is more Swift-friendly than a variety of optional methods on a
protocol.
- But most importantly: **this library handles the plumbing, allowing you to focus on the motion**.
### How to create a simple transition
In this guide we'll create scaffolding for a simple transition.
#### Step 1: Define a new Transition type
Transitions must be `NSObject` types that conform to the `Transition` protocol.
The sole method we're expected to implement, `start`, is invoked each time the view controller is
presented or dismissed.
```swift
final class FadeTransition: NSObject, Transition {
func start(with context: TransitionContext) {
}
}
```

#### Step 2: Invoke the completion handler once all animations are complete

If using Core Animation explicitly:

```swift
final class FadeTransition: NSObject, Transition {
func start(with context: TransitionContext) {
CATransaction.begin()

CATransaction.setCompletionBlock {
context.transitionDidEnd()
}

// Your motion...

CATransaction.commit()
}
}
```

If using UIView implicit animations:

```swift
final class FadeTransition: NSObject, Transition {
func start(with context: TransitionContext) {
UIView.animate(withDuration: context.duration, animations: {
// Your motion...

}, completion: { didComplete in
context.transitionDidEnd()
})
}
}
```

#### Step 3: Implement the motion

With the basic scaffolding in place, you can now implement your motion.

### How to customize presentation

You'll customize the presentation of a transition when you need to do any of the following:

- Add views, such as dimming views, that live beyond the lifetime of the transition.
- Change the destination frame of the presented view controller.

#### Step 1: Subclass UIPresentationController

You must subclass UIPresentationController in order to implement your custom behavior. If the user
of your transition can customize any presentation behavior then you'll want to define a custom
initializer.

> Note: Avoid storing the transition context in your presentation controller. Presentation
> controllers live for as long as their associated view controller, while the transition context is
> only valid while a transition is active. Each presentation and dismissal will receive its own
> unique transition context. Storing the context in the presentation controller would keep the
> context alive longer than it's meant to.
Override any `UIPresentationController` methods you'll need in order to implement your motion.

```swift
final class MyPresentationController: UIPresentationController {
}
```

#### Step 2: Implement TransitionWithPresentation on your transition

This ensures that your transition implement the required methods for presentation.

Presentation will only be customized if you return `.custom` from the
`defaultModalPresentationStyle` method and a non-nil `UIPresentationController` subclass from the
`presentationController` method.

```swift
extension VerticalSheetTransition: TransitionWithPresentation {
func defaultModalPresentationStyle() -> UIModalPresentationStyle {
return .custom
}

func presentationController(forPresented presented: UIViewController,
presenting: UIViewController,
source: UIViewController?) -> UIPresentationController? {
return MyPresentationController(presentedViewController: presented, presenting: presenting)
}
}
```

#### Optional Step 3: Implement Transition on your presentation controller

If your presentation controller needs to animate anything, you can conform to the `Transition`
protocol in order to receive a `start` invocation each time a transition begins. The presentation
controller's `start` will be invoked before the transition's `start`.

> Note: It's possible for your presentation controller and your transition to have different ideas
> of when a transition has completed, so consider which object should be responsible for invoking
> `transitionDidEnd`. The `Transition` object is usually the one that calls this method.
```swift
extension MyPresentationController: Transition {
func start(with context: TransitionContext) {
// Your motion...
}
}
```

## Contributing

We welcome contributions!

Check out our [upcoming milestones](https://github.com/material-motion/material-motion-transitioning-objc/milestones).
Check out our [upcoming milestones](https://github.com/material-motion/transitioning-objc/milestones).

Learn more about [our team](https://material-motion.github.io/material-motion/team/),
[our community](https://material-motion.github.io/material-motion/team/community/), and
Expand Down
8 changes: 4 additions & 4 deletions MaterialMotionTransitioning.podspec → Transitioning.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "MaterialMotionTransitioning"
s.summary = "Material Motion Transitioning"
s.name = "Transitioning"
s.summary = "Light-weight API for building UIViewController transitions."
s.version = "1.0.0"
s.authors = "The Material Motion Authors"
s.license = "Apache 2.0"
s.homepage = "https://github.com/material-motion/material-motion-transitioning-objc"
s.source = { :git => "https://github.com/material-motion/material-motion-transitioning-objc.git", :tag => "v" + s.version.to_s }
s.homepage = "https://github.com/material-motion/transitioning-objc"
s.source = { :git => "https://github.com/material-motion/transitioning-objc.git", :tag => "v" + s.version.to_s }
s.platform = :ios, "8.0"
s.requires_arc = true

Expand Down
Loading

0 comments on commit 8977b27

Please sign in to comment.