hybrid-navigation 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HybridNavigation.podspec +6 -6
- package/LICENSE +1 -1
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/.name +1 -0
- package/android/.idea/gradle.xml +16 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/modules/android.iml +18 -0
- package/android/.idea/modules.xml +8 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +4 -4
- package/android/local.properties +8 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +27 -40
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +77 -48
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +4 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +94 -43
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +134 -117
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +65 -35
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +14 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +133 -92
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +161 -126
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +145 -114
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +40 -28
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +96 -75
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/Navigator.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +111 -79
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +187 -117
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +137 -96
- package/ios/HybridNavigation/ViewController/HBDModalViewController.m +7 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/HybridNavigation.xcodeproj/project.xcworkspace/xcuserdata/listen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/HybridNavigation.xcodeproj/xcuserdata/listen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/ReactRegistry.d.ts +5 -3
- package/lib/typing.d.ts +1 -2
- package/package.json +24 -16
- package/src/DeepLink.ts +60 -0
- package/src/Garden.ts +171 -0
- package/src/NavigationModule.ts +33 -0
- package/src/Navigator.ts +404 -0
- package/src/ReactRegistry.tsx +140 -0
- package/src/hooks.ts +83 -0
- package/src/index.ts +9 -0
- package/src/router/drawer.ts +34 -0
- package/src/router/index.ts +166 -0
- package/src/router/screen.ts +12 -0
- package/src/router/stack.ts +80 -0
- package/src/router/tabs.ts +49 -0
- package/src/router/typing.ts +45 -0
- package/src/store.ts +49 -0
- package/src/typing.ts +148 -0
- package/src/utils.ts +83 -0
- package/.buckconfig +0 -6
- package/.editorconfig +0 -16
- package/.eslintignore +0 -5
- package/.gitattributes +0 -1
- package/.github/workflows/docs.yml +0 -25
- package/CHANGELOG.md +0 -429
- package/babel.config.js +0 -15
- package/docs/README.md +0 -109
- package/docs/custom-tabbar.md +0 -138
- package/docs/deeplink.md +0 -148
- package/docs/integration-native.md +0 -390
- package/docs/integration-react.md +0 -194
- package/docs/lifecycle.md +0 -85
- package/docs/navigation.md +0 -589
- package/docs/pass-and-return-value.md +0 -163
- package/docs/qa.md +0 -81
- package/docs/style.md +0 -533
- package/jest.config.js +0 -4
- package/metro.config.js +0 -17
- package/screenshot/android.png +0 -0
- package/screenshot/bulge.jpg +0 -0
- package/screenshot/controller-base.jpg +0 -0
- package/screenshot/demo-qrcode.png +0 -0
- package/screenshot/header-search-paths.jpg +0 -0
- package/screenshot/ios-react-script.png +0 -0
- package/screenshot/ios-run-script.jpg +0 -0
- package/screenshot/statusbar-inperfect.png +0 -0
- package/screenshot/statusbar-setup-step-1.png +0 -0
- package/screenshot/statusbar-setup-step-2.png +0 -0
- package/screenshot/tabbar.jpg +0 -0
- package/screenshot/topbar-default.png +0 -0
- package/screenshot/xcode-linking.png +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>HybridNavigation.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
package/lib/ReactRegistry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProvider } from 'react-native';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { Navigator } from './Navigator';
|
|
4
4
|
import { Garden } from './Garden';
|
|
5
5
|
import { RouteConfig } from './router';
|
|
@@ -9,12 +9,14 @@ export interface InjectedProps {
|
|
|
9
9
|
garden: Garden;
|
|
10
10
|
sceneId: string;
|
|
11
11
|
}
|
|
12
|
+
declare type ComponentType = ReturnType<ComponentProvider>;
|
|
12
13
|
export declare const NavigationContext: React.Context<any>;
|
|
13
|
-
export declare type HOC = (WrappedComponent: ComponentType
|
|
14
|
+
export declare type HOC = (WrappedComponent: ComponentType) => ComponentType;
|
|
14
15
|
export declare class ReactRegistry {
|
|
15
16
|
static registerEnded: boolean;
|
|
16
17
|
static startRegisterComponent(hoc?: HOC): void;
|
|
17
18
|
static endRegisterComponent(): void;
|
|
18
19
|
static registerComponent(appKey: string, getComponentFunc: ComponentProvider, routeConfig?: RouteConfig): void;
|
|
19
20
|
}
|
|
20
|
-
export declare function withNavigationItem(item: NavigationItem): (WrappedComponent: ComponentType
|
|
21
|
+
export declare function withNavigationItem(item: NavigationItem): (WrappedComponent: ComponentType) => ComponentType;
|
|
22
|
+
export {};
|
package/lib/typing.d.ts
CHANGED
|
@@ -39,7 +39,6 @@ export declare type LayoutFittingCompressed = typeof LayoutFittingCompressed;
|
|
|
39
39
|
export declare type LayoutFitting = LayoutFittingExpanded | LayoutFittingCompressed;
|
|
40
40
|
export interface NavigationOption {
|
|
41
41
|
screenBackgroundColor?: Color;
|
|
42
|
-
passThroughTouches?: boolean;
|
|
43
42
|
statusBarHidden?: boolean;
|
|
44
43
|
statusBarColorAndroid?: Color;
|
|
45
44
|
topBarStyle?: BarStyle;
|
|
@@ -57,7 +56,7 @@ export interface NavigationOption {
|
|
|
57
56
|
backInteractive?: boolean;
|
|
58
57
|
}
|
|
59
58
|
export interface NavigationItem extends NavigationOption {
|
|
60
|
-
|
|
59
|
+
passThroughTouches?: boolean;
|
|
61
60
|
forceTransparentDialogWindow?: boolean;
|
|
62
61
|
topBarHidden?: boolean;
|
|
63
62
|
extendedLayoutIncludesTopBar?: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.0",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"typings": "./lib/index.d.ts",
|
|
7
|
+
"react-native": "src/index",
|
|
8
|
+
"nativePackage": true,
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"lib",
|
|
12
|
+
"android",
|
|
13
|
+
"ios",
|
|
14
|
+
"HybridNavigation.podspec",
|
|
15
|
+
"!android/build",
|
|
16
|
+
"!ios/build",
|
|
17
|
+
"!**/__tests__"
|
|
18
|
+
],
|
|
19
|
+
"repository": "https://github.com/listenzz/hybrid-navigation",
|
|
20
|
+
"homepage": "https://github.com/listenzz/hybrid-navigation#readme",
|
|
21
|
+
"author": "listen <listenzz@163.com> (https://github.com/listenzz)",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"licenseFilename": "LICENSE",
|
|
5
24
|
"keywords": [
|
|
6
25
|
"react-native",
|
|
7
26
|
"navigation",
|
|
@@ -9,25 +28,15 @@
|
|
|
9
28
|
"router",
|
|
10
29
|
"hybrid"
|
|
11
30
|
],
|
|
12
|
-
"nativePackage": true,
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/listenzz/hybrid-navigation.git"
|
|
16
|
-
},
|
|
17
|
-
"homepage": "https://github.com/listenzz/hybrid-navigation",
|
|
18
|
-
"author": "listen <listenzz@163.com>",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"main": "./lib/index.js",
|
|
21
|
-
"typings": "./lib/index.d.ts",
|
|
22
31
|
"scripts": {
|
|
23
32
|
"build": "rm -rf ./lib && tsc -p tsconfig.build.json",
|
|
24
33
|
"prepare": "npm run build",
|
|
25
|
-
"tsc": "tsc",
|
|
26
34
|
"start": "react-native start --reset-cache",
|
|
27
35
|
"run:ios": "react-native run-ios --project-path ./example/ios",
|
|
28
36
|
"start:android": "adb shell am start -n com.reactnative.hybridnavigation.example/.MainActivity",
|
|
29
37
|
"run:android": "cd example/android && ./gradlew installDebug && npm run start:android",
|
|
30
38
|
"test": "jest",
|
|
39
|
+
"tsc": "tsc",
|
|
31
40
|
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
|
|
32
41
|
"docs:dev": "vuepress dev docs",
|
|
33
42
|
"docs:build": "vuepress build docs"
|
|
@@ -48,9 +57,8 @@
|
|
|
48
57
|
"@types/react": "^17.0.1",
|
|
49
58
|
"@types/react-native": "^0.66.2",
|
|
50
59
|
"@types/react-redux": "^7.1.9",
|
|
51
|
-
"@types/react-test-renderer": "17.0.
|
|
60
|
+
"@types/react-test-renderer": "17.0.2",
|
|
52
61
|
"babel-jest": "^27.2.0",
|
|
53
|
-
"babel-plugin-module-resolver": "^4.0.0",
|
|
54
62
|
"jest": "^27.2.0",
|
|
55
63
|
"metro-react-native-babel-preset": "^0.68.0",
|
|
56
64
|
"react": "17.0.2",
|
|
@@ -58,11 +66,11 @@
|
|
|
58
66
|
"react-native-fast-image": "^8.5.11",
|
|
59
67
|
"react-native-iphone-x-helper": "^1.2.0",
|
|
60
68
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
61
|
-
"react-native-toast-hybrid": "^2.
|
|
69
|
+
"react-native-toast-hybrid": "^2.5.0",
|
|
62
70
|
"react-redux": "^7.2.5",
|
|
63
71
|
"react-test-renderer": "17.0.2",
|
|
64
72
|
"redux": "^4.1.1",
|
|
65
|
-
"typescript": "^4.4
|
|
73
|
+
"typescript": "^4.6.4",
|
|
66
74
|
"vuepress": "^2.0.0-beta.26",
|
|
67
75
|
"zustand": "^3.7.1"
|
|
68
76
|
},
|
package/src/DeepLink.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EmitterSubscription, Linking } from 'react-native'
|
|
2
|
+
import { router } from './router'
|
|
3
|
+
|
|
4
|
+
let _active = 0
|
|
5
|
+
let _uriPrefix: string = ''
|
|
6
|
+
let _hasHandleInitialURL = false
|
|
7
|
+
let _linkingSubscription: EmitterSubscription | undefined
|
|
8
|
+
|
|
9
|
+
function activate(uriPrefix: string) {
|
|
10
|
+
if (!uriPrefix) {
|
|
11
|
+
throw new Error('must pass `uriPrefix` when activate router.')
|
|
12
|
+
}
|
|
13
|
+
if (_active === 0) {
|
|
14
|
+
_uriPrefix = uriPrefix
|
|
15
|
+
if (!_hasHandleInitialURL) {
|
|
16
|
+
_hasHandleInitialURL = true
|
|
17
|
+
Linking.getInitialURL()
|
|
18
|
+
.then(url => {
|
|
19
|
+
if (url) {
|
|
20
|
+
console.info(`deeplink:${url}`)
|
|
21
|
+
const path = url.replace(_uriPrefix, '')
|
|
22
|
+
return router.open(path)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
.catch(err => console.error('An error occurred', err))
|
|
26
|
+
}
|
|
27
|
+
_linkingSubscription = Linking.addEventListener('url', handleLinking)
|
|
28
|
+
}
|
|
29
|
+
_active++
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function deactivate() {
|
|
33
|
+
_active--
|
|
34
|
+
if (_active === 0) {
|
|
35
|
+
if (_linkingSubscription) {
|
|
36
|
+
_linkingSubscription.remove()
|
|
37
|
+
_linkingSubscription = undefined
|
|
38
|
+
} else {
|
|
39
|
+
Linking.removeEventListener('url', handleLinking)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (_active < 0) {
|
|
44
|
+
_active = 0
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleLinking(event: { url: string }): void {
|
|
49
|
+
console.info(`deeplink:${event.url}`)
|
|
50
|
+
let path = event.url.replace(_uriPrefix, '')
|
|
51
|
+
if (!path.startsWith('/')) {
|
|
52
|
+
path = '/' + path
|
|
53
|
+
}
|
|
54
|
+
router.open(path)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const DeepLink = {
|
|
58
|
+
activate,
|
|
59
|
+
deactivate,
|
|
60
|
+
}
|
package/src/Garden.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native'
|
|
2
|
+
import { bindBarButtonItemClickEvent } from './utils'
|
|
3
|
+
import { NavigationOption, ImageSource, Color, BarStyle, TitleAlignment, BarButtonItem, TitleItem } from './typing'
|
|
4
|
+
|
|
5
|
+
export interface ShadowImage {
|
|
6
|
+
image?: ImageSource
|
|
7
|
+
color?: Color
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Style {
|
|
11
|
+
screenBackgroundColor?: Color // 页面背景,默认是白色
|
|
12
|
+
topBarStyle?: BarStyle // TopBar 样式,决定了状态栏的颜色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
|
|
13
|
+
topBarColor?: Color // TopBar 背景颜色,默认根据 topBarStyle 来计算
|
|
14
|
+
topBarColorDarkContent?: Color // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 topBarColor 的值
|
|
15
|
+
topBarColorLightContent?: Color // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 topBarColor 的值
|
|
16
|
+
statusBarColorAndroid?: Color // 状态栏背景颜色,默认取 topBarColor 的值
|
|
17
|
+
navigationBarColorAndroid?: Color // 底部虚拟键背景颜色,仅对 Android 8.0 以上版本生效
|
|
18
|
+
hideBackTitleIOS?: boolean // 是否隐藏返回按钮旁边的文字,默认是 false, 仅对 iOS 生效
|
|
19
|
+
elevationAndroid?: number // TopBar 阴影高度,默认值为 4 dp
|
|
20
|
+
shadowImage?: ShadowImage // TopBar 阴影图片,仅对 iOS 生效
|
|
21
|
+
backIcon?: ImageSource // 返回按钮图片
|
|
22
|
+
topBarTintColor?: Color // TopBar 按钮的颜色。默认根据 topBarStyle 来计算
|
|
23
|
+
topBarTintColorDarkContent?: Color // TopBar 按钮颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 topBarTintColor 的值
|
|
24
|
+
topBarTintColorLightContent?: Color // TopBar 按钮颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 topBarTintColor 的值
|
|
25
|
+
titleTextColor?: Color // TopBar 标题颜色,默认根据 topBarStyle 来计算
|
|
26
|
+
titleTextColorDarkContent?: Color // TopBar 标题颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 titleTextColor 的值
|
|
27
|
+
titleTextColorLightContent?: Color // TopBar 标题颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 titleTextColor 的值
|
|
28
|
+
titleTextSize?: number // TopBar 标题字体大小,默认是 17 dp(pt)
|
|
29
|
+
titleAlignmentAndroid?: TitleAlignment // TopBar 标题的位置,可选项有 `TitleAlignmentLeft` 和 `TitleAlignmentCenter` ,仅对 Android 生效
|
|
30
|
+
barButtonItemTextSize?: number // TopBar 按钮字体大小,默认是 15 dp(pt)
|
|
31
|
+
swipeBackEnabledAndroid?: boolean // Android 是否开启右滑返回,默认是 false
|
|
32
|
+
splitTopBarTransitionIOS?: boolean // iOS 侧滑返回时,是否总是割裂导航栏背景
|
|
33
|
+
scrimAlphaAndroid?: number // Android 侧滑返回遮罩效果 [0 - 255]
|
|
34
|
+
displayCutoutWhenLandscapeAndroid?: boolean // 横屏时,是否将界面延伸至刘海区域,默认 true
|
|
35
|
+
|
|
36
|
+
tabBarColor?: Color // 底部 TabBar 背景颜色,请勿使用带透明度的颜色。
|
|
37
|
+
tabBarShadowImage?: ShadowImage // 底部 TabBar 阴影图片。对于 iOS, 只有同时设置了 tabBarColor 才会生效
|
|
38
|
+
tabBarItemColor?: Color // 底部 TabBarItem icon 选中颜色
|
|
39
|
+
tabBarUnselectedItemColor?: Color // 底部 TabBarItem icon 未选中颜色,默认为 #BDBDBD
|
|
40
|
+
tabBarBadgeColor?: Color // Tab badge 颜色
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type TabBarStyle = Pick<
|
|
44
|
+
Style,
|
|
45
|
+
'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'
|
|
46
|
+
>
|
|
47
|
+
|
|
48
|
+
export interface TabBadge {
|
|
49
|
+
index: number
|
|
50
|
+
text?: string
|
|
51
|
+
hidden: boolean
|
|
52
|
+
dot?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface TabItemInfo {
|
|
56
|
+
index: number
|
|
57
|
+
title?: string
|
|
58
|
+
badge?: {
|
|
59
|
+
text?: string
|
|
60
|
+
hidden: boolean
|
|
61
|
+
dot?: boolean
|
|
62
|
+
}
|
|
63
|
+
icon?: {
|
|
64
|
+
selected: ImageSource
|
|
65
|
+
unselected?: ImageSource
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TabIcon {
|
|
70
|
+
index: number
|
|
71
|
+
icon: ImageSource
|
|
72
|
+
unselectedIcon?: ImageSource
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
type Nullable<T> = {
|
|
76
|
+
[P in keyof T]: T[P] extends T[P] | undefined ? T[P] | null : T[P]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const GardenModule = NativeModules.GardenModule
|
|
80
|
+
export class Garden {
|
|
81
|
+
static setStyle(style: Style = {}) {
|
|
82
|
+
GardenModule.setStyle(style)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
constructor(public sceneId: string) {}
|
|
86
|
+
|
|
87
|
+
// --------------- instance method --------------
|
|
88
|
+
|
|
89
|
+
setLeftBarButtonItem(buttonItem: Nullable<BarButtonItem> | null) {
|
|
90
|
+
const options = bindBarButtonItemClickEvent(buttonItem, { sceneId: this.sceneId })
|
|
91
|
+
GardenModule.setLeftBarButtonItem(this.sceneId, options)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setRightBarButtonItem(buttonItem: Nullable<BarButtonItem> | null) {
|
|
95
|
+
const options = bindBarButtonItemClickEvent(buttonItem, { sceneId: this.sceneId })
|
|
96
|
+
GardenModule.setRightBarButtonItem(this.sceneId, options)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setLeftBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null) {
|
|
100
|
+
const options = bindBarButtonItemClickEvent(buttonItems, { sceneId: this.sceneId })
|
|
101
|
+
GardenModule.setLeftBarButtonItems(this.sceneId, options)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setRightBarButtonItems(buttonItems: Array<Nullable<BarButtonItem>> | null) {
|
|
105
|
+
const options = bindBarButtonItemClickEvent(buttonItems, { sceneId: this.sceneId })
|
|
106
|
+
GardenModule.setRightBarButtonItems(this.sceneId, options)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setTitleItem(titleItem: TitleItem) {
|
|
110
|
+
GardenModule.setTitleItem(this.sceneId, titleItem)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
updateOptions(options: NavigationOption) {
|
|
114
|
+
GardenModule.updateOptions(this.sceneId, options)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
updateTabBar(options: TabBarStyle) {
|
|
118
|
+
GardenModule.updateTabBar(this.sceneId, options)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
setTabItem(item: TabItemInfo | TabItemInfo[]) {
|
|
122
|
+
if (!Array.isArray(item)) {
|
|
123
|
+
item = [item]
|
|
124
|
+
}
|
|
125
|
+
GardenModule.setTabItem(this.sceneId, item)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setTabIcon(icon: TabIcon | TabIcon[]) {
|
|
129
|
+
console.warn(`Garden#setTabIcon is deprecated, use Garden#setTabItem instead.`)
|
|
130
|
+
if (!Array.isArray(icon)) {
|
|
131
|
+
icon = [icon]
|
|
132
|
+
}
|
|
133
|
+
const icons = icon
|
|
134
|
+
const items: Array<TabItemInfo> = []
|
|
135
|
+
for (const i of icons) {
|
|
136
|
+
items.push({
|
|
137
|
+
index: i.index,
|
|
138
|
+
icon: {
|
|
139
|
+
selected: i.icon,
|
|
140
|
+
unselected: i.unselectedIcon,
|
|
141
|
+
},
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
this.setTabItem(items)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
setTabBadge(badge: TabBadge | TabBadge[]) {
|
|
148
|
+
console.warn(`Garden#setTabBadge is deprecated, use Garden#setTabItem instead.`)
|
|
149
|
+
if (!Array.isArray(badge)) {
|
|
150
|
+
badge = [badge]
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const badges = badge
|
|
154
|
+
const items: Array<TabItemInfo> = []
|
|
155
|
+
for (const b of badges) {
|
|
156
|
+
items.push({
|
|
157
|
+
index: b.index,
|
|
158
|
+
badge: {
|
|
159
|
+
hidden: b.hidden,
|
|
160
|
+
text: b.text,
|
|
161
|
+
dot: b.dot,
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
this.setTabItem(items)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setMenuInteractive(enabled: boolean) {
|
|
169
|
+
GardenModule.setMenuInteractive(this.sceneId, enabled)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter } from 'react-native'
|
|
2
|
+
|
|
3
|
+
const NavigationModule = NativeModules.NavigationModule
|
|
4
|
+
const GardenModule = NativeModules.GardenModule
|
|
5
|
+
const HBDEventEmitter = NativeModules.HBDEventEmitter
|
|
6
|
+
|
|
7
|
+
const EventEmitter: NativeEventEmitter = new NativeEventEmitter(HBDEventEmitter)
|
|
8
|
+
export const EVENT_SWITCH_TAB: string = HBDEventEmitter.EVENT_SWITCH_TAB
|
|
9
|
+
export const EVENT_NAVIGATION: string = HBDEventEmitter.EVENT_NAVIGATION
|
|
10
|
+
export const EVENT_WILL_SET_ROOT: string = HBDEventEmitter.EVENT_WILL_SET_ROOT
|
|
11
|
+
export const EVENT_DID_SET_ROOT: string = HBDEventEmitter.EVENT_DID_SET_ROOT
|
|
12
|
+
|
|
13
|
+
export const ON_COMPONENT_RESULT: string = HBDEventEmitter.ON_COMPONENT_RESULT
|
|
14
|
+
export const ON_BAR_BUTTON_ITEM_CLICK: string = HBDEventEmitter.ON_BAR_BUTTON_ITEM_CLICK
|
|
15
|
+
export const ON_COMPONENT_APPEAR: string = HBDEventEmitter.ON_COMPONENT_APPEAR
|
|
16
|
+
export const ON_COMPONENT_DISAPPEAR: string = HBDEventEmitter.ON_COMPONENT_DISAPPEAR
|
|
17
|
+
|
|
18
|
+
export const KEY_ON: string = HBDEventEmitter.KEY_ON
|
|
19
|
+
export const KEY_REQUEST_CODE: string = HBDEventEmitter.KEY_REQUEST_CODE
|
|
20
|
+
export const KEY_RESULT_CODE: string = HBDEventEmitter.KEY_RESULT_CODE
|
|
21
|
+
export const KEY_RESULT_DATA: string = HBDEventEmitter.KEY_RESULT_DATA
|
|
22
|
+
export const KEY_SCENE_ID: string = HBDEventEmitter.KEY_SCENE_ID
|
|
23
|
+
export const KEY_MODULE_NAME: string = HBDEventEmitter.KEY_MODULE_NAME
|
|
24
|
+
export const KEY_INDEX: string = HBDEventEmitter.KEY_INDEX
|
|
25
|
+
export const KEY_ACTION: string = HBDEventEmitter.KEY_ACTION
|
|
26
|
+
|
|
27
|
+
export const RESULT_OK: number = NavigationModule.RESULT_OK
|
|
28
|
+
export const RESULT_CANCEL: number = NavigationModule.RESULT_CANCEL
|
|
29
|
+
|
|
30
|
+
export const toolbarHeight: number = GardenModule.TOOLBAR_HEIGHT
|
|
31
|
+
export const TOOLBAR_HEIGHT: number = GardenModule.TOOLBAR_HEIGHT
|
|
32
|
+
|
|
33
|
+
export { EventEmitter, NavigationModule }
|