-
-
Notifications
You must be signed in to change notification settings - Fork 448
Description
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:
- Is it possible to make a date picker only with month and year? #23
- Feature Request : Mode to select only month & year from the calendar #521
- is there way we can have year selection? or month and year selection not date? #632
As a workaround, I tried copying it with two react-native-pickers but there're some limitations where
selectionColorcan't go transparent in the latest version (how can i set the background color to transparent react-native-picker/picker#242 (comment))- Has different style from the year & month mode of UIDatePicker, e.g. gap between items & font styles
- 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?
datetimepicker/ios/RNDateTimePickerManager.m
Lines 24 to 29 in 53033d2
| 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
yearAndMonthmode - Map
yearAndMonthentry in iOS native code (above) - Use fallback mode in Android if
yearAndMonthis passed - Use fallback mode or warn in iOS if
yearAndMonthis passed and iOS version is below 17.4