hybrid-navigation 2.4.2 → 2.6.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/CHANGELOG.md +26 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Constants.java +1 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +13 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +12 -29
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +47 -49
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +35 -55
- package/docs/README.md +3 -3
- package/docs/custom-tabbar.md +1 -1
- package/docs/deeplink.md +1 -1
- package/docs/integration-native.md +2 -2
- package/docs/integration-react.md +1 -1
- package/docs/qa.md +17 -0
- package/docs/style.md +52 -67
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +3 -13
- package/ios/HybridNavigation/HBDUtils.m +0 -8
- package/ios/HybridNavigation/View/HBDNavigationBar.h +1 -0
- package/ios/HybridNavigation/View/HBDNavigationBar.m +4 -0
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +27 -14
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -3
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +34 -33
- package/ios/HybridNavigation/ViewController/HBDViewController.m +5 -0
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +49 -18
- package/lib/Garden.d.ts +14 -0
- package/lib/Garden.js +33 -2
- package/lib/typing.d.ts +1 -0
- package/package.json +7 -7
- package/docs/.vuepress/.cache/default-development/0.pack +0 -0
- package/docs/.vuepress/.cache/default-development/1.pack +0 -0
- package/docs/.vuepress/.cache/default-development/10.pack +0 -0
- package/docs/.vuepress/.cache/default-development/11.pack +0 -0
- package/docs/.vuepress/.cache/default-development/12.pack +0 -0
- package/docs/.vuepress/.cache/default-development/13.pack +0 -0
- package/docs/.vuepress/.cache/default-development/14.pack +0 -0
- package/docs/.vuepress/.cache/default-development/15.pack +0 -0
- package/docs/.vuepress/.cache/default-development/16.pack +0 -0
- package/docs/.vuepress/.cache/default-development/17.pack +0 -0
- package/docs/.vuepress/.cache/default-development/18.pack +0 -0
- package/docs/.vuepress/.cache/default-development/19.pack +0 -0
- package/docs/.vuepress/.cache/default-development/2.pack +0 -0
- package/docs/.vuepress/.cache/default-development/20.pack +0 -0
- package/docs/.vuepress/.cache/default-development/21.pack +0 -0
- package/docs/.vuepress/.cache/default-development/3.pack +0 -0
- package/docs/.vuepress/.cache/default-development/4.pack +0 -0
- package/docs/.vuepress/.cache/default-development/5.pack +0 -0
- package/docs/.vuepress/.cache/default-development/6.pack +0 -0
- package/docs/.vuepress/.cache/default-development/7.pack +0 -0
- package/docs/.vuepress/.cache/default-development/8.pack +0 -0
- package/docs/.vuepress/.cache/default-development/9.pack +0 -0
- package/docs/.vuepress/.cache/default-development/index.pack +0 -0
- package/docs/.vuepress/.cache/default-development/index.pack.old +0 -0
- package/docs/.vuepress/.cache/default-production/0.pack +0 -0
- package/docs/.vuepress/.cache/default-production/1.pack +0 -0
- package/docs/.vuepress/.cache/default-production/2.pack +0 -0
- package/docs/.vuepress/.cache/default-production/index.pack +0 -0
- package/docs/.vuepress/.cache/default-production/index.pack.old +0 -0
- package/docs/.vuepress/.temp/internal/clientAppEnhances.js +0 -9
- package/docs/.vuepress/.temp/internal/clientAppRootComponents.js +0 -5
- package/docs/.vuepress/.temp/internal/clientAppSetups.js +0 -9
- package/docs/.vuepress/.temp/internal/layoutComponents.js +0 -6
- package/docs/.vuepress/.temp/internal/pagesComponents.js +0 -26
- package/docs/.vuepress/.temp/internal/pagesData.js +0 -24
- package/docs/.vuepress/.temp/internal/pagesRoutes.js +0 -40
- package/docs/.vuepress/.temp/internal/siteData.js +0 -8
- package/docs/.vuepress/.temp/internal/themeData.js +0 -75
- package/docs/.vuepress/.temp/pages/404.html.js +0 -13
- package/docs/.vuepress/.temp/pages/404.html.vue +0 -1
- package/docs/.vuepress/.temp/pages/custom-tabbar.html.js +0 -32
- package/docs/.vuepress/.temp/pages/custom-tabbar.html.vue +0 -107
- package/docs/.vuepress/.temp/pages/deeplink.html.js +0 -50
- package/docs/.vuepress/.temp/pages/deeplink.html.vue +0 -93
- package/docs/.vuepress/.temp/pages/index.html.js +0 -51
- package/docs/.vuepress/.temp/pages/index.html.vue +0 -95
- package/docs/.vuepress/.temp/pages/integration-native.html.js +0 -38
- package/docs/.vuepress/.temp/pages/integration-native.html.vue +0 -292
- package/docs/.vuepress/.temp/pages/integration-react.html.js +0 -57
- package/docs/.vuepress/.temp/pages/integration-react.html.vue +0 -133
- package/docs/.vuepress/.temp/pages/lifecycle.html.js +0 -26
- package/docs/.vuepress/.temp/pages/lifecycle.html.vue +0 -69
- package/docs/.vuepress/.temp/pages/navigation.html.js +0 -50
- package/docs/.vuepress/.temp/pages/navigation.html.vue +0 -406
- package/docs/.vuepress/.temp/pages/pass-and-return-value.html.js +0 -51
- package/docs/.vuepress/.temp/pages/pass-and-return-value.html.vue +0 -94
- package/docs/.vuepress/.temp/pages/qa.html.js +0 -26
- package/docs/.vuepress/.temp/pages/qa.html.vue +0 -27
- package/docs/.vuepress/.temp/pages/style.html.js +0 -45
- package/docs/.vuepress/.temp/pages/style.html.vue +0 -452
- package/docs/.vuepress/.temp/styles/index.scss +0 -0
- package/docs/.vuepress/.temp/styles/palette.scss +0 -0
- package/docs/.vuepress/config.js +0 -51
- package/docs/.vuepress/dist/404.html +0 -15
- package/docs/.vuepress/dist/assets/css/styles.701e6109.css +0 -8
- package/docs/.vuepress/dist/assets/img/android.e350dcdd.png +0 -0
- package/docs/.vuepress/dist/assets/img/back-to-top.8b37f773.svg +0 -1
- package/docs/.vuepress/dist/assets/img/controller-base.96c0200f.jpg +0 -0
- package/docs/.vuepress/dist/assets/img/ios-react-script.6692a449.png +0 -0
- package/docs/.vuepress/dist/assets/img/ios-run-script.67339d42.jpg +0 -0
- package/docs/.vuepress/dist/assets/img/statusbar-inperfect.f32cfca0.png +0 -0
- package/docs/.vuepress/dist/assets/img/statusbar-setup-step-1.2669257d.png +0 -0
- package/docs/.vuepress/dist/assets/img/statusbar-setup-step-2.b18151ed.png +0 -0
- package/docs/.vuepress/dist/assets/img/tabbar.73212e13.jpg +0 -0
- package/docs/.vuepress/dist/assets/img/topbar-default.65d36143.png +0 -0
- package/docs/.vuepress/dist/assets/img/xcode-linking.685ce6ea.png +0 -0
- package/docs/.vuepress/dist/assets/js/293.071a173a.js +0 -1
- package/docs/.vuepress/dist/assets/js/491.4e0b3b61.js +0 -1
- package/docs/.vuepress/dist/assets/js/812.0c9a2f53.js +0 -2
- package/docs/.vuepress/dist/assets/js/812.0c9a2f53.js.LICENSE.txt +0 -8
- package/docs/.vuepress/dist/assets/js/app.a66f731a.js +0 -1
- package/docs/.vuepress/dist/assets/js/runtime~app.19128f21.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-123dff2c.47243fa1.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-3706649a.6536ff4d.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-384da568.667de1bc.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-44439230.8b89f9cb.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-548f4cfe.61f40391.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-6be4efb0.ec3640c3.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-77faca8c.ee876cd7.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-7900994c.059cfff8.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-7d5b94d0.b90251d7.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-8daa1a0e.eced6c93.js +0 -1
- package/docs/.vuepress/dist/assets/js/v-d11cd4e0.ca9b65ee.js +0 -1
- package/docs/.vuepress/dist/custom-tabbar.html +0 -105
- package/docs/.vuepress/dist/deeplink.html +0 -69
- package/docs/.vuepress/dist/index.html +0 -44
- package/docs/.vuepress/dist/integration-native.html +0 -258
- package/docs/.vuepress/dist/integration-react.html +0 -109
- package/docs/.vuepress/dist/lifecycle.html +0 -74
- package/docs/.vuepress/dist/navigation.html +0 -208
- package/docs/.vuepress/dist/pass-and-return-value.html +0 -74
- package/docs/.vuepress/dist/qa.html +0 -31
- package/docs/.vuepress/dist/style.html +0 -306
package/docs/style.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
1. 加载静态图片
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```ts
|
|
10
10
|
import { Image } from 'react-native';
|
|
11
11
|
|
|
12
12
|
icon: Image.resolveAssetSource(require('./images/ic_settings.png')),
|
|
@@ -14,7 +14,7 @@ icon: Image.resolveAssetSource(require('./images/ic_settings.png')),
|
|
|
14
14
|
|
|
15
15
|
2. 加载原生图片
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```ts
|
|
18
18
|
import { PixelRatio } from 'react-native';
|
|
19
19
|
|
|
20
20
|
icon: { uri: 'flower', scale: PixelRatio.get() },
|
|
@@ -22,7 +22,7 @@ icon: { uri: 'flower', scale: PixelRatio.get() },
|
|
|
22
22
|
|
|
23
23
|
3. 加载网络图片(不推荐)
|
|
24
24
|
|
|
25
|
-
```
|
|
25
|
+
```ts
|
|
26
26
|
icon: {
|
|
27
27
|
uri: 'http://xxx.xx/?width=24&height=24&scale=3'
|
|
28
28
|
}
|
|
@@ -32,7 +32,7 @@ icon: {
|
|
|
32
32
|
|
|
33
33
|
4. 使用 icon font
|
|
34
34
|
|
|
35
|
-
```
|
|
35
|
+
```ts
|
|
36
36
|
icon: { uri: fontUri('FontAwesome', 'navicon', 24)},
|
|
37
37
|
```
|
|
38
38
|
|
|
@@ -97,7 +97,7 @@ export type TitleAlignment = TitleAlignmentCenter | TitleAlignmentLeft
|
|
|
97
97
|
|
|
98
98
|
可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`,在 Android 6.0 效果如下:
|
|
99
99
|
|
|
100
|
-

|
|
101
101
|
|
|
102
102
|
- **statusBarColorAndroid**
|
|
103
103
|
|
|
@@ -105,21 +105,21 @@ export type TitleAlignment = TitleAlignmentCenter | TitleAlignmentLeft
|
|
|
105
105
|
|
|
106
106
|
系统启动时,由于还没有设置 statusBarColor,状态栏颜色会出现前后不一致的情况,下图是应用还没启动好时,状态栏可能的颜色。和上面的黑白图对比,是不是有种违和感。
|
|
107
107
|
|
|
108
|
-

|
|
109
109
|
|
|
110
110
|
为了提供一致的用户体验,你可以为 Android 配置 `andriod:statusBarColor` 样式。
|
|
111
111
|
|
|
112
112
|
1.在 res 目录下新建一个名为 values-v21 的文件夹
|
|
113
113
|
|
|
114
|
-

|
|
115
115
|
|
|
116
116
|
2.在 values-v21 文件夹新建一个名为 styles.xml 的资源文件
|
|
117
117
|
|
|
118
|
-

|
|
119
119
|
|
|
120
120
|
3.双击打开 values-v21 目录中的 styles.xml 文件,把 App 主题样式 `andriod:statusBarColor` 的值设置成和你用 Garden 设置的一样。
|
|
121
121
|
|
|
122
|
-
```
|
|
122
|
+
```ts
|
|
123
123
|
import { Garden } from 'hybrid-navigation'
|
|
124
124
|
|
|
125
125
|
Garden.setStyle({
|
|
@@ -142,7 +142,7 @@ Garden.setStyle({
|
|
|
142
142
|
|
|
143
143
|
导航栏阴影图片,仅对 iOS 生效。
|
|
144
144
|
|
|
145
|
-
```
|
|
145
|
+
```ts
|
|
146
146
|
// index.js
|
|
147
147
|
|
|
148
148
|
import { Image } from 'react-native'
|
|
@@ -159,7 +159,7 @@ Garden.setStyle({
|
|
|
159
159
|
|
|
160
160
|
shadowImage 会有一个默认值,如果你想去掉,可以这样设置
|
|
161
161
|
|
|
162
|
-
```
|
|
162
|
+
```ts
|
|
163
163
|
Garden.setStyle({
|
|
164
164
|
shadowImage: {},
|
|
165
165
|
})
|
|
@@ -169,7 +169,7 @@ Garden.setStyle({
|
|
|
169
169
|
|
|
170
170
|
配置返回按钮的图标。如果不配置,则采用平台默认的图标。配置方式如下
|
|
171
171
|
|
|
172
|
-
```
|
|
172
|
+
```ts
|
|
173
173
|
// index.js
|
|
174
174
|
|
|
175
175
|
import { Image } from 'react-native'
|
|
@@ -206,7 +206,7 @@ UITabBar(iOS)、BottomNavigationBar(Android) 的阴影图片。对于 iOS, 只
|
|
|
206
206
|
|
|
207
207
|
我们需要在页面实现 `navigationItem` 这个静态字段,完整的可配置项如下:
|
|
208
208
|
|
|
209
|
-
```
|
|
209
|
+
```ts
|
|
210
210
|
class Screen extends Component {
|
|
211
211
|
static navigationItem = {
|
|
212
212
|
passThroughTouches: false, // 触摸事件是否可以穿透到下一层页面,很少用。
|
|
@@ -317,8 +317,8 @@ layoutFitting 配合 moduleName 使用,自定义标题栏的布局模式,有
|
|
|
317
317
|
|
|
318
318
|
标题栏和所属页面共享同一个 navigator 对象,你可以在所属页面通过以下方式传递参数给标题栏使用
|
|
319
319
|
|
|
320
|
-
```
|
|
321
|
-
|
|
320
|
+
```ts
|
|
321
|
+
navigator.setParams({})
|
|
322
322
|
```
|
|
323
323
|
|
|
324
324
|
详情请参考 example 中 TopBarTitleView.js 这个文件。
|
|
@@ -351,7 +351,7 @@ hideTabBarWhenPush 表示当 stack 嵌套在 tabs 的时候,push 到另一个
|
|
|
351
351
|
|
|
352
352
|
譬如以下是 B 页面的静态配置
|
|
353
353
|
|
|
354
|
-
```
|
|
354
|
+
```ts
|
|
355
355
|
// B.js
|
|
356
356
|
class B extends Component {
|
|
357
357
|
static navigationItem = {
|
|
@@ -370,7 +370,7 @@ class B extends Component {
|
|
|
370
370
|
|
|
371
371
|
从 A 页面跳转到 B 页面时,我们可以改变 B 页面中的静态设置
|
|
372
372
|
|
|
373
|
-
```
|
|
373
|
+
```ts
|
|
374
374
|
// A.js
|
|
375
375
|
this.props.navigator.push(
|
|
376
376
|
'B',
|
|
@@ -430,7 +430,7 @@ export interface TitleItem {
|
|
|
430
430
|
```
|
|
431
431
|
|
|
432
432
|
```ts
|
|
433
|
-
|
|
433
|
+
garden.setTitleItem({
|
|
434
434
|
title: '新的标题',
|
|
435
435
|
})
|
|
436
436
|
```
|
|
@@ -451,8 +451,8 @@ export interface BarButtonItem {
|
|
|
451
451
|
}
|
|
452
452
|
```
|
|
453
453
|
|
|
454
|
-
```
|
|
455
|
-
|
|
454
|
+
```ts
|
|
455
|
+
garden.setLeftBarButtonItem({
|
|
456
456
|
title: 'Cancel',
|
|
457
457
|
insetsIOS: { top: -1, left: -8, bottom: 0, right: 8 },
|
|
458
458
|
action: navigator => {
|
|
@@ -465,8 +465,8 @@ this.props.garden.setLeftBarButtonItem({
|
|
|
465
465
|
|
|
466
466
|
更改右侧按钮
|
|
467
467
|
|
|
468
|
-
```
|
|
469
|
-
|
|
468
|
+
```ts
|
|
469
|
+
garden.setRightBarButtonItem({
|
|
470
470
|
enabled: false,
|
|
471
471
|
})
|
|
472
472
|
```
|
|
@@ -475,8 +475,8 @@ this.props.garden.setRightBarButtonItem({
|
|
|
475
475
|
|
|
476
476
|
动态改变 tabBar 样式, 可配置项如下
|
|
477
477
|
|
|
478
|
-
```
|
|
479
|
-
|
|
478
|
+
```ts
|
|
479
|
+
garden.updateTabBar({
|
|
480
480
|
tabBarColor: '#FFFFFF',
|
|
481
481
|
tabBarShadowImage: {
|
|
482
482
|
color: '#DDDDDD',
|
|
@@ -487,62 +487,47 @@ this.props.garden.updateTabBar({
|
|
|
487
487
|
})
|
|
488
488
|
```
|
|
489
489
|
|
|
490
|
-
- **
|
|
490
|
+
- **setTabItem(item: TabItemInfo | TabItemInfo[])**
|
|
491
491
|
|
|
492
|
-
|
|
492
|
+
动态设置 tab 的图标、文字、徽章
|
|
493
493
|
|
|
494
494
|
```ts
|
|
495
|
-
export interface
|
|
495
|
+
export interface TabItemInfo {
|
|
496
496
|
index: number
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
title?: string
|
|
498
|
+
badge?: {
|
|
499
|
+
text?: string
|
|
500
|
+
hidden: boolean
|
|
501
|
+
dot?: boolean
|
|
502
|
+
}
|
|
503
|
+
icon?: {
|
|
504
|
+
selected: ImageSource
|
|
505
|
+
unselected?: ImageSource
|
|
506
|
+
}
|
|
499
507
|
}
|
|
500
508
|
```
|
|
501
509
|
|
|
502
|
-
```
|
|
503
|
-
|
|
510
|
+
```ts
|
|
511
|
+
garden.setTabItem({
|
|
504
512
|
index: 1,
|
|
505
|
-
icon: {
|
|
513
|
+
icon: {
|
|
514
|
+
selected: Image.resolveAssetSource(require('./images/ic_settings.png')),
|
|
515
|
+
},
|
|
516
|
+
title: '选项',
|
|
506
517
|
})
|
|
507
518
|
```
|
|
508
519
|
|
|
509
|
-
- **setTabBadge(badge: TabBadge | TabBadge[])**
|
|
510
|
-
|
|
511
|
-
设置 badge
|
|
512
|
-
|
|
513
|
-
```ts
|
|
514
|
-
export interface TabBadge {
|
|
515
|
-
index: number
|
|
516
|
-
text?: string
|
|
517
|
-
hidden: boolean
|
|
518
|
-
dot?: boolean // 是否作为红点显示
|
|
519
|
-
}
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
```javascript
|
|
523
|
-
if (hideBadge) {
|
|
524
|
-
this.props.garden.setTabBadge([
|
|
525
|
-
{ index: 0, hidden: true },
|
|
526
|
-
{ index: 1, hidden: true },
|
|
527
|
-
])
|
|
528
|
-
} else {
|
|
529
|
-
this.props.garden.setTabBadge([
|
|
530
|
-
{ index: 0, hidden: false, dot: true },
|
|
531
|
-
{ index: 1, hidden: false, text: '99' },
|
|
532
|
-
])
|
|
533
|
-
}
|
|
534
|
-
```
|
|
535
|
-
|
|
536
520
|
- **setMenuInteractive(enabled: boolean)**
|
|
537
521
|
|
|
538
522
|
是否允许侧滑打开抽屉
|
|
539
523
|
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
524
|
+
```ts
|
|
525
|
+
useVisibleEffect(
|
|
526
|
+
useCallback(() => {
|
|
527
|
+
garden.setMenuInteractive(true)
|
|
528
|
+
return () => {
|
|
529
|
+
garden.setMenuInteractive(false)
|
|
530
|
+
}
|
|
531
|
+
}, [garden]),
|
|
532
|
+
)
|
|
548
533
|
```
|
|
@@ -97,24 +97,14 @@ RCT_EXPORT_METHOD(updateTabBar:(NSString *)sceneId item:(NSDictionary *)item) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
RCT_EXPORT_METHOD(
|
|
100
|
+
RCT_EXPORT_METHOD(setTabItem:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
|
|
101
|
+
RCTLogInfo(@"[Navigator] setTabItem: %@", options);
|
|
101
102
|
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
102
103
|
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
103
104
|
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
104
105
|
HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
|
|
105
|
-
[tabBarVC
|
|
106
|
+
[tabBarVC setTabItem:options];
|
|
106
107
|
}
|
|
107
|
-
RCTLogInfo(@"[Navigator] setTabBadge: %@", options);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
RCT_EXPORT_METHOD(setTabIcon:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
|
|
111
|
-
UIViewController *vc = [self.bridgeManager controllerForSceneId:sceneId];
|
|
112
|
-
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
113
|
-
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
114
|
-
HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
|
|
115
|
-
[tabBarVC setTabIcon:options];
|
|
116
|
-
}
|
|
117
|
-
RCTLogInfo(@"[Navigator] setTabIcon: %@", options);
|
|
118
108
|
}
|
|
119
109
|
|
|
120
110
|
RCT_EXPORT_METHOD(setMenuInteractive:(NSString *)sceneId enabled:(BOOL)enabled) {
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
#import "HBDUtils.h"
|
|
10
10
|
#import <React/RCTConvert.h>
|
|
11
|
-
#import <CallKit/CXCallObserver.h>
|
|
12
|
-
#import <CallKit/CXCall.h>
|
|
13
11
|
|
|
14
12
|
@implementation HBDUtils
|
|
15
13
|
|
|
@@ -188,12 +186,6 @@
|
|
|
188
186
|
|
|
189
187
|
+ (BOOL)isInCall {
|
|
190
188
|
if ([HBDUtils isIphoneX]) {
|
|
191
|
-
CXCallObserver *callCenter = [[CXCallObserver alloc] init] ;
|
|
192
|
-
for (CXCall *call in callCenter.calls) {
|
|
193
|
-
if (call.hasConnected) {
|
|
194
|
-
return YES;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
189
|
return NO;
|
|
198
190
|
} else {
|
|
199
191
|
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@property (nonatomic, strong, readonly) UIImageView *shadowImageView;
|
|
14
14
|
@property (nonatomic, strong, readonly) UIVisualEffectView *fakeView;
|
|
15
15
|
@property (nonatomic, strong, readonly) UILabel *backButtonLabel;
|
|
16
|
+
@property (nonatomic, strong, readonly) UIView *hbd_backgroundView;
|
|
16
17
|
|
|
17
18
|
@end
|
|
18
19
|
|
|
@@ -64,6 +64,10 @@
|
|
|
64
64
|
self.shadowImageView.frame = CGRectMake(0, CGRectGetHeight(self.shadowImageView.superview.bounds), CGRectGetWidth(self.shadowImageView.superview.bounds), 0.5);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
- (UIView *)hbd_backgroundView {
|
|
68
|
+
return [self valueForKey:@"_backgroundView"];
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
- (void)setBarTintColor:(UIColor *)barTintColor {
|
|
68
72
|
[super setBarTintColor:barTintColor];
|
|
69
73
|
self.fakeView.subviews.lastObject.backgroundColor = barTintColor;
|
|
@@ -60,6 +60,16 @@ void adjustLayout(UIViewController *vc) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
void printViewHierarchy(UIView *view, NSString *prefix) {
|
|
64
|
+
NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
65
|
+
NSLog(@"%@%@ %@", prefix, viewName, NSStringFromCGRect(view.frame));
|
|
66
|
+
if (view.subviews.count > 0) {
|
|
67
|
+
for (UIView *sub in view.subviews) {
|
|
68
|
+
printViewHierarchy(sub, [NSString stringWithFormat:@"--%@", prefix]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
@interface HBDNavigationControllerDelegate : UIScreenEdgePanGestureRecognizer <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
64
74
|
|
|
65
75
|
@property (nonatomic, weak) id<UINavigationControllerDelegate> proxiedDelegate;
|
|
@@ -395,8 +405,15 @@ void adjustLayout(UIViewController *vc) {
|
|
|
395
405
|
return YES;
|
|
396
406
|
}
|
|
397
407
|
|
|
398
|
-
|
|
399
|
-
|
|
408
|
+
if (to != viewController) {
|
|
409
|
+
return NO;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (![from.hbd_barTintColor.description isEqual:to.hbd_barTintColor.description]) {
|
|
413
|
+
return YES;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return from.hbd_barAlpha < 1.0 || to.hbd_barAlpha < 1.0;
|
|
400
417
|
}
|
|
401
418
|
|
|
402
419
|
@end
|
|
@@ -595,16 +612,6 @@ void adjustLayout(UIViewController *vc) {
|
|
|
595
612
|
}
|
|
596
613
|
}
|
|
597
614
|
|
|
598
|
-
- (void)printSubViews:(UIView *)view prefix:(NSString *)prefix {
|
|
599
|
-
// NSString *viewName = [[[view classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
|
|
600
|
-
// RCTLogInfo(@"[Navigator] %@%@", prefix, viewName);
|
|
601
|
-
if (view.subviews.count > 0) {
|
|
602
|
-
for (UIView *sub in view.subviews) {
|
|
603
|
-
[self printSubViews:sub prefix:[NSString stringWithFormat:@"--%@", prefix]];
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
615
|
- (void)updateNavigationBarForViewController:(UIViewController *)vc {
|
|
609
616
|
[self updateNavigationBarStyleForViewController:vc];
|
|
610
617
|
[self updateNavigationBarAlphaForViewController:vc];
|
|
@@ -628,6 +635,12 @@ void adjustLayout(UIViewController *vc) {
|
|
|
628
635
|
- (void)updateNavigationBarAlphaForViewController:(UIViewController *)vc {
|
|
629
636
|
self.navigationBar.fakeView.alpha = vc.hbd_barAlpha;
|
|
630
637
|
self.navigationBar.shadowImageView.alpha = vc.hbd_barShadowAlpha;
|
|
638
|
+
|
|
639
|
+
if (vc.hbd_barAlpha == 0) {
|
|
640
|
+
self.navigationBar.hbd_backgroundView.layer.mask = [CALayer new];
|
|
641
|
+
} else {
|
|
642
|
+
self.navigationBar.hbd_backgroundView.layer.mask = nil;
|
|
643
|
+
}
|
|
631
644
|
}
|
|
632
645
|
|
|
633
646
|
- (void)updateNavigationBarBackgroundForViewController:(UIViewController *)vc {
|
|
@@ -645,9 +658,9 @@ void adjustLayout(UIViewController *vc) {
|
|
|
645
658
|
|
|
646
659
|
- (void)showFakeBarFrom:(UIViewController *)from {
|
|
647
660
|
self.fromFakeBar.subviews.lastObject.backgroundColor = from.hbd_barTintColor;
|
|
648
|
-
self.fromFakeBar.alpha = from.hbd_barAlpha
|
|
661
|
+
self.fromFakeBar.alpha = from.hbd_barAlpha;
|
|
649
662
|
if (from.hbd_barAlpha == 0) {
|
|
650
|
-
self.fromFakeBar.subviews.lastObject.
|
|
663
|
+
self.fromFakeBar.subviews.lastObject.layer.mask = [CALayer new];
|
|
651
664
|
}
|
|
652
665
|
self.fromFakeBar.frame = [self fakeBarFrameForViewController:from];
|
|
653
666
|
[from.view addSubview:self.fromFakeBar];
|
|
@@ -116,42 +116,11 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
- (void)
|
|
119
|
+
- (void)setTabItem:(NSArray<NSDictionary *> *)options {
|
|
120
120
|
for (NSDictionary *option in options) {
|
|
121
121
|
NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
|
|
122
|
-
BOOL hidden = option[@"hidden"] ? [option[@"hidden"] boolValue] : YES;
|
|
123
|
-
|
|
124
|
-
NSString *text = hidden ? nil : (option[@"text"] ? option[@"text"] : nil);
|
|
125
|
-
BOOL dot = hidden ? NO : (option[@"dot"] ? [option[@"dot"] boolValue] : NO);
|
|
126
|
-
|
|
127
122
|
if (self.hasCustomTabBar) {
|
|
128
|
-
|
|
129
|
-
tab[@"dot"] = @(dot);
|
|
130
|
-
tab[@"badgeText"] = RCTNullIfNil(text);
|
|
131
|
-
} else {
|
|
132
|
-
UIViewController *vc = self.viewControllers[index];
|
|
133
|
-
vc.tabBarItem.badgeValue = text;
|
|
134
|
-
UITabBar *tabBar = self.tabBar;
|
|
135
|
-
if (dot) {
|
|
136
|
-
[tabBar showDotBadgeAtIndex:index];
|
|
137
|
-
} else {
|
|
138
|
-
[tabBar hideDotBadgeAtIndex:index];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (self.hasCustomTabBar) {
|
|
144
|
-
self.rootView.appProperties = [self props];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
- (void)setTabIcon:(NSArray<NSDictionary *> *)options {
|
|
149
|
-
for (NSDictionary *option in options) {
|
|
150
|
-
NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
|
|
151
|
-
if (self.hasCustomTabBar) {
|
|
152
|
-
NSMutableDictionary *tab = [self tabAtIndex:index];
|
|
153
|
-
tab[@"icon"] = [HBDUtils iconUriFromUri:option[@"icon"][@"uri"]];
|
|
154
|
-
tab[@"unselectedIcon"] = RCTNullIfNil([HBDUtils iconUriFromUri:option[@"unselectedIcon"][@"uri"]]);
|
|
123
|
+
[self updateCustomTabItem:option atIndex:index];
|
|
155
124
|
} else {
|
|
156
125
|
UIViewController *tab = [self.viewControllers objectAtIndex:index];
|
|
157
126
|
[tab hbd_updateTabBarItem:option];
|
|
@@ -173,6 +142,38 @@
|
|
|
173
142
|
return tab;
|
|
174
143
|
}
|
|
175
144
|
|
|
145
|
+
- (void)updateCustomTabItem:(NSDictionary *)option atIndex:(NSUInteger)index {
|
|
146
|
+
NSMutableDictionary *tab = [self tabAtIndex:index];
|
|
147
|
+
|
|
148
|
+
// title
|
|
149
|
+
NSString *title = option[@"title"];
|
|
150
|
+
if (title != nil) {
|
|
151
|
+
tab[@"title"] = title;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// icon title
|
|
155
|
+
NSDictionary *icon = option[@"icon"];
|
|
156
|
+
if (icon != nil) {
|
|
157
|
+
NSDictionary *selected = icon[@"selected"];
|
|
158
|
+
tab[@"icon"] = [HBDUtils iconUriFromUri:selected[@"uri"]];
|
|
159
|
+
|
|
160
|
+
NSDictionary *unselected = icon[@"unselected"];
|
|
161
|
+
if (unselected != nil) {
|
|
162
|
+
tab[@"unselectedIcon"] = RCTNullIfNil([HBDUtils iconUriFromUri:unselected[@"uri"]]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// badge
|
|
167
|
+
NSDictionary *badge = option[@"badge"];
|
|
168
|
+
if (badge != nil) {
|
|
169
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
170
|
+
NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
|
|
171
|
+
BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
|
|
172
|
+
tab[@"dot"] = @(dot);
|
|
173
|
+
tab[@"badgeText"] = RCTNullIfNil(text);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
176
177
|
- (void)updateTabBar:(NSDictionary *)options {
|
|
177
178
|
UITabBar *tabBar = self.tabBar;
|
|
178
179
|
NSString *tabBarColor = [options objectForKey:@"tabBarColor"];
|
|
@@ -285,6 +285,11 @@
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
[self applyNavigationBarOptions:target];
|
|
288
|
+
|
|
289
|
+
NSString *screenColor = options[@"screenBackgroundColor"];
|
|
290
|
+
if (screenColor && [self isViewLoaded]) {
|
|
291
|
+
self.view.backgroundColor = [HBDUtils colorWithHexString:screenColor];
|
|
292
|
+
}
|
|
288
293
|
|
|
289
294
|
NSNumber *statusBarHidden = [options objectForKey:@"statusBarHidden"];
|
|
290
295
|
if (statusBarHidden) {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#import "HBDModalViewController.h"
|
|
14
14
|
#import <React/RCTLog.h>
|
|
15
15
|
#import "HBDGarden.h"
|
|
16
|
+
#import "UITabBar+Badge.h"
|
|
16
17
|
|
|
17
18
|
@implementation UIViewController (HBD)
|
|
18
19
|
|
|
@@ -117,20 +118,25 @@
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
121
|
+
UIColor *color;
|
|
120
122
|
if (obj) {
|
|
121
|
-
|
|
123
|
+
color = obj;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
UIColor *colorWithBarStyle = [[HBDGarden globalStyle] barTintColorWithBarStyle:self.hbd_barStyle];
|
|
125
|
-
if (colorWithBarStyle) {
|
|
126
|
-
|
|
127
|
+
if (color == nil && colorWithBarStyle != nil) {
|
|
128
|
+
color = colorWithBarStyle;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
if ([UINavigationBar appearance].barTintColor) {
|
|
130
|
-
|
|
131
|
+
if (color == nil && [UINavigationBar appearance].barTintColor != nil) {
|
|
132
|
+
color = [UINavigationBar appearance].barTintColor;
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
if (color == nil) {
|
|
136
|
+
color = [UINavigationBar appearance].barStyle == UIBarStyleDefault ? [UIColor whiteColor]: [UIColor blackColor];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return color;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
- (void)setHbd_barTintColor:(UIColor *)tintColor {
|
|
@@ -363,19 +369,44 @@
|
|
|
363
369
|
return nil;
|
|
364
370
|
}
|
|
365
371
|
|
|
366
|
-
- (void)hbd_updateTabBarItem:(NSDictionary *)
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
tabBarItem =
|
|
374
|
-
}
|
|
375
|
-
|
|
372
|
+
- (void)hbd_updateTabBarItem:(NSDictionary *)option {
|
|
373
|
+
UITabBarItem *tabBarItem = self.tabBarItem;
|
|
374
|
+
NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
|
|
375
|
+
|
|
376
|
+
// title
|
|
377
|
+
NSString *title = option[@"title"];
|
|
378
|
+
if (title != nil) {
|
|
379
|
+
tabBarItem.title = title;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// icon
|
|
383
|
+
NSDictionary *icon = option[@"icon"];
|
|
384
|
+
if (icon != nil) {
|
|
385
|
+
NSDictionary *unselected = icon[@"unselected"];
|
|
386
|
+
NSDictionary *selected = icon[@"selected"];
|
|
387
|
+
if (unselected) {
|
|
388
|
+
tabBarItem.selectedImage = [[HBDUtils UIImage:selected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
389
|
+
tabBarItem.image = [[HBDUtils UIImage:unselected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
390
|
+
} else {
|
|
391
|
+
tabBarItem.image = [HBDUtils UIImage:selected];
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// badge
|
|
396
|
+
NSDictionary *badge = option[@"badge"];
|
|
397
|
+
if (badge != nil) {
|
|
398
|
+
BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
|
|
399
|
+
NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
|
|
400
|
+
BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
|
|
401
|
+
|
|
402
|
+
tabBarItem.badgeValue = text;
|
|
403
|
+
UITabBar *tabBar = self.tabBarController.tabBar;
|
|
404
|
+
if (dot) {
|
|
405
|
+
[tabBar showDotBadgeAtIndex:index];
|
|
406
|
+
} else {
|
|
407
|
+
[tabBar hideDotBadgeAtIndex:index];
|
|
408
|
+
}
|
|
376
409
|
}
|
|
377
|
-
tabBarItem.badgeValue = self.tabBarItem.badgeValue;
|
|
378
|
-
self.tabBarItem = tabBarItem;
|
|
379
410
|
}
|
|
380
411
|
|
|
381
412
|
- (NSString *)hbd_mode {
|
package/lib/Garden.d.ts
CHANGED
|
@@ -41,6 +41,19 @@ export interface TabBadge {
|
|
|
41
41
|
hidden: boolean;
|
|
42
42
|
dot?: boolean;
|
|
43
43
|
}
|
|
44
|
+
export interface TabItemInfo {
|
|
45
|
+
index: number;
|
|
46
|
+
title?: string;
|
|
47
|
+
badge?: {
|
|
48
|
+
text?: string;
|
|
49
|
+
hidden: boolean;
|
|
50
|
+
dot?: boolean;
|
|
51
|
+
};
|
|
52
|
+
icon?: {
|
|
53
|
+
selected: ImageSource;
|
|
54
|
+
unselected?: ImageSource;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
44
57
|
export interface TabIcon {
|
|
45
58
|
index: number;
|
|
46
59
|
icon: ImageSource;
|
|
@@ -60,6 +73,7 @@ export declare class Garden {
|
|
|
60
73
|
setTitleItem(titleItem: TitleItem): void;
|
|
61
74
|
updateOptions(options: NavigationOption): void;
|
|
62
75
|
updateTabBar(options: TabBarStyle): void;
|
|
76
|
+
setTabItem(item: TabItemInfo | TabItemInfo[]): void;
|
|
63
77
|
setTabIcon(icon: TabIcon | TabIcon[]): void;
|
|
64
78
|
setTabBadge(badge: TabBadge | TabBadge[]): void;
|
|
65
79
|
setMenuInteractive(enabled: boolean): void;
|