@tarojs/router-rn 3.4.0 → 3.4.3
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/dist/navigationBar.js +5 -17
- package/dist/navigationBar.js.map +1 -1
- package/dist/provider.js +1 -9
- package/dist/provider.js.map +1 -1
- package/dist/rootNavigation.js.map +1 -1
- package/dist/router.js +35 -60
- package/dist/router.js.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/view/BackButton.js +0 -2
- package/dist/view/BackButton.js.map +1 -1
- package/dist/view/Badge.js +0 -3
- package/dist/view/Badge.js.map +1 -1
- package/dist/view/HeadTitle.js +0 -2
- package/dist/view/HeadTitle.js.map +1 -1
- package/dist/view/Loading.js +0 -2
- package/dist/view/Loading.js.map +1 -1
- package/dist/view/TabBar.js +8 -18
- package/dist/view/TabBar.js.map +1 -1
- package/dist/view/TabBarItem.js +2 -4
- package/dist/view/TabBarItem.js.map +1 -1
- package/package.json +13 -13
- package/src/navigationBar.ts +6 -16
- package/src/provider.ts +1 -8
- package/src/rootNavigation.ts +4 -3
- package/src/{router.ts → router.tsx} +82 -97
- package/src/utils/index.ts +0 -1
- package/src/view/BackButton.tsx +0 -2
- package/src/view/Badge.tsx +0 -3
- package/src/view/HeadTitle.tsx +0 -2
- package/src/view/Loading.tsx +0 -2
- package/src/view/TabBar.tsx +13 -19
- package/src/view/TabBarItem.tsx +3 -5
package/src/view/TabBar.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line no-use-before-define
|
|
2
1
|
import * as React from 'react'
|
|
3
2
|
import {
|
|
4
3
|
Link
|
|
@@ -12,7 +11,8 @@ import {
|
|
|
12
11
|
Platform,
|
|
13
12
|
Dimensions,
|
|
14
13
|
LayoutChangeEvent,
|
|
15
|
-
Keyboard
|
|
14
|
+
Keyboard,
|
|
15
|
+
EmitterSubscription
|
|
16
16
|
} from 'react-native'
|
|
17
17
|
import { getTabVisible, getTabConfig, getTabItemConfig, getDefalutTabItem, isUrl } from '../utils/index'
|
|
18
18
|
import { getInitSafeAreaInsets } from './tabBarUtils'
|
|
@@ -22,7 +22,7 @@ interface TabBarProps extends TabBarOptions {
|
|
|
22
22
|
state: Record<string, any>,
|
|
23
23
|
navigation: any,
|
|
24
24
|
descriptors: Record<string, any>,
|
|
25
|
-
|
|
25
|
+
tabOptions: TabOptions
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
interface TabBarState {
|
|
@@ -71,11 +71,13 @@ const styles = StyleSheet.create({
|
|
|
71
71
|
})
|
|
72
72
|
|
|
73
73
|
export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
74
|
+
handleKeyboardShowEvent: EmitterSubscription
|
|
75
|
+
handleKeyboardHideEvent: EmitterSubscription
|
|
74
76
|
constructor (props: TabBarProps) {
|
|
75
77
|
super(props)
|
|
76
78
|
const { height = 0, width = 0 } = Dimensions.get('window')
|
|
77
|
-
const { safeAreaInsets,
|
|
78
|
-
const { tabBarVisible = true } =
|
|
79
|
+
const { safeAreaInsets, tabOptions = {} } = this.props
|
|
80
|
+
const { tabBarVisible = true } = tabOptions
|
|
79
81
|
const tabVisible = tabBarVisible === false ? false : getTabVisible()
|
|
80
82
|
this.state = {
|
|
81
83
|
visible: new Animated.Value(tabVisible ? 1 : 0),
|
|
@@ -93,11 +95,11 @@ export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
|
93
95
|
const { keyboardHidesTabBar = false } = this.props
|
|
94
96
|
if (keyboardHidesTabBar) {
|
|
95
97
|
if (Platform.OS === 'ios') {
|
|
96
|
-
Keyboard.addListener('keyboardWillShow', () => this.handleKeyboardShow())
|
|
97
|
-
Keyboard.addListener('keyboardWillHide', () => this.handleKeyboardHide())
|
|
98
|
+
this.handleKeyboardShowEvent = Keyboard.addListener('keyboardWillShow', () => this.handleKeyboardShow())
|
|
99
|
+
this.handleKeyboardHideEvent = Keyboard.addListener('keyboardWillHide', () => this.handleKeyboardHide())
|
|
98
100
|
} else {
|
|
99
|
-
Keyboard.addListener('keyboardDidShow', () => this.handleKeyboardShow())
|
|
100
|
-
Keyboard.addListener('keyboardDidHide', () => this.handleKeyboardHide())
|
|
101
|
+
this.handleKeyboardShowEvent = Keyboard.addListener('keyboardDidShow', () => this.handleKeyboardShow())
|
|
102
|
+
this.handleKeyboardHideEvent = Keyboard.addListener('keyboardDidHide', () => this.handleKeyboardHide())
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
}
|
|
@@ -105,13 +107,8 @@ export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
|
105
107
|
componentWillUnmount () {
|
|
106
108
|
const { keyboardHidesTabBar = false } = this.props
|
|
107
109
|
if (keyboardHidesTabBar) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Keyboard.removeListener('keyboardWillHide', () => this.handleKeyboardHide())
|
|
111
|
-
} else {
|
|
112
|
-
Keyboard.removeListener('keyboardDidShow', () => this.handleKeyboardShow())
|
|
113
|
-
Keyboard.removeListener('keyboardDidHide', () => this.handleKeyboardHide())
|
|
114
|
-
}
|
|
110
|
+
this.handleKeyboardShowEvent.remove()
|
|
111
|
+
this.handleKeyboardHideEvent.remove()
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
|
|
@@ -229,7 +226,6 @@ export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
|
229
226
|
return isUrl(path) ? { uri: path } : { uri: path }
|
|
230
227
|
}
|
|
231
228
|
|
|
232
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
233
229
|
renderContent () {
|
|
234
230
|
const { state, descriptors, navigation } = this.props
|
|
235
231
|
const horizontal = true
|
|
@@ -336,7 +332,6 @@ export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
|
336
332
|
</View>
|
|
337
333
|
}
|
|
338
334
|
|
|
339
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
340
335
|
render () {
|
|
341
336
|
const { insets, visible, layout, tabVisible, isKeyboardShown } = this.state
|
|
342
337
|
const paddingBottom = Math.max(
|
|
@@ -349,7 +344,6 @@ export class TabBar extends React.PureComponent<TabBarProps, TabBarState> {
|
|
|
349
344
|
|
|
350
345
|
const showTabBar = tabVisible !== false && !isKeyboardShown
|
|
351
346
|
if (!needAnimate) {
|
|
352
|
-
// eslint-disable-next-line multiline-ternary
|
|
353
347
|
return (!showTabBar ? null
|
|
354
348
|
: (
|
|
355
349
|
<View
|
package/src/view/TabBarItem.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line no-use-before-define
|
|
2
1
|
import * as React from 'react'
|
|
3
2
|
import {
|
|
4
3
|
View,
|
|
@@ -38,7 +37,7 @@ interface TabBarItemProps extends TabBarOptions{
|
|
|
38
37
|
labelColor: string,
|
|
39
38
|
iconSource: ImageSourcePropType
|
|
40
39
|
size?: number,
|
|
41
|
-
|
|
40
|
+
tabOptions?: TabOptions
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
const styles = StyleSheet.create({
|
|
@@ -97,7 +96,6 @@ const styles = StyleSheet.create({
|
|
|
97
96
|
})
|
|
98
97
|
|
|
99
98
|
export default class TabBarItem extends React.PureComponent<TabBarItemProps> {
|
|
100
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
101
99
|
render () {
|
|
102
100
|
const {
|
|
103
101
|
label,
|
|
@@ -107,13 +105,13 @@ export default class TabBarItem extends React.PureComponent<TabBarItemProps> {
|
|
|
107
105
|
size = 20,
|
|
108
106
|
labelColor,
|
|
109
107
|
iconSource,
|
|
110
|
-
|
|
108
|
+
tabOptions,
|
|
111
109
|
tabStyle = {},
|
|
112
110
|
labelStyle = {},
|
|
113
111
|
allowFontScaling = true,
|
|
114
112
|
showLabel = true
|
|
115
113
|
} = this.props
|
|
116
|
-
const tabBarBadgeStyle =
|
|
114
|
+
const tabBarBadgeStyle = tabOptions?.tabBarBadgeStyle || {}
|
|
117
115
|
return (
|
|
118
116
|
<View style={[styles.tabItem, styles.itemHorizontal, tabStyle]}>
|
|
119
117
|
<View style={styles.icon}>
|