Git Product home page Git Product logo

picker's Introduction

DatePicker&TimePicker

Picker is a date and time picker library that supports view-based and jetpack compose UI design.

The library has many different feature options to customize your widget. Also checkout this Wheelview.

Recent Article 2


        


        



        




Jetpack Compose Usage


WheelDatePicker(
	offset =/*offset*/,
	yearsRange = IntRange(/*minYear*/,/*maxYear*/),
	startDate =/*startDate*/,
	textSize =/*textSize*/,
	selectorEffectEnabled =/*selectorEffectEnabled*/,
	darkModeEnabled =/*darkModeEnabled*/,
	onDateChanged = { day, month, year, date ->
	  /*Handle date changes*/
	}
)

Parameters

Parameter Type Description
offset Int Count of items to be shown on picker
yearsRange IntRange Min and max date of picker
startDate Long Selected date of picker by default today date
textSize Int Size of text on picker
selectorEffectEnabled Boolean Uses to enable or disable the selection effect
darkModeEnabled Boolean Uses to enable or disable dark mode. If you disable it, although you set display settings dark, component stay light mode
onDateSelected Called when the values in the picker date picker are updated


WheelTimePicker(
	offset =/*offset*/,
	timeFormat = TimeFormat.CLOCK_12H,
	startTime =/*startTime*/,
	textSize =/*textSize*/,
        selectorEffectEnabled =/*selectorEffectEnabled*/, 
	darkModeEnabled =/*darkModeEnabled*/,
	onTimeChanged = { hour, minute, format ->
	  /*Handle time changes*/       
	}
)

Parameters

Parameter Type Description
offset Int Count of items to be shown on picker
timeFormat TimeFormat Time format of picker. TimeFormat.CLOCK_12H or TimeFormat.CLOCK_24H
startTime Time Selected time of picker by default current time
textSize Int Size of text on picker
selectorEffectEnabled Boolean Uses to enable or disable the selection effect
darkModeEnabled Boolean Uses to enable or disable dark mode. If you disable it, although you set display settings dark, component stay light mode
onTimeSelected Called when the values in the picker date picker are updated



View Usage


NOTE: If you would like to use library on view based ui, add androidx.compose.material3 to gradle dependencies.


Date Picker

datePicker.apply {
            setOffset(/*offset*/)
            setTextSize(/*textSize*/)
            setDate(getCurrentTime())
            setDarkModeEnabled(/*darkModeEnabled*/)
            setDateChangeListener(object : DatePicker.DateChangeListener {
                override fun onDateChanged(date: Long, day: Int, month: Int, year: Int) {
                    //Handle date changes
                }
            })
        }
    <com.ozcanalasalvar.datepicker.view.datepicker.DatePicker
            android:id="@+id/datepicker"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:darkModeEnabled="true"
            app:offset="3"
            app:textSize="19" />


XML attributes

Parameter Type Description
offset Int Count of items to be shown on picker
textSize Int Size of text on picker
darkModeEnabled Boolean Uses to enable or disable dark mode. If you disable it, although you set display settings dark, component stay light mode
Popup Usage
 val datePickerPopup = DatePickerPopup.Builder()
            .from(/*context*/)
            .offset(/*offset*/)
            .textSize(/*textSize*/)
            .selectedDate(getCurrentTime())
            .darkModeEnabled(/*darkModeEnabled*/)
            .listener(object : DatePickerPopup.DateSelectListener {
                override fun onDateSelected(
                    dp: DatePicker?,
                    date: Long,
                    day: Int,
                    month: Int,
                    year: Int
                ) {

                }
            })
            .build()

datePickerPopup.show(supportFragmentManager, TAG)

Time Picker

timePicker.apply {
            setOffset(/*offset*/)
            setTextSize(/*textSize*/)
            setTimeFormat(TimeFormat.CLOCK_12H)
            setTime(/*hour*/, /*minute*/)
            setDarkModeEnabled(/*darkModeEnabled*/)
            setTimeChangeListener(object : TimePicker.TimeChangeListener {
                override fun onTimeChanged(hour: Int, minute: Int, timeFormat: String?) {
                    //Handle time changes
                }
            })
        }
<com.ozcanalasalvar.datepicker.view.timepicker.TimePicker
            android:id="@+id/timepicker"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            app:darkModeEnabled="true"
            app:is24HourViewEnabled="false"
            app:offset="2"
            app:textSize="17" />

XML attributes

Parameter Type Description
offset Int Count of items to be shown on picker
is24HourViewEnabled Boolen Time format of picker. If true TimeFormat.CLOCK_24H else TimeFormat.CLOCK_12H
textSize Int Size of text on picker
darkModeEnabled Boolean Uses to enable or disable dark mode. If you disable it, although you set display settings dark, component stay light mode


