TComposeDateTimePicker
3.7.2indexedLibrary for creating customizable date, time, and date-time pickers with configuration options for labels and selection handling, enhancing user interaction and interface flexibility.
Library for creating customizable date, time, and date-time pickers with configuration options for labels and selection handling, enhancing user interaction and interface flexibility.
A Compose Multiplatform library for elegant and customizable date, time, and date-time pickers.
Compose Date Time Picker is a powerful and flexible library for Compose Multiplatform that provides easy-to-use and customizable date, time, and date-time pickers. It is designed to work seamlessly across multiple platforms, including Android, iOS, macOS, JVM, and * JS/WASM*.
The library also includes a rich set of extensions for kotlinx.datetime to simplify date and time
manipulation, formatting, and conversion.
Add the dependency to your build.gradle.kts file:
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.the-best-is-best:compose_date_time_picker:3.7.0")
}
TKDatePicker(
config = ConfigDatePicker(
label = { Text("Select Date") }
),
useAdaptive = false,
isDialogOpen = { /* Handle dialog state */ },
onDateSelected = { selectedDate ->
println("Selected date: $selectedDate")
}
)
TKTimePicker(
config = ConfigTimePicker(
label = { Text("Select Time") }
),
useAdaptive = false,
isDialogOpen = { /* Handle dialog state */ },
onTimeSelected = { selectedTime ->
println("Selected time: $selectedTime")
}
)
TKDateTimePicker(
textFieldType = TextFieldType.Filled,
config = ConfigDateTimePicker(
label = { Text("Select Date and Time") }
),
useAdaptive = false,
isDialogOpen = { /* Handle dialog state */ },
onDateTimeSelected = { selectedDateTime ->
println("Selected date and time: ${selectedDateTime?.toIsoStringWithOffset()}")
}
)
TKDateTimePicker(
textFieldType = TextFieldType.Custom { modifier -> },
config = ConfigDateTimePicker(
label = { Text("Select Date and Time") }
),
useAdaptive = false,
isDialogOpen = { /* Handle dialog state */ },
onDateTimeSelected = { selectedDateTime ->
println("Selected date and time: ${selectedDateTime?.toIsoStringWithOffset()}")
}
)
val today = LocalDate.now() // Get current date
val formattedDate = today.formatLocalDate() // Format as "dd/MM/yyyy"
val epochMillis = today.toEpochMillis() // Convert to epoch milliseconds
val isLeapYear = today.isLeapYear() // Check if the year is a leap year
val now = LocalDateTime.now()
val formattedDateTime = now.formatLocalDateTime(use24HourFormat = false)
val truncatedDateTime = now.truncatedTo(DurationUnit.HOURS)
val currentTime = LocalTime.now()
val formattedTime = currentTime.formatLocalTime(withoutSeconds = true)
The useAdaptive parameter enables adaptive UI support, ensuring that the pickers look great on all
platforms and screen sizes. This feature relies on
the calf-ui library.
This library is open-source and licensed under the MIT License.
MIT License
Copyright (c) 2023 the-best-is-best
Permission hereby granted, charge, person obtaining a
this software associated documentation files (the "Software"), deal
the Software restriction, including limitation the rights
use, , modify, , publish, distribute, sublicense, sell
copies the Software.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
TKDatePickerTKTimePickerTKDateTimePickerkotlinx.datetime, including:
LocalDate, LocalDateTime, and epoch milliseconds.Surfaced from shared tags and platforms — no rankings paid for.