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

Commit

Permalink
Add arc move example.
Browse files Browse the repository at this point in the history
Summary:
Tapping anywhere on the example moves the source position and restarts the animation.

Available for checkout on github under the `wip-arcmove` branch.

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/D2648
  • Loading branch information
Jeff Verkoeyen committed Feb 8, 2017
1 parent 7d06720 commit 8367b1a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
55 changes: 55 additions & 0 deletions examples/ArcMoveExample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
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
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import UIKit
import IndefiniteObservable
import MaterialMotionStreams

public class ArcMoveExampleViewController: UIViewController {

var runtime: MotionRuntime!
public override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

view.backgroundColor = .white

var center = view.center
center.x -= 32
center.y -= 32

let square = UIView(frame: .init(x: center.x, y: center.y, width: 64, height: 64))
square.backgroundColor = .red
view.addSubview(square)

let square2 = UIView(frame: .init(x: center.x, y: center.y, width: 64, height: 64))
square2.backgroundColor = .green
view.addSubview(square2)

let circle = UIView(frame: .init(x: center.x, y: center.y, width: 64, height: 64))
circle.backgroundColor = .blue
circle.layer.cornerRadius = circle.bounds.width / 2
view.addSubview(circle)

runtime.add(Tap(), to: runtime.get(square.layer).position)

let path = arcMove(from: runtime.get(square.layer).position,
to: runtime.get(circle.layer).position)
let tween = Tween<CGPoint>(duration: 0.4, path: path, system: coreAnimation)
runtime.add(tween, to: runtime.get(square2.layer).position)
}
}
6 changes: 6 additions & 0 deletions examples/apps/Catalog/Catalog/TableOfContents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ extension DragSourceExampleViewController {
}
}

extension ArcMoveExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Arc move"]
}
}

extension ModalDialogExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Modal dialog"]
Expand Down

0 comments on commit 8367b1a

Please sign in to comment.