Popup Usage
val pickerPopup = TimePickerPopup.Builder()
            .from(/*context*/)
            .offset(/*offset*/)
            .textSize(/*textSize*/)
            .setTime(/*hour*/, /*minute*/)
            .setTimeFormat(TimeFormat.CLOCK_24H)
            .darkModeEnabled(/*darkModeEnabled*/)
            .listener(object : TimePickerPopup.TimeSelectListener {
                override fun onTimeSelected(
                    timePicker: TimePicker?,
                    hour: Int,
                    minute: Int,
                    format: String?
                ) {
                    
                }
            })
            .build()

pickerPopup.show(supportFragmentManager, TAG)

Implementation Gradle

Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		mavenCentral()
		maven { url 'https://jitpack.io' }
	}
}
Add the dependency
dependencies {
	implementation 'com.github.ozcanalasalvar.picker:datepicker:2.0.7'
	implementation 'com.github.ozcanalasalvar.picker:wheelview:2.0.7'

	//For view based UI's
	implementation 'androidx.compose.material3:material3:Tag'
}

picker's People

Contributors

crazycotanak avatar ozcanalasalvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

picker's Issues

Bug in release build

Fatal Exception: java.lang.NoSuchMethodError
No static method items$default(Landroidx/compose/foundation/lazy/LazyListScope;ILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;ILjava/lang/Object;)V in class Landroidx/compose/foundation/lazy/LazyListScope; or its super classes (declaration of 'androidx.compose.foundation.lazy.LazyListScope' appears in /data/app/~~dvpxDbu2j4qrjTulliy9vw==/com.ruchitech.quicklinkcaller-Ax3zZoB_MjrjwlLaM9JrBQ==/base.apk)

It is not working in nested scroll view

Add this method in WheelView.java
@OverRide
public boolean onInterceptTouchEvent(MotionEvent ev) {
// Stop ScrollView from getting involved once you interact with the View
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
ViewParent p = getParent();
if (p != null){
p.requestDisallowInterceptTouchEvent(true);
}
}
return super.onInterceptTouchEvent(ev);
}

implementation error !!!

I added the implementation code and maven line in Gradle

implementation 'com.github.OzcanAlasalvar:DatePicker:1.0.4'

Failed to resolve: com.github.OzcanAlasalvar:DatePicker:1.0.4

but it still giving me error :(

Min SDK 23

Why this library requires min sdk 23 ?
any specific reason??

Can not scroll dates, month or year

I have implemented this library in kotlin code. But it is always disabled. I can not scroll any of 3 pickers.
Edit:-
I found that it works fine in normal screen but inside RecyclerView adapter or viewpager it is not working.

Can you please make in cycle mode

The date picker is not set in cycle mode like the current month date is 1 to 30, we scroll down 1 to 30 then stop scrolling on 30. I have to continually 1 to 30 again and again like IOS

No Static method weight$default

I get the following error only when installing the app via the Google Play Store as an internal testing build, rather than installing via Android Studio on a test device

No static method weight$default(Landroidx/compose/foundation/layout/RowScope;Landroidx/compose/ui/Modifier;FZILjava/lang/Object;)Landroidx/compose/ui/Modifier; in class Landroidx/compose/foundation/layout/RowScope; or its super classes (declaration of 'androidx.compose.foundation.layout.RowScope' appears in base.apk)

Is there anything specific I need to do for release builds with the library?

HELP

I've been stuck trying to figure out how to use this lib for hours. Can you kindly help me with this implementation...like how can i make such a UI using your lib:
IMG_20210617_192742

Can you help me

I want use this on my project and ı added this to my project . I want use this on popup but I can!t Can you Help Me

datePickerPopup = new DatePickerPopup.Builder()
                        .from(this) //I have an error in there
                        .offset(3)
                        .pickerMode(DatePicker.MONTH_ON_FIRST)
                        .textSize(19)
                        .endDate(DateUtils.getTimeMiles(2050, 10, 25))
                        .currentDate(DateUtils.getCurrentTime())
                        .startDate(DateUtils.getTimeMiles(1995, 0, 1))
                        .listener(new DatePickerPopup.OnDateSelectListener() {
                            @Override
                            public void onDateSelected(DatePicker dp, long date, int day, int month, int year) {
                                Toast.makeText(getApplicationContext(), "" + day + "/" + (month + 1) + "/" + year, Toast.LENGTH_SHORT).show();
                            }
                        })
                        .build();

onDateSelected triggered in every scroll

Right now, onDateSelected works like onDateChanged as it is triggered every time we scroll any of the sliders.

In some cases, we just need to open the date picker dialog and get the final selected Date after user clicks OK. So, maybe it would be great if we have these two options as callbacks? (onDateSelected and onDataChanged)

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.