react-native-date-picker icon indicating copy to clipboard operation
react-native-date-picker copied to clipboard

Modal not showing working with scenes

Open dani-cabal opened this issue 2 years ago • 7 comments

I've recently moved my app to scenes due to CarPlay implementations. No changes have been made in date picker, so I think my problem is related to scenes (or my phone scene implementation). I must say I have no experience with Swift or Objective C, so it's likely that my scene implementation is incompatible at some point with modal view, but I'm not sure about that.

Searching through iOS code of the library I've found this:

// Finding the top view controller which is neccessary to be able to show the picker from within modal
        self->_topViewController = rootViewController;
        while (self->_topViewController.presentedViewController){
            self->_topViewController = self->_topViewController.presentedViewController;
        }
        [self->_topViewController presentViewController:alertController animated:YES completion:nil];

My scene looks this way:

class PhoneSceneDelegate: UIResponder, UIWindowSceneDelegate {
  var window: UIWindow?
  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) -> Void {
    guard let appDelegate = (UIApplication.shared.delegate as? AppDelegate) else { return }
    guard let windowScene = (scene as? UIWindowScene) else { return }

    let rootViewController = UIViewController()
    rootViewController.view = appDelegate.rootView;

    let window = UIWindow(windowScene: windowScene)
    window.rootViewController = rootViewController
    self.window = window
    window.makeKeyAndVisible()
  }
}

Smartphone:

  • OS: iOS 15.4 (emulator) iOS 16.2 (phone)
  • React Native version 0.66.5
  • react-native-date-picker version 4.2.10

dani-cabal avatar Apr 12 '23 10:04 dani-cabal

Hi! Could you provide an example repo where this issue is reproducable?

henninghall avatar Apr 12 '23 19:04 henninghall

Hi! Thanks for your reply.

I created a new repository with a demo app: https://github.com/dcabal/datepicker-demo

In branch develop there's a working example with datepicker's modal opening correctly. To run it, as usual:

  • yarn install
  • cd ios && pod install
  • yarn ios

In branch feature/scenes there's a reproduction of my issue. This branch has all CarPlay stuff with scenes and an AppDelegate in Swift as described here https://github.com/birkir/react-native-carplay/pull/85

You have to install all dependencies and pods in scenes branch, as develop branch is not configured for CarPlay

Thanks a lot

dani-cabal avatar Apr 13 '23 12:04 dani-cabal

@henninghall did you have the time to review this?

dani-cabal avatar Apr 21 '23 10:04 dani-cabal

We're having this exact same issue in our App, Did you find any solution @dani-cabal? Is there any workaround @henninghall?

Robby2023 avatar Apr 25 '23 10:04 Robby2023

@henninghall @dani-cabal any update regarding this topic?

Robby2023 avatar May 08 '23 08:05 Robby2023

Nothing here @Robby2023

dani-cabal avatar May 12 '23 11:05 dani-cabal

Thanks for the demo app, I won't be able to prioritize this at the moment. Please give this issue a thumbs up if this is bothering you.

If anyone wants to investigate this, PRs are always welcome and let me know if you have any questions about the codebase.

henninghall avatar May 23 '23 17:05 henninghall