hybrid-navigation 3.1.5 → 4.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/README.md +4 -4
- package/android/build.gradle +1 -2
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +22 -0
- package/android/src/main/java/com/navigation/androidx/AppUtils.java +54 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +211 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +685 -0
- package/android/src/main/java/com/navigation/androidx/BarStyle.java +7 -0
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +89 -0
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +57 -0
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +392 -0
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +318 -0
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +86 -0
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +23 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +195 -0
- package/android/src/main/java/com/navigation/androidx/PresentationStyle.java +5 -0
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +111 -0
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +287 -0
- package/android/src/main/java/com/navigation/androidx/StackLayoutInflater.java +34 -0
- package/android/src/main/java/com/navigation/androidx/Style.java +141 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +240 -0
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +87 -0
- package/android/src/main/java/com/navigation/androidx/TabBar.java +353 -0
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +313 -0
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +102 -0
- package/android/src/main/java/com/navigation/androidx/TabBarProvider.java +30 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +226 -0
- package/android/src/main/java/com/navigation/androidx/TransitionAnimation.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +6 -243
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +8 -141
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +4 -68
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +12 -61
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -47
- package/android/src/main/java/com/reactnative/hybridnavigation/Parameters.java +3 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +2 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +1 -88
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +0 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +0 -18
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +1 -10
- package/android/src/main/res/anim/{nav_push_translucent_enter.xml → nav_delay.xml} +1 -1
- package/android/src/main/res/anim/{nav_pop_translucent_enter.xml → nav_dismiss_enter.xml} +1 -1
- package/android/src/main/res/anim/nav_dismiss_exit.xml +6 -0
- package/android/src/main/res/anim/nav_fade_in.xml +5 -0
- package/android/src/main/res/anim/nav_fade_out.xml +5 -0
- package/android/src/main/res/anim/nav_pop_enter.xml +6 -0
- package/android/src/main/res/anim/nav_pop_exit.xml +6 -0
- package/android/src/main/res/anim/nav_present_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_pop_translucent_exit.xml → nav_present_exit.xml} +1 -1
- package/android/src/main/res/anim/nav_push_enter.xml +6 -0
- package/android/src/main/res/anim/{nav_push_translucent_exit.xml → nav_push_exit.xml} +2 -1
- package/android/src/main/res/drawable/nav_dot_badge_background.xml +5 -0
- package/android/src/main/res/drawable/nav_text_badge_background.xml +5 -0
- package/android/src/main/res/drawable-v21/nav_toolbar_button_item_background.xml +24 -0
- package/android/src/main/res/layout/nav_fragment_drawer.xml +23 -0
- package/android/src/main/res/layout/nav_fragment_navigation.xml +7 -0
- package/android/src/main/res/layout/nav_fragment_tabbar.xml +13 -0
- package/android/src/main/res/layout/nav_tab_bar_container.xml +15 -0
- package/android/src/main/res/layout/nav_tab_bar_item.xml +49 -0
- package/android/src/main/res/values/dimens.xml +11 -0
- package/android/src/main/res/values/strings.xml +1 -0
- package/dist/{NativeEvent.d.ts → src/NativeEvent.d.ts} +0 -5
- package/dist/{NativeGarden.d.ts → src/NativeGarden.d.ts} +0 -5
- package/dist/{Navigation.d.ts → src/Navigation.d.ts} +1 -11
- package/dist/{Navigation.js → src/Navigation.js} +1 -31
- package/dist/{Navigator.js → src/Navigator.js} +0 -4
- package/dist/src/Options.d.ts +61 -0
- package/dist/src/Options.js +2 -0
- package/ios/GlobalStyle.h +1 -9
- package/ios/GlobalStyle.mm +48 -310
- package/ios/HBDUtils.h +0 -14
- package/ios/HBDUtils.mm +1 -116
- package/ios/HybridNavigation.h +0 -3
- package/ios/Navigator/HBDScreenNavigator.mm +12 -4
- package/ios/Navigator/HBDStackNavigator.mm +36 -39
- package/ios/React/HBDNativeGarden.mm +0 -40
- package/ios/React/HBDNativeNavigation.mm +21 -16
- package/ios/View/HBDRootView.h +0 -2
- package/ios/View/HBDRootView.mm +0 -21
- package/ios/ViewController/HBDDrawerController.mm +3 -11
- package/ios/ViewController/HBDFadeAnimation.mm +10 -26
- package/ios/ViewController/HBDNavigationController.h +0 -6
- package/ios/ViewController/HBDNavigationController.mm +42 -661
- package/ios/ViewController/HBDReactViewController.mm +7 -101
- package/ios/ViewController/HBDTabBarController.mm +10 -6
- package/ios/ViewController/HBDViewController.mm +58 -182
- package/ios/ViewController/UINavigationController+HBD.mm +0 -3
- package/ios/ViewController/UIViewController+HBD.h +0 -9
- package/ios/ViewController/UIViewController+HBD.mm +1 -131
- package/package.json +1 -1
- package/src/NativeEvent.ts +0 -6
- package/src/NativeGarden.ts +0 -11
- package/src/Navigation.ts +2 -68
- package/src/Navigator.ts +0 -5
- package/src/Options.ts +2 -76
- package/dist/Options.d.ts +0 -129
- package/dist/Options.js +0 -6
- package/dist/handler/BarButtonEventHandler.d.ts +0 -10
- package/dist/handler/BarButtonEventHandler.js +0 -38
- package/ios/View/HBDBackBarButtonItem.h +0 -9
- package/ios/View/HBDBackBarButtonItem.mm +0 -13
- package/ios/View/HBDBarButtonItem.h +0 -24
- package/ios/View/HBDBarButtonItem.mm +0 -69
- package/ios/View/HBDNavigationBar.h +0 -15
- package/ios/View/HBDNavigationBar.mm +0 -207
- package/ios/View/HBDTitleView.h +0 -7
- package/ios/View/HBDTitleView.mm +0 -66
- package/ios/ViewController/HBDPopAnimation.h +0 -9
- package/ios/ViewController/HBDPopAnimation.mm +0 -27
- package/ios/ViewController/HBDPushAnimation.h +0 -9
- package/ios/ViewController/HBDPushAnimation.mm +0 -28
- package/ios/ViewController/HBDViewController+Garden.h +0 -17
- package/ios/ViewController/HBDViewController+Garden.mm +0 -183
- package/src/handler/BarButtonEventHandler.ts +0 -50
- /package/dist/{DeepLink.d.ts → src/DeepLink.d.ts} +0 -0
- /package/dist/{DeepLink.js → src/DeepLink.js} +0 -0
- /package/dist/{NativeEvent.js → src/NativeEvent.js} +0 -0
- /package/dist/{NativeGarden.js → src/NativeGarden.js} +0 -0
- /package/dist/{NativeNavigation.d.ts → src/NativeNavigation.d.ts} +0 -0
- /package/dist/{NativeNavigation.js → src/NativeNavigation.js} +0 -0
- /package/dist/{NavigationComponentWrap.d.ts → src/NavigationComponentWrap.d.ts} +0 -0
- /package/dist/{NavigationComponentWrap.js → src/NavigationComponentWrap.js} +0 -0
- /package/dist/{Navigator.d.ts → src/Navigator.d.ts} +0 -0
- /package/dist/{Route.d.ts → src/Route.d.ts} +0 -0
- /package/dist/{Route.js → src/Route.js} +0 -0
- /package/dist/{handler → src/handler}/DispatchCommandHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/DispatchCommandHandler.js +0 -0
- /package/dist/{handler → src/handler}/LayoutCommandHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/LayoutCommandHandler.js +0 -0
- /package/dist/{handler → src/handler}/ResultEventHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/ResultEventHandler.js +0 -0
- /package/dist/{handler → src/handler}/VisibilityEventHandler.d.ts +0 -0
- /package/dist/{handler → src/handler}/VisibilityEventHandler.js +0 -0
- /package/dist/{hooks.d.ts → src/hooks.d.ts} +0 -0
- /package/dist/{hooks.js → src/hooks.js} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{router → src/router}/drawer.d.ts +0 -0
- /package/dist/{router → src/router}/drawer.js +0 -0
- /package/dist/{router → src/router}/index.d.ts +0 -0
- /package/dist/{router → src/router}/index.js +0 -0
- /package/dist/{router → src/router}/screen.d.ts +0 -0
- /package/dist/{router → src/router}/screen.js +0 -0
- /package/dist/{router → src/router}/stack.d.ts +0 -0
- /package/dist/{router → src/router}/stack.js +0 -0
- /package/dist/{router → src/router}/tabs.d.ts +0 -0
- /package/dist/{router → src/router}/tabs.js +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{store.js → src/store.js} +0 -0
|
@@ -3,7 +3,6 @@ package com.reactnative.hybridnavigation;
|
|
|
3
3
|
import static com.reactnative.hybridnavigation.Parameters.mergeOptions;
|
|
4
4
|
import static com.reactnative.hybridnavigation.Parameters.toBundle;
|
|
5
5
|
|
|
6
|
-
import android.content.Context;
|
|
7
6
|
import android.graphics.Color;
|
|
8
7
|
import android.graphics.drawable.ColorDrawable;
|
|
9
8
|
import android.os.Bundle;
|
|
@@ -11,21 +10,13 @@ import android.text.TextUtils;
|
|
|
11
10
|
import android.view.View;
|
|
12
11
|
|
|
13
12
|
import androidx.annotation.NonNull;
|
|
14
|
-
import androidx.annotation.Nullable;
|
|
15
13
|
|
|
16
|
-
import com.facebook.react.bridge.Arguments;
|
|
17
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
18
|
-
import com.navigation.androidx.AwesomeToolbar;
|
|
19
15
|
import com.navigation.androidx.BarStyle;
|
|
20
16
|
import com.navigation.androidx.Style;
|
|
21
|
-
import com.navigation.androidx.ToolbarButtonItem;
|
|
22
|
-
|
|
23
|
-
import java.util.ArrayList;
|
|
24
17
|
|
|
25
18
|
public class Garden {
|
|
26
19
|
|
|
27
|
-
private static final String TAG = "Navigation";
|
|
28
|
-
|
|
29
20
|
private static GlobalStyle globalStyle;
|
|
30
21
|
|
|
31
22
|
static void createGlobalStyle(Bundle options) {
|
|
@@ -44,171 +35,26 @@ public class Garden {
|
|
|
44
35
|
|
|
45
36
|
private final Style style;
|
|
46
37
|
|
|
47
|
-
private final Bundle options;
|
|
48
|
-
|
|
49
|
-
boolean backButtonHidden = false;
|
|
50
|
-
|
|
51
38
|
boolean backInteractive = true;
|
|
52
39
|
|
|
53
|
-
boolean swipeBackEnabled;
|
|
54
|
-
|
|
55
|
-
boolean hidesBottomBarWhenPushed;
|
|
56
|
-
|
|
57
|
-
boolean toolbarHidden;
|
|
58
|
-
|
|
59
|
-
boolean extendedLayoutIncludesTopBar;
|
|
60
|
-
|
|
61
|
-
boolean forceTransparentDialogWindow;
|
|
62
|
-
|
|
63
40
|
Garden(@NonNull HybridFragment fragment, Style style) {
|
|
64
|
-
// 构造 garden 实例时,Toolbar 还没有被创建
|
|
65
|
-
|
|
66
41
|
this.fragment = fragment;
|
|
67
42
|
this.style = style;
|
|
68
43
|
|
|
69
44
|
Bundle options = fragment.getOptions();
|
|
70
|
-
this.options = options;
|
|
71
|
-
|
|
72
|
-
this.swipeBackEnabled = options.getBoolean("swipeBackEnabled", true);
|
|
73
|
-
this.toolbarHidden = options.getBoolean("topBarHidden", false);
|
|
74
|
-
// 全局 topBarHidden 优先,一旦设置则局部开启无效
|
|
75
|
-
if (getGlobalStyle().isTopBarHidden()) {
|
|
76
|
-
this.toolbarHidden = true;
|
|
77
|
-
}
|
|
78
|
-
Bundle tabItem = options.getBundle("tabItem");
|
|
79
|
-
this.hidesBottomBarWhenPushed = tabItem == null || tabItem.getBoolean("hideTabBarWhenPush", true);
|
|
80
|
-
this.extendedLayoutIncludesTopBar = options.getBoolean("extendedLayoutIncludesTopBar", false);
|
|
81
|
-
|
|
82
|
-
if (options.get("fitsOpaqueNavigationBarAndroid") != null) {
|
|
83
|
-
boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid");
|
|
84
|
-
style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
|
|
85
|
-
}
|
|
86
45
|
|
|
87
46
|
String screenColor = options.getString("screenBackgroundColor");
|
|
88
47
|
if (!TextUtils.isEmpty(screenColor)) {
|
|
89
48
|
style.setScreenBackgroundColor(Color.parseColor(screenColor));
|
|
90
49
|
}
|
|
91
50
|
|
|
92
|
-
this.forceTransparentDialogWindow = options.getBoolean("forceTransparentDialogWindow");
|
|
93
|
-
|
|
94
51
|
applyOptions(options);
|
|
95
52
|
}
|
|
96
53
|
|
|
97
|
-
void setupToolbar() {
|
|
98
|
-
AwesomeToolbar toolbar = fragment.getToolbar();
|
|
99
|
-
if (toolbar == null) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
Bundle titleItem = options.getBundle("titleItem");
|
|
104
|
-
if (titleItem != null) {
|
|
105
|
-
setTitleItem(titleItem);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Bundle rightBarButtonItem = options.getBundle("rightBarButtonItem");
|
|
109
|
-
ArrayList<Bundle> rightBarButtonItems = options.getParcelableArrayList("rightBarButtonItems");
|
|
110
|
-
if (rightBarButtonItems != null) {
|
|
111
|
-
setRightBarButtonItems(rightBarButtonItems);
|
|
112
|
-
} else if (rightBarButtonItem != null) {
|
|
113
|
-
setRightBarButtonItem(rightBarButtonItem);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
Bundle leftBarButtonItem = options.getBundle("leftBarButtonItem");
|
|
117
|
-
ArrayList<Bundle> leftBarButtonItems = options.getParcelableArrayList("leftBarButtonItems");
|
|
118
|
-
if (leftBarButtonItems != null) {
|
|
119
|
-
setLeftBarButtonItems(leftBarButtonItems);
|
|
120
|
-
} else if (leftBarButtonItem != null) {
|
|
121
|
-
setLeftBarButtonItem(leftBarButtonItem);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
void setTitleItem(@NonNull Bundle titleItem) {
|
|
126
|
-
String moduleName = titleItem.getString("moduleName");
|
|
127
|
-
if (moduleName == null) {
|
|
128
|
-
String title = titleItem.getString("title");
|
|
129
|
-
fragment.setTitle(title);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
void setLeftBarButtonItems(ArrayList<Bundle> items) {
|
|
134
|
-
if (items == null) {
|
|
135
|
-
fragment.setLeftBarButtonItems(null);
|
|
136
|
-
} else {
|
|
137
|
-
fragment.setLeftBarButtonItems(barButtonItemsFromBundle(items));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
void setRightBarButtonItems(ArrayList<Bundle> items) {
|
|
142
|
-
if (items == null) {
|
|
143
|
-
fragment.setRightBarButtonItems(null);
|
|
144
|
-
} else {
|
|
145
|
-
fragment.setRightBarButtonItems(barButtonItemsFromBundle(items));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private ToolbarButtonItem[] barButtonItemsFromBundle(ArrayList<Bundle> items) {
|
|
150
|
-
ArrayList<ToolbarButtonItem> buttonItems = new ArrayList<>();
|
|
151
|
-
for (int i = 0; i < items.size(); i++) {
|
|
152
|
-
Bundle item = items.get(i);
|
|
153
|
-
buttonItems.add(barButtonItemFromBundle(item));
|
|
154
|
-
}
|
|
155
|
-
return buttonItems.toArray(new ToolbarButtonItem[0]);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
void setLeftBarButtonItem(@Nullable Bundle item) {
|
|
159
|
-
if (item == null) {
|
|
160
|
-
fragment.setLeftBarButtonItem(null);
|
|
161
|
-
} else {
|
|
162
|
-
fragment.setLeftBarButtonItem(barButtonItemFromBundle(item));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
void setRightBarButtonItem(@Nullable Bundle item) {
|
|
167
|
-
if (item == null) {
|
|
168
|
-
fragment.setRightBarButtonItem(null);
|
|
169
|
-
} else {
|
|
170
|
-
fragment.setRightBarButtonItem(barButtonItemFromBundle(item));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private ToolbarButtonItem barButtonItemFromBundle(@NonNull Bundle item) {
|
|
175
|
-
Context context = fragment.getContext();
|
|
176
|
-
if (context == null) return null;
|
|
177
|
-
String title = item.getString("title");
|
|
178
|
-
boolean enabled = item.getBoolean("enabled", true);
|
|
179
|
-
String uri = uri(item);
|
|
180
|
-
String action = item.getString("action");
|
|
181
|
-
int tintColor = tintColor(item);
|
|
182
|
-
boolean renderOriginal = item.getBoolean("renderOriginal", false);
|
|
183
|
-
return new ToolbarButtonItem(uri, 0, renderOriginal, title, tintColor, enabled, view -> {
|
|
184
|
-
Bundle bundle = new Bundle();
|
|
185
|
-
bundle.putString("action", action);
|
|
186
|
-
bundle.putString("sceneId", fragment.getSceneId());
|
|
187
|
-
NativeEvent.getInstance().emitOnBarButtonItemClick(Arguments.fromBundle(bundle));
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private int tintColor(@NonNull Bundle item) {
|
|
192
|
-
String tintColor = item.getString("tintColor");
|
|
193
|
-
if (tintColor != null) {
|
|
194
|
-
return Color.parseColor(tintColor);
|
|
195
|
-
}
|
|
196
|
-
return 0;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
@Nullable
|
|
200
|
-
private String uri(@NonNull Bundle item) {
|
|
201
|
-
Bundle icon = item.getBundle("icon");
|
|
202
|
-
if (icon != null) {
|
|
203
|
-
return icon.getString("uri");
|
|
204
|
-
}
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
54
|
private void applyOptions(@NonNull Bundle options) {
|
|
209
|
-
String
|
|
210
|
-
if (
|
|
211
|
-
if (
|
|
55
|
+
String statusBarStyle = options.getString("statusBarStyle");
|
|
56
|
+
if (statusBarStyle != null) {
|
|
57
|
+
if (statusBarStyle.equals("dark-content")) {
|
|
212
58
|
style.setStatusBarStyle(BarStyle.DarkContent);
|
|
213
59
|
} else {
|
|
214
60
|
style.setStatusBarStyle(BarStyle.LightContent);
|
|
@@ -228,45 +74,13 @@ public class Garden {
|
|
|
228
74
|
style.setDisplayCutoutWhenLandscape(options.getBoolean("displayCutoutWhenLandscapeAndroid"));
|
|
229
75
|
}
|
|
230
76
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
String topBarTintColor = options.getString("topBarTintColor");
|
|
235
|
-
if (!TextUtils.isEmpty(topBarTintColor)) {
|
|
236
|
-
style.setToolbarTintColor(Color.parseColor(topBarTintColor));
|
|
77
|
+
if (options.get("statusBarHidden") != null) {
|
|
78
|
+
style.setStatusBarHidden(options.getBoolean("statusBarHidden"));
|
|
237
79
|
}
|
|
238
80
|
|
|
239
|
-
String titleTextColor = options.getString("titleTextColor");
|
|
240
|
-
if (!TextUtils.isEmpty(titleTextColor)) {
|
|
241
|
-
style.setTitleTextColor(Color.parseColor(titleTextColor));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
double titleTextSize = options.getDouble("titleTextSize", -1);
|
|
245
|
-
if (titleTextSize != -1) {
|
|
246
|
-
style.setTitleTextSize((int) titleTextSize);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
String topBarColor = options.getString("topBarColor");
|
|
250
|
-
if (!TextUtils.isEmpty(topBarColor)) {
|
|
251
|
-
int color = Color.parseColor(topBarColor);
|
|
252
|
-
style.setToolbarBackgroundColor(color);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
double topBarAlpha = options.getDouble("topBarAlpha", -1);
|
|
256
|
-
if (topBarAlpha != -1) {
|
|
257
|
-
style.setToolbarAlpha((float) topBarAlpha);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
boolean topBarShadowHidden = options.getBoolean("topBarShadowHidden", false);
|
|
261
|
-
style.setToolbarShadowHidden(topBarShadowHidden);
|
|
262
|
-
|
|
263
81
|
if (options.get("backInteractive") != null) {
|
|
264
82
|
this.backInteractive = options.getBoolean("backInteractive");
|
|
265
83
|
}
|
|
266
|
-
|
|
267
|
-
if (options.get("backButtonHidden") != null) {
|
|
268
|
-
this.backButtonHidden = options.getBoolean("backButtonHidden");
|
|
269
|
-
}
|
|
270
84
|
}
|
|
271
85
|
|
|
272
86
|
void updateOptions(@NonNull ReadableMap readableMap) {
|
|
@@ -284,66 +98,16 @@ public class Garden {
|
|
|
284
98
|
fragment.setNeedsStatusBarAppearanceUpdate();
|
|
285
99
|
}
|
|
286
100
|
|
|
287
|
-
if (shouldUpdateToolbar(readableMap)) {
|
|
288
|
-
fragment.setNeedsToolbarAppearanceUpdate();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
101
|
if (shouldUpdateNavigationBar(readableMap)) {
|
|
292
102
|
fragment.setNeedsNavigationBarAppearanceUpdate();
|
|
293
103
|
}
|
|
294
104
|
|
|
295
105
|
Bundle options = mergeOptions(fragment.getOptions(), patches);
|
|
296
106
|
fragment.setOptions(options);
|
|
297
|
-
// 全局 topBarHidden 优先,一旦设置则局部开启无效
|
|
298
|
-
if (getGlobalStyle().isTopBarHidden()) {
|
|
299
|
-
this.toolbarHidden = true;
|
|
300
|
-
} else if (readableMap.hasKey("topBarHidden")) {
|
|
301
|
-
this.toolbarHidden = options.getBoolean("topBarHidden", false);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (readableMap.hasKey("leftBarButtonItem")) {
|
|
305
|
-
Bundle bundle = options.getBundle("leftBarButtonItem");
|
|
306
|
-
setLeftBarButtonItem(bundle);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (readableMap.hasKey("rightBarButtonItem")) {
|
|
310
|
-
Bundle bundle = options.getBundle("rightBarButtonItem");
|
|
311
|
-
setRightBarButtonItem(bundle);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (readableMap.hasKey("leftBarButtonItems")) {
|
|
315
|
-
ArrayList<Bundle> items = options.getParcelableArrayList("leftBarButtonItems");
|
|
316
|
-
setLeftBarButtonItems(items);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (readableMap.hasKey("rightBarButtonItems")) {
|
|
320
|
-
ArrayList<Bundle> items = options.getParcelableArrayList("rightBarButtonItems");
|
|
321
|
-
setRightBarButtonItems(items);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (readableMap.hasKey("titleItem")) {
|
|
325
|
-
Bundle titleItem = options.getBundle("titleItem");
|
|
326
|
-
setTitleItem(titleItem);
|
|
327
|
-
}
|
|
328
107
|
}
|
|
329
108
|
|
|
330
109
|
private boolean shouldUpdateStatusBar(@NonNull ReadableMap readableMap) {
|
|
331
|
-
String[] keys = new String[]{"
|
|
332
|
-
for (String key : keys) {
|
|
333
|
-
if (readableMap.hasKey(key)) {
|
|
334
|
-
return true;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
private boolean shouldUpdateToolbar(@NonNull ReadableMap readableMap) {
|
|
341
|
-
String[] keys = new String[]{
|
|
342
|
-
"topBarStyle",
|
|
343
|
-
"topBarColor", "topBarAlpha", "topBarShadowHidden", "topBarTintColor",
|
|
344
|
-
"titleTextSize", "titleTextColor", "backButtonHidden"
|
|
345
|
-
};
|
|
346
|
-
|
|
110
|
+
String[] keys = new String[]{"statusBarStyle", "statusBarHidden", "displayCutoutWhenLandscapeAndroid"};
|
|
347
111
|
for (String key : keys) {
|
|
348
112
|
if (readableMap.hasKey(key)) {
|
|
349
113
|
return true;
|
|
@@ -361,5 +125,4 @@ public class Garden {
|
|
|
361
125
|
}
|
|
362
126
|
return false;
|
|
363
127
|
}
|
|
364
|
-
|
|
365
128
|
}
|
|
@@ -7,13 +7,11 @@ import android.graphics.drawable.BitmapDrawable;
|
|
|
7
7
|
import android.graphics.drawable.ColorDrawable;
|
|
8
8
|
import android.graphics.drawable.Drawable;
|
|
9
9
|
import android.os.Bundle;
|
|
10
|
-
import android.view.Gravity;
|
|
11
10
|
|
|
12
11
|
import androidx.annotation.NonNull;
|
|
13
12
|
import androidx.annotation.Nullable;
|
|
14
13
|
|
|
15
14
|
import com.facebook.common.logging.FLog;
|
|
16
|
-
import com.facebook.react.uimanager.PixelUtil;
|
|
17
15
|
import com.navigation.androidx.BarStyle;
|
|
18
16
|
import com.navigation.androidx.DrawableUtils;
|
|
19
17
|
import com.navigation.androidx.Style;
|
|
@@ -25,19 +23,9 @@ public class GlobalStyle {
|
|
|
25
23
|
private static final String TAG = "Navigation";
|
|
26
24
|
|
|
27
25
|
private final Bundle options;
|
|
28
|
-
private final boolean topBarHidden;
|
|
29
|
-
|
|
30
|
-
public Bundle getOptions() {
|
|
31
|
-
return options;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public boolean isTopBarHidden() {
|
|
35
|
-
return topBarHidden;
|
|
36
|
-
}
|
|
37
26
|
|
|
38
27
|
public GlobalStyle(Bundle options) {
|
|
39
28
|
this.options = options;
|
|
40
|
-
this.topBarHidden = options != null && options.getBoolean("topBarHidden", false);
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
public void inflateStyle(Context context, Style style) {
|
|
@@ -46,170 +34,50 @@ public class GlobalStyle {
|
|
|
46
34
|
return;
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
// screenBackgroundColor
|
|
50
37
|
String screenBackgroundColor = options.getString("screenBackgroundColor");
|
|
51
38
|
if (screenBackgroundColor != null) {
|
|
52
39
|
style.setScreenBackgroundColor(Color.parseColor(screenBackgroundColor));
|
|
53
40
|
}
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
style.setToolbarHeight((int) PixelUtil.toPixelFromDIP(toolbarHeight));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// topBarStyle
|
|
62
|
-
String topBarStyle = options.getString("topBarStyle");
|
|
63
|
-
if (topBarStyle != null) {
|
|
64
|
-
style.setStatusBarStyle(topBarStyle.equals("dark-content") ? BarStyle.DarkContent : BarStyle.LightContent);
|
|
42
|
+
String statusBarStyle = options.getString("statusBarStyle");
|
|
43
|
+
if (statusBarStyle != null) {
|
|
44
|
+
style.setStatusBarStyle(statusBarStyle.equals("dark-content") ? BarStyle.DarkContent : BarStyle.LightContent);
|
|
65
45
|
} else {
|
|
66
46
|
style.setStatusBarStyle(BarStyle.DarkContent);
|
|
67
47
|
}
|
|
68
48
|
|
|
69
|
-
// topBarColor
|
|
70
|
-
String topBarColor = options.getString("topBarColor");
|
|
71
|
-
if (topBarColor != null) {
|
|
72
|
-
style.setToolbarBackgroundColor(Color.parseColor(topBarColor));
|
|
73
|
-
} else {
|
|
74
|
-
if (style.getStatusBarStyle() == BarStyle.LightContent) {
|
|
75
|
-
style.setToolbarBackgroundColor(Color.BLACK);
|
|
76
|
-
} else {
|
|
77
|
-
style.setToolbarBackgroundColor(Color.WHITE);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
String topBarColorDarkContent = options.getString("topBarColorDarkContent");
|
|
82
|
-
if (topBarColorDarkContent != null) {
|
|
83
|
-
style.setToolbarBackgroundColorDarkContent(Color.parseColor(topBarColorDarkContent));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
String topBarColorLightContent = options.getString("topBarColorLightContent");
|
|
87
|
-
if (topBarColorLightContent != null) {
|
|
88
|
-
style.setToolbarBackgroundColorLightContent(Color.parseColor(topBarColorLightContent));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
//
|
|
92
49
|
boolean displayCutout = options.getBoolean("displayCutoutWhenLandscapeAndroid", true);
|
|
93
50
|
style.setDisplayCutoutWhenLandscape(displayCutout);
|
|
94
51
|
|
|
95
|
-
// navigationBarColor
|
|
96
52
|
String navigationBarColor = options.getString("navigationBarColorAndroid");
|
|
97
53
|
if (navigationBarColor != null) {
|
|
98
54
|
style.setNavigationBarColor(Color.parseColor(navigationBarColor));
|
|
99
55
|
}
|
|
100
56
|
|
|
101
|
-
// elevation
|
|
102
|
-
double elevation = options.getDouble("elevationAndroid", -1);
|
|
103
|
-
if (elevation != -1) {
|
|
104
|
-
style.setElevation((int) elevation);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// topBarTintColor
|
|
108
|
-
String topBarTintColor = options.getString("topBarTintColor");
|
|
109
|
-
if (topBarTintColor != null) {
|
|
110
|
-
style.setToolbarTintColor(Color.parseColor(topBarTintColor));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
String topBarTintColorDarkContent = options.getString("topBarTintColorDarkContent");
|
|
114
|
-
if (topBarTintColorDarkContent != null) {
|
|
115
|
-
style.setToolbarTintColorDarkContent(Color.parseColor(topBarTintColorDarkContent));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
String topBarTintColorLightContent = options.getString("topBarTintColorLightContent");
|
|
119
|
-
if (topBarTintColorLightContent != null) {
|
|
120
|
-
style.setToolbarTintColorLightContent(Color.parseColor(topBarTintColorLightContent));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// titleTextColor
|
|
124
|
-
String titleTextColor = options.getString("titleTextColor");
|
|
125
|
-
if (titleTextColor != null) {
|
|
126
|
-
style.setTitleTextColor(Color.parseColor(titleTextColor));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
String titleTextColorDarkContent = options.getString("titleTextColorDarkContent");
|
|
130
|
-
if (titleTextColorDarkContent != null) {
|
|
131
|
-
style.setTitleTextColorDarkContent(Color.parseColor(titleTextColorDarkContent));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
String titleTextColorLightContent = options.getString("titleTextColorLightContent");
|
|
135
|
-
if (titleTextColorLightContent != null) {
|
|
136
|
-
style.setTitleTextColorLightContent(Color.parseColor(titleTextColorLightContent));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// titleTextSize
|
|
140
|
-
double titleTextSize = options.getDouble("titleTextSize", -1);
|
|
141
|
-
if (titleTextSize != -1) {
|
|
142
|
-
style.setTitleTextSize((int) titleTextSize);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// titleAlignment
|
|
146
|
-
String titleAlignment = options.getString("titleAlignmentAndroid");
|
|
147
|
-
if (titleAlignment != null) {
|
|
148
|
-
style.setTitleGravity(titleAlignment.equals("center") ? Gravity.CENTER : Gravity.START);
|
|
149
|
-
} else {
|
|
150
|
-
style.setTitleGravity(Gravity.START);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// barButtonItemTextSize
|
|
154
|
-
double barButtonItemTextSize = options.getDouble("barButtonItemTextSize", -1);
|
|
155
|
-
if (barButtonItemTextSize != -1) {
|
|
156
|
-
style.setToolbarButtonTextSize((int) barButtonItemTextSize);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// backIcon
|
|
160
|
-
Bundle backIcon = options.getBundle("backIcon");
|
|
161
|
-
if (backIcon != null) {
|
|
162
|
-
String uri = backIcon.getString("uri");
|
|
163
|
-
if (uri != null) {
|
|
164
|
-
Drawable drawable = DrawableUtils.fromUri(context, uri);
|
|
165
|
-
style.setBackIcon(drawable);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
57
|
// --------- tabBar ------------
|
|
170
|
-
// -----------------------------
|
|
171
|
-
|
|
172
|
-
// tabBarBackgroundColor
|
|
173
58
|
String tabBarBackgroundColor = options.getString("tabBarBackgroundColor");
|
|
174
59
|
if (tabBarBackgroundColor != null) {
|
|
175
60
|
style.setTabBarBackgroundColor(tabBarBackgroundColor);
|
|
176
61
|
}
|
|
177
62
|
|
|
178
63
|
String tabBarItemSelectedColor = options.getString("tabBarItemSelectedColor");
|
|
179
|
-
|
|
64
|
+
style.setTabBarItemColor(Objects.requireNonNullElse(tabBarItemSelectedColor, "#FF5722"));
|
|
180
65
|
|
|
181
66
|
String tabBarItemNormalColor = options.getString("tabBarItemNormalColor");
|
|
182
|
-
|
|
67
|
+
style.setTabBarUnselectedItemColor(Objects.requireNonNullElse(tabBarItemNormalColor, "#666666"));
|
|
183
68
|
|
|
184
|
-
// tabBarShadowImage
|
|
185
69
|
Bundle shadowImage = options.getBundle("tabBarShadowImage");
|
|
186
70
|
if (shadowImage != null) {
|
|
187
|
-
|
|
71
|
+
setTabBarShadowImage(context, style, shadowImage);
|
|
188
72
|
}
|
|
189
73
|
|
|
190
|
-
// swipeBackEnabledAndroid
|
|
191
|
-
boolean swipeBackEnabled = options.getBoolean("swipeBackEnabledAndroid", false);
|
|
192
|
-
style.setSwipeBackEnabled(swipeBackEnabled);
|
|
193
|
-
|
|
194
|
-
// badgeColor
|
|
195
74
|
String badgeColor = options.getString("tabBarBadgeColor");
|
|
196
75
|
if (badgeColor != null) {
|
|
197
76
|
style.setTabBarBadgeColor(badgeColor);
|
|
198
77
|
}
|
|
199
|
-
|
|
200
|
-
// scrimAlphaAndroid
|
|
201
|
-
double scrimAlpha = options.getDouble("scrimAlphaAndroid", -1);
|
|
202
|
-
if (scrimAlpha != -1) {
|
|
203
|
-
style.setScrimAlpha((int) scrimAlpha);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// fitsOpaqueNavigationBarAndroid
|
|
207
|
-
boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid", true);
|
|
208
|
-
style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
|
|
209
|
-
|
|
210
78
|
}
|
|
211
79
|
|
|
212
|
-
private void
|
|
80
|
+
private void setTabBarShadowImage(@NonNull Context context, @NonNull Style style, @NonNull Bundle shadowImage) {
|
|
213
81
|
Bundle image = shadowImage.getBundle("image");
|
|
214
82
|
if (image != null) {
|
|
215
83
|
style.setTabBarShadow(buildDrawableFromImageBundle(context, image));
|
|
@@ -231,9 +99,8 @@ public class GlobalStyle {
|
|
|
231
99
|
|
|
232
100
|
Drawable drawable = DrawableUtils.fromUri(context, uri);
|
|
233
101
|
if (drawable instanceof BitmapDrawable bitmapDrawable) {
|
|
234
|
-
|
|
102
|
+
bitmapDrawable.setTileModeX(Shader.TileMode.REPEAT);
|
|
235
103
|
}
|
|
236
104
|
return drawable;
|
|
237
105
|
}
|
|
238
|
-
|
|
239
106
|
}
|
|
@@ -12,13 +12,8 @@ import android.widget.FrameLayout;
|
|
|
12
12
|
import androidx.annotation.NonNull;
|
|
13
13
|
import androidx.annotation.Nullable;
|
|
14
14
|
|
|
15
|
-
import com.facebook.react.bridge.ReactContext;
|
|
16
|
-
import com.facebook.react.bridge.UIManager;
|
|
17
15
|
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
18
16
|
import com.facebook.react.runtime.ReactSurfaceView;
|
|
19
|
-
import com.facebook.react.uimanager.TouchTargetHelper;
|
|
20
|
-
import com.facebook.react.uimanager.UIManagerHelper;
|
|
21
|
-
import com.facebook.react.uimanager.common.UIManagerType;
|
|
22
17
|
|
|
23
18
|
import java.lang.reflect.InvocationTargetException;
|
|
24
19
|
import java.lang.reflect.Method;
|
|
@@ -32,8 +27,6 @@ public class HBDRootView extends FrameLayout {
|
|
|
32
27
|
@Nullable
|
|
33
28
|
private ReactSurfaceView reactSurfaceView;
|
|
34
29
|
|
|
35
|
-
private boolean passThroughTouches;
|
|
36
|
-
|
|
37
30
|
@Nullable
|
|
38
31
|
private Bundle appProperties;
|
|
39
32
|
|
|
@@ -49,10 +42,6 @@ public class HBDRootView extends FrameLayout {
|
|
|
49
42
|
super(context, attrs, defStyleAttr);
|
|
50
43
|
}
|
|
51
44
|
|
|
52
|
-
public void setPassThroughTouches(boolean passThroughTouches) {
|
|
53
|
-
this.passThroughTouches = passThroughTouches;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
45
|
public void setSurface(@NonNull ReactSurface reactSurface) {
|
|
57
46
|
if (surface == reactSurface) {
|
|
58
47
|
return;
|
|
@@ -95,7 +84,10 @@ public class HBDRootView extends FrameLayout {
|
|
|
95
84
|
|
|
96
85
|
public void clearSurface(boolean stopSurface) {
|
|
97
86
|
if (surface != null && stopSurface) {
|
|
98
|
-
|
|
87
|
+
try {
|
|
88
|
+
surface.stop();
|
|
89
|
+
} catch (RuntimeException ignored) {
|
|
90
|
+
}
|
|
99
91
|
}
|
|
100
92
|
if (reactSurfaceView != null) {
|
|
101
93
|
reactSurfaceView.setOnTouchListener(null);
|
|
@@ -110,62 +102,6 @@ public class HBDRootView extends FrameLayout {
|
|
|
110
102
|
applyAppProperties(this.appProperties);
|
|
111
103
|
}
|
|
112
104
|
|
|
113
|
-
@Override
|
|
114
|
-
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
115
|
-
if (shouldPassTouches(ev)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
return super.dispatchTouchEvent(ev);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
private boolean shouldPassTouches(@NonNull MotionEvent ev) {
|
|
122
|
-
if (!passThroughTouches) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
int action = ev.getAction() & MotionEvent.ACTION_MASK;
|
|
127
|
-
if (action != MotionEvent.ACTION_DOWN) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
ReactSurfaceView surfaceView = getReactSurfaceView();
|
|
132
|
-
if (surfaceView == null) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
ViewGroup rootViewGroup = surfaceView.getRootViewGroup();
|
|
137
|
-
|
|
138
|
-
int tag = TouchTargetHelper.findTargetTagForTouch(ev.getX(), ev.getY(), rootViewGroup);
|
|
139
|
-
ReactContext reactContext = surfaceView.getCurrentReactContext();
|
|
140
|
-
if (reactContext == null) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC);
|
|
145
|
-
if (uiManager == null) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
View view = uiManager.resolveView(tag);
|
|
150
|
-
if (view == null) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (view == surfaceView || view == surfaceView.getChildAt(0)) {
|
|
155
|
-
return view.getWidth() == surfaceView.getWidth() && view.getHeight() == surfaceView.getHeight();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
@Nullable
|
|
162
|
-
private ReactSurfaceView getReactSurfaceView() {
|
|
163
|
-
if (reactSurfaceView == null) {
|
|
164
|
-
reactSurfaceView = findReactSurfaceView(this);
|
|
165
|
-
}
|
|
166
|
-
return reactSurfaceView;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
105
|
@Nullable
|
|
170
106
|
private ReactSurfaceView findReactSurfaceView(@NonNull ViewGroup parent) {
|
|
171
107
|
for (int i = 0; i < parent.getChildCount(); i++) {
|