Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DatePickerDialog to the latest AOSP version #1666

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,27 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.DialogProperties

/**
* <a href="https://m3.material.io/components/date-pickers/overview" class="external" target="_blank">Material Design date picker dialog</a>.
* <a href="https://m3.material.io/components/date-pickers/overview" class="external"
* target="_blank">Material Design date picker dialog</a>.
*
* A dialog for displaying a [DatePicker]. Date pickers let people select a date.
*
* A sample for displaying a [DatePicker] in a dialog:
* @sample androidx.compose.material3.samples.DatePickerDialogSample
*
* @param onDismissRequest called when the user tries to dismiss the Dialog by clicking outside
* or pressing the back button. This is not called when the dismiss button is clicked.
* @sample androidx.compose.material3.samples.DatePickerDialogSample
* @param onDismissRequest called when the user tries to dismiss the Dialog by clicking outside or
* pressing the back button. This is not called when the dismiss button is clicked.
* @param confirmButton button which is meant to confirm a proposed action, thus resolving what
* triggered the dialog. The dialog does not set up any events for this button, nor does it control
* its enablement, so those need to be set up by the caller.
* triggered the dialog. The dialog does not set up any events for this button, nor does it
* control its enablement, so those need to be set up by the caller.
* @param modifier the [Modifier] to be applied to this dialog's content.
* @param dismissButton button which is meant to dismiss the dialog. The dialog does not set up any
* events for this button so they need to be set up by the caller.
* events for this button so they need to be set up by the caller.
* @param shape defines the dialog's surface shape as well its shadow
* @param tonalElevation when [DatePickerColors.containerColor] is [ColorScheme.surface], a higher
* the elevation will result in a darker color in light theme and lighter color in dark theme
* the elevation will result in a darker color in light theme and lighter color in dark theme
* @param colors [DatePickerColors] that will be used to resolve the colors used for this date
* picker in different states. See [DatePickerDefaults.colors].
* picker in different states. See [DatePickerDefaults.colors].
* @param properties typically platform specific properties to further configure the dialog
* @param content the content of the dialog (i.e. a [DatePicker], for example)
*/
Expand All @@ -79,25 +80,25 @@ actual fun DatePickerDialog(
properties = properties
) {
Surface(
modifier = Modifier
.requiredWidth(DatePickerModalTokens.ContainerWidth)
modifier =
Modifier.requiredWidth(DatePickerModalTokens.ContainerWidth)
.heightIn(max = DatePickerModalTokens.ContainerHeight),
shape = shape,
color = colors.containerColor,
tonalElevation = tonalElevation,
) {
Column(verticalArrangement = Arrangement.SpaceBetween) {
content()
// Wrap the content with a Box and Modifier.weight(1f) to ensure that any "confirm"
// and "dismiss" buttons are not pushed out of view when running on small screens,
// or when nesting a DateRangePicker.
// Fill is false to support collapsing the dialog's height when switching to input
// mode.
Box(Modifier.weight(1f, fill = false)) { this@Column.content() }
// Buttons
Box(
modifier = Modifier
.align(Alignment.End)
.padding(DialogButtonsPadding)
) {
Box(modifier = Modifier.align(Alignment.End).padding(DialogButtonsPadding)) {
ProvideContentColorTextStyle(
contentColor = DialogTokens.ActionLabelTextColor.value,
textStyle =
MaterialTheme.typography.fromToken(DialogTokens.ActionLabelTextFont)
textStyle = DialogTokens.ActionLabelTextFont.value
) {
AlertDialogFlowRow(
mainAxisSpacing = DialogButtonsMainAxisSpacing,
Expand Down
Loading