Open kmelmon opened 5 years ago
Hey, this is something I interested in working on, can you provide a little bit more detail on what you would like done?
@jrdlnx thanks for the offer! The work involves tracking device orientation and firing the "namedOrientationDidChange" event when the orientation changes, using the global device event emitter. You can look at the Android implementation here to get an idea of what's required: https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
UWP has an API to retrieve the device orientation and it also fires events when it changes: https://docs.microsoft.com/en-us/uwp/api/windows.graphics.display.displayinformation.orientationchanged
So the work involves using this API to get and track the current device orientation. Note that this API won't work correctly when RN4W is hosted inside a XamlIsland, but unfortunately there isn't a replacement API that scenario yet. So we should use the DisplayInformation API for now while we wait for the islands-friendly version to be added.
I suggest changing DeviceInfoModule.cpp to leverage the orientation API and fire the event.
Cool thanks for the information! I will try my best to implement a fix!
Note that for the XAML Islands scenario, we won't be able to just use the DisplayInformation API as that API only works in UWPs. Added "Needs WinUI 3" tag to track this aspect.
RN4W is missing support for the "namedOrientationDidChange" event, which is supposed to be raised when the device orientation changes.
Currently, the Modal component uses this event, but apps are also free to subscribe to the event for other reasons.
See: https://facebook.github.io/react-native/docs/modal#onorientationchange https://facebook.github.io/react-native/docs/modal#supportedorientations