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

Commit

Permalink
Organizing the example view controllers in groups and cleaning up the…
Browse files Browse the repository at this point in the history
…ir implementations.

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/D2877
  • Loading branch information
jverkoey committed Mar 15, 2017
1 parent ffd9b25 commit a63e61a
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 37 deletions.
15 changes: 10 additions & 5 deletions examples/CarouselExample.swift
Expand Up @@ -17,16 +17,14 @@
import UIKit
import ReactiveMotion

public class CarouselExampleViewController: UIViewController, UIScrollViewDelegate {
class CarouselExampleViewController: ExampleViewController, UIScrollViewDelegate {

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

automaticallyAdjustsScrollViewInsets = false

runtime = MotionRuntime(containerView: view)

view.backgroundColor = UIColor(hexColor: 0xF8AA36)

let scrollView = UIScrollView(frame: view.bounds)
Expand All @@ -49,6 +47,8 @@ public class CarouselExampleViewController: UIViewController, UIScrollViewDelega
(title: "Purr purr", description: "Meow", image: UIImage(named: "sticker2")!),
]

runtime = MotionRuntime(containerView: view)

let stream = runtime.get(scrollView)
for (index, data) in datas.enumerated() {
let page = CarouselPage(frame: view.bounds)
Expand All @@ -71,9 +71,14 @@ public class CarouselExampleViewController: UIViewController, UIScrollViewDelega

var pager: UIPageControl!

public func scrollViewDidScroll(_ scrollView: UIScrollView) {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
pager.currentPage = Int((scrollView.contentOffset.x + scrollView.bounds.width / 2) / scrollView.bounds.width)
}

override func exampleInformation() -> ExampleInfo {
return .init(title: type(of: self).catalogBreadcrumbs().last!,
instructions: "Swipe betwen pages to see the scroll effects.")
}
}

private class CarouselPage: UIView {
Expand Down
5 changes: 1 addition & 4 deletions examples/DirectlyManipulableExample.swift
Expand Up @@ -24,13 +24,10 @@ class DirectlyManipulableExampleViewController: ExampleViewController {
override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

view.backgroundColor = .white

let square = center(createExampleView(), within: view)
view.addSubview(square)

runtime = MotionRuntime(containerView: view)
runtime.add(DirectlyManipulable(), to: square)
}

Expand Down
3 changes: 1 addition & 2 deletions examples/DraggableConstraintExample.swift
Expand Up @@ -24,11 +24,10 @@ class DraggableConstraintExampleViewController: ExampleViewController {
override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

let square = center(createExampleView(), within: view)
view.addSubview(square)

runtime = MotionRuntime(containerView: view)
runtime.add(Draggable(), to: square) { $0.xLocked(to: square.layer.position.x) }
}

Expand Down
3 changes: 1 addition & 2 deletions examples/DraggableCustomOperatorExample.swift
Expand Up @@ -24,11 +24,10 @@ class DraggableCustomOperatorExampleViewController: ExampleViewController {
override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

let square = center(createExampleView(), within: view)
view.addSubview(square)

runtime = MotionRuntime(containerView: view)
runtime.add(Draggable(), to: square) { $0.wobble(width: 100) }
}

Expand Down
3 changes: 1 addition & 2 deletions examples/DraggableExample.swift
Expand Up @@ -24,11 +24,10 @@ class DraggableExampleViewController: ExampleViewController {
override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

let square = center(createExampleView(), within: view)
view.addSubview(square)

runtime = MotionRuntime(containerView: view)
runtime.add(Draggable(), to: square)
}

Expand Down
4 changes: 2 additions & 2 deletions examples/DraggableReactiveConstraintExample.swift
Expand Up @@ -24,15 +24,15 @@ class DraggableReactiveConstraintExampleViewController: ExampleViewController {
override func viewDidLoad() {
super.viewDidLoad()

runtime = MotionRuntime(containerView: view)

let axisLine = UIView(frame: .init(x: view.bounds.midX - 8, y: 0, width: 16, height: view.bounds.height))
axisLine.backgroundColor = .red
view.addSubview(axisLine)

let square = center(createExampleView(), within: view)
view.addSubview(square)

runtime = MotionRuntime(containerView: view)

let axisCenterX = runtime.get(axisLine.layer).position.x()
runtime.add(Draggable(), to: square) { $0
.initialValue(square.layer.position)
Expand Down
60 changes: 46 additions & 14 deletions examples/apps/Catalog/Catalog.xcodeproj/project.pbxproj
Expand Up @@ -175,16 +175,14 @@
isa = PBXGroup;
children = (
664A5B761DD10D320082B5DF /* TableOfContents.swift */,
66DDFD0B1E71F0B300AA46B7 /* Draggable */,
66DDFD0E1E71F0F600AA46B7 /* Directly Manipulable */,
66DDFD0B1E71F0B300AA46B7 /* How to drag views */,
66DDFD231E788DC500AA46B7 /* How to apply constraints to an interaction */,
66DDFD0E1E71F0F600AA46B7 /* How to directly manipulate views */,
66DDFD221E788D1B00AA46B7 /* How to build a view controller transition */,
66DDFD211E788C1200AA46B7 /* How to react to scrolling */,
66DDFD241E788DD500AA46B7 /* How to create custom operators */,
667E94451E71EF0E005CAC78 /* ArcMoveExample.swift */,
667E94461E71EF0E005CAC78 /* CarouselExample.swift */,
667E94471E71EF0E005CAC78 /* ContextualTransitionExample.swift */,
667E94491E71EF0E005CAC78 /* DragSourceExample.swift */,
667E944A1E71EF0E005CAC78 /* FabTransitionExample.swift */,
667E944B1E71EF0E005CAC78 /* InteractivePushBackTransitionExample.swift */,
667E944C1E71EF0E005CAC78 /* ModalDialogExample.swift */,
667E944D1E71EF0E005CAC78 /* PushBackTransitionExample.swift */,
667E944E1E71EF0E005CAC78 /* StickerPickerExample.swift */,
667E94511E71EF0E005CAC78 /* SwipeExample.swift */,
667E944F1E71EF0E005CAC78 /* supplemental */,
Expand Down Expand Up @@ -265,23 +263,57 @@
path = ../../supplemental;
sourceTree = "<group>";
};
66DDFD0B1E71F0B300AA46B7 /* Draggable */ = {
66DDFD0B1E71F0B300AA46B7 /* How to drag views */ = {
isa = PBXGroup;
children = (
66DDFD0C1E71F0F100AA46B7 /* DraggableExample.swift */,
);
name = "How to drag views";
sourceTree = "<group>";
};
66DDFD0E1E71F0F600AA46B7 /* How to directly manipulate views */ = {
isa = PBXGroup;
children = (
667E94481E71EF0E005CAC78 /* DirectlyManipulableExample.swift */,
);
name = "How to directly manipulate views";
sourceTree = "<group>";
};
66DDFD211E788C1200AA46B7 /* How to react to scrolling */ = {
isa = PBXGroup;
children = (
667E94461E71EF0E005CAC78 /* CarouselExample.swift */,
);
name = "How to react to scrolling";
sourceTree = "<group>";
};
66DDFD221E788D1B00AA46B7 /* How to build a view controller transition */ = {
isa = PBXGroup;
children = (
667E944D1E71EF0E005CAC78 /* PushBackTransitionExample.swift */,
667E944B1E71EF0E005CAC78 /* InteractivePushBackTransitionExample.swift */,
667E94471E71EF0E005CAC78 /* ContextualTransitionExample.swift */,
667E944C1E71EF0E005CAC78 /* ModalDialogExample.swift */,
667E944A1E71EF0E005CAC78 /* FabTransitionExample.swift */,
);
name = "How to build a view controller transition";
sourceTree = "<group>";
};
66DDFD231E788DC500AA46B7 /* How to apply constraints to an interaction */ = {
isa = PBXGroup;
children = (
66DDFD0F1E71F32800AA46B7 /* DraggableConstraintExample.swift */,
66DDFD151E71F90F00AA46B7 /* DraggableReactiveConstraintExample.swift */,
66DDFD1F1E73281200AA46B7 /* DraggableCustomOperatorExample.swift */,
);
name = Draggable;
name = "How to apply constraints to an interaction";
sourceTree = "<group>";
};
66DDFD0E1E71F0F600AA46B7 /* Directly Manipulable */ = {
66DDFD241E788DD500AA46B7 /* How to create custom operators */ = {
isa = PBXGroup;
children = (
667E94481E71EF0E005CAC78 /* DirectlyManipulableExample.swift */,
66DDFD1F1E73281200AA46B7 /* DraggableCustomOperatorExample.swift */,
);
name = "Directly Manipulable";
name = "How to create custom operators";
sourceTree = "<group>";
};
8C6A745BCA20C3282C1419A7 /* Pods */ = {
Expand Down
10 changes: 4 additions & 6 deletions examples/apps/Catalog/Catalog/TableOfContents.swift
Expand Up @@ -34,6 +34,10 @@ extension DraggableReactiveConstraintExampleViewController {
class func catalogBreadcrumbs() -> [String] { return ["Draggable with reactive constraints"] }
}

extension DirectlyManipulableExampleViewController {
class func catalogBreadcrumbs() -> [String] { return ["Directly manipulable"] }
}

@available(iOS 9.0, *)
extension DragSourceExampleViewController {
class func catalogBreadcrumbs() -> [String] {
Expand Down Expand Up @@ -99,9 +103,3 @@ extension StickerPickerExampleViewController {
return ["Sticker picker"]
}
}

extension DirectlyManipulableExampleViewController {
class func catalogBreadcrumbs() -> [String] {
return ["Directly manipulable"]
}
}

0 comments on commit a63e61a

Please sign in to comment.