BRDroid
BRDroid

Reputation: 4388

Composable TimePicker does not set the time to 23:50

I have an seeing this issue with composable TimePicker, which uses a timePickerState - rememberTimePickerState. to test this I am setting manually the time to be 23:59 but the displayed time in the TimePicker is 12:59.

Note: any other time I set works fine, it is just when I set hours to 23, it shows as 12. Also tested with both 12 hours and 24 hours, it is the same issue.

Any one has seen this behaviour?

val timePickerState = rememberTimePickerState(
    initialHour = 23,
    initialMinute = 59
)

 TimePicker(
            state = timePickerState,
            colors = TimePickerDefaults.colors(
                clockDialColor = md_theme_accessible_blue,
                timeSelectorSelectedContainerColor = MaterialTheme.colorScheme.primary,
                timeSelectorSelectedContentColor = md_theme_accessible_blue,
                timeSelectorUnselectedContainerColor = md_theme_accessible_blue,
                periodSelectorSelectedContainerColor = md_theme_accessible_blue,
                periodSelectorSelectedContentColor = MaterialTheme.colorScheme.primary,
                periodSelectorUnselectedContainerColor = md_theme_accessible_blue,
            )
        )

This is what I see on the timePicker enter image description here

Could you suggest anything I could try to resolve this please

Thanks R

Edit: Gradle

//Compose
val composeBom = platform("androidx.compose:compose-bom:2023.08.00")
implementation(composeBom)
implementation("androidx.compose.material:material")
implementation("androidx.compose.material3:material3:1.2.0-alpha05")
implementation("androidx.activity:activity-compose")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.runtime:runtime-livedata")

Upvotes: 0

Views: 670

Answers (1)

Jan Bína
Jan Bína

Reputation: 7278

Seems like a bug that has been already fixed: https://android-review.googlesource.com/c/platform/frameworks/support/+/2443699

Works fine for me with the latest version of material3 library (1.2.0-alpha05). Try updating.

Upvotes: 0

Related Questions