hybrid-navigation 2.20.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HybridNavigation.podspec +7 -5
- package/README.md +17 -0
- package/android/build.gradle +56 -19
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +320 -326
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +13 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -11
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +55 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +223 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +370 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +239 -224
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +177 -198
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactDrawerFragment.java +2 -9
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +41 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +438 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +10 -19
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +7 -15
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +135 -173
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +54 -227
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +12 -14
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +18 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +17 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +13 -26
- package/dist/NativeEvent.d.ts +33 -0
- package/dist/NativeEvent.js +2 -0
- package/dist/NativeGarden.d.ts +18 -0
- package/dist/NativeGarden.js +2 -0
- package/dist/NativeNavigation.d.ts +47 -0
- package/dist/NativeNavigation.js +2 -0
- package/dist/Navigation.js +3 -3
- package/dist/NavigationModule.d.ts +3 -3
- package/dist/NavigationModule.js +18 -19
- package/dist/Navigator.js +1 -2
- package/dist/Options.d.ts +4 -7
- package/dist/Route.d.ts +0 -2
- package/dist/handler/BarButtonEventHandler.js +2 -2
- package/dist/handler/LayoutCommandHandler.js +3 -3
- package/dist/handler/ResultEventHandler.js +3 -3
- package/dist/handler/VisibilityEventHandler.js +11 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/ios/HybridNavigation/GlobalStyle.h +0 -6
- package/ios/HybridNavigation/{GlobalStyle.m → GlobalStyle.mm} +54 -44
- package/ios/HybridNavigation/HBDUtils.h +0 -4
- package/ios/HybridNavigation/{HBDUtils.m → HBDUtils.mm} +0 -41
- package/ios/HybridNavigation/Navigator/{HBDScreenNavigator.m → HBDScreenNavigator.mm} +3 -9
- package/ios/HybridNavigation/Navigator/{HBDStackNavigator.m → HBDStackNavigator.mm} +0 -4
- package/ios/HybridNavigation/Navigator/{HBDTabNavigator.m → HBDTabNavigator.mm} +1 -55
- package/ios/HybridNavigation/React/HBDNativeEvent.h +13 -0
- package/ios/HybridNavigation/React/HBDNativeEvent.mm +31 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.h +10 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.mm +151 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.h +11 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.mm +263 -0
- package/ios/HybridNavigation/{ReactBridge → React}/HBDReactBridgeManager.h +3 -1
- package/ios/HybridNavigation/{ReactBridge/HBDReactBridgeManager.m → React/HBDReactBridgeManager.mm} +7 -30
- package/ios/HybridNavigation/View/HBDRootView.h +2 -2
- package/ios/HybridNavigation/View/{HBDRootView.m → HBDRootView.mm} +2 -2
- package/ios/HybridNavigation/View/HBDTitleView.h +2 -2
- package/ios/HybridNavigation/View/{HBDTitleView.m → HBDTitleView.mm} +3 -3
- package/ios/HybridNavigation/View/UIImage+WithBadge.h +13 -0
- package/ios/HybridNavigation/View/UIImage+WithBadge.mm +36 -0
- package/ios/HybridNavigation/ViewController/{HBDDrawerController.m → HBDDrawerController.mm} +2 -25
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -4
- package/ios/HybridNavigation/ViewController/{HBDReactViewController.m → HBDReactViewController.mm} +40 -31
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -2
- package/ios/HybridNavigation/ViewController/HBDTabBarController.mm +140 -0
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +0 -2
- package/ios/HybridNavigation/ViewController/{HBDViewController+Garden.m → HBDViewController+Garden.mm} +8 -26
- package/ios/HybridNavigation/ViewController/HBDViewController.h +2 -0
- package/ios/HybridNavigation/ViewController/{HBDViewController.m → HBDViewController.mm} +67 -57
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +0 -2
- package/ios/HybridNavigation/ViewController/{UIViewController+HBD.m → UIViewController+HBD.mm} +1 -42
- package/package.json +11 -2
- package/src/DeepLink.ts +3 -3
- package/src/NativeEvent.ts +40 -0
- package/src/NativeGarden.ts +27 -0
- package/src/NativeNavigation.ts +72 -0
- package/src/Navigation.ts +13 -13
- package/src/NavigationComponentWrap.tsx +4 -4
- package/src/NavigationModule.ts +21 -46
- package/src/Navigator.ts +13 -13
- package/src/Options.ts +9 -9
- package/src/Route.ts +0 -2
- package/src/handler/BarButtonEventHandler.ts +4 -8
- package/src/handler/DispatchCommandHandler.ts +4 -8
- package/src/handler/LayoutCommandHandler.ts +4 -5
- package/src/handler/ResultEventHandler.ts +11 -27
- package/src/handler/VisibilityEventHandler.ts +23 -32
- package/src/hooks.ts +2 -2
- package/src/index.ts +4 -5
- package/src/router/drawer.ts +5 -5
- package/src/router/index.ts +15 -15
- package/src/router/screen.ts +2 -2
- package/src/router/stack.ts +4 -4
- package/src/router/tabs.ts +3 -3
- package/src/store.ts +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/DefaultTabBarProvider.java +0 -143
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +0 -230
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +0 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +0 -71
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +0 -370
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +0 -445
- package/dist/Event.d.ts +0 -16
- package/dist/Event.js +0 -62
- package/dist/GardenModule.d.ts +0 -24
- package/dist/GardenModule.js +0 -21
- package/ios/HybridNavigation/HBDAnimationObserver.h +0 -24
- package/ios/HybridNavigation/HBDAnimationObserver.m +0 -45
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.h +0 -28
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.m +0 -72
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +0 -157
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +0 -249
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -9
- package/ios/HybridNavigation/View/HBDReactTabBar.m +0 -36
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -9
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -46
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +0 -265
- package/src/Event.ts +0 -117
- package/src/GardenModule.ts +0 -50
- /package/ios/HybridNavigation/Navigator/{HBDDrawerNavigator.m → HBDDrawerNavigator.mm} +0 -0
- /package/ios/HybridNavigation/Navigator/{HBDNavigatorRegistry.m → HBDNavigatorRegistry.mm} +0 -0
- /package/ios/HybridNavigation/{ReactBridge → React}/HBDNavigator.h +0 -0
- /package/ios/HybridNavigation/View/{HBDBackBarButtonItem.m → HBDBackBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/View/{HBDBarButtonItem.m → HBDBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/View/{HBDNavigationBar.m → HBDNavigationBar.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDFadeAnimation.m → HBDFadeAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDNavigationController.m → HBDNavigationController.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPopAnimation.m → HBDPopAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPushAnimation.m → HBDPushAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{UINavigationController+HBD.m → UINavigationController+HBD.mm} +0 -0
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.EVENT_NAVIGATION;
|
|
4
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_ACTION;
|
|
5
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_ON;
|
|
6
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.KEY_SCENE_ID;
|
|
7
|
-
import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_BAR_BUTTON_ITEM_CLICK;
|
|
8
3
|
import static com.reactnative.hybridnavigation.Parameters.mergeOptions;
|
|
9
4
|
import static com.reactnative.hybridnavigation.Parameters.toBundle;
|
|
10
5
|
|
|
@@ -29,333 +24,332 @@ import java.util.ArrayList;
|
|
|
29
24
|
|
|
30
25
|
public class Garden {
|
|
31
26
|
|
|
32
|
-
|
|
27
|
+
private static final String TAG = "Navigation";
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
private static GlobalStyle globalStyle;
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
static void createGlobalStyle(Bundle options) {
|
|
32
|
+
globalStyle = new GlobalStyle(options);
|
|
33
|
+
}
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
@NonNull
|
|
36
|
+
static GlobalStyle getGlobalStyle() {
|
|
37
|
+
if (globalStyle == null) {
|
|
38
|
+
globalStyle = new GlobalStyle(new Bundle());
|
|
39
|
+
}
|
|
40
|
+
return globalStyle;
|
|
41
|
+
}
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
private final HybridFragment fragment;
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
private final Style style;
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
private final Bundle options;
|
|
53
48
|
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
49
|
+
boolean backButtonHidden = false;
|
|
50
|
+
|
|
51
|
+
boolean backInteractive = true;
|
|
52
|
+
|
|
53
|
+
boolean swipeBackEnabled;
|
|
54
|
+
|
|
55
|
+
boolean hidesBottomBarWhenPushed;
|
|
56
|
+
|
|
57
|
+
boolean toolbarHidden;
|
|
58
|
+
|
|
59
|
+
boolean extendedLayoutIncludesTopBar;
|
|
60
|
+
|
|
61
|
+
boolean forceTransparentDialogWindow;
|
|
62
|
+
|
|
63
|
+
Garden(@NonNull HybridFragment fragment, Style style) {
|
|
64
|
+
// 构造 garden 实例时,Toolbar 还没有被创建
|
|
65
|
+
|
|
66
|
+
this.fragment = fragment;
|
|
67
|
+
this.style = style;
|
|
68
|
+
|
|
69
|
+
Bundle options = fragment.getOptions();
|
|
70
|
+
this.options = options;
|
|
71
|
+
|
|
72
|
+
this.swipeBackEnabled = options.getBoolean("swipeBackEnabled", true);
|
|
73
|
+
this.toolbarHidden = options.getBoolean("topBarHidden", false);
|
|
74
|
+
Bundle tabItem = options.getBundle("tabItem");
|
|
75
|
+
this.hidesBottomBarWhenPushed = tabItem == null || tabItem.getBoolean("hideTabBarWhenPush", true);
|
|
76
|
+
this.extendedLayoutIncludesTopBar = options.getBoolean("extendedLayoutIncludesTopBar", false);
|
|
77
|
+
|
|
78
|
+
if (options.get("fitsOpaqueNavigationBarAndroid") != null) {
|
|
79
|
+
boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid");
|
|
80
|
+
style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
String screenColor = options.getString("screenBackgroundColor");
|
|
84
|
+
if (!TextUtils.isEmpty(screenColor)) {
|
|
85
|
+
style.setScreenBackgroundColor(Color.parseColor(screenColor));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");
|
|
89
|
+
|
|
90
|
+
applyOptions(options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
void setupToolbar() {
|
|
94
|
+
AwesomeToolbar toolbar = fragment.getToolbar();
|
|
95
|
+
if (toolbar == null) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Bundle titleItem = options.getBundle("titleItem");
|
|
100
|
+
if (titleItem != null) {
|
|
101
|
+
setTitleItem(titleItem);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Bundle rightBarButtonItem = options.getBundle("rightBarButtonItem");
|
|
105
|
+
ArrayList<Bundle> rightBarButtonItems = options.getParcelableArrayList("rightBarButtonItems");
|
|
106
|
+
if (rightBarButtonItems != null) {
|
|
107
|
+
setRightBarButtonItems(rightBarButtonItems);
|
|
108
|
+
} else if (rightBarButtonItem != null) {
|
|
109
|
+
setRightBarButtonItem(rightBarButtonItem);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
Bundle leftBarButtonItem = options.getBundle("leftBarButtonItem");
|
|
113
|
+
ArrayList<Bundle> leftBarButtonItems = options.getParcelableArrayList("leftBarButtonItems");
|
|
114
|
+
if (leftBarButtonItems != null) {
|
|
115
|
+
setLeftBarButtonItems(leftBarButtonItems);
|
|
116
|
+
} else if (leftBarButtonItem != null) {
|
|
117
|
+
setLeftBarButtonItem(leftBarButtonItem);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void setTitleItem(@NonNull Bundle titleItem) {
|
|
122
|
+
String moduleName = titleItem.getString("moduleName");
|
|
123
|
+
if (moduleName == null) {
|
|
124
|
+
String title = titleItem.getString("title");
|
|
125
|
+
fragment.setTitle(title);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
void setLeftBarButtonItems(ArrayList<Bundle> items) {
|
|
130
|
+
if (items == null) {
|
|
131
|
+
fragment.setLeftBarButtonItems(null);
|
|
132
|
+
} else {
|
|
133
|
+
fragment.setLeftBarButtonItems(barButtonItemsFromBundle(items));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
void setRightBarButtonItems(ArrayList<Bundle> items) {
|
|
138
|
+
if (items == null) {
|
|
139
|
+
fragment.setRightBarButtonItems(null);
|
|
140
|
+
} else {
|
|
141
|
+
fragment.setRightBarButtonItems(barButtonItemsFromBundle(items));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private ToolbarButtonItem[] barButtonItemsFromBundle(ArrayList<Bundle> items) {
|
|
146
|
+
ArrayList<ToolbarButtonItem> buttonItems = new ArrayList<>();
|
|
147
|
+
for (int i = 0; i < items.size(); i++) {
|
|
148
|
+
Bundle item = items.get(i);
|
|
149
|
+
buttonItems.add(barButtonItemFromBundle(item));
|
|
150
|
+
}
|
|
151
|
+
return buttonItems.toArray(new ToolbarButtonItem[0]);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
void setLeftBarButtonItem(@Nullable Bundle item) {
|
|
155
|
+
if (item == null) {
|
|
156
|
+
fragment.setLeftBarButtonItem(null);
|
|
157
|
+
} else {
|
|
158
|
+
fragment.setLeftBarButtonItem(barButtonItemFromBundle(item));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void setRightBarButtonItem(@Nullable Bundle item) {
|
|
163
|
+
if (item == null) {
|
|
164
|
+
fragment.setRightBarButtonItem(null);
|
|
165
|
+
} else {
|
|
166
|
+
fragment.setRightBarButtonItem(barButtonItemFromBundle(item));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private ToolbarButtonItem barButtonItemFromBundle(@NonNull Bundle item) {
|
|
171
|
+
Context context = fragment.getContext();
|
|
172
|
+
if (context == null) return null;
|
|
173
|
+
String title = item.getString("title");
|
|
174
|
+
boolean enabled = item.getBoolean("enabled", true);
|
|
175
|
+
String uri = uri(item);
|
|
176
|
+
String action = item.getString("action");
|
|
177
|
+
int tintColor = tintColor(item);
|
|
178
|
+
boolean renderOriginal = item.getBoolean("renderOriginal", false);
|
|
179
|
+
return new ToolbarButtonItem(uri, 0, renderOriginal, title, tintColor, enabled, view -> {
|
|
180
|
+
Bundle bundle = new Bundle();
|
|
181
|
+
bundle.putString("action", action);
|
|
182
|
+
bundle.putString("sceneId", fragment.getSceneId());
|
|
183
|
+
NativeEvent.getInstance().emitOnBarButtonItemClick(Arguments.fromBundle(bundle));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private int tintColor(@NonNull Bundle item) {
|
|
188
|
+
String tintColor = item.getString("tintColor");
|
|
189
|
+
if (tintColor != null) {
|
|
190
|
+
return Color.parseColor(tintColor);
|
|
191
|
+
}
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@Nullable
|
|
196
|
+
private String uri(@NonNull Bundle item) {
|
|
197
|
+
Bundle icon = item.getBundle("icon");
|
|
198
|
+
if (icon != null) {
|
|
199
|
+
return icon.getString("uri");
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private void applyOptions(@NonNull Bundle options) {
|
|
205
|
+
String barStyle = options.getString("topBarStyle");
|
|
206
|
+
if (barStyle != null) {
|
|
207
|
+
if (barStyle.equals("dark-content")) {
|
|
208
|
+
style.setStatusBarStyle(BarStyle.DarkContent);
|
|
209
|
+
} else {
|
|
210
|
+
style.setStatusBarStyle(BarStyle.LightContent);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
String navigationBarColor = options.getString("navigationBarColorAndroid");
|
|
215
|
+
if (!TextUtils.isEmpty(navigationBarColor)) {
|
|
216
|
+
style.setNavigationBarColor(Color.parseColor(navigationBarColor));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (options.get("navigationBarHiddenAndroid") != null) {
|
|
220
|
+
style.setNavigationBarHidden(options.getBoolean("navigationBarHiddenAndroid"));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (options.get("displayCutoutWhenLandscapeAndroid") != null) {
|
|
224
|
+
style.setDisplayCutoutWhenLandscape(options.getBoolean("displayCutoutWhenLandscapeAndroid"));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
boolean statusBarHidden = options.getBoolean("statusBarHidden");
|
|
228
|
+
style.setStatusBarHidden(statusBarHidden);
|
|
229
|
+
|
|
230
|
+
String topBarTintColor = options.getString("topBarTintColor");
|
|
231
|
+
if (!TextUtils.isEmpty(topBarTintColor)) {
|
|
232
|
+
style.setToolbarTintColor(Color.parseColor(topBarTintColor));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
String titleTextColor = options.getString("titleTextColor");
|
|
236
|
+
if (!TextUtils.isEmpty(titleTextColor)) {
|
|
237
|
+
style.setTitleTextColor(Color.parseColor(titleTextColor));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
double titleTextSize = options.getDouble("titleTextSize", -1);
|
|
241
|
+
if (titleTextSize != -1) {
|
|
242
|
+
style.setTitleTextSize((int) titleTextSize);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
String topBarColor = options.getString("topBarColor");
|
|
246
|
+
if (!TextUtils.isEmpty(topBarColor)) {
|
|
247
|
+
int color = Color.parseColor(topBarColor);
|
|
248
|
+
style.setToolbarBackgroundColor(color);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
double topBarAlpha = options.getDouble("topBarAlpha", -1);
|
|
252
|
+
if (topBarAlpha != -1) {
|
|
253
|
+
style.setToolbarAlpha((float) topBarAlpha);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
boolean topBarShadowHidden = options.getBoolean("topBarShadowHidden", false);
|
|
257
|
+
style.setToolbarShadowHidden(topBarShadowHidden);
|
|
258
|
+
|
|
259
|
+
if (options.get("backInteractive") != null) {
|
|
260
|
+
this.backInteractive = options.getBoolean("backInteractive");
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (options.get("backButtonHidden") != null) {
|
|
264
|
+
this.backButtonHidden = options.getBoolean("backButtonHidden");
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
void updateOptions(@NonNull ReadableMap readableMap) {
|
|
269
|
+
Bundle patches = toBundle(readableMap);
|
|
270
|
+
applyOptions(patches);
|
|
271
|
+
|
|
272
|
+
if (readableMap.hasKey("screenBackgroundColor")) {
|
|
273
|
+
String color = readableMap.getString("screenBackgroundColor");
|
|
274
|
+
style.setScreenBackgroundColor(Color.parseColor(color));
|
|
275
|
+
View root = fragment.requireView();
|
|
276
|
+
root.setBackground(new ColorDrawable(Color.parseColor(color)));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (shouldUpdateStatusBar(readableMap)) {
|
|
280
|
+
fragment.setNeedsStatusBarAppearanceUpdate();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (shouldUpdateToolbar(readableMap)) {
|
|
284
|
+
fragment.setNeedsToolbarAppearanceUpdate();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (shouldUpdateNavigationBar(readableMap)) {
|
|
288
|
+
fragment.setNeedsNavigationBarAppearanceUpdate();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
Bundle options = mergeOptions(fragment.getOptions(), patches);
|
|
292
|
+
fragment.setOptions(options);
|
|
293
|
+
|
|
294
|
+
if (readableMap.hasKey("leftBarButtonItem")) {
|
|
295
|
+
Bundle bundle = options.getBundle("leftBarButtonItem");
|
|
296
|
+
setLeftBarButtonItem(bundle);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (readableMap.hasKey("rightBarButtonItem")) {
|
|
300
|
+
Bundle bundle = options.getBundle("rightBarButtonItem");
|
|
301
|
+
setRightBarButtonItem(bundle);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (readableMap.hasKey("leftBarButtonItems")) {
|
|
305
|
+
ArrayList<Bundle> items = options.getParcelableArrayList("leftBarButtonItems");
|
|
306
|
+
setLeftBarButtonItems(items);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (readableMap.hasKey("rightBarButtonItems")) {
|
|
310
|
+
ArrayList<Bundle> items = options.getParcelableArrayList("rightBarButtonItems");
|
|
311
|
+
setRightBarButtonItems(items);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (readableMap.hasKey("titleItem")) {
|
|
315
|
+
Bundle titleItem = options.getBundle("titleItem");
|
|
316
|
+
setTitleItem(titleItem);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private boolean shouldUpdateStatusBar(@NonNull ReadableMap readableMap) {
|
|
321
|
+
String[] keys = new String[]{"topBarStyle", "statusBarHidden", "topBarColor", "displayCutoutWhenLandscapeAndroid"};
|
|
322
|
+
for (String key : keys) {
|
|
323
|
+
if (readableMap.hasKey(key)) {
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private boolean shouldUpdateToolbar(@NonNull ReadableMap readableMap) {
|
|
331
|
+
String[] keys = new String[]{
|
|
332
|
+
"topBarStyle",
|
|
333
|
+
"topBarColor", "topBarAlpha", "topBarShadowHidden", "topBarTintColor",
|
|
334
|
+
"titleTextSize", "titleTextColor", "backButtonHidden"
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
for (String key : keys) {
|
|
338
|
+
if (readableMap.hasKey(key)) {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
private boolean shouldUpdateNavigationBar(@NonNull ReadableMap readableMap) {
|
|
346
|
+
String[] keys = new String[]{"navigationBarColorAndroid", "navigationBarHiddenAndroid", "screenBackgroundColor"};
|
|
347
|
+
for (String key : keys) {
|
|
348
|
+
if (readableMap.hasKey(key)) {
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
360
354
|
|
|
361
355
|
}
|