GithubHelp home page GithubHelp logo

datepickerdialog's Introduction

Date Picker Dialog Gregorian/Jalali

forthebadge forthebadge
platform

A customizable date picker dialog for Android that supports both Gregorian and Jalali calendars. Users can easily select dates using either a dialog or a bottom sheet. The library is designed to be simple to use and integrate into your existing projects.

Gregorian Jalali
Gregorian Jalali

Features

  • Dual Calendar Support: Pick dates using either the Gregorian or Jalali calendar.
  • Dialog & Bottom Sheet: Choose between a traditional dialog or a modern bottom sheet for date selection.

Usages

You use it in your project like below.

 DatePickerDialog.Builder(this) // context
    .setCalendarType(calendarType)
    .setMaxYear(DatePickerDialog.THIS_YEAR)
    .setMaxMonth(DatePickerDialog.THIS_MONTH)
    .setMaxDay(DatePickerDialog.THIS_DAY)
    .setPositiveButtonString(R.string.ok)
    .setNegativeButtonString(R.string.cancel)
    .setCancelable(false)
    .setShowInBottomSheet(true)
    .setListener(object : DatePickerListener {
        override fun onDateSelected(datePicker: IDatePicker) {
            Log.d(TAG, "onDateSelected: " + datePicker.getTimeStamp())
            Log.d(TAG, "onDateSelected: " + datePicker.getGregorianDate())
            Log.d(TAG, "onDateSelected: " + datePicker.getJalaliLongDate())
            Log.d(TAG, "onDateSelected: " + datePicker.getJalaliMonthName())

            Toast.makeText(this@MainActivity, "${datePicker.getJalaliYear()}/${datePicker.getJalaliMonth()}/${datePicker.getJalaliDay()} ", Toast.LENGTH_SHORT).show()
        }

        override fun onDismiss() {
            Toast.makeText(this@MainActivity, "dismissed", Toast.LENGTH_SHORT).show()
        }

    })
    .build().show()

Public Methods

Name Description
setMaxYear(int) set maximum year can be selected
setMaxMonth(int) set maximum month can be selected
setMaxDay(int) set maximum day can be selected in the last month
setMinYear(int) set minimum year can be selected
setCalendarType(CalendarType) set calendar type(Gregorian or Jalali)
setPositiveButtonString(@StringRes int) set positive button text from strings.xml
setNegativeButtonString(@StringRes int) set negative button text from strings.xml
setCancelable(boolean) set dialog cancelable or not
setShowInBottomSheet(bool) switch between dialog and bottomsheet
setListener(Listener) set dialog callback listener

STYLING

The pickers will be themed automatically based on the current theme where they are created. you can theme the pickers by overwriting the color resources mdtp_accent_color and mdtp_accent_color_dark in your project.

<color name="mdtp_accent_color">#009688</color>
<color name="mdtp_accent_color_dark">#00796b</color>

Credits

This library is completely based on Persian Date Picker Dialog.

datepickerdialog's People

Contributors

ahmadnosratian avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.