@tarojs/router-rn 3.4.2 → 3.4.5

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.
@@ -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
- userOptions: TabOptions
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, userOptions = {} } = this.props
78
- const { tabBarVisible = true } = userOptions
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
- if (Platform.OS === 'ios') {
109
- Keyboard.removeListener('keyboardWillShow', () => this.handleKeyboardShow())
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
@@ -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
- userOptions?: TabOptions
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
- userOptions,
108
+ tabOptions,
111
109
  tabStyle = {},
112
110
  labelStyle = {},
113
111
  allowFontScaling = true,
114
112
  showLabel = true
115
113
  } = this.props
116
- const tabBarBadgeStyle = userOptions?.tabBarBadgeStyle || {}
114
+ const tabBarBadgeStyle = tabOptions?.tabBarBadgeStyle || {}
117
115
  return (
118
116
  <View style={[styles.tabItem, styles.itemHorizontal, tabStyle]}>
119
117
  <View style={styles.icon}>