Skip to content

Commit

Permalink
[Docs][DatePicker] update DatePicker.md
Browse files Browse the repository at this point in the history
Resolves #4384

GIT_ORIGIN_REV_ID=aa9dc84695a6ad2026891efe35cc6dc58e325645
PiperOrigin-RevId: 708404155
  • Loading branch information
manabu-nakamura authored and imhappi committed Dec 23, 2024
1 parent 8726702 commit f29063e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/components/DatePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ To set a default selection:

```kt
// Opens the date picker with today's date selected.
MaterialDatePicker.Builder().datePicker()
MaterialDatePicker.Builder.datePicker()
...
.setSelection(MaterialDatePicker.todayInUtcMilliseconds())

Expand All @@ -96,23 +96,23 @@ MaterialDatePicker.Builder.dateRangePicker()
The picker can be started in text input mode with:

```kt
MaterialDatePicker.Builder().datePicker()
MaterialDatePicker.Builder.datePicker()
...
.setInputMode(MaterialDatePicker.INPUT_MODE_TEXT)
```

A `DayViewDecorator` can be set allowing customizing the day of month views within the picker ([example of a `DayViewDecorator`](https://github.com/material-components/material-components-android/tree/master/catalog/java/io/material/catalog/datepicker/CircleIndicatorDecorator.java)):

```kt
MaterialDatePicker.Builder().datePicker()
MaterialDatePicker.Builder.datePicker()
...
.setDayViewDecorator(new CircleIndicatorDecorator())
.setDayViewDecorator(CircleIndicatorDecorator())
```

To show the picker to the user:

```kt
picker.show(supportFragmentManager, "tag");
picker.show(supportFragmentManager, "tag")
```

Subscribe to button clicks or dismiss events with the following calls:
Expand All @@ -132,7 +132,7 @@ picker.addOnDismissListener {
}
```

Finally, you can get the user selection with `datePicker.selection`.
Finally, you can get the user selection with `picker.selection`.

### Adding calendar constraints

Expand Down Expand Up @@ -183,7 +183,7 @@ To set a validator:
// Makes only dates from today forward selectable.
val constraintsBuilder =
CalendarConstraints.Builder()
.setValidator(DateValidatorPointForward.now)
.setValidator(DateValidatorPointForward.now())

// Makes only dates from February forward selectable.
val constraintsBuilder =
Expand All @@ -199,7 +199,7 @@ in the MDC catalog).
Set the constraint to the picker's builder:

```kt
MaterialDatePicker.Builder().datePicker()
MaterialDatePicker.Builder.datePicker()
...
.setCalendarConstraints(constraintsBuilder.build())
```
Expand All @@ -212,7 +212,7 @@ Use a descriptive title for the task:

```kt
val picker =
MaterialDatePicker.Builder()
MaterialDatePicker.Builder.datePicker()
...
.setTitleText("Select appointment date")
...
Expand Down Expand Up @@ -452,7 +452,7 @@ Set the theme in code, which affects only this date picker:

```kt
val picker =
MaterialDatePicker.Builder()
MaterialDatePicker.Builder.datePicker()
...
.setTheme(.style.ThemeOverlay_App_DatePicker)
.setTheme(R.style.ThemeOverlay_App_DatePicker)
```

0 comments on commit f29063e

Please sign in to comment.