hybrid-navigation 2.8.3 → 2.10.1

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.
Files changed (79) hide show
  1. package/HybridNavigation.podspec +6 -6
  2. package/LICENSE +1 -1
  3. package/android/build.gradle +4 -4
  4. package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +27 -40
  5. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +77 -48
  6. package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +4 -4
  7. package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +1 -8
  8. package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +94 -43
  9. package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +134 -117
  10. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +65 -35
  11. package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +14 -3
  12. package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +133 -89
  13. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +161 -126
  14. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +145 -114
  15. package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +40 -28
  16. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +96 -75
  17. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/Navigator.java +1 -1
  18. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +111 -79
  19. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +187 -117
  20. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +137 -96
  21. package/ios/HybridNavigation/ViewController/HBDModalViewController.m +7 -0
  22. package/ios/HybridNavigation/ViewController/HBDViewController+Garden.m +16 -0
  23. package/ios/HybridNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  24. package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  25. package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcuserdata/listen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  26. package/ios/HybridNavigation.xcodeproj/xcuserdata/listen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  27. package/lib/Navigator.d.ts +6 -6
  28. package/lib/ReactRegistry.d.ts +3 -3
  29. package/lib/ReactRegistry.js +14 -10
  30. package/lib/typing.d.ts +8 -8
  31. package/package.json +27 -16
  32. package/src/DeepLink.ts +60 -0
  33. package/src/Garden.ts +171 -0
  34. package/src/NavigationModule.ts +33 -0
  35. package/src/Navigator.ts +404 -0
  36. package/src/ReactRegistry.tsx +138 -0
  37. package/src/hooks.ts +83 -0
  38. package/src/index.ts +9 -0
  39. package/src/router/drawer.ts +34 -0
  40. package/src/router/index.ts +166 -0
  41. package/src/router/screen.ts +12 -0
  42. package/src/router/stack.ts +80 -0
  43. package/src/router/tabs.ts +49 -0
  44. package/src/router/typing.ts +45 -0
  45. package/src/store.ts +49 -0
  46. package/src/typing.ts +148 -0
  47. package/src/utils.ts +83 -0
  48. package/.buckconfig +0 -6
  49. package/.editorconfig +0 -16
  50. package/.eslintignore +0 -5
  51. package/.gitattributes +0 -1
  52. package/.github/workflows/docs.yml +0 -25
  53. package/CHANGELOG.md +0 -399
  54. package/babel.config.js +0 -15
  55. package/docs/README.md +0 -109
  56. package/docs/custom-tabbar.md +0 -138
  57. package/docs/deeplink.md +0 -148
  58. package/docs/integration-native.md +0 -390
  59. package/docs/integration-react.md +0 -194
  60. package/docs/lifecycle.md +0 -85
  61. package/docs/navigation.md +0 -589
  62. package/docs/pass-and-return-value.md +0 -163
  63. package/docs/qa.md +0 -57
  64. package/docs/style.md +0 -533
  65. package/jest.config.js +0 -4
  66. package/metro.config.js +0 -17
  67. package/screenshot/android.png +0 -0
  68. package/screenshot/bulge.jpg +0 -0
  69. package/screenshot/controller-base.jpg +0 -0
  70. package/screenshot/demo-qrcode.png +0 -0
  71. package/screenshot/header-search-paths.jpg +0 -0
  72. package/screenshot/ios-react-script.png +0 -0
  73. package/screenshot/ios-run-script.jpg +0 -0
  74. package/screenshot/statusbar-inperfect.png +0 -0
  75. package/screenshot/statusbar-setup-step-1.png +0 -0
  76. package/screenshot/statusbar-setup-step-2.png +0 -0
  77. package/screenshot/tabbar.jpg +0 -0
  78. package/screenshot/topbar-default.png +0 -0
  79. package/screenshot/xcode-linking.png +0 -0
