Skip to content

Commit 4e245ac

Browse files
andrewovertonmaterial-automation
authored andcommitted
[Multiple components] Miscellaneous doc updates
This PR closes out all current doc change requests. Closes #10181 COPYBARA_INTEGRATE_REVIEW=#10181 from andrewoverton:dev-docs-03-15-cherry-pick 00414a4 PiperOrigin-RevId: 363178361
1 parent ff33bab commit 4e245ac

File tree

17 files changed

+177
-94
lines changed

17 files changed

+177
-94
lines changed

components/BottomSheet/README.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,16 @@ As a user of the bottom sheet component, it is up to you to determine that its c
6868

6969
We recommend giving all of these properties appropriate values for your use case.
7070

71-
## Types
71+
**Types**
7272

7373
There are three types suitable for different use cases:
74-
1. [Standard bottom sheets](#standard-bottom-sheet) display content that complements the screen’s primary content and remain visible while users interact with the primary content
74+
1. Standard bottom sheets display content that complements the screen’s primary content and remain visible while users interact with the primary content
7575
1. [Modal bottom sheets](#modal-bottom-sheet) are an alternative to inline menus or simple dialogs on mobile and provide room for additional items, longer descriptions, and iconography, and must be dismissed in order to interact with the underlying content
7676
1. [Expanding bottom sheets](#expanding-bottom-sheet) provide a small, collapsed surface that can be expanded by the user to access a key feature or task to offer the persistent access of a standard sheet with the space and focus of a modal sheet.
7777

7878
![Composite image of bottom sheet types](docs/assets/bottom-sheet-types.png)
7979

80-
## Standard bottom sheet
81-
82-
Standard bottom sheets coexist with the screen’s main UI region and allow for simultaneously viewing and interacting with both regions. They are commonly used to keep a feature or secondary content visible on screen when content in main UI region is frequently scrolled or panned.
83-
84-
There is no standard bottom sheet implementation on iOS. This is because the iOS bottom sheet implementation makes use of custom view controller transitions, which do not allow interaction with the presenting view controller, even when the presented view controller does not take up the whole screen.
80+
_**Note:** Standard bottom sheets aren't supported on iOS. This is because the iOS bottom sheet implementation makes use of custom view controller transitions, which do not allow interaction with the presenting view controller, even when the presented view controller does not take up the whole screen._
8581

8682
## Modal bottom sheet
8783

components/Buttons/docs/buttons.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ repeats weekly on the following day(s)." The list items do not need
160160
(representing a day of the week) has the `accessibilityHint` value, "Toggles
161161
this day."
162162

163-
## Types
163+
**Types**
164164

165-
There are four types of buttons: 1. [Text button](#text-button) 2. [Outlined button](#outlined-button) 3. [Contained button](#contained-button) 4. Toggle button (*not supported in iOS*)"
165+
There are four types of buttons: 1\. [Text button](#text-button) 2\. [Outlined button](#outlined-button) 3\. [Contained button](#contained-button) 4\. Toggle button (*not supported in iOS*)"
166166

167167
![Example of the four button types](assets/buttons_types.png)
168168

components/Buttons/docs/fabs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ repeats weekly on the following day(s)." The list items do not need
140140
(representing a day of the week) has the `accessibilityHint` value, "Toggles
141141
this day."
142142

143-
## Types
143+
**Types**
144144

145145
There are three types of FABs: 1\. [Regular FABs](#regular-fab) 2\. [Mini FABs](#mini-fab) 3\. [Extended FABs](#extended-fab)
146146

components/Chips/README.md

+132-25
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,9 @@ Always verify that your chips meet minimum touch requirements, as defined by eit
6767

6868
Remember to set any relevant `accessibilityLabels` or `accessibilityTraits`, especially if you are not satisfied with default system-assigned values.
6969

70-
## Types
70+
**Types**
7171

72-
There are four types of chips:
73-
74-
1. [Input (text entry)](#input-chip)
75-
1. [Choice](#choice-chip)
76-
1. [Filter](#filter-chip)
77-
1. [Action](#action-chip)
72+
There are four types of chips: 1\. [Input (text entry)](#input-chip) 2\. [Choice](#choice-chip) 3\. [Filter](#filter-chip) 4\. [Action](#action-chip)
7873

7974
![Examples of the four different chip types](docs/assets/chips-composite.png)
8075

@@ -92,7 +87,6 @@ self.view.addSubview(chipView)
9287
```
9388

9489
#### Objective-C
95-
9690
```objc
9791
MDCChipView *chipView = [[MDCChipView alloc] init];
9892
chipView.titleLabel.text = @"Tap me";
@@ -156,6 +150,18 @@ Input chips represent a complex piece of information in compact form, such as an
156150

157151
We currently provide an implementation of Input Chips called `MDCChipField`.
158152

153+
<!--<div class="material-code-render" markdown="1">-->
154+
#### Swift
155+
```swift
156+
let chipField = MDCChipField()
157+
chipField.delegate = self
158+
chipField.textField.placeholderLabel.text = "This is a chip field."
159+
chipField.showChipsDeleteButton = true
160+
chipField.sizeToFit()
161+
view.addSubview(chipField)
162+
```
163+
164+
#### Objective-C
159165
```objc
160166
MDCChipField *chipField = [[MDCChipField alloc] init];
161167
chipField.delegate = self;
@@ -176,33 +182,60 @@ It is easiest to create choice Chips using a `UICollectionView`:
176182
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
177183
178184
<!--<div class="material-code-render" markdown="1">-->
185+
#### Swift
186+
```swift
187+
let layout = MDCChipCollectionViewFlowLayout()
188+
collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
189+
```
190+
191+
#### Objective-C
179192
```objc
180193
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
181194
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
182195
```
183196
<!--</div>-->
184197
185198
- Leave the default `UICollectionView` selection setting (single selection).
186-
187199
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)
188200
189201
<!--<div class="material-code-render" markdown="1">-->
202+
#### Swift
203+
```swift
204+
func loadView() {
205+
super.loadView()
206+
207+
collectionView.register(
208+
MDCChipCollectionViewCell.self,
209+
forCellWithReuseIdentifier: "identifier")
210+
}
211+
212+
func collectionView(
213+
_ collectionView: UICollectionView,
214+
cellForItemAt indexPath: IndexPath
215+
) -> UICollectionViewCell {
216+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as! MDCChipCollectionViewCell
217+
let chipView = cell.chipView
218+
// configure the chipView to be a choice chip
219+
return cell
220+
}
221+
```
222+
223+
#### Objective-C
190224
```objc
191225
- (void)loadView {
192226
[super loadView];
193-
227+
194228
[_collectionView registerClass:[MDCChipCollectionViewCell class]
195229
forCellWithReuseIdentifier:@"identifier"];
196-
...
197-
}
230+
}
198231

199232
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
200233
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
201234
MDCChipCollectionViewCell *cell =
202235
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
203236
MDCChipView *chipView = cell.chipView;
204-
// configure the chipView
205-
return cell;
237+
// configure the chipView to be a choice chip
238+
return cell;
206239
}
207240
```
208241
<!--</div>-->
@@ -222,6 +255,13 @@ It is easiest to create filter Chips using a `UICollectionView`:
222255
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
223256

224257
<!--<div class="material-code-render" markdown="1">-->
258+
#### Swift
259+
```swift
260+
let layout = MDCChipCollectionViewFlowLayout()
261+
collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
262+
```
263+
264+
#### Objective-C
225265
```objc
226266
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
227267
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
@@ -231,30 +271,57 @@ _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionV
231271
- Allow multi cell selection in the `UICollectionView`:
232272
233273
<!--<div class="material-code-render" markdown="1">-->
274+
#### Swift
275+
```swift
276+
collectionView.allowsMultipleSelection = true
277+
```
278+
279+
#### Objective-C
234280
```objc
235-
collectionView.allowsMultipleSelection = YES;
281+
collectionView.allowsMultipleSelection = YES;
236282
```
237283
<!--</div>-->
238284

239285
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)
240286

241287
<!--<div class="material-code-render" markdown="1">-->
288+
#### Swift
289+
```swift
290+
func loadView() {
291+
super.loadView()
292+
293+
collectionView.register(
294+
MDCChipCollectionViewCell.self,
295+
forCellWithReuseIdentifier: "identifier")
296+
}
297+
298+
func collectionView(
299+
_ collectionView: UICollectionView,
300+
cellForItemAt indexPath: IndexPath
301+
) -> UICollectionViewCell {
302+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as! MDCChipCollectionViewCell
303+
let chipView = cell.chipView
304+
// configure the chipView to be a filter chip
305+
return cell
306+
}
307+
```
308+
309+
#### Objective-C
242310
```objc
243311
- (void)loadView {
244312
[super loadView];
245-
313+
246314
[_collectionView registerClass:[MDCChipCollectionViewCell class]
247315
forCellWithReuseIdentifier:@"identifier"];
248-
...
249-
}
316+
}
250317

251318
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
252319
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
253320
MDCChipCollectionViewCell *cell =
254321
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
255322
MDCChipView *chipView = cell.chipView;
256-
// configure the chipView
257-
return cell;
323+
// configure the chipView to be a filter chip
324+
return cell;
258325
}
259326
```
260327
<!--</div>-->
@@ -274,6 +341,13 @@ It is easiest to create action Chips using a `UICollectionView`:
274341
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
275342

276343
<!--<div class="material-code-render" markdown="1">-->
344+
#### Swift
345+
```swift
346+
let layout = MDCChipCollectionViewFlowLayout()
347+
collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: layout)
348+
```
349+
350+
#### Objective-C
277351
```objc
278352
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
279353
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
@@ -284,29 +358,62 @@ _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionV
284358
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)
285359
286360
<!--<div class="material-code-render" markdown="1">-->
361+
#### Swift
362+
```swift
363+
func loadView() {
364+
super.loadView()
365+
366+
collectionView.register(
367+
MDCChipCollectionViewCell.self,
368+
forCellWithReuseIdentifier: "identifier")
369+
}
370+
371+
func collectionView(
372+
_ collectionView: UICollectionView,
373+
cellForItemAt indexPath: IndexPath
374+
) -> UICollectionViewCell {
375+
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as! MDCChipCollectionViewCell
376+
let chipView = cell.chipView
377+
// configure the chipView to be an action chip
378+
return cell
379+
}
380+
```
381+
382+
#### Objective-C
287383
```objc
288384
- (void)loadView {
289385
[super loadView];
290-
386+
291387
[_collectionView registerClass:[MDCChipCollectionViewCell class]
292388
forCellWithReuseIdentifier:@"identifier"];
293-
...
294-
}
389+
}
295390

296391
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
297392
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
298393
MDCChipCollectionViewCell *cell =
299394
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
300395
MDCChipView *chipView = cell.chipView;
301-
// configure the chipView
302-
return cell;
396+
// configure the chipView to be an action chip
397+
return cell;
303398
}
304399
```
305400
<!--</div>-->
306401

307402
- Make sure that `MDCChipCollectionViewCell` does not stay in selected state
308403

309404
<!--<div class="material-code-render" markdown="1">-->
405+
#### Swift
406+
```swift
407+
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
408+
// For action chips, we never want the chip to stay in selected state.
409+
// Other possible apporaches would be relying on theming or Customizing collectionViewCell
410+
// selected state.
411+
collectionView.deselectItem(at: indexPath, animated: false)
412+
// Trigger the action
413+
}
414+
```
415+
416+
#### Objective-C
310417
```objc
311418
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
312419
// For action chips, we never want the chip to stay in selected state.

components/List/README.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,13 @@ An instance of `MDCSelfSizingStereoCell` can be configured to be a single-line,
155155
**Title text** |`titleLabel` | N/A | N/A
156156
**Detail text** |`titleLabel` | N/A | N/A
157157

158-
## Types
158+
**Types**
159159

160-
There are three list types:
161-
1. [Single-line list](#single-line-list)
162-
1. [Two-line list](#two-line-list)
163-
1. [Three-line list](#three-line-list)
160+
There are three list types: 1\. [Single-line list](#single-line-list), 2\. [Two-line list](#two-line-list) 3\. [Three-line list](#three-line-list)
164161

165162
![Composite image of the three list types](docs/assets/lists-types.png)
166163

167-
### Single-line list
164+
## Single-line list
168165

169166
Single-line list items contain a maximum of one line of text.
170167

@@ -202,7 +199,7 @@ func collectionView(_ collectionView: UICollectionView,
202199
```
203200
<!--</div>-->
204201

205-
### Two-line list
202+
## Two-line list
206203

207204
Two-line list items contain a maximum of two lines of text.
208205

@@ -242,7 +239,7 @@ func collectionView(_ collectionView: UICollectionView,
242239
```
243240
<!--</div>-->
244241

245-
### Three-line list
242+
## Three-line list
246243

247244
Three-line list items contains a maximum of three lines of text.
248245

components/NavigationDrawer/README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ import MaterialComponents.MaterialNavigationDrawer
6161

6262
While `MDCBottomDrawerViewController` supports the accessibility escape "Z" gesture, it is advisible that the content view controller provides its own dismiss action affordance. Note that it is the responsibility of the header and content view controllers to implement any custom accessibility behavior.
6363

64-
## Types
64+
## Bottom navigation drawer
6565

6666
Both bottom navigation drawers and side navigation drawers exist, but we only offer a bottom navigation drawer implementation.
6767

68-
## Bottom navigation drawer
69-
7068
Our bottom navigation drawer implementation is centered around `MDCBottomDrawerViewController`, a `UIViewController` subclass. `MDCBottomDrawerViewController` has a `contentViewController` property, whose view is displayed as the primary content of the drawer, as well as a `headerViewController` property, whose view is positioned above the content view controller and sticks to the top when the drawer is full-screen. For more information on implementing custom view controller classes see [Apple's View Controller Programming Guide](https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/DefiningYourSubclass.html#//apple_ref/doc/uid/TP40007457-CH7-SW1).
7169

7270
Bottom navigation drawers are recommended for:

0 commit comments

Comments
 (0)