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
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
package com.navigation.androidx;
|
|
2
|
+
|
|
3
|
+
import android.app.Activity;
|
|
4
|
+
import android.content.ContentResolver;
|
|
5
|
+
import android.os.Build;
|
|
6
|
+
import android.provider.Settings;
|
|
7
|
+
import android.view.DisplayCutout;
|
|
8
|
+
import android.view.View;
|
|
9
|
+
import android.view.Window;
|
|
10
|
+
import android.view.WindowInsets;
|
|
11
|
+
import android.view.WindowManager;
|
|
12
|
+
|
|
13
|
+
import androidx.annotation.NonNull;
|
|
14
|
+
import androidx.core.view.ViewCompat;
|
|
15
|
+
import androidx.core.view.WindowCompat;
|
|
16
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
17
|
+
import androidx.core.view.WindowInsetsControllerCompat;
|
|
18
|
+
|
|
19
|
+
public class SystemUI {
|
|
20
|
+
public static void enableEdgeToEdge(@NonNull Window window) {
|
|
21
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
22
|
+
SystemUI30.enableEdgeToEdge(window);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
WindowCompat.setDecorFitsSystemWindows(window, false);
|
|
27
|
+
|
|
28
|
+
View decorView = window.getDecorView();
|
|
29
|
+
int systemUi = decorView.getSystemUiVisibility();
|
|
30
|
+
systemUi |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
|
31
|
+
systemUi |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
|
32
|
+
decorView.setSystemUiVisibility(systemUi);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static void setRenderContentInShortEdgeCutoutAreas(@NonNull Window window, boolean shortEdges) {
|
|
36
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
37
|
+
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
|
38
|
+
if (shortEdges) {
|
|
39
|
+
layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
|
40
|
+
} else {
|
|
41
|
+
|
|
42
|
+
layoutParams.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
|
|
43
|
+
}
|
|
44
|
+
window.setAttributes(layoutParams);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public static void setStatusBarColor(@NonNull Window window, int color) {
|
|
49
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
50
|
+
window.setStatusBarContrastEnforced(false);
|
|
51
|
+
}
|
|
52
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
|
53
|
+
window.setStatusBarColor(color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public static void setStatusBarStyle(@NonNull Window window, boolean dark) {
|
|
57
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
58
|
+
SystemUI30.setStatusBarStyle(window, dark);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
View decorView = window.getDecorView();
|
|
67
|
+
int systemUi = decorView.getSystemUiVisibility();
|
|
68
|
+
if (dark) {
|
|
69
|
+
systemUi |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
|
70
|
+
} else {
|
|
71
|
+
systemUi &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
|
72
|
+
}
|
|
73
|
+
decorView.setSystemUiVisibility(systemUi);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public static BarStyle activityStatusBarStyle(@NonNull Activity activity) {
|
|
77
|
+
boolean isDark = isStatusBarStyleDark(activity.getWindow());
|
|
78
|
+
return isDark ? BarStyle.DarkContent : BarStyle.LightContent;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public static boolean isStatusBarStyleDark(@NonNull Window window) {
|
|
82
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
83
|
+
return SystemUI30.isStatusBarStyleDark(window);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public static void setStatusBarHidden(@NonNull Window window, boolean hidden) {
|
|
94
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
95
|
+
SystemUI30.setStatusBarHidden(window, hidden);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
View decorView = window.getDecorView();
|
|
100
|
+
int systemUi = decorView.getSystemUiVisibility();
|
|
101
|
+
if (hidden) {
|
|
102
|
+
systemUi |= View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
103
|
+
} else {
|
|
104
|
+
systemUi &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
|
105
|
+
}
|
|
106
|
+
window.getDecorView().setSystemUiVisibility(systemUi);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public static boolean isStatusBarHidden(@NonNull Window window) {
|
|
110
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
111
|
+
return SystemUI30.isStatusBarHidden(window);
|
|
112
|
+
}
|
|
113
|
+
return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 是否刘海屏
|
|
117
|
+
public static boolean isCutout(@NonNull Window window) {
|
|
118
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
View decorView = window.getDecorView();
|
|
123
|
+
WindowInsets windowInsets = decorView.getRootWindowInsets();
|
|
124
|
+
if (windowInsets == null) {
|
|
125
|
+
throw new IllegalStateException("Activity has not yet attach to window, you must call `isCutout` after `Activity#onAttachedToWindow` is called.");
|
|
126
|
+
}
|
|
127
|
+
DisplayCutout displayCutout = windowInsets.getDisplayCutout();
|
|
128
|
+
return displayCutout != null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public static boolean isGestureNavigationEnabled(ContentResolver contentResolver) {
|
|
132
|
+
return Settings.Secure.getInt(contentResolver, "navigation_mode", 0) == 2;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public static void setNavigationBarColor(final Window window, int color) {
|
|
136
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
141
|
+
window.setNavigationBarContrastEnforced(false);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
|
145
|
+
window.setNavigationBarColor(color);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public static void setNavigationBarStyle(Window window, boolean dark) {
|
|
149
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
150
|
+
SystemUI30.setNavigationBarStyle(window, dark);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
View decorView = window.getDecorView();
|
|
159
|
+
int systemUi = decorView.getSystemUiVisibility();
|
|
160
|
+
if (dark) {
|
|
161
|
+
systemUi |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
|
162
|
+
} else {
|
|
163
|
+
systemUi &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
|
164
|
+
}
|
|
165
|
+
decorView.setSystemUiVisibility(systemUi);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public static boolean isNavigationBarStyleDark(Window window) {
|
|
169
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
170
|
+
return SystemUI30.isNavigationBarStyleDark(window);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) != 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public static BarStyle activityNavigationBarStyle(Activity activity) {
|
|
181
|
+
boolean isDark = isNavigationBarStyleDark(activity.getWindow());
|
|
182
|
+
return isDark ? BarStyle.DarkContent : BarStyle.LightContent;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public static boolean isNavigationBarHidden(Window window) {
|
|
186
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
187
|
+
return SystemUI30.isNavigationBarHidden(window);
|
|
188
|
+
}
|
|
189
|
+
return (window.getDecorView().getSystemUiVisibility() & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
public static void setNavigationBarHidden(Window window, boolean hidden) {
|
|
193
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
194
|
+
SystemUI30.setNavigationBarHidden(window, hidden);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
View decorView = window.getDecorView();
|
|
199
|
+
int systemUi = decorView.getSystemUiVisibility();
|
|
200
|
+
if (hidden) {
|
|
201
|
+
systemUi |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
202
|
+
} else {
|
|
203
|
+
systemUi &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
|
204
|
+
}
|
|
205
|
+
window.getDecorView().setSystemUiVisibility(systemUi);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public static boolean isImeVisible(@NonNull Window window) {
|
|
209
|
+
WindowInsetsCompat insetsCompat = ViewCompat.getRootWindowInsets(window.getDecorView());
|
|
210
|
+
if (insetsCompat == null) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return insetsCompat.isVisible(WindowInsetsCompat.Type.ime());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public static boolean isImeVisible(@NonNull View view) {
|
|
217
|
+
WindowInsetsCompat insetsCompat = ViewCompat.getRootWindowInsets(view.getRootView());
|
|
218
|
+
if (insetsCompat == null) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return insetsCompat.isVisible(WindowInsetsCompat.Type.ime());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public static void showIme(@NonNull Window window) {
|
|
225
|
+
WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
|
|
226
|
+
controller.show(WindowInsetsCompat.Type.ime());
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public static void hideIme(@NonNull Window window) {
|
|
230
|
+
WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
|
|
231
|
+
controller.hide(WindowInsetsCompat.Type.ime());
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
public static void hideIme(@NonNull View view) {
|
|
235
|
+
WindowInsetsControllerCompat controller = ViewCompat.getWindowInsetsController(view.getRootView());
|
|
236
|
+
assert controller != null;
|
|
237
|
+
controller.hide(WindowInsetsCompat.Type.ime());
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package com.navigation.androidx;
|
|
2
|
+
|
|
3
|
+
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS;
|
|
4
|
+
import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
|
5
|
+
|
|
6
|
+
import android.view.View;
|
|
7
|
+
import android.view.Window;
|
|
8
|
+
import android.view.WindowInsets;
|
|
9
|
+
import android.view.WindowInsetsController;
|
|
10
|
+
|
|
11
|
+
import androidx.annotation.NonNull;
|
|
12
|
+
import androidx.annotation.RequiresApi;
|
|
13
|
+
|
|
14
|
+
@RequiresApi(30)
|
|
15
|
+
public class SystemUI30 {
|
|
16
|
+
|
|
17
|
+
public static void enableEdgeToEdge(@NonNull Window window) {
|
|
18
|
+
window.setDecorFitsSystemWindows(false);
|
|
19
|
+
|
|
20
|
+
View decorView = window.getDecorView();
|
|
21
|
+
WindowInsetsController controller = decorView.getWindowInsetsController();
|
|
22
|
+
assert controller != null;
|
|
23
|
+
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static void setStatusBarStyle(@NonNull Window window, boolean dark) {
|
|
27
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
28
|
+
assert controller != null;
|
|
29
|
+
controller.setSystemBarsAppearance(dark ? APPEARANCE_LIGHT_STATUS_BARS : 0, APPEARANCE_LIGHT_STATUS_BARS);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static boolean isStatusBarStyleDark(@NonNull Window window) {
|
|
33
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
34
|
+
assert controller != null;
|
|
35
|
+
return (controller.getSystemBarsAppearance() & APPEARANCE_LIGHT_STATUS_BARS) != 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static void setStatusBarHidden(@NonNull Window window, boolean hidden) {
|
|
39
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
40
|
+
assert controller != null;
|
|
41
|
+
if (hidden) {
|
|
42
|
+
controller.hide(WindowInsets.Type.statusBars());
|
|
43
|
+
} else {
|
|
44
|
+
controller.show(WindowInsets.Type.statusBars());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public static boolean isStatusBarHidden(@NonNull Window window) {
|
|
49
|
+
View decorView = window.getDecorView();
|
|
50
|
+
WindowInsets insets = decorView.getRootWindowInsets();
|
|
51
|
+
if (insets == null) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return !insets.isVisible(WindowInsets.Type.statusBars());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static void setNavigationBarStyle(Window window, boolean dark) {
|
|
58
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
59
|
+
assert controller != null;
|
|
60
|
+
controller.setSystemBarsAppearance(dark ? APPEARANCE_LIGHT_NAVIGATION_BARS : 0, APPEARANCE_LIGHT_NAVIGATION_BARS);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static boolean isNavigationBarStyleDark(Window window) {
|
|
64
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
65
|
+
assert controller != null;
|
|
66
|
+
return (controller.getSystemBarsAppearance() & APPEARANCE_LIGHT_NAVIGATION_BARS) != 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public static void setNavigationBarHidden(Window window, boolean hidden) {
|
|
70
|
+
WindowInsetsController controller = window.getDecorView().getWindowInsetsController();
|
|
71
|
+
assert controller != null;
|
|
72
|
+
if (hidden) {
|
|
73
|
+
controller.hide(WindowInsets.Type.navigationBars());
|
|
74
|
+
} else {
|
|
75
|
+
controller.show(WindowInsets.Type.navigationBars());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public static boolean isNavigationBarHidden(Window window) {
|
|
80
|
+
View decorView = window.getDecorView();
|
|
81
|
+
WindowInsets insets = decorView.getRootWindowInsets();
|
|
82
|
+
if (insets == null) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return !insets.isVisible(WindowInsets.Type.navigationBars());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
package com.navigation.androidx;
|
|
2
|
+
|
|
3
|
+
import com.reactnative.hybridnavigation.R;
|
|
4
|
+
|
|
5
|
+
import android.content.Context;
|
|
6
|
+
import android.graphics.Canvas;
|
|
7
|
+
import android.graphics.Color;
|
|
8
|
+
import android.graphics.drawable.ColorDrawable;
|
|
9
|
+
import android.graphics.drawable.Drawable;
|
|
10
|
+
import android.util.AttributeSet;
|
|
11
|
+
import android.view.LayoutInflater;
|
|
12
|
+
import android.view.View;
|
|
13
|
+
import android.view.ViewGroup;
|
|
14
|
+
import android.view.ViewOutlineProvider;
|
|
15
|
+
import android.widget.FrameLayout;
|
|
16
|
+
import android.widget.LinearLayout;
|
|
17
|
+
|
|
18
|
+
import androidx.annotation.ColorRes;
|
|
19
|
+
import androidx.annotation.NonNull;
|
|
20
|
+
import androidx.annotation.Nullable;
|
|
21
|
+
import androidx.core.content.ContextCompat;
|
|
22
|
+
import androidx.core.view.ViewCompat;
|
|
23
|
+
import androidx.core.view.WindowInsetsCompat;
|
|
24
|
+
|
|
25
|
+
import java.util.ArrayList;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Created by Listen on 2018/1/30.
|
|
29
|
+
* fork from https://github.com/Ashok-Varma/BottomNavigation/blob/master/bottom-navigation-bar/src/main/java/com/ashokvarma/bottomnavigation/BottomNavigationBar.java
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
public class TabBar extends FrameLayout {
|
|
33
|
+
ArrayList<TabBarItem> tabBarItems = new ArrayList<>();
|
|
34
|
+
ArrayList<TabView> tabs = new ArrayList<>();
|
|
35
|
+
|
|
36
|
+
private Drawable shadowDrawable = new ColorDrawable(Color.parseColor("#dddddd"));
|
|
37
|
+
private static final int DEFAULT_SELECTED_POSITION = -1;
|
|
38
|
+
private int selectedPosition = DEFAULT_SELECTED_POSITION;
|
|
39
|
+
private OnTabSelectedListener tabSelectedListener;
|
|
40
|
+
|
|
41
|
+
private int selectedItemColor;
|
|
42
|
+
private int unselectedItemColor;
|
|
43
|
+
private int barBackgroundColor;
|
|
44
|
+
private int badgeColor;
|
|
45
|
+
|
|
46
|
+
private FrameLayout container;
|
|
47
|
+
private LinearLayout tabContainer;
|
|
48
|
+
|
|
49
|
+
public TabBar(Context context) {
|
|
50
|
+
this(context, null);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public TabBar(Context context, AttributeSet attrs) {
|
|
54
|
+
this(context, attrs, 0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public TabBar(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
58
|
+
super(context, attrs, defStyleAttr);
|
|
59
|
+
init(context);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public TabBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
|
63
|
+
super(context, attrs, defStyleAttr, defStyleRes);
|
|
64
|
+
init(context);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private void init(Context context) {
|
|
68
|
+
selectedItemColor = AppUtils.fetchContextColor(context, android.R.attr.colorAccent);
|
|
69
|
+
unselectedItemColor = Color.LTGRAY;
|
|
70
|
+
barBackgroundColor = Color.WHITE;
|
|
71
|
+
badgeColor = Color.parseColor("#FF3B30");
|
|
72
|
+
|
|
73
|
+
setLayoutParams(new ViewGroup.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)));
|
|
74
|
+
LayoutInflater inflater = LayoutInflater.from(getContext());
|
|
75
|
+
View parentView = inflater.inflate(R.layout.nav_tab_bar_container, this, true);
|
|
76
|
+
container = parentView.findViewById(R.id.nav_tab_bar_container);
|
|
77
|
+
tabContainer = parentView.findViewById(R.id.nav_tab_bar_item_container);
|
|
78
|
+
this.setOutlineProvider(ViewOutlineProvider.BOUNDS);
|
|
79
|
+
ViewCompat.setElevation(this, 0);
|
|
80
|
+
setClipToPadding(false);
|
|
81
|
+
|
|
82
|
+
ViewCompat.setOnApplyWindowInsetsListener(this, (v, insets) -> {
|
|
83
|
+
int bottom = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom;
|
|
84
|
+
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), bottom);
|
|
85
|
+
return insets;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@Override
|
|
90
|
+
protected void dispatchDraw(Canvas canvas) {
|
|
91
|
+
super.dispatchDraw(canvas);
|
|
92
|
+
if (shadowDrawable != null) {
|
|
93
|
+
int height = (int) getContext().getResources().getDisplayMetrics().density;
|
|
94
|
+
shadowDrawable.setBounds(0, 0, getWidth(), height);
|
|
95
|
+
shadowDrawable.draw(canvas);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public void setShadowDrawable(@Nullable Drawable drawable) {
|
|
100
|
+
shadowDrawable = drawable;
|
|
101
|
+
postInvalidate();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public void addTabBarItem(TabBarItem item) {
|
|
105
|
+
tabBarItems.add(item);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public void removeTabBarItem(TabBarItem item) {
|
|
109
|
+
tabBarItems.remove(item);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Nullable
|
|
113
|
+
public TabBarItem getTabBarItem(int index) {
|
|
114
|
+
if (tabBarItems.size() > index) {
|
|
115
|
+
return tabBarItems.get(index);
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public void renderTabView(int index) {
|
|
121
|
+
TabView tabView = getTabView(index);
|
|
122
|
+
TabBarItem tabBarItem = getTabBarItem(index);
|
|
123
|
+
if (tabBarItem != null && tabView != null) {
|
|
124
|
+
bindTabWithData(tabBarItem, tabView, this);
|
|
125
|
+
tabView.initialise();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public void renderAllTabView() {
|
|
130
|
+
for (int i = 0; i < tabs.size(); i++) {
|
|
131
|
+
renderTabView(i);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public TabBar setSelectedItemColor(@ColorRes int color) {
|
|
136
|
+
this.selectedItemColor = ContextCompat.getColor(getContext(), color);
|
|
137
|
+
return this;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public TabBar setSelectedItemColor(@NonNull String color) {
|
|
141
|
+
this.selectedItemColor = Color.parseColor(color);
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public TabBar setUnselectedItemColor(@ColorRes int color) {
|
|
146
|
+
this.unselectedItemColor = ContextCompat.getColor(getContext(), color);
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public TabBar setUnselectedItemColor(@NonNull String color) {
|
|
151
|
+
this.unselectedItemColor = Color.parseColor(color);
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public TabBar setBadgeColor(@ColorRes int color) {
|
|
156
|
+
this.badgeColor = ContextCompat.getColor(getContext(), color);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
public TabBar setBadgeColor(String color) {
|
|
161
|
+
this.badgeColor = Color.parseColor(color);
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public TabBar setBarBackgroundColor(@ColorRes int backgroundColor) {
|
|
166
|
+
this.barBackgroundColor = ContextCompat.getColor(getContext(), backgroundColor);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public TabBar setBarBackgroundColor(String backgroundColorCode) {
|
|
171
|
+
this.barBackgroundColor = Color.parseColor(backgroundColorCode);
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public void initialise(int firstSelectedPosition) {
|
|
176
|
+
selectedPosition = DEFAULT_SELECTED_POSITION;
|
|
177
|
+
tabs.clear();
|
|
178
|
+
|
|
179
|
+
if (!tabBarItems.isEmpty()) {
|
|
180
|
+
tabContainer.removeAllViews();
|
|
181
|
+
|
|
182
|
+
setBackgroundColor(barBackgroundColor);
|
|
183
|
+
|
|
184
|
+
int availableWidth = resolveAvailableWidth();
|
|
185
|
+
int itemWidth = getTabWidth(getContext(), availableWidth, tabBarItems.size());
|
|
186
|
+
|
|
187
|
+
for (TabBarItem currentItem : tabBarItems) {
|
|
188
|
+
TabView tab = new TabView(getContext());
|
|
189
|
+
setupTab(tab, currentItem, itemWidth);
|
|
190
|
+
}
|
|
191
|
+
if (firstSelectedPosition >= 0 && tabs.size() > firstSelectedPosition) {
|
|
192
|
+
selectTabInternal(firstSelectedPosition, false);
|
|
193
|
+
} else if (!tabs.isEmpty()) {
|
|
194
|
+
selectTabInternal(0, false);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Re-layout with the actual measured width to keep tab width stable after
|
|
198
|
+
// orientation / split-screen / multi-window size changes.
|
|
199
|
+
post(() -> relayoutTabs(resolveAvailableWidth()));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public TabBar setTabSelectedListener(OnTabSelectedListener tabSelectedListener) {
|
|
204
|
+
this.tabSelectedListener = tabSelectedListener;
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
public void selectTab(int newPosition) {
|
|
209
|
+
selectTab(newPosition, true);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public void selectTab(int newPosition, boolean callListener) {
|
|
213
|
+
selectTabInternal(newPosition, callListener);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public TabView getTabView(int index) {
|
|
217
|
+
if (tabs.size() > index) {
|
|
218
|
+
return tabs.get(index);
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private void setupTab(TabView tab, TabBarItem currentItem, int itemWidth) {
|
|
224
|
+
tab.setTabWidth(itemWidth);
|
|
225
|
+
tab.setPosition(tabBarItems.indexOf(currentItem));
|
|
226
|
+
|
|
227
|
+
tab.setOnClickListener(v -> {
|
|
228
|
+
TabView tabView = (TabView) v;
|
|
229
|
+
selectTabInternal(tabView.getPosition(), true);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
tabs.add(tab);
|
|
233
|
+
|
|
234
|
+
bindTabWithData(currentItem, tab, this);
|
|
235
|
+
|
|
236
|
+
tab.initialise();
|
|
237
|
+
|
|
238
|
+
tabContainer.addView(tab);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private void selectTabInternal(int newPosition, boolean callListener) {
|
|
242
|
+
if (newPosition < 0 || newPosition >= tabs.size()) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
int oldPosition = selectedPosition;
|
|
247
|
+
if (selectedPosition != newPosition) {
|
|
248
|
+
if (selectedPosition != DEFAULT_SELECTED_POSITION) {
|
|
249
|
+
tabs.get(selectedPosition).unSelect();
|
|
250
|
+
}
|
|
251
|
+
tabs.get(newPosition).select();
|
|
252
|
+
selectedPosition = newPosition;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (callListener) {
|
|
256
|
+
sendListenerCall(oldPosition, newPosition);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private void sendListenerCall(int oldPosition, int newPosition) {
|
|
261
|
+
if (tabSelectedListener != null) {
|
|
262
|
+
if (oldPosition == newPosition) {
|
|
263
|
+
tabSelectedListener.onTabReselected(newPosition);
|
|
264
|
+
} else {
|
|
265
|
+
tabSelectedListener.onTabSelected(newPosition);
|
|
266
|
+
if (oldPosition != DEFAULT_SELECTED_POSITION) {
|
|
267
|
+
tabSelectedListener.onTabUnselected(oldPosition);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
public int getCurrentSelectedPosition() {
|
|
274
|
+
return selectedPosition;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
public interface OnTabSelectedListener {
|
|
278
|
+
|
|
279
|
+
void onTabSelected(int position);
|
|
280
|
+
|
|
281
|
+
void onTabUnselected(int position);
|
|
282
|
+
|
|
283
|
+
void onTabReselected(int position);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
static int getTabWidth(Context context, int screenWidth, int noOfTabs) {
|
|
287
|
+
int maxWidth = (int) context.getResources().getDimension(R.dimen.nav_tab_item_min_width);
|
|
288
|
+
int itemWidth = screenWidth / noOfTabs;
|
|
289
|
+
if (itemWidth > maxWidth) {
|
|
290
|
+
itemWidth = maxWidth;
|
|
291
|
+
}
|
|
292
|
+
return itemWidth;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private int resolveAvailableWidth() {
|
|
296
|
+
int availableWidth = tabContainer.getWidth();
|
|
297
|
+
if (availableWidth <= 0) {
|
|
298
|
+
availableWidth = getWidth();
|
|
299
|
+
}
|
|
300
|
+
if (availableWidth <= 0) {
|
|
301
|
+
availableWidth = getMeasuredWidth();
|
|
302
|
+
}
|
|
303
|
+
if (availableWidth <= 0) {
|
|
304
|
+
availableWidth = AppUtils.getScreenWidth(getContext());
|
|
305
|
+
}
|
|
306
|
+
return availableWidth;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
private void relayoutTabs(int availableWidth) {
|
|
310
|
+
if (availableWidth <= 0 || tabs.isEmpty() || tabBarItems.isEmpty()) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
int itemWidth = getTabWidth(getContext(), availableWidth, tabBarItems.size());
|
|
315
|
+
for (TabView tab : tabs) {
|
|
316
|
+
tab.setTabWidth(itemWidth);
|
|
317
|
+
}
|
|
318
|
+
tabContainer.requestLayout();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@Override
|
|
322
|
+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
323
|
+
super.onSizeChanged(w, h, oldw, oldh);
|
|
324
|
+
if (w > 0 && w != oldw) {
|
|
325
|
+
relayoutTabs(w);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
static void bindTabWithData(TabBarItem tabBarItem, TabView tab, TabBar tabBar) {
|
|
330
|
+
|
|
331
|
+
Context context = tabBar.getContext();
|
|
332
|
+
tab.setLabel(tabBarItem.title);
|
|
333
|
+
|
|
334
|
+
tab.setSelectedColor(tabBar.selectedItemColor);
|
|
335
|
+
tab.setUnselectedColor(tabBar.unselectedItemColor);
|
|
336
|
+
|
|
337
|
+
if (tabBarItem.iconRes > 0) {
|
|
338
|
+
tab.setIcon(ContextCompat.getDrawable(context, tabBarItem.iconRes));
|
|
339
|
+
} else if (tabBarItem.iconUri != null) {
|
|
340
|
+
tab.setIcon(DrawableUtils.fromUri(context, tabBarItem.iconUri));
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (tabBarItem.unselectedIconRes > 0) {
|
|
344
|
+
tab.setUnselectedIcon(ContextCompat.getDrawable(context, tabBarItem.unselectedIconRes));
|
|
345
|
+
} else if (tabBarItem.unselectedIconUri != null) {
|
|
346
|
+
tab.setUnselectedIcon(DrawableUtils.fromUri(context, tabBarItem.unselectedIconUri));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
tab.setBadgeColor(tabBar.badgeColor);
|
|
350
|
+
tab.setBadgeText(tabBarItem.badgeText);
|
|
351
|
+
tab.setShowDotBadge(tabBarItem.showDotBadge);
|
|
352
|
+
}
|
|
353
|
+
}
|