NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

DatePicker : onDateChange callback for Android

Open Corpsomium opened this issue 8 years ago • 6 comments

Hi,

NativeBase's version v2.5.2 added support for onDateChange on iOS (#1987), but I need it on Android.

The support on IOS is made by using an internal setDate(date) function. Why not use it on both cases ?

Actual code :

async openAndroidDatePicker() {
/****/
      if (action === "dateSetAction") {
        this.setState({ chosenDate: new Date(year, month, day) });
      }

That could turn into something like :

async openAndroidDatePicker() {
/****/
      if (action === "dateSetAction") {
        this.setDate.bind(this)(new Date(year, month, day));
      }

Also, the setDate and showDatePicker functions could be turned into an arrow function to avoid binding on every render, but instead only once at the object's instantiation.

Edit : Oh, and I forgot : I can make a PR about it.

Corpsomium avatar Jun 15 '18 15:06 Corpsomium

Any updates on this? Are there any workarounds for now? I would love for this to be added!

EricGhildyal avatar Jun 17 '18 20:06 EricGhildyal

https://github.com/GeekyAnts/NativeBase/pull/1987#issuecomment-396595806

SupriyaKalghatgi avatar Jun 18 '18 05:06 SupriyaKalghatgi

Little update on this : I added it on my project and it works just fine. Maybe not on all cases, but on every that I used, it worked.

Corpsomium avatar Jun 18 '18 08:06 Corpsomium

Corresponding changed line Full commit with several changes

I don't get why it would not work on Android ?

Corpsomium avatar Jun 18 '18 15:06 Corpsomium

@Corpsomium That's exactly what I suggested when the iOS onDateChange support was added. Maybe we're missing something?

ferreirix avatar Jun 18 '18 15:06 ferreirix

Fixed with 2.6.1

SupriyaKalghatgi avatar Jun 22 '18 13:06 SupriyaKalghatgi