Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

io.github.bobbysandhu:unified-date-time-picker-kt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io.github.bobbysandhu:unified-date-time-picker-kt

A library to manage Date & Time with a single UI component.

  • 1.1.0
  • Source
  • Maven
  • Socket score

Version published
Maintainers
1
Source

UnifiedDateTimePicker

UnifiedDateTimePicker would help you pick Date and Time with just single UI component. It's inspired & took from Telegram and extended with all the customization to fulfill the needs of any modern app.

Java version of the library is also available here:

https://github.com/BobbySandhu/unified-date-time-picker

Usage

UnifiedDateTimePicker.Builder(this)
            .title("Select Date and Time")
            .addListener(object : OnDateTimeSelectedListener {
                override fun onDateTimeSelected(millis: Long) {
                    val sdf = SimpleDateFormat(DATE_FORMAT_Z, Locale.ROOT)
                    val calendar: Calendar = Calendar.getInstance()
                    calendar.timeInMillis = millis

                    binding.textDateTime.text = sdf.format(calendar.time)
                }

                override fun onPickerDismissed(millis: Long) {
                    /* no use as of now */
                }
            })
            .show();

With default setting it would look like this:

drawing

Customizations

UnifiedDateTimePicker.Builder(this)
            .title("Select Date and Time")
            .titleTextColor(R.color.white)
            .backgroundColor(R.color.big_stone)
            .dateTimeTextColor(R.color.white)
            .buttonColor(R.color.picton_blue)
            .buttonTextColor(R.color.white)
            .vibration(true) //heptic feedback when values are scrolled
            .setTodayText("Today") //new 
            .setLocale(Locale.getDefault() ?: Locale.ENGLISH) //new
            .setButtonText(
                "'Today' HH:mm",
                "'Send on' d MMM yyyy 'at' HH:mm",
                "'Send on' d MMM yyyy 'at' HH:mm"
            ) //new
            //.setDateTimeMillis(/* long milliseconds*/)
            .addListener(object : OnDateTimeSelectedListener {
                override fun onDateTimeSelected(millis: Long) {
                    val sdf = SimpleDateFormat(DATE_FORMAT_Z, Locale.ROOT)
                    val calendar: Calendar = Calendar.getInstance()
                    calendar.timeInMillis = millis

                    binding.textDateTime.text = sdf.format(calendar.time)
                }

                override fun onPickerDismissed(millis: Long) {
                    /* no use as of now */
                }
            })
            .show();

With all these customizations applied, it would look like:

drawing

Implementation

// Top level build file
repositories {
    // Add this to the end of any existing repositories
    mavenCentral()
}

// app level dependencies section
dependencies {
    implementation 'io.github.bobbysandhu:unified-date-time-picker-kt:1.1.0'
}

Want to extend the feature, have any improvement or bug fix?

You can contribute and help the community. All you need to do is share your PR with clear message. That's it!!

FAQs

Package last updated on 30 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc