react-native-date-picker
react-native-date-picker copied to clipboard
Modal not showing working with scenes
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
Hi! Could you provide an example repo where this issue is reproducable?
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
@henninghall did you have the time to review this?
We're having this exact same issue in our App, Did you find any solution @dani-cabal? Is there any workaround @henninghall?
@henninghall @dani-cabal any update regarding this topic?
Nothing here @Robby2023
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.