RCTWrapper.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <UIKit/UIKit.h>
  8. #import <RCTWrapper/RCTWrapperView.h>
  9. #import <RCTWrapper/RCTWrapperViewControllerHostingView.h>
  10. #import <RCTWrapper/RCTWrapperViewManager.h>
  11. // Umbrella header with macros
  12. // RCT_WRAPPER_FOR_VIEW
  13. #define RCT_WRAPPER_FOR_VIEW(ClassName) \
  14. \
  15. NS_ASSUME_NONNULL_BEGIN \
  16. \
  17. @interface ClassName##Manager : RCTWrapperViewManager \
  18. \
  19. @end \
  20. \
  21. NS_ASSUME_NONNULL_END \
  22. \
  23. @implementation ClassName##Manager \
  24. \
  25. RCT_EXPORT_MODULE() \
  26. \
  27. - (UIView *)view \
  28. { \
  29. RCTWrapperView *wrapperView = [super view]; \
  30. wrapperView.contentView = [ClassName new]; \
  31. return wrapperView; \
  32. } \
  33. \
  34. @end
  35. // RCT_WRAPPER_FOR_VIEW_CONTROLLER
  36. #define RCT_WRAPPER_FOR_VIEW_CONTROLLER(ClassName) \
  37. \
  38. NS_ASSUME_NONNULL_BEGIN \
  39. \
  40. @interface ClassName##Manager : RCTWrapperViewManager \
  41. \
  42. @end \
  43. \
  44. NS_ASSUME_NONNULL_END \
  45. \
  46. @implementation ClassName##Manager \
  47. \
  48. RCT_EXPORT_MODULE() \
  49. \
  50. - (UIView *)view \
  51. { \
  52. RCTWrapperViewControllerHostingView *contentViewControllerHostingView = \
  53. [RCTWrapperViewControllerHostingView new]; \
  54. contentViewControllerHostingView.contentViewController = \
  55. [[ClassName alloc] initWithNibName:nil bundle:nil]; \
  56. RCTWrapperView *wrapperView = [super view]; \
  57. wrapperView.contentView = contentViewControllerHostingView; \
  58. return wrapperView; \
  59. } \
  60. \
  61. @end