
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.
TKDatePicker
TKTimePicker
TKDateTimePicker
kotlinx.datetime, including:
LocalDate, LocalDateTime, and epoch milliseconds.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 yearval 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 is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
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.
TKDatePicker
TKTimePicker
TKDateTimePicker
kotlinx.datetime, including:
LocalDate, LocalDateTime, and epoch milliseconds.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 yearval 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 is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.