Skip to content

Commit

Permalink
[Material-iOS/Chips, Material-iOS/BottomSheet] Clean up markdown form…
Browse files Browse the repository at this point in the history
…atting.

PiperOrigin-RevId: 355431936
  • Loading branch information
Nobody authored and material-automation committed Feb 3, 2021
1 parent 73e4048 commit d0ac5f2
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 111 deletions.
3 changes: 2 additions & 1 deletion components/BottomSheet/README.md
Expand Up @@ -124,6 +124,7 @@ MDCBottomSheetController *bottomSheet = [[MDCBottomSheetController alloc] initWi
// Present the bottom sheet
[self presentViewController:bottomSheet animated:true completion:nil];
```
<!--</div>-->
#### Behavioral customizations
Expand Down Expand Up @@ -265,4 +266,4 @@ id<MDCShapeScheming> shapeScheme = [[MDCShapeScheme alloc] init];
[MDCBottomSheetControllerShapeThemer applyShapeScheme:shapeScheme
toBottomSheetController:component];
```
<!--</div>-->
<!--</div>-->
225 changes: 115 additions & 110 deletions components/Chips/README.md
Expand Up @@ -164,7 +164,6 @@ chipField.showChipsDeleteButton = true
[chipField sizeToFit];
[self.view addSubview:chipField];
```
<!--</div>-->
## Choice chip
Expand All @@ -174,37 +173,39 @@ Choice chips clearly delineate and display options in a compact area. They are a
It is easiest to create choice Chips using a `UICollectionView`:
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->

- Leave the default `UICollectionView` selection setting (single selection).
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->

- Leave the default `UICollectionView` selection setting (single selection).

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

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->

- Use `UICollectionViewDelegate` methods `collectionView:didSelectItemAtIndexPath:` for reacting to new choices.

Expand All @@ -218,42 +219,45 @@ Filter chips clearly delineate and display options in a compact area. They are a

It is easiest to create filter Chips using a `UICollectionView`:

- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->

- Allow multi cell selection in the `UICollectionView`:
<!--<div class="material-code-render" markdown="1">-->
```objc
collectionView.allowsMultipleSelection = YES;
```
<!--</div>-->
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:

<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->
- Allow multi cell selection in the `UICollectionView`:
<!--<div class="material-code-render" markdown="1">-->
```objc
collectionView.allowsMultipleSelection = YES;
```
<!--</div>-->

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

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->

- Use `UICollectionViewDelegate` methods `collectionView:didSelectItemAtIndexPath:` and `collectionView:didDeselectItemAtIndexPath:` for reacting to filter changes.

Expand All @@ -267,51 +271,52 @@ An alternative to action chips are buttons, which should appear persistently and

It is easiest to create action Chips using a `UICollectionView`:

- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:
<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->

- Leave the default `UICollectionView` selection setting (single selection).
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->
- Use `MDCChipCollectionViewFlowLayout` as the `UICollectionView` layout:

<!--<div class="material-code-render" markdown="1">-->
```objc
MDCChipCollectionViewFlowLayout *layout = [[MDCChipCollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
```
<!--</div>-->
- Leave the default `UICollectionView` selection setting (single selection).
- Use `MDCChipCollectionViewCell` as `UICollectionView` cells. (`MDCChipCollectionViewCell` manages the state of the chip based on selection state of `UICollectionView` automatically)
<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)loadView {
[super loadView];
[_collectionView registerClass:[MDCChipCollectionViewCell class]
forCellWithReuseIdentifier:@"identifier"];
...
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MDCChipCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:@"identifier" forIndexPath:indexPath];
MDCChipView *chipView = cell.chipView;
// configure the chipView
return cell;
}
```
<!--</div>-->

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

<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// For action chips, we never want the chip to stay in selected state.
// Other possible apporaches would be relying on theming or Customizing collectionViewCell
// selected state.
[collectionView deselectItemAtIndexPath:indexPath animated:NO];
// Trigger the action
}
```
<!--</div>-->
<!--<div class="material-code-render" markdown="1">-->
```objc
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
// For action chips, we never want the chip to stay in selected state.
// Other possible apporaches would be relying on theming or Customizing collectionViewCell
// selected state.
[collectionView deselectItemAtIndexPath:indexPath animated:NO];
// Trigger the action
}
```
<!--</div>-->

- Use `UICollectionViewDelegate` method `collectionView:didSelectItemAtIndexPath:` to Trigger the action.

Expand Down

0 comments on commit d0ac5f2

Please sign in to comment.