Sin descripción

RNCSafeAreaViewManager.m 832B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #import "RNCSafeAreaViewManager.h"
  2. #import "RNCSafeAreaView.h"
  3. @implementation RNCSafeAreaViewManager
  4. RCT_EXPORT_MODULE(RNCSafeAreaView)
  5. RCT_EXPORT_VIEW_PROPERTY(onInsetsChange, RCTBubblingEventBlock)
  6. + (BOOL)requiresMainQueueSetup
  7. {
  8. return YES;
  9. }
  10. - (UIView *)view
  11. {
  12. return [RNCSafeAreaView new];
  13. }
  14. - (NSDictionary *)constantsToExport
  15. {
  16. if (@available(iOS 11.0, *)) {
  17. UIWindow* window = [[UIApplication sharedApplication] keyWindow];
  18. UIEdgeInsets safeAreaInsets = window.safeAreaInsets;
  19. return @{
  20. @"initialWindowSafeAreaInsets": @{
  21. @"top": @(safeAreaInsets.top),
  22. @"right": @(safeAreaInsets.right),
  23. @"bottom": @(safeAreaInsets.bottom),
  24. @"left": @(safeAreaInsets.left),
  25. }
  26. };
  27. } else {
  28. return @{ @"initialWindowSafeAreaInsets": [NSNull null] };
  29. }
  30. }
  31. @end