Skip to content

Commit

Permalink
[ProgressView] Add the ProgressView component.
Browse files Browse the repository at this point in the history
Summary:
Adds a ProgressView component. It displays determinate progress linearly.

Note: the README.md and API has previously been reviewed. Feel free to leave comments, but you can also skip for this review and focus on the implementation.

Test Plan: - Open Catalog > Progress View and verify looks.

Reviewers: randallli, junius, iangordon, O1 Material components iOS, ajsecord

Reviewed By: O1 Material components iOS, ajsecord

Tags: #material_components_ios

Differential Revision: http://codereview.cc/D1103
  • Loading branch information
Arcank committed Jul 8, 2016
1 parent 112ff54 commit a806413
Show file tree
Hide file tree
Showing 15 changed files with 874 additions and 4 deletions.
8 changes: 8 additions & 0 deletions MaterialComponents.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ Pod::Spec.new do |s|
ss.header_mappings_dir = "components/#{ss.base_name}/src"
end

s.subspec "ProgressView" do |ss|
ss.public_header_files = "components/#{ss.base_name}/src/*.h"
ss.source_files = "components/#{ss.base_name}/src/*.{h,m}"
ss.header_mappings_dir = "components/#{ss.base_name}/src"

ss.dependency "MaterialComponents/private/RTL"
end

s.subspec "RobotoFontLoader" do |ss|
ss.public_header_files = "components/#{ss.base_name}/src/*.h"
ss.source_files = "components/#{ss.base_name}/src/*.{h,m}", "components/#{ss.base_name}/src/private/*.{h,m}"
Expand Down
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ components:
- HUD
- Textfields
- ActivityIndicator
- ProgressBar
- ProgressView

For suggestions, please [file a GitHub issue](https://github.com/google/material-components-ios/issues).
5 changes: 4 additions & 1 deletion catalog/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PODS:
- MaterialComponents/PageControl (= 12.0.1)
- MaterialComponents/Palettes (= 12.0.1)
- MaterialComponents/private (= 12.0.1)
- MaterialComponents/ProgressView (= 12.0.1)
- MaterialComponents/RobotoFontLoader (= 12.0.1)
- MaterialComponents/ShadowElevations (= 12.0.1)
- MaterialComponents/ShadowLayer (= 12.0.1)
Expand Down Expand Up @@ -113,6 +114,8 @@ PODS:
- MaterialComponents/private/Color
- MaterialComponents/ShadowElevations
- MaterialComponents/ShadowLayer
- MaterialComponents/ProgressView (12.0.1):
- MaterialComponents/private/RTL
- MaterialComponents/RobotoFontLoader (12.0.1):
- MaterialComponents/FontDiskLoader
- MaterialComponents/Typography
Expand Down Expand Up @@ -152,7 +155,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
CatalogByConvention: 0137d280781667dd3d856a14cdf507f5ac8eedc0
MaterialComponents: c9194c49be10b8ac59cb8f857bedecbb511705a8
MaterialComponents: ed704822f99f7286a3e5d2d4cc7ffdeac044c211
MaterialComponentsCatalog: c2911e8ad9f380350107f124f88a43b9fe012d19
MaterialComponentsUnitTests: 03755d2a184c1d21a66c86c0e333d7b087e2f662

Expand Down
5 changes: 5 additions & 0 deletions components/ProgressView/.jazzy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Auto-generated by ./scripts/generate_jazzy_yamls.sh. Used primarily by scripts/external/arc-jazzy-linter.
module: ProgressView
umbrella_header: src/MaterialProgressView.h
objc: true
sdk: iphonesimulator
166 changes: 166 additions & 0 deletions components/ProgressView/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
---
title: "Progress View"
layout: detail
section: components
excerpt: "Progress View is a determinate and linear progress indicator that implements Material Design animation and layout."
---
# Progress View

<div class="ios-animation right" markdown="1">
<video src="docs/assets/progress_view.mp4" autoplay loop></video>
[![ScreenShot](docs/assets/progress_view.png)](docs/assets/progress_view.mp4)
</div>

This control is designed to be a drop-in replacement for `UIProgressView`, with a user experience
influenced by [Material Design specifications](https://material.google.com/components/progress-activity.html#)
for animation and layout. The API methods are the same as a `UIProgressView`, with the addition of a
few key methods required to achieve the desired animation of the control.
<!--{: .intro }-->

### Material Design Specifications

<ul class="icon-list">
<li class="icon-link"><a href="https://material.google.com/components/progress-activity.html">Progress & activity</a></li>
</ul>

### API Documentation

<ul class="icon-list">
<li class="icon-link"><a href="/components/ProgressView/apidocs/Classes/MDCProgressView.html">MDCProgressView</a></li>
</ul>

- - -

## Installation

### Requirements

- Xcode 7.0 or higher
- iOS SDK version 7.0 or higher

### Installation with CocoaPods

To add this component to your Xcode project using CocoaPods, add the following to your `Podfile`:

~~~ bash
pod 'MaterialComponents/ProgressView'
~~~

Then, run the following command:

~~~ bash
$ pod install
~~~

- - -

## Differences From UIProgressView

This progress view provides an animation effect when showing and hidding it: it grows up (resp.
shrinks down). Additionally, all animated changes APIs take an optional completion block, to
synchronize multistep animations.

- - -

## Usage

### Importing

Before using Progress View, you'll need to import it:

<!--<div class="material-code-render" markdown="1">-->
#### Objective-C

~~~ objc
#import "MaterialProgressView.h"
~~~

#### Swift
~~~ swift
import MaterialComponents
~~~
<!--</div>-->

Add the progress view to your view hierarchy like you would with any other view. Note that it works
best when the progress view is added at the bottom of a view, as showing (resp. hiding) grows up
(resp. shrinks down).

### Step 1: Add the progress view to a view

Add the progress view to a view and set the desired progress and hidden state.

<!--<div class="material-code-render" markdown="1">-->
#### Objective-C

~~~ objc
@implementation ViewController {
MDCProgressView *_progressView;
}

- (void)viewDidLoad {
[super viewDidLoad];

// Progress view configuration.
_progressView = [[MDCProgressView alloc] initWithFrame:myFrame];
_progressView.progress = 0; // You can also set a greater progress for actions already started.
[self.view addSubview:_progressView];
}

~~~
#### Swift
~~~ swift
class ProgressViewSwiftExampleViewController: UIViewController {
let progressView = MDCProgressView()
override func viewDidLoad() {
super.viewDidLoad()
progressView.progress = 0
let progressViewHeight = CGFloat(2)
progressView.frame = CGRectMake(0, view.bounds.height - progressViewHeight, view.bounds.width, progressViewHeight);
view.addSubview(progressView)
}
~~~
<!--</div>-->

### Step 2: Change the progress and hidden state

Both the progress and the hidden state can be animated, with a completion block.

<!--<div class="material-code-render" markdown="1">-->
#### Objective-C

~~~ objc
- (void)startAndShowProgressView {
_progressView.progress = 0;
[_progressView setHidden:NO animated:YES completion:nil];
}

- (void)completeAndHideProgressView {
[_progressView setProgress:1 animated:YES completion:^(BOOL finished){
[_progressView setHidden:YES animated:YES completion:nil];
}];
}
~~~

#### Swift

~~~ swift
func startAndShowProgressView {
progressView.progress = 0
progressView.setHidden(false, animated: true)
}

func completeAndHideProgressView {
progressView.setProgress(1, animated: true) { BOOL finished in
progressView.setHidden(true, animated: true)
}
}
~~~

<!--</div>-->
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a806413

Please sign in to comment.