Skip to content

Support yearAndMonth mode on iOS #1000

@thisisgit

Description

@thisisgit

Feature request

Hi, I just found out that iOS date picker supports year&month mode starting 17.4 and this isn't supported in this library yet.

Why it is needed

There were already some people requesting for this feature but I believe it was not possible at the time:

As a workaround, I tried copying it with two react-native-pickers but there're some limitations where

  1. selectionColor can't go transparent in the latest version (how can i set the background color to transparent react-native-picker/picker#242 (comment))
  2. Has different style from the year & month mode of UIDatePicker, e.g. gap between items & font styles
  3. Has limited number of rows even height of the picker is increased

I was able to somehow solve 1&2 by sticking to the older version(2.6.0) and adjusting the styles by changing font size and scaling the whole picker down, but 3 is something that can't be solved due to limitation of the picker itself.

Possible implementation

I'm not really familiar with native code but I guess adding one more entry in the enum here would at least make it work?

RCT_ENUM_CONVERTER(UIDatePickerMode, (@{
@"time": @(UIDatePickerModeTime),
@"date": @(UIDatePickerModeDate),
@"datetime": @(UIDatePickerModeDateAndTime),
@"countdown": @(UIDatePickerModeCountDownTimer),
}), UIDatePickerModeTime, integerValue)

But overall, I think following needs to be handled:

  • Type support and validation on the JS side for yearAndMonth mode
  • Map yearAndMonth entry in iOS native code (above)
  • Use fallback mode in Android if yearAndMonth is passed
  • Use fallback mode or warn in iOS if yearAndMonth is passed and iOS version is below 17.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions