BBASMRenderBaseViewControllerProtocol.h
11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
//
// BBASMRenderBaseViewControllerProtocol.h
// BBAMNP
//
// Created by baidu on 2020/11/4.
//
#import <Foundation/Foundation.h>
#import "BBASMConfigWindowProtocol.h"
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class BBASMCircleRefreshHeader, BBASMAnimation, BBASMPageStackSlaveModel, WKWebView, BBASMPageStackController, BBASMSlaveWebView, BBASMRenderBaseViewController;
///page container 初始化完成回调完成回调
typedef void(^BBASMPageInitReadyCallback)(void);
@protocol BBASMRenderBaseViewControllerProtocol <NSObject>
/// 小程序Id
@property (nonatomic) NSString *appId;
/// 唯一标识slaveWebView的ID,会一直增长
@property (nonatomic, assign) NSInteger webViewID;
/// 页面配置项
@property (nonatomic, copy) NSObject<BBASMConfigWindowProtocol> *window;
/// 是否是第一次显示
@property (nonatomic, assign) BOOL isFirstShow;
/// container 初始化的frame
@property (nonatomic, assign) CGRect conatinerInitalFrame;
/// webview页面资源相对路径,可以带参数
@property (nonatomic, copy) NSString *URL;
/// 应用路由规则路由后的相对路径(可能包含参数). 11.20 路由规则新增.
@property (nonatomic, copy) NSString *routedURL;
/// 应用路由规则转换后的相对路径.(不包含参数)
@property (nonatomic, copy) NSString *routedPagePath;
/// 业务包路径
@property (nonatomic, copy) NSString *bundlePath;
/// 下拉刷新控件
@property (nonatomic, strong, nullable) BBASMCircleRefreshHeader *refreshHeader;
/// JS route事件中需要传的type
@property (nonatomic, copy) NSString *routeType;
/// 导航栏的标题label
@property (nonatomic) UILabel *titleLabel;
//由URL生成的pagePath
@property (nonatomic, copy) NSString *pagePath;
/// 导航栏是否显示加载动画
@property (nonatomic) BOOL didNavigationBarShowLoading;
/// BarButtonItem是否完成创建
@property (nonatomic) BOOL isButtonItemsCreated;
/// 导航栏返回BarButtonItem
@property (nonatomic) UIBarButtonItem *backItem;
/// 后退按钮,用于导航左边两个按钮出现时
@property (nonatomic) UIButton *backButton;
/// 关闭按钮,用于导航左边两个按钮出现时
@property (nonatomic) UIButton *closeButton;
/// 回首页按钮
@property (nonatomic) UIButton *goHomeButton;
/// 回首页Item
@property (nonatomic) UIBarButtonItem *goHomeItem;
/// 更多菜单按钮
@property (nonatomic) UIButton *moreMenuButton;
/// 小程序消息飘新--胶囊位置
@property (nonatomic, strong) UIView *badgeView;
/// 更多菜单按钮
@property (nonatomic, strong) UIView *rightCustomView;
/// 胶囊按钮中间的分割线
@property (nonatomic, strong) UIView *dividingLineView;
/// 不支持右滑退出
@property (nonatomic, assign) BOOL notSupportFullscreenPopGesture;
/// slaveVC上是否有initialAnimationVC的childVC,通常为首次启动的情况
@property (nonatomic) BOOL hasIninialAnimationVCAsChildVC;
/// 动画VC
@property (nonatomic, weak) UIViewController *initialAnimationController;
/// 全屏弹窗slaveVC的数组
/// 全屏弹窗允许 modalPageA 页面跳转到 modalPageB 跳转到 modalPageC。
/// 多层全屏弹窗页面以数组的形式存储到通过正常push方式进入的slaveVC中。
/// 普通的 slaveVC 才会使用这个属性,全屏弹窗 slaveVC 不会使用。所以不会循环引用
@property (nonatomic, strong) NSMutableArray<BBASMRenderBaseViewController *> *modalPageControllers;
/// 是否是全屏弹窗VC
@property (nonatomic, assign) BOOL isModalPageController;
/// 导航过度动画动画的 view
@property (nonatomic, weak) UIView *navbarAnimationView;
/// 导航过度动画状态
@property (nonatomic, assign) BOOL navbarColorAnimationing;
/// 键盘弹出状态
@property (nonatomic, assign) BOOL isKeyboardShow;
/// 从端能力解析出来的透传initData数据,用于二跳页面pageReady事件
@property (nonatomic, copy) NSString *nextPageDataFromDispatcher;
/// 是否是小程序打开的第一个页面
@property (nonatomic, assign) BOOL isFirstOpenedPage;
/// 当前页面是否已收藏(用于展示pannal面板)
@property (nonatomic, assign) BOOL isSlaveFavored;
/// 小程序的tabbarController
@property (nonatomic, strong) UITabBarController *smTabBarController;
/// 全屏
@property (nonatomic, assign) BOOL isFullScreen;
/// 全屏方向, 0正常竖向,90屏幕顺时针90 度,-90屏幕逆时针90 度
@property (nonatomic, strong) NSNumber *direction;
/// slaveWebView
@property (nonatomic, nullable) WKWebView *webView;
/// slave FMP到达
@property (nonatomic, assign) BOOL isFMPArrived;
/// slave FCP到达
@property (nonatomic, assign) BOOL isFCPArrived;
/// 已上传606到达打点
@property (nonatomic, assign) BOOL hasReportFMPArrived;
/// 当前页面是否通过relauch打开
@property (nonatomic, assign) BOOL isReLaunchPage;
/// 页面是否来自吊起,冷启动和热启动时候赋值为YES,页面onhide时设置为NO
@property (nonatomic, assign) BOOL isShowFromLaunch;
/// 当前vc所属的的页面栈
@property (nonatomic, weak) BBASMPageStackController *pageStackViewCtroller;
/// 侧滑取消
@property (nonatomic, assign) BOOL isPopGestureCanceld;
///pageReady(slave收到maser发来的initData消息后认为pageReady)回调
@property (nonatomic, copy, nullable) BBASMPageInitReadyCallback initReadyCallBack;
/// WebView组件
@property (strong, nullable, nonatomic) BBASMSlaveWebView *webViewComponent;
/// 根据BBASMPageStackSlaveModel初始化一个renderVC
/// @param slaveInfo 数据model
- (instancetype)initWithSlaveInfo:(BBASMPageStackSlaveModel *)slaveInfo;
#pragma mark - SWAN组件消息转发
/// 向swan组件转发消息
/// @param sel sel 方法名
/// @param params params 方法对应的参数
/// @param block block 是否终止分发的blok block返回值为YES时不再转发
- (void)forwardMessageToBBASMCompontentsWithSel:(SEL)sel
params:(NSArray * _Nullable)params
needStop:(BOOL(^_Nullable)(_Nullable id returnObj))block;
/// @brief 向swan组件转发消息
/// @param sel sel 方法名
/// @param params params 方法对应的参数
- (void)forwardMessageToBBASMCompontentsWithSel:(SEL)sel
params:(NSArray * _Nullable)params;
/// 返回真实展示页面的 pagePath.当有路由页面的时候, 返回路由后的 routedPagePath, 否则返回原页面的 pagePath.
- (NSString *)realityPagePath;
/// 向slave派发eventName事件
/// @param eventName NSString,事件名为以上声明kSwanEventXXX
/// @param eventParam NSDictionary,派发事件传递的参数
/// @param completionHandler block,js执行完成
- (void)dispatchToSlaveEventName:(NSString *)eventName
eventParam:(NSDictionary * _Nullable)eventParam
completionHandler:(void (^ _Nullable)(_Nullable id result,
NSError * _Nullable error))completionHandler;
/// 遍历组件获取bool 类型的值
/// @param selector selector 方法名
/// @param params breakValue = !默认值 只要有一个组件返回的值不等于默认值 则使用该值并且停止分发
/// @param breakValue 组件返回的BOOL 值
- (BOOL)boolValueOfBBASMComponentsForSEL:(SEL)selector
params:(NSArray *_Nullable)params
breakValue:(BOOL)breakValue;
/// 加载时长统计的流式打点;
/// @param info info 打点数据
- (BOOL)endLoadingTimeFLow:(NSDictionary *)info;
/// 兼容之前的接口,naview下为空
- (WKWebView *)webView;
/// 派发事件toSlave
- (void)dispatchToSlaveEventJS:(NSString *)jsCode
completionHandler:(void (^ _Nullable)(_Nullable id result,
NSError * _Nullable error))completionHandler;
/**
* 返回slave的url
* @return url
*/
- (NSString *)getURL;
/**
* 展示全屏弹窗
* @param pageVC 全屏弹窗VC
*/
- (void)addModalPgaeWithPageVC:(BBASMRenderBaseViewController *)pageVC;
/**
* 移除最上层的全屏弹窗
* @param completionBlock 是否移除成功(是否应该被移除,比如不存在全屏弹窗时会返回false)
*/
- (void)removeTopModalPage:(void (^)(BOOL success))completionBlock;
/**
* 移除最上层的 delta 个全屏弹窗
* @param delta 移除全屏弹窗个数
*/
- (void)removeModalPagesWithDelta:(NSInteger)delta;
/**
* 移除所有全屏弹窗
*/
- (void)removeAllModalPages;
@end
@protocol BBASMRenderBaseControllerUIProtocol <NSObject>
/// Temp storage of webview y value when keyboard is visible for `textarea` and `input` to type.
@property (nonatomic, strong, nullable) NSNumber *webViewYWhenKeyboardIsVisible;
/// slaveVC 将要被 pop 出导航栈的回调(包括手势滑动返回 和 点击返回按钮触发)
@property (nonatomic, copy, nullable) void (^willPopFromPageStackBlock)(void);
/// 创建navigationBar上的按钮
- (void)createButtonsAndItems;
/// 根据rect生成titleLabel属性
- (void)generateTitleLabelForRect:(CGRect)rect;
/// 显示导航条加载动画
- (void)showNavigationBarLoading;
/// 隐藏导航条加载动画
- (void)hideNavigationBarLoading;
/// 更新导航栏加载状态
- (void)updateNavigationBarLoading;
/// 更新导航栏标题
- (void)updateNavigationBarTitle;
// 设置导航栏左边item
- (void)updateNavigationLeftBarButtonItems;
// 设置导航栏右边item
- (void)updateNavigationRightBarButtonItems;
/// 更新导航栏背景颜色
- (void)updateNavigationBarColor;
/// 更新导航栏外观
- (void)updateNavigationBarAppearance;
/// 修改view的frame适配tabbar隐藏或展示
- (void)adjustViewFrameWhenTabbarShowOrHidden;
/// 关闭小程序
- (void)close;
/// 设置状态栏颜色
- (void)setSlaveStatusBarStyle;
/// 更新导航栏颜色
- (void)updateNavigationBarColorWithAnimation:(nullable BBASMAnimation *)animation;
/// Get webView y value in different navigation style.
- (CGFloat)mnpWebViewYDefaultValue;
/// 获取 webView 的宽度
- (CGFloat)webViewWidth;
/// 获取全屏弹窗的 webView frame
- (CGRect)getModalPageWebViewFrame;
/// 关闭小程序
/// @param sender sender
- (void)close:(nullable id)sender;
/// 更新下拉刷新时小球的颜色
- (void)updateRefreshHeaderCircleStyle;
/// 更新 webview 相关背景颜色
- (void)updateWebviewBackgroundStyle;
/// 获取胶囊位置
- (CGRect)getMenuButtonBoundingClientRect;
/// 增加头部下拉刷新组件
- (void)addRefreshHeaderForWebView:(WKWebView *)webView;
/// 是否使用自定义NavigationBar
- (BOOL)useCustomNavigationBar;
/// 清空克隆xcx计时器
- (void)cleanReportCountAndTimer;
/// 切换全屏
/// @param isFullScreen YES 切换到全屏
/// @param isLand YES 是横屏
- (void)changeToFullScreen:(BOOL)isFullScreen
isLand:(BOOL)isLand;
/// 切换全屏
/// @param isFullScreen isFullScreen YES 切换到全屏
/// @param isLand isLand YES 是横屏
/// @param scrollEnabled 是否可以滚动
- (void)changeToFullScreen:(BOOL)isFullScreen
isLand:(BOOL)isLand
scrollEnable:(BOOL)scrollEnabled;
/// 切换全屏
/// @param isFullScreen isFullScreen YES 切换到全屏
/// @param isLand isLand YES 是横屏
/// @param scrollEnabled 是否可以滚动
/// @param direction 全屏方向
- (void)changeToFullScreen:(BOOL)isFullScreen
isLand:(BOOL)isLand
scrollEnable:(BOOL)scrollEnabled
direction:(NSNumber *)direction;
/// 获取slave-webview的frame
- (CGRect)getWebViewFrame;
/// 将view的frame换算为相对于page的frame
/// @param view view
- (CGRect)convertRectToPageFromView:(UIView *)view;
/// 恢复ScrollView 的偏移
- (void)resetScrollViewOffsetYZero;
/// 刷新导航布局
- (void)layoutLeftRightCustomViewIfNoNavigator;
/// 渲染的view,slavewebview下是webview,naview下是talos
- (UIView *)renderView;
/// 页面展现白屏监控开始
- (void)pageShowWhiteMonitorStart;
/// 页面展现白屏监控结束
- (void)pageShowWhiteMonitorStop;
/// 页面fmp到达打点
- (void)reportSlavePageFMPArrived;
@end
NS_ASSUME_NONNULL_END