RCTSurfacePresenter.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <React/RCTPrimitives.h>
  9. #import <React/RCTSurfacePresenterStub.h>
  10. #import <React/RCTSurfaceStage.h>
  11. #import <react/utils/ContextContainer.h>
  12. #import <react/utils/RuntimeExecutor.h>
  13. NS_ASSUME_NONNULL_BEGIN
  14. @class RCTFabricSurface;
  15. @class RCTImageLoader;
  16. @class RCTMountingManager;
  17. /**
  18. * Coordinates presenting of React Native Surfaces and represents application
  19. * facing interface of running React Native core.
  20. */
  21. @interface RCTSurfacePresenter : NSObject
  22. - (instancetype)initWithContextContainer:(facebook::react::ContextContainer::Shared)contextContainer
  23. runtimeExecutor:(facebook::react::RuntimeExecutor)runtimeExecutor;
  24. @property (nonatomic) facebook::react::ContextContainer::Shared contextContainer;
  25. @property (nonatomic) facebook::react::RuntimeExecutor runtimeExecutor;
  26. /*
  27. * Suspends/resumes all surfaces associated with the presenter.
  28. * Suspending is a process or gracefull stopping all surfaces and destroying all underlying infrastructure
  29. * with a future possibility of recreating the infrastructure and restarting the surfaces from scratch.
  30. * Suspending is usually a part of a bundle reloading process.
  31. * Can be called on any thread.
  32. */
  33. - (BOOL)suspend;
  34. - (BOOL)resume;
  35. @end
  36. @interface RCTSurfacePresenter (Surface) <RCTSurfacePresenterStub>
  37. /**
  38. * Surface uses these methods to register itself in the Presenter.
  39. */
  40. - (void)registerSurface:(RCTFabricSurface *)surface;
  41. - (void)unregisterSurface:(RCTFabricSurface *)surface;
  42. - (void)setProps:(NSDictionary *)props surface:(RCTFabricSurface *)surface;
  43. - (nullable RCTFabricSurface *)surfaceForRootTag:(ReactTag)rootTag;
  44. /**
  45. * Measures the Surface with given constraints.
  46. */
  47. - (CGSize)sizeThatFitsMinimumSize:(CGSize)minimumSize
  48. maximumSize:(CGSize)maximumSize
  49. surface:(RCTFabricSurface *)surface;
  50. /**
  51. * Sets `minimumSize` and `maximumSize` layout constraints for the Surface.
  52. */
  53. - (void)setMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)maximumSize surface:(RCTFabricSurface *)surface;
  54. - (BOOL)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag props:(NSDictionary *)props;
  55. - (BOOL)synchronouslyWaitSurface:(RCTFabricSurface *)surface timeout:(NSTimeInterval)timeout;
  56. - (void)addObserver:(id<RCTSurfacePresenterObserver>)observer;
  57. - (void)removeObserver:(id<RCTSurfacePresenterObserver>)observer;
  58. @end
  59. NS_ASSUME_NONNULL_END