DCUniBasePlugin.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //
  2. // DCUniBasePlugin.h
  3. //
  4. // Created by DCloud on 2020/11/2.
  5. // Copyright © 2020 DCloud. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "DCUniDefine.h"
  9. #import "WXComponent.h"
  10. #import "WXSDKInstance.h"
  11. NS_ASSUME_NONNULL_BEGIN
  12. typedef NS_ENUM(NSInteger, DCUniState) {//state.code
  13. DCUniInstanceAppear = 100,
  14. DCUniInstanceDisappear,
  15. DCUniInstanceForeground,
  16. DCUniInstanceBackground,
  17. DCUniInstanceMemoryWarning,
  18. DCUniInstanceBindChanged,
  19. DCUniInstanceDestroy
  20. };
  21. @interface DCUniBaseCompenent : WXComponent
  22. @end
  23. @interface DCUniSDKInstance : WXSDKInstance
  24. /**
  25. * DCUni 所呈现的viewControler。
  26. **/
  27. @property (nonatomic, weak) UIViewController *viewController;
  28. /**
  29. * 用于承载vue文件呈现的视图。
  30. * rootView由DCUniSDKInstance 控制,因此只能获取它,而不能更改它
  31. **/
  32. @property (nonatomic, strong) UIView *rootView;
  33. /**
  34. * The scriptURL of vue.
  35. **/
  36. @property (nonatomic, strong) NSURL *scriptURL;
  37. /**
  38. * 父 实例
  39. **/
  40. @property (nonatomic, weak) DCUniSDKInstance *parentInstance;
  41. /**
  42. * 父 节点
  43. **/
  44. @property (nonatomic, weak) NSString *parentNodeRef;
  45. /**
  46. * 标识当前DCUni 实例的唯一ID。
  47. **/
  48. @property (nonatomic, strong) NSString *instanceId;
  49. /**
  50. * 自定义的一些信息.
  51. **/
  52. @property (nonatomic, strong) NSDictionary* containerInfo;
  53. @property (nonatomic, assign) DCUniState uniState;
  54. /**
  55. * 实例完成创建body时触发的回调。
  56. *
  57. * @return 带有UIView参数的block,它是根视图
  58. **/
  59. @property (nonatomic, copy) void (^onCreate)(UIView *);
  60. /**
  61. * 根容器的框架发生更改时触发的回调。
  62. *
  63. * @return 带有UIView参数的block,它是根视图
  64. **/
  65. @property (nonatomic, copy) void (^onLayoutChange)(UIView *);
  66. /**
  67. * 实例完成渲染后触发的回调。
  68. *
  69. * @return 带有UIView参数的block,它是根视图
  70. **/
  71. @property (nonatomic, copy) void (^renderFinish)(UIView *);
  72. /**
  73. * 实例完成刷新视图时触发的回调。
  74. *
  75. * @return 带有UIView参数的block,它是根视图
  76. **/
  77. @property (nonatomic, copy) void (^refreshFinish)(UIView *);
  78. /**
  79. * 实例渲染失败时触发的回调。
  80. *
  81. * @return 带有NSError参数的块,即发生的错误
  82. **/
  83. @property (nonatomic, copy) void (^onFailed)(NSError *error);
  84. /**
  85. * 当前实例的框架。
  86. **/
  87. @property (nonatomic, assign) CGRect frame;
  88. /**
  89. * 用户存储的信息。
  90. */
  91. @property (atomic, strong) NSMutableDictionary *userInfo;
  92. - (void)renderWithURL:(NSURL *)url;
  93. - (void)renderWithURL:(NSURL *)url options:(NSDictionary * _Nullable)options data:(id _Nullable)data;
  94. /**
  95. * 从当前URL重新加载js包并重新呈现。
  96. *
  97. * @param forcedReload 当此参数为true时,将始终从服务器重新加载js捆绑包。 如果为false,则实例可以从其缓存中重新加载js捆绑包。 默认为false。
  98. *
  99. **/
  100. - (void)reload:(BOOL)forcedReload;
  101. /**
  102. * 设置自定义视图端口/设备宽度后,刷新当前实例组件的布局。
  103. **/
  104. - (void)reloadLayout;
  105. /**
  106. * 用数据刷新当前实例。
  107. *
  108. * @param data 捆绑包呈现时需要的数据。
  109. **/
  110. - (void)refreshInstance:(id)data;
  111. /**
  112. * 销毁当前实例。 销毁的实例不应再次用于渲染,请创建另一个实例。
  113. **/
  114. - (void)destroyInstance;
  115. /**
  116. * 发送全局事件
  117. */
  118. - (void)fireGlobalEvent:(NSString *)eventName params:(NSDictionary *)params;
  119. @end
  120. NS_ASSUME_NONNULL_END