react-native-datepicker icon indicating copy to clipboard operation
react-native-datepicker copied to clipboard

iOS 14

Open isnifer opened this issue 5 years ago • 33 comments

Issue

Looks like iOS 14 introduced new design for Calendar

Expected Behaviour

Looks like this component needs to be updated to handle these changes for iOS 14

Environment

  1. react-native -v: 0.62.2
  2. node -v: v10.18.1
  3. npm -v: 6.13.4
  4. yarn --version: 1.22.4
  5. target platform: iOS (14)
  6. operating system: macOS

image

isnifer avatar Jun 24 '20 17:06 isnifer

Any update on this?

pramodsharma403 avatar Jul 06 '20 13:07 pramodsharma403

The question is: Is this lib still maintained ? 😕

karims10 avatar Jul 14 '20 15:07 karims10

@pramodsharma403 Have you get any solution for this issue?

ashishkanhasoft avatar Aug 07 '20 12:08 ashishkanhasoft

Same issue here. What I experienced now is that my app displays the datepicker correctly in the "old" way when the app is built with XCode 11. My current app live in the store (archived with XCode 11) running on a real device with iOS 14 beta 4 the Datepicker looks OK. If I build/archive with XCode 12 beta 4 the DatePicker looks broken like the one above.

ymc-thzi avatar Aug 11 '20 12:08 ymc-thzi

one solution for this may be to override the preferedStyle of any UIDatePicker in the iOS native Workspace:

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}

But there is one catch 👎 The DatePickerWheel is smaller in iOS14 and wont fill the Libraries Modal sadly Maybe someone else here has any Idea for that ^^

If you are fine with a left aligned Wheel though just put the code from above in your AppDelegate -> didFinishLaunchingWithOptions function

IMAGE 2020-09-14 12:52:34

undeaDD avatar Sep 14 '20 10:09 undeaDD

okay i just fixed the misalignment with some customStyles ...

<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

Result: iOS 14 ( compiled with XCode 12 ) IMAGE 2020-09-14 13:53:47

undeaDD avatar Sep 14 '20 11:09 undeaDD

were did you update the ios datepicker code? In workspace? @undeaDD

jithinlal avatar Sep 17 '20 10:09 jithinlal

Anywhere before the datepicker is loaded is fine ;) I personally put it in the AppDelegate didFinishLaunching function 👍 so that it gets executed at App launch

undeaDD avatar Sep 17 '20 11:09 undeaDD

Cool it worked

jithinlal avatar Sep 17 '20 12:09 jithinlal

The solution from @undeaDD worked for me as well, thank you so much for sharing this.

burivuhster avatar Sep 29 '20 19:09 burivuhster

Hello, can anyone explain where to do the workaround for alignment issue? Knowing that if you do it inside the component rendering it only works when you save the file and after you open the picker again it goes left.. Any advise? Thanks

najielchemaly avatar Oct 02 '20 13:10 najielchemaly

The solution @undeaDD provided worked just fine, but, I still kinda want to be able to use iOS 14 date picker, anyone has any approach to do this?

miguelacio avatar Oct 15 '20 22:10 miguelacio

We desperately need a new repository that's maintained for date picking.

syntag avatar Oct 22 '20 23:10 syntag

can confirm @undeaDD workaround works well enough

Real solution i think is to just go back to reactnative(community) date pickers which look to have come a long way since this libraries inception

cameroncharles avatar Oct 30 '20 00:10 cameroncharles

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

Check the full code here- https://github.com/xgfe/react-native-datepicker/issues/425#issuecomment-744475142

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
  1. In DatePicker customStyles :
<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

dhavalpanchani avatar Nov 08 '20 05:11 dhavalpanchani

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

if (@available(iOS 14, *)) { UIDatePicker *picker = [UIDatePicker appearance]; picker.preferredDatePickerStyle = UIDatePickerStyleWheels; }

  1. In DatePicker customStyles :

<DatePicker customStyles={{ datePicker: { backgroundColor: '#d1d3d8', justifyContent:'center' } }} ... />

Cool it worked

wo-xiaoxiao avatar Nov 17 '20 12:11 wo-xiaoxiao

@wo-xiaoxiao on real device ?

dmitryshelomanov avatar Nov 20 '20 08:11 dmitryshelomanov

Any solution for expo..? I have try many thing but not work. Plz help

komelabbbas avatar Dec 03 '20 16:12 komelabbbas

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

if (@available(iOS 14, *)) { UIDatePicker *picker = [UIDatePicker appearance]; picker.preferredDatePickerStyle = UIDatePickerStyleWheels; }

  1. In DatePicker customStyles :

<DatePicker customStyles={{ datePicker: { backgroundColor: '#d1d3d8', justifyContent:'center' } }} ... />

Hi, @dhavalpanchani Thanks for your help, but can you show your appdelegate.m file code here, especially the rows where you added your code. I think, we have different files, but i hope i can use your code for better understanding of what i have to do to make my datepicker work correctly =).