package/docs/style.md DELETED
@@ -1,533 +0,0 @@
1
- # 样式和主题
2
-
3
- 一个 APP 中的风格通常是一致的,使用 `Garden.setStyle` 可以全局设置 APP 的主题。
4
-
5
- 我们提供了三种设置图片的方式
6
-
7
- 1. 加载静态图片
8
-
9
- ```ts
10
- import { Image } from 'react-native';
11
-
12
- icon: Image.resolveAssetSource(require('./images/ic_settings.png')),
13
- ```
14
-
15
- 2. 加载原生图片
16
-
17
- ```ts
18
- import { PixelRatio } from 'react-native';
19
-
20
- icon: { uri: 'flower', scale: PixelRatio.get() },
21
- ```
22
-
23
- 3. 加载网络图片(不推荐)
24
-
25
- ```ts
26
- icon: {
27
- uri: 'http://xxx.xx/?width=24&height=24&scale=3'
28
- }
29
- ```
30
-
31
- 会占用主线程,导致卡顿,并且没有缓存
32
-
33
- 4. 使用 icon font
34
-
35
- ```ts
36
- icon: { uri: fontUri('FontAwesome', 'navicon', 24)},
37
- ```
38
-
39
- 如果项目中使用了 react-native-vector-icons 这样的库,请参考 example 中 Options.js 这个文件
40
-
41
- ## 设置全局主题
42
-
43
- 我们通过 `Garden.setStyle(style: Style = {})` 来设置全局样式。可配置项如下:
44
-
45
- ```ts
46
- export interface Style {
47
- screenBackgroundColor?: Color // 页面背景,默认是白色
48
- topBarStyle?: BarStyle // 顶部导航栏样式,决定了状态栏的颜色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
49
- topBarColor?: Color // 顶部导航栏背景颜色,默认根据 topBarStyle 来计算
50
- statusBarColorAndroid?: Color // 状态栏背景颜色,默认取 topBarColor 的值
51
- navigationBarColorAndroid?: Color // 底部虚拟键背景颜色,仅对 Android 8.0 以上版本生效
52
- hideBackTitleIOS?: boolean // 是否隐藏返回按钮旁边的文字,默认是 false, 仅对 iOS 生效
53
- elevationAndroid?: number // 顶部导航栏阴影高度,默认值为 4 dp
54
- shadowImage?: ShadowImage // 顶部导航栏阴影图片,仅对 iOS 生效
55
- backIcon?: Image // 返回按钮图片
56
- topBarTintColor?: Color // 顶部导航栏按钮的颜色。默认根据 topBarStyle 来计算
57
- titleTextColor?: Color // 顶部导航栏标题颜色,默认根据 topBarStyle 来计算
58
- titleTextSize?: number // 顶部导航栏标题字体大小,默认是 17 dp(pt)
59
- titleAlignmentAndroid?: TitleAlignment // 顶部导航栏标题的位置,可选项有 `TitleAlignmentLeft` 和 `TitleAlignmentCenter` ,仅对 Android 生效
60
- barButtonItemTextSize?: number // 顶部导航栏按钮字体大小,默认是 15 dp(pt)
61
- swipeBackEnabledAndroid?: boolean // Android 是否开启侧滑返回,默认是 false
62
- scrimAlphaAndroid?: number // Android 侧滑返回遮罩效果 [0 - 255]
63
- displayCutoutWhenLandscapeAndroid: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
64
-
65
- tabBarColor?: Color // 底部 TabBar 背景颜色,请勿使用带透明度的颜色。
66
- tabBarShadowImage?: ShadowImage // 底部 TabBar 阴影图片。对于 iOS, 只有同时设置了 tabBarColor 才会生效
67
- tabBarItemColor?: Color // 底部 TabBarItem icon 选中颜色
68
- tabBarUnselectedItemColor?: Color // 底部 TabBarItem icon 未选中颜色,默认为 #BDBDBD
69
- tabBarBadgeColor?: Color // Tab badge 颜色
70
- }
71
-
72
- export type Color = string
73
- export type Image = { uri: string; scale?: number; height?: number; width?: number }
74
- export interface ShadowImage {
75
- image?: Image
76
- color?: Color
77
- }
78
-
79
- export const BarStyleLightContent = 'light-content'
80
- export const BarStyleDarkContent = 'dark-content'
81
- export type BarStyle = BarStyleLightContent | BarStyleDarkContent
82
-
83
- export const TitleAlignmentLeft = 'left'
84
- export const TitleAlignmentCenter = 'center'
85
- export type TitleAlignment = TitleAlignmentCenter | TitleAlignmentLeft
86
- ```
87
-
88
- > 全局设置主题,有些样式需要重新运行原生应用才能看到效果。
89
-
90
- > 所有关于颜色的设置,仅支持 #AARRGGBB 或者 #RRGGBB 格式的字符。
91
-
92
- > 所有可配置项均是可选
93
-
94
- - **topBarStyle**
95
-
96
- 导航栏和状态栏前景色,在 iOS 中,默认是白底黑字,在 Android 中,默认是黑底白字。
97
-
98
- 可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`,在 Android 6.0 效果如下:
99
-
100
- ![style-2021-10-19-15-43-21](https://todoit.oss-cn-shanghai.aliyuncs.com/todoit/style-2021-10-19-15-43-21.png)
101
-
102
- - **statusBarColorAndroid**
103
-
104
- 默认取 `topBarColor` 的值。
105
-
106
- 系统启动时,由于还没有设置 statusBarColor,状态栏颜色会出现前后不一致的情况,下图是应用还没启动好时,状态栏可能的颜色。和上面的黑白图对比,是不是有种违和感。
107
-
108
- ![style-2021-10-19-15-43-53](https://todoit.oss-cn-shanghai.aliyuncs.com/todoit/style-2021-10-19-15-43-53.png)
109
-
110
- 为了提供一致的用户体验,你可以为 Android 配置 `andriod:statusBarColor` 样式。
111
-
112
- 1.在 res 目录下新建一个名为 values-v21 的文件夹
113
-
114
- ![style-2021-10-19-15-44-13](https://todoit.oss-cn-shanghai.aliyuncs.com/todoit/style-2021-10-19-15-44-13.png)
115
-
116
- 2.在 values-v21 文件夹新建一个名为 styles.xml 的资源文件
117
-
118
- ![style-2021-10-19-15-44-33](https://todoit.oss-cn-shanghai.aliyuncs.com/todoit/style-2021-10-19-15-44-33.png)
119
-
120
- 3.双击打开 values-v21 目录中的 styles.xml 文件,把 App 主题样式 `andriod:statusBarColor` 的值设置成和你用 Garden 设置的一样。
121
-
122
- ```ts
123
- import { Garden } from 'hybrid-navigation'
124
-
125
- Garden.setStyle({
126
- statusBarColor: '#ffffff',
127
- })
128
- ```
129
-
130
- ```xml
131
- <?xml version="1.0" encoding="utf-8"?>
132
- <resources>
133
- <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
134
- <item name="android:statusBarColor">#ffffff</item>
135
- </style>
136
- </resources>
137
- ```
138
-
139
- 现在,应用启动时和启动完成后的状态栏颜色是一致的了。
140
-
141
- - **shadowImage**
142
-
143
- 导航栏阴影图片,仅对 iOS 生效。
144
-
145
- ```ts
146
- // index.js
147
-
148
- import { Image } from 'react-native'
149
- import { Garden } from 'hybrid-navigation'
150
-
151
- Garden.setStyle({
152
- shadowImage: {
153
- // color 和 image 二选其一,如果选择 color ,默认生成 1 dp(pt) 高度的纯色图片
154
- color: '#cccccc',
155
- // image: Image.resolveAssetSource(require('./divider.png'))
156
- },
157
- })
158
- ```
159
-
160
- shadowImage 会有一个默认值,如果你想去掉,可以这样设置
161
-
162
- ```ts
163
- Garden.setStyle({
164
- shadowImage: {},
165
- })
166
- ```
167
-
168
- - **backIcon**
169
-
170
- 配置返回按钮的图标。如果不配置,则采用平台默认的图标。配置方式如下
171
-
172
- ```ts
173
- // index.js
174
-
175
- import { Image } from 'react-native'
176
- import { Garden } from 'hybrid-navigation'
177
-
178
- Garden.setStyle({
179
- backIcon: Image.resolveAssetSource(require('./ic_back.png')),
180
- })
181
- ```
182
-
183
- - **tabBarShadowImage**
184
-
185
- UITabBar(iOS)、BottomNavigationBar(Android) 的阴影图片。对于 iOS, 只有设置了 tabBarColor 才会生效。
186
-
187
- 配置方式请参考 `shadowImage`
188
-
189
- - **navigationBarColorAndroid**
190
-
191
- 用于修改底部虚拟键的背景颜色,对 Andriod 8.0 以上版本生效。默认规则如下:
192
-
193
- - 含「底部 Tab」的页面,虚拟键设置为「底部 Tab」的颜色
194
-
195
- - 不含「底部 Tab」的页面,默认使用页面背景颜色,也就是 screenBackgroundColor
196
-
197
- - modal 默认是透明色
198
-
199
- 一旦全局设置了 navigationBarColorAndroid,默认规则就会失效。
200
-
201
- <a name="static-options"></a>
202
-
203
- ## 静态配置页面
204
-
205
- 每个页面的标题、按钮,通常是固定的,我们可以通过静态的方式来配置。
206
-
207
- 我们需要在页面实现 `navigationItem` 这个静态字段,完整的可配置项如下:
208
-
209
- ```ts
210
- class Screen extends Component {
211
- static navigationItem = {
212
- passThroughTouches: false, // 触摸事件是否可以穿透到下一层页面,很少用。
213
- screenBackgroundColor: '#FFFFFF', // 当前页面背景
214
- topBarStyle: string, // 状态栏和导航栏前景色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
215
- topBarColor: '#FDFF0000', // 当前页面顶部导航栏背景颜色,如果颜色带有透明度,则页面会延伸到 topBar 底下。
216
- topBarAlpha: 0.5, // 当前页面顶部导航背景透明度
217
- extendedLayoutIncludesTopBar: false, // 当前页面的内容是否延伸到 topBar 底下,通常用于需要动态改变 `topBarAlpha` 的场合
218
- topBarTintColor: '#FFFFFF', // 当前页面按钮颜色
219
- titleTextColor: '#FFFFFF', // 当前页面标题颜色
220
- titleTextSize: Int, // 当前页面顶部导航栏标题字体大小
221
- topBarShadowHidden: true, // 是否隐藏当前页面 topBar 的阴影
222
- topBarHidden: true, // 是否隐藏当前页面 topBar
223
- statusBarHidden: true, // 是否隐藏当前页面的状态栏,对 iPhoneX 无效
224
- statusBarColorAndroid: string, // 状态栏颜色,仅对 Android 生效
225
- navigationBarColorAndroid: string, // 底部虚拟键背景颜色,仅对 Android 8.0 以上版本生效
226
- navigationBarHiddenAndroid: boolean, // 是否隐藏 Android 底部的虚拟导航栏
227
- displayCutoutWhenLandscapeAndroid: boolean, // 横屏时,是否将界面延伸至刘海区域,默认 true
228
- homeIndicatorAutoHiddenIOS: boolean // 是否隐藏 Home 指示器,默认 false
229
-
230
- backButtonHidden: true, // 当前页面是否隐藏返回按钮
231
- backInteractive: true, // 当前页面是否可以通过右滑或返回键返回
232
- swipeBackEnabled: true, // 当前页面是否可以通过右滑返回。如果 `backInteractive` 设置为 false, 那么该值无效。Android 下,只有开启了侧滑返回功能,该值才会生效。
233
-
234
- titleItem: {
235
- // 导航栏标题
236
- tilte: '这是标题',
237
- // 自定义标题栏模块名
238
- moduleName: 'ModuleName',
239
- // 自定义标题栏填充模式,可选项有 `LayoutFittingExpanded` 和 `LayoutFittingCompressed`。仅对自定义标题模块生效
240
- layoutFitting: 'expanded',
241
- },
242
-
243
- // 导航栏左侧按钮
244
- leftBarButtonItem: {
245
- // 按钮文字,如果设置了 icon ,将会失效
246
- title: '按钮',
247
- // icon 图片
248
- icon: Image.resolveAssetSource(require('./ic_settings.png')),
249
- // 图片位置调整,仅对 iOS 生效
250
- insetsIOS: { top: -1, left: -8, bottom: 0, right: 0 },
251
- // 按钮点击事件处理
252
- action: navigator => {
253
- navigator.toggleMenu()
254
- },
255
- // 按钮是否可以点击
256
- enabled: true,
257
- // 按钮颜色
258
- tintColor: '#FFFF00', // 默认取 topBarTintColor 的值
259
- renderOriginal: true, // 是否保留图片原来的颜色,默认为 false,如果该值为 true,tintColor 将失效
260
- },
261
-
262
- rightBarButtonItem: {
263
- // 导航栏右侧按钮
264
- // 可配置项同 leftBarButtonItem
265
- },
266
-
267
- leftBarButtonItems: [
268
- {
269
- // 可配置项同 leftBarButtonItem
270
- },
271
- {
272
- // 可配置项同 leftBarButtonItem
273
- },
274
- ],
275
-
276
- rightBarButtonItems: [
277
- {
278
- // 可配置项同 leftBarButtonItem
279
- },
280
- {
281
- // 可配置项同 leftBarButtonItem
282
- },
283
- ],
284
-
285
- // 返回按钮文字和颜色,仅对 iOS 生效
286
- backItemIOS: {
287
- title: 'Back',
288
- tintColor: '#000000', // 仅对 iOS 11.0 以上生效
289
- },
290
-
291
- // 底部 TabBarItem 可配置项
292
- tabItem: {
293
- // tab 标题文字
294
- title: 'Style',
295
- // tab 图片,可选
296
- icon: { uri: fontUri('FontAwesome', 'leaf', 20) },
297
- // tab 未选中时的图片,可选,只有设置了 icon,unselectedIcon 才会生效
298
- unselectedIcon: { uri: fontUri('FontAwesome', 'leaf', 20) },
299
- // push 时是否隐藏 tabBar
300
- hideTabBarWhenPush: true,
301
- },
302
- }
303
- }
304
- ```
305
-
306
- - **extendedLayoutIncludesTopBar**
307
-
308
- 默认情况下,这个值根据 `topBarColor` 的初始值计算得出,如果 `topBarColor` 含有透明度,那么这个值为 true,否则为 false。通常用于需要动态改变 `topBarAlpha` 的场合。参看 [example/TopBarAlpha](https://github.com/listenzz/hybrid-navigation/blob/master/example/src/TopBarAlpha.js) 这个例子。
309
-
310
- - **titleItem**
311
-
312
- 如果希望自定义标题栏,可以通过 moduleName 来指定标题栏对应的组件。组件需要通过 ReactRegistry.registerComponent 注册。一旦设置了 moduleName,title 字段将失效。
313
-
314
- layoutFitting 配合 moduleName 使用,自定义标题栏的布局模式,有 expanded 和 compressed 两个可选值,默认是 compressed。 expanded 是指尽可能占据更多的空间, compressed 是指刚好能包裹自身内容。
315
-
316
- 当自定义标题栏时,可能需要将 backButtonHidden 设置为 true,以为标题栏提供更多的空间。
317
-
318
- 标题栏和所属页面共享同一个 navigator 对象,你可以在所属页面通过以下方式传递参数给标题栏使用
319
-
320
- ```ts
321
- navigator.setParams({})
322
- ```
323
-
324
- 详情请参考 example 中 TopBarTitleView.js 这个文件。
325
-
326
- - **tabItem**
327
-
328
- 如果同时设置了 icon 与 unselectedIcon, 则保留图片原始颜色,否则用全局配置中的 `tabBarItemColor` 与 `tabBarUnselectedItemColor` 对 icon 进行染色。
329
-
330
- hideTabBarWhenPush 表示当 stack 嵌套在 tabs 的时候,push 到另一个页面时是否隐藏 TabBar。
331
-
332
- - **navigationBarColorAndroid**
333
-
334
- 用于修改虚拟键的背景颜色,对 Andriod 8.0 以上版本生效。默认规则如下:
335
-
336
- - 含「底部 Tab」的页面,虚拟键设置为「底部 Tab」的颜色
337
-
338
- - 不含「底部 Tab」的页面,默认使用页面背景颜色,也就是 screenBackgroundColor
339
-
340
- - modal 默认是透明色
341
-
342
- 某些页面,比如从底部往上滑的 modal, 需要开发者使用 navigationBarColorAndroid 自行适配,请参考 example/src/ReactModal.js 这个文件
343
-
344
- ## 动态配置页面
345
-
346
- 有时,需要根据业务状态来动态改变导航栏中的项目。比如 rightBarButtonItem 是否可以点击,就是个很好的例子。
347
-
348
- 动态配置页面有两种方式,一种是页面跳转时,由前一个页面决定后一个页面的配置(传值配置)。另一种是当前页面根据应用状态来动态改变(动态配置)。
349
-
350
- ### 传值配置
351
-
352
- 譬如以下是 B 页面的静态配置
353
-
354
- ```ts
355
- // B.js
356
- class B extends Component {
357
- static navigationItem = {
358
- titleItem: {
359
- tilte: 'B 的标题',
360
- },
361
- rightBarButtonItem: {
362
- title: 'B 的按钮',
363
- action: navigator => {},
364
- },
365
- }
366
- }
367
- ```
368
-
369
- 正常情况下,B 的导航栏标题是 _B 的标题_,导航栏右侧按钮的标题是 _B 的按钮_。
370
-
371
- 从 A 页面跳转到 B 页面时,我们可以改变 B 页面中的静态设置
372
-
373
- ```ts
374
- // A.js
375
- this.props.navigator.push(
376
- 'B',
377
- {
378
- /*props*/
379
- },
380
- {
381
- titleItem: {
382
- title: '来自 A 的标题',
383
- },
384
- rightBarButtonItem: {
385
- title: '来自 A 的按钮',
386
- },
387
- },
388
- )
389
- ```
390
-
391
- 那么,如果 B 页面是从 A 跳过来的,那么 B 的导航栏标题就会变成 _来自 A 的标题_ ,导航栏右侧按钮的标题就会变成 _来自 A 的按钮_。
392
-
393
- ### 动态配置
394
-
395
- Garden 提供了一些实例方法,来帮助我们动态改变这些项目。
396
-
397
- - **updateOptions(options: NavigationOption)**
398
-
399
- 动态改变设置, 可配置项如下
400
-
401
- ```ts
402
- export interface NavigationOption {
403
- passThroughTouches?: boolean // 触摸事件是否可以穿透到下一层页面,很少用。
404
- statusBarHidden?: boolean // 是否隐藏状态栏
405
- statusBarColorAndroid?: Color // 状态栏背景颜色
406
- topBarStyle?: BarStyle // 顶部导航栏样式,决定了状态栏的颜色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
407
- topBarColor?: Color // 当前页面顶部导航栏背景颜色
408
- topBarShadowHidden?: boolean // 是否隐藏当前页面导航栏的阴影
409
- topBarAlpha?: number // 当前页面顶部导航栏背景透明度
410
- topBarTintColor?: Color // 当前页面按钮颜色
411
- titleTextColor?: Color // 当前页面顶部导航栏标题字体颜色
412
- titleTextSize?: number // 当前页面顶部导航栏标题字体大小
413
- navigationBarColorAndroid?: Color // Android 底部虚拟按钮背景颜色
414
- navigationBarHiddenAndroid: boolean // 是否隐藏 Android 底部的虚拟导航栏
415
- displayCutoutWhenLandscapeAndroid: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
416
- homeIndicatorAutoHiddenIOS: boolean // 是否隐藏 Home 指示器,默认 false
417
- backButtonHidden?: boolean // 是否显示返回按钮
418
- backInteractive?: boolean // 是否允许侧滑返回或通过返回键返回
419
- }
420
- ```
421
-
422
- - **setTitleItem(titleItem: TitleItem)**
423
-
424
- 更改标题
425
-
426
- ```ts
427
- export interface TitleItem {
428
- title?: string
429
- }
430
- ```
431
-
432
- ```ts
433
- garden.setTitleItem({
434
- title: '新的标题',
435
- })
436
- ```
437
-
438
- - **setLeftBarButtonItem(buttonItem: BarButtonItem)**
439
-
440
- 更改左侧按钮
441
-
442
- ```ts
443
- export interface BarButtonItem {
444
- title?: string
445
- icon?: Image
446
- insetsIOS?: Insets
447
- action?: string | Action
448
- enabled?: boolean
449
- tintColor?: Color
450
- renderOriginal?: boolean
451
- }
452
- ```
453
-
454
- ```ts
455
- garden.setLeftBarButtonItem({
456
- title: 'Cancel',
457
- insetsIOS: { top: -1, left: -8, bottom: 0, right: 8 },
458
- action: navigator => {
459
- navigator.dismiss()
460
- },
461
- })
462
- ```
463
-
464
- - **setRightBarButtonItem(buttonItem: BarButtonItem)**
465
-
466
- 更改右侧按钮
467
-
468
- ```ts
469
- garden.setRightBarButtonItem({
470
- enabled: false,
471
- })
472
- ```
473
-
474
- - **updateTabBar**
475
-
476
- 动态改变 tabBar 样式, 可配置项如下
477
-
478
- ```ts
479
- garden.updateTabBar({
480
- tabBarColor: '#FFFFFF',
481
- tabBarShadowImage: {
482
- color: '#DDDDDD',
483
- // image: Image.resolveAssetSource(require('./src/images/divider.png')),
484
- },
485
- tabBarItemColor: '#8BC34A',
486
- tabBarUnselectedItemColor: '#BDBDBD',
487
- })
488
- ```
489
-
490
- - **setTabItem(item: TabItemInfo | TabItemInfo[])**
491
-
492
- 动态设置 tab 的图标、文字、徽章
493
-
494
- ```ts
495
- export interface TabItemInfo {
496
- index: number
497
- title?: string
498
- badge?: {
499
- text?: string
500
- hidden: boolean
501
- dot?: boolean
502
- }
503
- icon?: {
504
- selected: ImageSource
505
- unselected?: ImageSource
506
- }
507
- }
508
- ```
509
-
510
- ```ts
511
- garden.setTabItem({
512
- index: 1,
513
- icon: {
514
- selected: Image.resolveAssetSource(require('./images/ic_settings.png')),
515
- },
516
- title: '选项',
517
- })
518
- ```
519
-
520
- - **setMenuInteractive(enabled: boolean)**
521
-
522
- 是否允许侧滑打开抽屉
523
-
524
- ```ts
525
- useVisibleEffect(
526
- useCallback(() => {
527
- garden.setMenuInteractive(true)
528
- return () => {
529
- garden.setMenuInteractive(false)
530
- }
531
- }, [garden]),
532
- )
533
- ```
package/jest.config.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- preset: 'react-native',
3
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
4
- }
package/metro.config.js DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Metro configuration for React Native
3
- * https://github.com/facebook/react-native
4
- *
5
- * @format
6
- */
7
-
8
- module.exports = {
9
- transformer: {
10
- getTransformOptions: async () => ({
11
- transform: {
12
- experimentalImportSupport: false,
13
- inlineRequires: true,
14
- },
15
- }),
16
- },
17
- }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file