Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Snackbar] Split the documentation into separate articles and run the…
… readme generator. (#3627)
- Loading branch information
Showing
7 changed files
with
240 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Snackbar | ||
|
||
<div class="article__asset article__asset--screenshot"> | ||
<img src="docs/assets/snackbar.png" alt="Snackbar" width="375"> | ||
</div> | ||
|
||
Snackbars provide brief feedback about an operation through a message at the bottom of the screen. | ||
Snackbars contain up to two lines of text directly related to the operation performed. They may | ||
contain a text action, but no icons. | ||
|
||
## Design & API documentation | ||
|
||
* [Material Design guidelines: Snackbars](https://material.io/go/design-snackbars) | ||
|
||
## Related components | ||
|
||
* [OverlayWindow](../../OverlayWindow) | ||
|
||
<!-- toc --> | ||
|
||
- - - | ||
|
||
## Overview | ||
|
||
### Snackbar Manager and Message | ||
|
||
Snackbar is comprised of two classes: MDCSnackbarManager and MDCSnackbarMessage. Snackbar messages | ||
contain text to be displayed to a user. Messages are passed to the manager. The manager decides when | ||
it is appropriate to show a message to the user. | ||
|
||
### Suspending and Resuming Display of Messages | ||
|
||
Snackbar manager can be instructed to suspend and resume displaying messages as needed. When | ||
messages are suspended the manager provides a suspension token that the client must keep as long as | ||
messages are suspended. When the client releases the suspension token or calls the manager's resume | ||
method with the suspension token, then messages will resume being displayed. | ||
|
||
## Installation | ||
|
||
- [Typical installation](../../../docs/component-installation.md) | ||
|
||
## Usage | ||
|
||
Displaying a snackbar requires using two classes: MDCSnackbarManager and MDCSnackbarMessage. | ||
First, create an instance of MDCSnackbarMessage and provide a string to display to the user. Next, | ||
pass the MDCSnackbarMessage to the MDCSnackbarManager with the static showMessage method. This will | ||
automatically construct an MDCSnackbarMessageView and appropriate overlay views so the snackbar is | ||
visible to the user. | ||
|
||
- [Typical use: display a message](typical-use-display-a-message.md) | ||
- [Typical use: display a message with an action](typical-use-display-a-message-with-action.md) | ||
|
||
## Extensions | ||
|
||
- [Color Theming](color-theming.md) | ||
- [Typography Theming](typography-theming.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
components/Snackbar/docs/typical-use-display-a-message-with-action.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Typical use: display a message with an action | ||
|
||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
|
||
```swift | ||
let action = MDCSnackbarMessageAction() | ||
let actionHandler = {() in | ||
let answerMessage = MDCSnackbarMessage() | ||
answerMessage.text = "Fascinating" | ||
MDCSnackbarManager.show(answerMessage) | ||
} | ||
action.handler = actionHandler | ||
action.title = "OK" | ||
message.action = action | ||
``` | ||
|
||
#### Objective-C | ||
|
||
```objc | ||
MDCSnackbarMessageAction *action = [[MDCSnackbarMessageAction alloc] init]; | ||
void (^actionHandler)() = ^() { | ||
MDCSnackbarMessage *answerMessage = [[MDCSnackbarMessage alloc] init]; | ||
answerMessage.text = @"A lot"; | ||
[MDCSnackbarManager showMessage:answerMessage]; | ||
}; | ||
action.handler = actionHandler; | ||
action.title = @"Answer"; | ||
message.action = action; | ||
``` | ||
<!--</div>--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Typical use: display a message | ||
|
||
<!--<div class="material-code-render" markdown="1">--> | ||
#### Swift | ||
|
||
```swift | ||
let message = MDCSnackbarMessage() | ||
message.text = "The groundhog (Marmota monax) is also known as a woodchuck or whistlepig." | ||
MDCSnackbarManager.show(message) | ||
``` | ||
|
||
#### Objective-C | ||
|
||
```objc | ||
MDCSnackbarMessage *message = [[MDCSnackbarMessage alloc] init]; | ||
message.text = @"How much wood would a woodchuck chuck if a woodchuck could chuck wood?"; | ||
[MDCSnackbarManager showMessage:message]; | ||
``` | ||
<!--</div>--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters