featherless a247edea76
Update bazel to 0.20 and all dependencies as a result (#5926)
Kokoro's Bazel version has been increased from 0.11.0 to 0.20.0

As part of this change, the `.kokoro` bazel header rewrite phase's rewrites for MDF libraries has been made less generic because MDFInternationalization can now be imported using framework-style imports as expected. MDFTextAccessibility does not yet have this functionality, so we still need to rewrite it.

Version changes in the bazel workspace:

- bazelbuild/rules_apple has been increased from 0.3.0 to 0.9.0
- bazel_skylib has been increased from 0.2.0 to 0.6.0
- bazelbuild/rules_swift has been added at 0.4.0
- xctestrunner has been increased from 0.2.1 to 0.2.5
- material_internationalization_ios has been increased from v1.0.4 to v2.0.1
- material_text_accessibility_ios has been increased from fd570d71ae0124c75ad5af00e6b8b4b1668d5e40 to v2.0.0
- motion_interchange_objc has been increased from v1.6.0 to v2.0.0
- motion_animator_objc has been increased from v2.5.0 to v3.0.0
- motion_transitioning_objc has been increased from v5.0.0 to v6.0.0
- Swift version has been pinned to 3 for all swift libraries.

buildifier was ran on all affected build targets.

This unblocks https://github.com/material-components/material-components-ios/pull/5550.
2018-12-13 14:27:43 -05:00
..

Circular progress & activity indicator

Open bugs badge

Material Design progress indicators display the length of a process or express an unspecified wait time. There are two styles of progress indicators: linear and circular.

This component only provides the circular implementation. See Progress View for the linear implementation.

An animation showing a determinate and indeterminate activity indicator.

Design & API documentation

Table of contents


Overview

MDCActivityIndicator is a view that has two modes: indeterminate and determinate. Indeterminate indicators express an unspecified wait time, while determinate indicators represent the length of a process. Activity indicators are indeterminate by default.

Installation

Installation with CocoaPods

Add the following to your Podfile:

pod 'MaterialComponents/ActivityIndicator'

Then, run the following command:

pod install

Importing

To import the component:

Swift

import MaterialComponents.MaterialActivityIndicator

Objective-C

#import "MaterialActivityIndicator.h"

Usage

Typical use: Indeterminate

MDCActivityIndicator instances are indeterminate by default.

Swift

let activityIndicator = MDCActivityIndicator()
activityIndicator.sizeToFit()
view.addSubview(activityIndicator)

// To make the activity indicator appear:
activityIndicator.startAnimating()

// To make the activity indicator disappear:
activityIndicator.stopAnimating()

Objective-C

MDCActivityIndicator *activityIndicator = [[MDCActivityIndicator alloc] init];
[activityIndicator sizeToFit];
[view addSubview:activityIndicator];

// To make the activity indicator appear:
[activityIndicator startAnimating];

// To make the activity indicator disappear:
[activityIndicator stopAnimating];

Typical use: Determinate

MDCActivityIndicator instances can be shown as determinate by modifying the indicatorMode property and setting a percentage progress with progress. progress must be set to a floating point number between 0 and 1. Values beyond this range will be capped within the range.

Note: Activity indicators are hidden unless they are animating, even if the indicator is determinate progress.

Swift

let activityIndicator = MDCActivityIndicator()
activityIndicator.sizeToFit()
activityIndicator.indicatorMode = .determinate
activityIndicator.progress = 0.5
view.addSubview(activityIndicator)

// To make the activity indicator appear:
activityIndicator.startAnimating()

// To make the activity indicator disappear:
activityIndicator.stopAnimating()

Objective-C

MDCActivityIndicator *activityIndicator = [[MDCActivityIndicator alloc] init];
[activityIndicator sizeToFit];
activityIndicator.indicatorMode = MDCActivityIndicatorModeDeterminate;
activityIndicator.progress = 0.5;
[view addSubview:activityIndicator];

// To make the activity indicator appear:
[activityIndicator startAnimating];

// To make the activity indicator disappear:
[activityIndicator stopAnimating];

Showing multiple indeterminate colors

Indeterminate activity indicators support showing multiple colors via the cycleColors API. Consider using this property if your brand consists of more than one primary color.

Swift

let activityIndicator = MDCActivityIndicator()
activityIndicator.cycleColors = [.blue, .red, .green, .yellow]

Objective-C

MDCActivityIndicator *activityIndicator = [[MDCActivityIndicator alloc] init];
activityIndicator.cycleColors =  @[ UIColor.blueColor,
                                    UIColor.redColor,
                                    UIColor.greenColor,
                                    UIColor.yellowColor ];

Extensions

Color Theming

You can theme an activity indicator with your app's color scheme using the ColorThemer extension.

You must first add the Color Themer extension to your project:

pod 'MaterialComponents/ActivityIndicator+ColorThemer'

Run pod install again.

Swift

// Step 1: Import the ColorThemer extension
import MaterialComponents.MaterialActivityIndicator_ColorThemer

// Step 2: Create or get a color scheme
let colorScheme = MDCSemanticColorScheme()

// Step 3: Apply the color scheme to your component
MDCActivityIndicatorColorThemer.applySemanticColorScheme(colorScheme, to: activityIndicator)

Objective-C

// Step 1: Import the ColorThemer extension
#import "MaterialActivityIndicator+ColorThemer.h"

// Step 2: Create or get a color scheme
id<MDCColorScheming> colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804];

// Step 3: Apply the color scheme to your component
[MDCActivityIndicatorColorThemer applySemanticColorScheme:colorScheme
     toActivityIndicator:activityIndicator];