uvrik avatar Dec 14 '20 14:12 uvrik

@uvrik : Sure, here it's.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  
  if (@available(iOS 14, *)) {
    UIDatePicker *picker = [UIDatePicker appearance];
    picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
  }
  
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"App"
                                            initialProperties:nil];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
    
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  
  return YES;
}

dhavalpanchani avatar Dec 14 '20 14:12 dhavalpanchani

Found a work around for expo apps without eject:

  1. Install this fork that allows using a custom datepicker controller for iOS (https://github.com/codynguyen/react-native-datepicker/tree/ios-datepicker-component) with:
 npm install git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component --save
  1. Install @react-native-community/datetimepicker
npm install --save @react-native-community/datetimepicker
  1. Add this prop to your datepicker
import RNDatePicker from '@react-native-community/datetimepicker';
// ...
<DatePicker 
    iOSDatePickerComponent={(props) => (<RNDatePicker {...props} display={Platform.OS === 'ios' ? 'spinner' : 'default' }/>)} 
/>

enjoy :)

vhuerta avatar Jan 20 '21 03:01 vhuerta

@vhuerta this solution is not working for expo.

aliiqbal436 avatar Feb 11 '21 14:02 aliiqbal436

@aliiqbal436 have it working on my own expo app, these are my versions

"react-native-datepicker": "git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component",
"@react-native-community/datetimepicker": "^3.0.9",

I think expo installs a different @react-native-community/datetimepicker version

vhuerta avatar Feb 11 '21 23:02 vhuerta

"@react-native-community/datetimepicker": "3.0.9", "react-native-datepicker": "git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component", @vhuerta I also have the same versions.

aliiqbal436 avatar Feb 12 '21 10:02 aliiqbal436

Found a work around for expo apps without eject:

  1. Install this fork that allows using a custom datepicker controller for iOS (https://github.com/codynguyen/react-native-datepicker/tree/ios-datepicker-component) with:
 npm install git+https://github.com/codynguyen/react-native-datepicker.git#ios-datepicker-component --save
  1. Install @react-native-community/datetimepicker
npm install --save @react-native-community/datetimepicker
  1. Add this prop to your datepicker
import RNDatePicker from '@react-native-community/datetimepicker';
// ...
<DatePicker 
    iOSDatePickerComponent={(props) => (<RNDatePicker {...props} display={Platform.OS === 'ios' ? 'spinner' : 'default' }/>)} 
/>

enjoy :)

Works like charm.. Thanks @vhuerta 👍

ikismail avatar Mar 02 '21 15:03 ikismail

These two things worked for me only in Development mode .

Add below code in didFinishLaunching function in appdelegate.m : if (@available(iOS 14, *)) { UIDatePicker *picker = [UIDatePicker appearance]; picker.preferredDatePickerStyle = UIDatePickerStyleWheels; }

In DatePicker customStyles : <DatePicker customStyles={{ datePicker: { backgroundColor: '#d1d3d8', justifyContent:'center' } }} ... />

but after building it in release mode in ios, I'm getting like this

Screenshot 2021-03-05 at 3 05 14 PM

any fix ?

telltokichu avatar Mar 05 '21 09:03 telltokichu

These two things worked for me only in Development mode .

Add below code in didFinishLaunching function in appdelegate.m : if (@available(iOS 14, *)) { UIDatePicker *picker = [UIDatePicker appearance]; picker.preferredDatePickerStyle = UIDatePickerStyleWheels; }

In DatePicker customStyles : <DatePicker customStyles={{ datePicker: { backgroundColor: '#d1d3d8', justifyContent:'center' } }} ... />

but after building it in release mode in ios, I'm getting like this

Screenshot 2021-03-05 at 3 05 14 PM

any fix ?

Looks like a dark mode issue. Do you have the same view in light mode?

adaniels5201 avatar Mar 08 '21 21:03 adaniels5201

yes It was issue with dark mode - after changing uiappearance mode in xcode to light - it got fixed

telltokichu avatar Mar 09 '21 08:03 telltokichu

These two things worked for me.

  1. Add below code in didFinishLaunching function in appdelegate.m :

Check the full code here- #425 (comment)

if (@available(iOS 14, *)) {
  UIDatePicker *picker = [UIDatePicker appearance];
  picker.preferredDatePickerStyle = UIDatePickerStyleWheels;
}
  1. In DatePicker customStyles :
<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

this worked for my xcode 11.1

syedamirali14 avatar Apr 01 '21 15:04 syedamirali14

okay i just fixed the misalignment with some customStyles ...

<DatePicker
    customStyles={{
      datePicker: {
        backgroundColor: '#d1d3d8',
        justifyContent:'center'
      }
    }}
...
/>

Result: iOS 14 ( compiled with XCode 12 ) IMAGE 2020-09-14 13:53:47

Thank you, it will work for me

ksjmb avatar May 04 '21 07:05 ksjmb