react-native-tab-view 3.1.1 → 3.2.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.
Files changed (59) hide show
  1. package/README.md +9 -1
  2. package/lib/commonjs/Pager.android.js.map +1 -1
  3. package/lib/commonjs/Pager.ios.js.map +1 -1
  4. package/lib/commonjs/Pager.js.map +1 -1
  5. package/lib/commonjs/PagerViewAdapter.js +17 -15
  6. package/lib/commonjs/PagerViewAdapter.js.map +1 -1
  7. package/lib/commonjs/PanResponderAdapter.js +20 -16
  8. package/lib/commonjs/PanResponderAdapter.js.map +1 -1
  9. package/lib/commonjs/PlatformPressable.js +19 -15
  10. package/lib/commonjs/PlatformPressable.js.map +1 -1
  11. package/lib/commonjs/SceneMap.js +14 -11
  12. package/lib/commonjs/SceneMap.js.map +1 -1
  13. package/lib/commonjs/SceneView.js +2 -2
  14. package/lib/commonjs/SceneView.js.map +1 -1
  15. package/lib/commonjs/TabBar.js +124 -81
  16. package/lib/commonjs/TabBar.js.map +1 -1
  17. package/lib/commonjs/TabBarIndicator.js +7 -6
  18. package/lib/commonjs/TabBarIndicator.js.map +1 -1
  19. package/lib/commonjs/TabBarItem.js +7 -6
  20. package/lib/commonjs/TabBarItem.js.map +1 -1
  21. package/lib/commonjs/TabView.js +40 -33
  22. package/lib/commonjs/TabView.js.map +1 -1
  23. package/lib/commonjs/index.js +6 -6
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/types.js +4 -0
  26. package/lib/commonjs/types.js.map +1 -1
  27. package/lib/commonjs/useAnimatedValue.js.map +1 -1
  28. package/lib/module/Pager.android.js.map +1 -1
  29. package/lib/module/Pager.ios.js.map +1 -1
  30. package/lib/module/Pager.js.map +1 -1
  31. package/lib/module/PagerViewAdapter.js +17 -15
  32. package/lib/module/PagerViewAdapter.js.map +1 -1
  33. package/lib/module/PanResponderAdapter.js +20 -16
  34. package/lib/module/PanResponderAdapter.js.map +1 -1
  35. package/lib/module/PlatformPressable.js +19 -15
  36. package/lib/module/PlatformPressable.js.map +1 -1
  37. package/lib/module/SceneMap.js +14 -11
  38. package/lib/module/SceneMap.js.map +1 -1
  39. package/lib/module/SceneView.js +2 -2
  40. package/lib/module/SceneView.js.map +1 -1
  41. package/lib/module/TabBar.js +125 -81
  42. package/lib/module/TabBar.js.map +1 -1
  43. package/lib/module/TabBarIndicator.js +7 -6
  44. package/lib/module/TabBarIndicator.js.map +1 -1
  45. package/lib/module/TabBarItem.js +7 -6
  46. package/lib/module/TabBarItem.js.map +1 -1
  47. package/lib/module/TabView.js +39 -32
  48. package/lib/module/TabView.js.map +1 -1
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/module/types.js +1 -1
  51. package/lib/module/types.js.map +1 -1
  52. package/lib/module/useAnimatedValue.js.map +1 -1
  53. package/lib/typescript/TabBar.d.ts +3 -1
  54. package/lib/typescript/TabBarIndicator.d.ts +1 -0
  55. package/lib/typescript/TabView.d.ts +2 -1
  56. package/package.json +19 -18
  57. package/src/TabBar.tsx +75 -31
  58. package/src/TabBarIndicator.tsx +14 -5
  59. package/src/TabView.tsx +3 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["TabBarItem.tsx"],"names":["React","Animated","StyleSheet","View","PlatformPressable","DEFAULT_ACTIVE_COLOR","DEFAULT_INACTIVE_COLOR","TabBarItem","Component","position","routes","tabIndex","length","inputRange","map","_","i","interpolate","outputRange","render","route","navigationState","renderLabel","renderLabelCustom","renderIcon","renderBadge","getLabelText","getTestID","getAccessibilityLabel","getAccessible","activeColor","activeColorCustom","inactiveColor","inactiveColorCustom","pressColor","pressOpacity","labelStyle","style","onLayout","onPress","onLongPress","props","indexOf","isFocused","index","labelColorFromStyle","flatten","color","undefined","activeOpacity","getActiveOpacity","inactiveOpacity","getInactiveOpacity","icon","label","activeIcon","focused","inactiveIcon","styles","opacity","absoluteFill","labelText","marginTop","activeLabel","inactiveLabel","tabStyle","isWidthSet","width","tabContainerStyle","flex","scene","accessibilityLabel","badge","borderless","selected","pressable","item","create","margin","backgroundColor","textTransform","alignItems","justifyContent","padding","minHeight","top","right"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,QADF,EAEEC,UAFF,EAGEC,IAHF,QAQO,cARP;AASA,OAAOC,iBAAP,MAA8B,qBAA9B;AAiCA,MAAMC,oBAAoB,GAAG,wBAA7B;AACA,MAAMC,sBAAsB,GAAG,0BAA/B;AAEA,eAAe,MAAMC,UAAN,SAA0CP,KAAK,CAACQ,SAAhD,CAEb;AAAA;AAAA;;AAAA,8CAC2B,CACzBC,QADyB,EAEzBC,MAFyB,EAGzBC,QAHyB,KAItB;AACH,UAAID,MAAM,CAACE,MAAP,GAAgB,CAApB,EAAuB;AACrB,cAAMC,UAAU,GAAGH,MAAM,CAACI,GAAP,CAAW,CAACC,CAAD,EAAIC,CAAJ,KAAUA,CAArB,CAAnB;AAEA,eAAOP,QAAQ,CAACQ,WAAT,CAAqB;AAC1BJ,UAAAA,UAD0B;AAE1BK,UAAAA,WAAW,EAAEL,UAAU,CAACC,GAAX,CAAgBE,CAAD,IAAQA,CAAC,KAAKL,QAAN,GAAiB,CAAjB,GAAqB,CAA5C;AAFa,SAArB,CAAP;AAID,OAPD,MAOO;AACL,eAAO,CAAP;AACD;AACF,KAhBD;;AAAA,gDAkB6B,CAC3BF,QAD2B,EAE3BC,MAF2B,EAG3BC,QAH2B,KAIxB;AACH,UAAID,MAAM,CAACE,MAAP,GAAgB,CAApB,EAAuB;AACrB,cAAMC,UAAU,GAAGH,MAAM,CAACI,GAAP,CAAW,CAACC,CAAD,EAAWC,CAAX,KAAyBA,CAApC,CAAnB;AAEA,eAAOP,QAAQ,CAACQ,WAAT,CAAqB;AAC1BJ,UAAAA,UAD0B;AAE1BK,UAAAA,WAAW,EAAEL,UAAU,CAACC,GAAX,CAAgBE,CAAD,IAAgBA,CAAC,KAAKL,QAAN,GAAiB,CAAjB,GAAqB,CAApD;AAFa,SAArB,CAA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AELC,IAAAA,eAAe,EAAE,aAFZ;AAGLC,IAAAA,aAAa,EAAE;AAHV,GADwB;AAM/B3B,EAAAA,IAAI,EAAE;AACJyB,IAAAA,MAAM,EAAE;AADJ,GANyB;AAS/BF,EAAAA,IAAI,EAAE;AACJP,IAAAA,IAAI,EAAE,CADF;AAEJY,IAAAA,UAAU,EAAE,QAFR;AAGJC,IAAAA,cAAc,EAAE,QAHZ;AAIJC,IAAAA,OAAO,EAAE,EAJL;AAKJC,IAAAA,SAAS,EAAE;AALP,GATyB;AAgB/BZ,EAAAA,KAAK,EAAE;AACL/D,IAAAA,QAAQ,EAAE,UADL;AAEL4E,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,KAAK,EAAE;AAHF,GAhBwB;AAqB/BX,EAAAA,SAAS,EAAE;AACT;AACA;AACAI,IAAAA,eAAe,EAAE;AAHR;AArBoB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n StyleProp,\n LayoutChangeEvent,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport PlatformPressable from './PlatformPressable';\nimport type { Scene, Route, NavigationState } from './types';\n\nexport type Props<T extends Route> = {\n position: Animated.AnimatedInterpolation;\n route: T;\n navigationState: NavigationState<T>;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderIcon?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n onLayout?: (event: LayoutChangeEvent) => void;\n onPress: () => void;\n onLongPress: () => void;\n labelStyle?: StyleProp<TextStyle>;\n style: StyleProp<ViewStyle>;\n};\n\nconst DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';\nconst DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';\n\nexport default class TabBarItem<T extends Route> extends React.Component<\n Props<T>\n> {\n private getActiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_, i) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),\n });\n } else {\n return 1;\n }\n };\n\n private getInactiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_: Route, i: number) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),\n });\n } else {\n return 0;\n }\n };\n\n render() {\n const {\n route,\n position,\n navigationState,\n renderLabel: renderLabelCustom,\n renderIcon,\n renderBadge,\n getLabelText,\n getTestID,\n getAccessibilityLabel,\n getAccessible,\n activeColor: activeColorCustom,\n inactiveColor: inactiveColorCustom,\n pressColor,\n pressOpacity,\n labelStyle,\n style,\n onLayout,\n onPress,\n onLongPress,\n } = this.props;\n\n const tabIndex = navigationState.routes.indexOf(route);\n const isFocused = navigationState.index === tabIndex;\n\n const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;\n\n const activeColor =\n activeColorCustom !== undefined\n ? activeColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_ACTIVE_COLOR;\n const inactiveColor =\n inactiveColorCustom !== undefined\n ? inactiveColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_INACTIVE_COLOR;\n\n const activeOpacity = this.getActiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n const inactiveOpacity = this.getInactiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n\n let icon: React.ReactNode | null = null;\n let label: React.ReactNode | null = null;\n\n if (renderIcon) {\n const activeIcon = renderIcon({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveIcon = renderIcon({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n if (inactiveIcon != null && activeIcon != null) {\n icon = (\n <View style={styles.icon}>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveIcon}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeIcon}\n </Animated.View>\n </View>\n );\n }\n }\n\n const renderLabel =\n renderLabelCustom !== undefined\n ? renderLabelCustom\n : ({ route, color }: { route: T; color: string }) => {\n const labelText = getLabelText({ route });\n\n if (typeof labelText === 'string') {\n return (\n <Animated.Text\n style={[\n styles.label,\n icon ? { marginTop: 0 } : null,\n labelStyle,\n { color },\n ]}\n >\n {labelText}\n </Animated.Text>\n );\n }\n\n return labelText;\n };\n\n if (renderLabel) {\n const activeLabel = renderLabel({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveLabel = renderLabel({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n label = (\n <View>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveLabel}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeLabel}\n </Animated.View>\n </View>\n );\n }\n\n const tabStyle = StyleSheet.flatten(style);\n const isWidthSet = tabStyle?.width !== undefined;\n const tabContainerStyle: ViewStyle | null = isWidthSet ? null : { flex: 1 };\n\n const scene = { route };\n\n let accessibilityLabel = getAccessibilityLabel(scene);\n\n accessibilityLabel =\n typeof accessibilityLabel !== 'undefined'\n ? accessibilityLabel\n : getLabelText(scene);\n\n const badge = renderBadge ? renderBadge(scene) : null;\n\n return (\n <PlatformPressable\n android_ripple={{ borderless: true }}\n testID={getTestID(scene)}\n accessible={getAccessible(scene)}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isFocused }}\n // @ts-ignore: this is to support older React Native versions\n accessibilityStates={isFocused ? ['selected'] : []}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n delayPressIn={0}\n onLayout={onLayout}\n onPress={onPress}\n onLongPress={onLongPress}\n style={[styles.pressable, tabContainerStyle]}\n >\n <View pointerEvents=\"none\" style={[styles.item, tabStyle]}>\n {icon}\n {label}\n {badge != null ? <View style={styles.badge}>{badge}</View> : null}\n </View>\n </PlatformPressable>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n label: {\n margin: 4,\n backgroundColor: 'transparent',\n textTransform: 'uppercase',\n },\n icon: {\n margin: 2,\n },\n item: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 10,\n minHeight: 48,\n },\n badge: {\n position: 'absolute',\n top: 0,\n right: 0,\n },\n pressable: {\n // The label is not pressable on Windows\n // Adding backgroundColor: 'transparent' seems to fix it\n backgroundColor: 'transparent',\n },\n});\n"]}
1
+ {"version":3,"names":["React","Animated","StyleSheet","View","PlatformPressable","DEFAULT_ACTIVE_COLOR","DEFAULT_INACTIVE_COLOR","TabBarItem","Component","position","routes","tabIndex","length","inputRange","map","_","i","interpolate","outputRange","render","route","navigationState","renderLabel","renderLabelCustom","renderIcon","renderBadge","getLabelText","getTestID","getAccessibilityLabel","getAccessible","activeColor","activeColorCustom","inactiveColor","inactiveColorCustom","pressColor","pressOpacity","labelStyle","style","onLayout","onPress","onLongPress","props","indexOf","isFocused","index","labelColorFromStyle","flatten","color","undefined","activeOpacity","getActiveOpacity","inactiveOpacity","getInactiveOpacity","icon","label","activeIcon","focused","inactiveIcon","styles","opacity","absoluteFill","labelText","marginTop","activeLabel","inactiveLabel","tabStyle","isWidthSet","width","tabContainerStyle","flex","scene","accessibilityLabel","badge","borderless","selected","pressable","item","create","margin","backgroundColor","textTransform","alignItems","justifyContent","padding","minHeight","top","right"],"sources":["TabBarItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n StyleProp,\n LayoutChangeEvent,\n TextStyle,\n ViewStyle,\n} from 'react-native';\nimport PlatformPressable from './PlatformPressable';\nimport type { Scene, Route, NavigationState } from './types';\n\nexport type Props<T extends Route> = {\n position: Animated.AnimatedInterpolation;\n route: T;\n navigationState: NavigationState<T>;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n pressOpacity?: number;\n getLabelText: (scene: Scene<T>) => string | undefined;\n getAccessible: (scene: Scene<T>) => boolean | undefined;\n getAccessibilityLabel: (scene: Scene<T>) => string | undefined;\n getTestID: (scene: Scene<T>) => string | undefined;\n renderLabel?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderIcon?: (scene: {\n route: T;\n focused: boolean;\n color: string;\n }) => React.ReactNode;\n renderBadge?: (scene: Scene<T>) => React.ReactNode;\n onLayout?: (event: LayoutChangeEvent) => void;\n onPress: () => void;\n onLongPress: () => void;\n labelStyle?: StyleProp<TextStyle>;\n style: StyleProp<ViewStyle>;\n};\n\nconst DEFAULT_ACTIVE_COLOR = 'rgba(255, 255, 255, 1)';\nconst DEFAULT_INACTIVE_COLOR = 'rgba(255, 255, 255, 0.7)';\n\nexport default class TabBarItem<T extends Route> extends React.Component<\n Props<T>\n> {\n private getActiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_, i) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i) => (i === tabIndex ? 1 : 0)),\n });\n } else {\n return 1;\n }\n };\n\n private getInactiveOpacity = (\n position: Animated.AnimatedInterpolation,\n routes: Route[],\n tabIndex: number\n ) => {\n if (routes.length > 1) {\n const inputRange = routes.map((_: Route, i: number) => i);\n\n return position.interpolate({\n inputRange,\n outputRange: inputRange.map((i: number) => (i === tabIndex ? 0 : 1)),\n });\n } else {\n return 0;\n }\n };\n\n render() {\n const {\n route,\n position,\n navigationState,\n renderLabel: renderLabelCustom,\n renderIcon,\n renderBadge,\n getLabelText,\n getTestID,\n getAccessibilityLabel,\n getAccessible,\n activeColor: activeColorCustom,\n inactiveColor: inactiveColorCustom,\n pressColor,\n pressOpacity,\n labelStyle,\n style,\n onLayout,\n onPress,\n onLongPress,\n } = this.props;\n\n const tabIndex = navigationState.routes.indexOf(route);\n const isFocused = navigationState.index === tabIndex;\n\n const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;\n\n const activeColor =\n activeColorCustom !== undefined\n ? activeColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_ACTIVE_COLOR;\n const inactiveColor =\n inactiveColorCustom !== undefined\n ? inactiveColorCustom\n : typeof labelColorFromStyle === 'string'\n ? labelColorFromStyle\n : DEFAULT_INACTIVE_COLOR;\n\n const activeOpacity = this.getActiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n const inactiveOpacity = this.getInactiveOpacity(\n position,\n navigationState.routes,\n tabIndex\n );\n\n let icon: React.ReactNode | null = null;\n let label: React.ReactNode | null = null;\n\n if (renderIcon) {\n const activeIcon = renderIcon({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveIcon = renderIcon({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n if (inactiveIcon != null && activeIcon != null) {\n icon = (\n <View style={styles.icon}>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveIcon}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeIcon}\n </Animated.View>\n </View>\n );\n }\n }\n\n const renderLabel =\n renderLabelCustom !== undefined\n ? renderLabelCustom\n : ({ route, color }: { route: T; color: string }) => {\n const labelText = getLabelText({ route });\n\n if (typeof labelText === 'string') {\n return (\n <Animated.Text\n style={[\n styles.label,\n icon ? { marginTop: 0 } : null,\n labelStyle,\n { color },\n ]}\n >\n {labelText}\n </Animated.Text>\n );\n }\n\n return labelText;\n };\n\n if (renderLabel) {\n const activeLabel = renderLabel({\n route,\n focused: true,\n color: activeColor,\n });\n const inactiveLabel = renderLabel({\n route,\n focused: false,\n color: inactiveColor,\n });\n\n label = (\n <View>\n <Animated.View style={{ opacity: inactiveOpacity }}>\n {inactiveLabel}\n </Animated.View>\n <Animated.View\n style={[StyleSheet.absoluteFill, { opacity: activeOpacity }]}\n >\n {activeLabel}\n </Animated.View>\n </View>\n );\n }\n\n const tabStyle = StyleSheet.flatten(style);\n const isWidthSet = tabStyle?.width !== undefined;\n const tabContainerStyle: ViewStyle | null = isWidthSet ? null : { flex: 1 };\n\n const scene = { route };\n\n let accessibilityLabel = getAccessibilityLabel(scene);\n\n accessibilityLabel =\n typeof accessibilityLabel !== 'undefined'\n ? accessibilityLabel\n : getLabelText(scene);\n\n const badge = renderBadge ? renderBadge(scene) : null;\n\n return (\n <PlatformPressable\n android_ripple={{ borderless: true }}\n testID={getTestID(scene)}\n accessible={getAccessible(scene)}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole=\"tab\"\n accessibilityState={{ selected: isFocused }}\n // @ts-ignore: this is to support older React Native versions\n accessibilityStates={isFocused ? ['selected'] : []}\n pressColor={pressColor}\n pressOpacity={pressOpacity}\n delayPressIn={0}\n onLayout={onLayout}\n onPress={onPress}\n onLongPress={onLongPress}\n style={[styles.pressable, tabContainerStyle]}\n >\n <View pointerEvents=\"none\" style={[styles.item, tabStyle]}>\n {icon}\n {label}\n {badge != null ? <View style={styles.badge}>{badge}</View> : null}\n </View>\n </PlatformPressable>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n label: {\n margin: 4,\n backgroundColor: 'transparent',\n textTransform: 'uppercase',\n },\n icon: {\n margin: 2,\n },\n item: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 10,\n minHeight: 48,\n },\n badge: {\n position: 'absolute',\n top: 0,\n right: 0,\n },\n pressable: {\n // The label is not pressable on Windows\n // Adding backgroundColor: 'transparent' seems to fix it\n backgroundColor: 'transparent',\n },\n});\n"],"mappings":";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UAAD,CAAH,GAAkB,EARlD;MASE,UAAU,EAAET,UATd;MAUE,YAAY,EAAEC,YAVhB;MAWE,YAAY,EAAE,CAXhB;MAYE,QAAQ,EAAEG,QAZZ;MAaE,OAAO,EAAEC,OAbX;MAcE,WAAW,EAAEC,WAdf;MAeE,KAAK,EAAE,CAACkB,MAAM,CAACiB,SAAR,EAAmBP,iBAAnB;IAfT,gBAiBE,oBAAC,IAAD;MAAM,aAAa,EAAC,MAApB;MAA2B,KAAK,EAAE,CAACV,MAAM,CAACkB,IAAR,EAAcX,QAAd;IAAlC,GACGZ,IADH,EAEGC,KAFH,EAGGkB,KAAK,IAAI,IAAT,gBAAgB,oBAAC,IAAD;MAAM,KAAK,EAAEd,MAAM,CAACc;IAApB,GAA4BA,KAA5B,CAAhB,GAA4D,IAH/D,CAjBF,CADF;EAyBD;;AAhND;AAmNF,MAAMd,MAAM,GAAGxD,UAAU,CAAC2E,MAAX,CAAkB;EAC/BvB,KAAK,EAAE;IACLwB,MAAM,EAAE,CADH;IAELC,eAAe,EAAE,aAFZ;IAGLC,aAAa,EAAE;EAHV,CADwB;EAM/B3B,IAAI,EAAE;IACJyB,MAAM,EAAE;EADJ,CANyB;EAS/BF,IAAI,EAAE;IACJP,IAAI,EAAE,CADF;IAEJY,UAAU,EAAE,QAFR;IAGJC,cAAc,EAAE,QAHZ;IAIJC,OAAO,EAAE,EAJL;IAKJC,SAAS,EAAE;EALP,CATyB;EAgB/BZ,KAAK,EAAE;IACL/D,QAAQ,EAAE,UADL;IAEL4E,GAAG,EAAE,CAFA;IAGLC,KAAK,EAAE;EAHF,CAhBwB;EAqB/BX,SAAS,EAAE;IACT;IACA;IACAI,eAAe,EAAE;EAHR;AArBoB,CAAlB,CAAf"}
@@ -1,27 +1,29 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import * as React from 'react';
4
4
  import { StyleSheet, View } from 'react-native';
5
5
  import TabBar from './TabBar';
6
6
  import SceneView from './SceneView';
7
7
  import Pager from './Pager';
8
- export default function TabView({
9
- onIndexChange,
10
- navigationState,
11
- renderScene,
12
- initialLayout,
13
- keyboardDismissMode = 'auto',
14
- lazy = false,
15
- lazyPreloadDistance = 0,
16
- onSwipeStart,
17
- onSwipeEnd,
18
- renderLazyPlaceholder = () => null,
19
- renderTabBar = props => /*#__PURE__*/React.createElement(TabBar, props),
20
- sceneContainerStyle,
21
- style,
22
- swipeEnabled = true,
23
- tabBarPosition = 'top'
24
- }) {
8
+ export default function TabView(_ref) {
9
+ let {
10
+ onIndexChange,
11
+ navigationState,
12
+ renderScene,
13
+ initialLayout,
14
+ keyboardDismissMode = 'auto',
15
+ lazy = false,
16
+ lazyPreloadDistance = 0,
17
+ onSwipeStart,
18
+ onSwipeEnd,
19
+ renderLazyPlaceholder = () => null,
20
+ renderTabBar = props => /*#__PURE__*/React.createElement(TabBar, props),
21
+ sceneContainerStyle,
22
+ pagerStyle,
23
+ style,
24
+ swipeEnabled = true,
25
+ tabBarPosition = 'top'
26
+ } = _ref;
25
27
  const [layout, setLayout] = React.useState({
26
28
  width: 0,
27
29
  height: 0,
@@ -61,13 +63,15 @@ export default function TabView({
61
63
  swipeEnabled: swipeEnabled,
62
64
  onSwipeStart: onSwipeStart,
63
65
  onSwipeEnd: onSwipeEnd,
64
- onIndexChange: jumpToIndex
65
- }, ({
66
- position,
67
- render,
68
- addEnterListener,
69
- jumpTo
70
- }) => {
66
+ onIndexChange: jumpToIndex,
67
+ style: pagerStyle
68
+ }, _ref2 => {
69
+ let {
70
+ position,
71
+ render,
72
+ addEnterListener,
73
+ jumpTo
74
+ } = _ref2;
71
75
  // All of the props here must not change between re-renders
72
76
  // This is crucial to optimizing the routes with PureComponent
73
77
  const sceneRendererProps = {
@@ -88,13 +92,16 @@ export default function TabView({
88
92
  lazyPreloadDistance: lazyPreloadDistance,
89
93
  navigationState: navigationState,
90
94
  style: sceneContainerStyle
91
- }), ({
92
- loading
93
- }) => loading ? renderLazyPlaceholder({
94
- route
95
- }) : renderScene({ ...sceneRendererProps,
96
- route
97
- }));
95
+ }), _ref3 => {
96
+ let {
97
+ loading
98
+ } = _ref3;
99
+ return loading ? renderLazyPlaceholder({
100
+ route
101
+ }) : renderScene({ ...sceneRendererProps,
102
+ route
103
+ });
104
+ });
98
105
  })), tabBarPosition === 'bottom' && renderTabBar({ ...sceneRendererProps,
99
106
  navigationState
100
107
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["TabView.tsx"],"names":["React","StyleSheet","View","TabBar","SceneView","Pager","TabView","onIndexChange","navigationState","renderScene","initialLayout","keyboardDismissMode","lazy","lazyPreloadDistance","onSwipeStart","onSwipeEnd","renderLazyPlaceholder","renderTabBar","props","sceneContainerStyle","style","swipeEnabled","tabBarPosition","layout","setLayout","useState","width","height","jumpToIndex","index","handleLayout","e","nativeEvent","prevLayout","styles","pager","position","render","addEnterListener","jumpTo","sceneRendererProps","routes","map","route","i","key","loading","create","flex","overflow"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,IAFF,QAMO,cANP;AAOA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AAyBA,eAAe,SAASC,OAAT,CAAkC;AAC/CC,EAAAA,aAD+C;AAE/CC,EAAAA,eAF+C;AAG/CC,EAAAA,WAH+C;AAI/CC,EAAAA,aAJ+C;AAK/CC,EAAAA,mBAAmB,GAAG,MALyB;AAM/CC,EAAAA,IAAI,G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EA+BGrB,cAAc,KAAK,QAAnB,IACCL,YAAY,CAAC,EACX,GAAGuB,kBADQ;AAEXhC,MAAAA;AAFW,KAAD,CAhChB,CADF;AAuCD,GAzDH,CADF,CADF;AA+DD;AAED,MAAM0B,MAAM,GAAGjC,UAAU,CAAC8C,MAAX,CAAkB;AAC/BZ,EAAAA,KAAK,EAAE;AACLa,IAAAA,IAAI,EAAE,CADD;AAELC,IAAAA,QAAQ,EAAE;AAFL;AADwB,CAAlB,CAAf","sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from 'react-native';\nimport TabBar from './TabBar';\nimport SceneView from './SceneView';\nimport Pager from './Pager';\nimport type {\n Layout,\n NavigationState,\n Route,\n SceneRendererProps,\n PagerProps,\n} from './types';\n\nexport type Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;\n renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;\n renderTabBar?: (\n props: SceneRendererProps & { navigationState: NavigationState<T> }\n ) => React.ReactNode;\n tabBarPosition?: 'top' | 'bottom';\n initialLayout?: Partial<Layout>;\n lazy?: ((props: { route: T }) => boolean) | boolean;\n lazyPreloadDistance?: number;\n sceneContainerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\nexport default function TabView<T extends Route>({\n onIndexChange,\n navigationState,\n renderScene,\n initialLayout,\n keyboardDismissMode = 'auto',\n lazy = false,\n lazyPreloadDistance = 0,\n onSwipeStart,\n onSwipeEnd,\n renderLazyPlaceholder = () => null,\n renderTabBar = (props) => <TabBar {...props} />,\n sceneContainerStyle,\n style,\n swipeEnabled = true,\n tabBarPosition = 'top',\n}: Props<T>) {\n const [layout, setLayout] = React.useState({\n width: 0,\n height: 0,\n ...initialLayout,\n });\n\n const jumpToIndex = (index: number) => {\n if (index !== navigationState.index) {\n onIndexChange(index);\n }\n };\n\n const handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n setLayout((prevLayout) => {\n if (prevLayout.width === width && prevLayout.height === height) {\n return prevLayout;\n }\n\n return { height, width };\n });\n };\n\n return (\n <View onLayout={handleLayout} style={[styles.pager, style]}>\n <Pager\n layout={layout}\n navigationState={navigationState}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n onSwipeStart={onSwipeStart}\n onSwipeEnd={onSwipeEnd}\n onIndexChange={jumpToIndex}\n >\n {({ position, render, addEnterListener, jumpTo }) => {\n // All of the props here must not change between re-renders\n // This is crucial to optimizing the routes with PureComponent\n const sceneRendererProps = {\n position,\n layout,\n jumpTo,\n };\n\n return (\n <React.Fragment>\n {tabBarPosition === 'top' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n {render(\n navigationState.routes.map((route, i) => {\n return (\n <SceneView\n {...sceneRendererProps}\n addEnterListener={addEnterListener}\n key={route.key}\n index={i}\n lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}\n lazyPreloadDistance={lazyPreloadDistance}\n navigationState={navigationState}\n style={sceneContainerStyle}\n >\n {({ loading }) =>\n loading\n ? renderLazyPlaceholder({ route })\n : renderScene({\n ...sceneRendererProps,\n route,\n })\n }\n </SceneView>\n );\n })\n )}\n {tabBarPosition === 'bottom' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n </React.Fragment>\n );\n }}\n </Pager>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n pager: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"]}
1
+ {"version":3,"names":["React","StyleSheet","View","TabBar","SceneView","Pager","TabView","onIndexChange","navigationState","renderScene","initialLayout","keyboardDismissMode","lazy","lazyPreloadDistance","onSwipeStart","onSwipeEnd","renderLazyPlaceholder","renderTabBar","props","sceneContainerStyle","pagerStyle","style","swipeEnabled","tabBarPosition","layout","setLayout","useState","width","height","jumpToIndex","index","handleLayout","e","nativeEvent","prevLayout","styles","pager","position","render","addEnterListener","jumpTo","sceneRendererProps","routes","map","route","i","key","loading","create","flex","overflow"],"sources":["TabView.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n StyleSheet,\n View,\n StyleProp,\n ViewStyle,\n LayoutChangeEvent,\n} from 'react-native';\nimport TabBar from './TabBar';\nimport SceneView from './SceneView';\nimport Pager from './Pager';\nimport type {\n Layout,\n NavigationState,\n Route,\n SceneRendererProps,\n PagerProps,\n} from './types';\n\nexport type Props<T extends Route> = PagerProps & {\n onIndexChange: (index: number) => void;\n navigationState: NavigationState<T>;\n renderScene: (props: SceneRendererProps & { route: T }) => React.ReactNode;\n renderLazyPlaceholder?: (props: { route: T }) => React.ReactNode;\n renderTabBar?: (\n props: SceneRendererProps & { navigationState: NavigationState<T> }\n ) => React.ReactNode;\n tabBarPosition?: 'top' | 'bottom';\n initialLayout?: Partial<Layout>;\n lazy?: ((props: { route: T }) => boolean) | boolean;\n lazyPreloadDistance?: number;\n sceneContainerStyle?: StyleProp<ViewStyle>;\n pagerStyle?: StyleProp<ViewStyle>;\n style?: StyleProp<ViewStyle>;\n};\n\nexport default function TabView<T extends Route>({\n onIndexChange,\n navigationState,\n renderScene,\n initialLayout,\n keyboardDismissMode = 'auto',\n lazy = false,\n lazyPreloadDistance = 0,\n onSwipeStart,\n onSwipeEnd,\n renderLazyPlaceholder = () => null,\n renderTabBar = (props) => <TabBar {...props} />,\n sceneContainerStyle,\n pagerStyle,\n style,\n swipeEnabled = true,\n tabBarPosition = 'top',\n}: Props<T>) {\n const [layout, setLayout] = React.useState({\n width: 0,\n height: 0,\n ...initialLayout,\n });\n\n const jumpToIndex = (index: number) => {\n if (index !== navigationState.index) {\n onIndexChange(index);\n }\n };\n\n const handleLayout = (e: LayoutChangeEvent) => {\n const { height, width } = e.nativeEvent.layout;\n\n setLayout((prevLayout) => {\n if (prevLayout.width === width && prevLayout.height === height) {\n return prevLayout;\n }\n\n return { height, width };\n });\n };\n\n return (\n <View onLayout={handleLayout} style={[styles.pager, style]}>\n <Pager\n layout={layout}\n navigationState={navigationState}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n onSwipeStart={onSwipeStart}\n onSwipeEnd={onSwipeEnd}\n onIndexChange={jumpToIndex}\n style={pagerStyle}\n >\n {({ position, render, addEnterListener, jumpTo }) => {\n // All of the props here must not change between re-renders\n // This is crucial to optimizing the routes with PureComponent\n const sceneRendererProps = {\n position,\n layout,\n jumpTo,\n };\n\n return (\n <React.Fragment>\n {tabBarPosition === 'top' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n {render(\n navigationState.routes.map((route, i) => {\n return (\n <SceneView\n {...sceneRendererProps}\n addEnterListener={addEnterListener}\n key={route.key}\n index={i}\n lazy={typeof lazy === 'function' ? lazy({ route }) : lazy}\n lazyPreloadDistance={lazyPreloadDistance}\n navigationState={navigationState}\n style={sceneContainerStyle}\n >\n {({ loading }) =>\n loading\n ? renderLazyPlaceholder({ route })\n : renderScene({\n ...sceneRendererProps,\n route,\n })\n }\n </SceneView>\n );\n })\n )}\n {tabBarPosition === 'bottom' &&\n renderTabBar({\n ...sceneRendererProps,\n navigationState,\n })}\n </React.Fragment>\n );\n }}\n </Pager>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n pager: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SACEC,UADF,EAEEC,IAFF,QAMO,cANP;AAOA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AA0BA,eAAe,SAASC,OAAT,OAiBF;EAAA,IAjBoC;IAC/CC,aAD+C;IAE/CC,eAF+C;IAG/CC,WAH+C;IAI/CC,aAJ+C;IAK/CC,mBAAmB,GAAG,MALyB;IAM/CC,IAAI,GAAG,KANwC;IAO/CC,mBAAm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AAlB,CAAf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["default","TabBar","TabView","TabBarIndicator","TabBarItem","SceneMap"],"mappings":"AAAA,SAASA,OAAO,IAAIC,MAApB,QAAkC,UAAlC;AAGA,SAASD,OAAO,IAAIE,OAApB,QAAmC,WAAnC;AAGA,SAASF,OAAO,IAAIG,eAApB,QAA2C,mBAA3C;AAGA,SAASH,OAAO,IAAII,UAApB,QAAsC,cAAtC;AAGA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,YAApC","sourcesContent":["export { default as TabBar } from './TabBar';\nexport type { Props as TabBarProps } from './TabBar';\n\nexport { default as TabView } from './TabView';\nexport type { Props as TabViewProps } from './TabView';\n\nexport { default as TabBarIndicator } from './TabBarIndicator';\nexport type { Props as TabBarIndicatorProps } from './TabBarIndicator';\n\nexport { default as TabBarItem } from './TabBarItem';\nexport type { Props as TabBarItemProps } from './TabBarItem';\n\nexport { default as SceneMap } from './SceneMap';\n\nexport type { Route, NavigationState, SceneRendererProps } from './types';\n"]}
1
+ {"version":3,"names":["default","TabBar","TabView","TabBarIndicator","TabBarItem","SceneMap"],"sources":["index.tsx"],"sourcesContent":["export { default as TabBar } from './TabBar';\nexport type { Props as TabBarProps } from './TabBar';\n\nexport { default as TabView } from './TabView';\nexport type { Props as TabViewProps } from './TabView';\n\nexport { default as TabBarIndicator } from './TabBarIndicator';\nexport type { Props as TabBarIndicatorProps } from './TabBarIndicator';\n\nexport { default as TabBarItem } from './TabBarItem';\nexport type { Props as TabBarItemProps } from './TabBarItem';\n\nexport { default as SceneMap } from './SceneMap';\n\nexport type { Route, NavigationState, SceneRendererProps } from './types';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,MAApB,QAAkC,UAAlC;AAGA,SAASD,OAAO,IAAIE,OAApB,QAAmC,WAAnC;AAGA,SAASF,OAAO,IAAIG,eAApB,QAA2C,mBAA3C;AAGA,SAASH,OAAO,IAAII,UAApB,QAAsC,cAAtC;AAGA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,YAApC"}
@@ -1,2 +1,2 @@
1
-
1
+ export {};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
1
+ {"version":3,"names":[],"sources":["types.tsx"],"sourcesContent":["import type { Animated } from 'react-native';\nimport type { PagerViewProps } from 'react-native-pager-view';\n\nexport type Route = {\n key: string;\n icon?: string;\n title?: string;\n accessible?: boolean;\n accessibilityLabel?: string;\n testID?: string;\n};\n\nexport type Event = {\n defaultPrevented: boolean;\n preventDefault(): void;\n};\n\nexport type Scene<T extends Route> = {\n route: T;\n};\n\nexport type NavigationState<T extends Route> = {\n index: number;\n routes: T[];\n};\n\nexport type Layout = {\n width: number;\n height: number;\n};\n\nexport type Listener = (value: number) => void;\n\nexport type SceneRendererProps = {\n layout: Layout;\n position: Animated.AnimatedInterpolation;\n jumpTo: (key: string) => void;\n};\n\nexport type EventEmitterProps = {\n addEnterListener: (listener: Listener) => () => void;\n};\n\nexport type PagerProps = Omit<\n PagerViewProps,\n | 'initialPage'\n | 'scrollEnabled'\n | 'onPageScroll'\n | 'onPageSelected'\n | 'onPageScrollStateChanged'\n | 'keyboardDismissMode'\n | 'children'\n> & {\n keyboardDismissMode?: 'none' | 'on-drag' | 'auto';\n swipeEnabled?: boolean;\n onSwipeStart?: () => void;\n onSwipeEnd?: () => void;\n};\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["useAnimatedValue.tsx"],"names":["React","Animated","useAnimatedValue","initialValue","lazyRef","useRef","current","undefined","Value"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,eAAe,SAASC,gBAAT,CAA0BC,YAA1B,EAAgD;AAC7D,QAAMC,OAAO,GAAGJ,KAAK,CAACK,MAAN,EAAhB;;AAEA,MAAID,OAAO,CAACE,OAAR,KAAoBC,SAAxB,EAAmC;AACjCH,IAAAA,OAAO,CAACE,OAAR,GAAkB,IAAIL,QAAQ,CAACO,KAAb,CAAmBL,YAAnB,CAAlB;AACD;;AAED,SAAOC,OAAO,CAACE,OAAf;AACD","sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\nexport default function useAnimatedValue(initialValue: number) {\n const lazyRef = React.useRef<Animated.Value>();\n\n if (lazyRef.current === undefined) {\n lazyRef.current = new Animated.Value(initialValue);\n }\n\n return lazyRef.current as Animated.Value;\n}\n"]}
1
+ {"version":3,"names":["React","Animated","useAnimatedValue","initialValue","lazyRef","useRef","current","undefined","Value"],"sources":["useAnimatedValue.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Animated } from 'react-native';\n\nexport default function useAnimatedValue(initialValue: number) {\n const lazyRef = React.useRef<Animated.Value>();\n\n if (lazyRef.current === undefined) {\n lazyRef.current = new Animated.Value(initialValue);\n }\n\n return lazyRef.current as Animated.Value;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,eAAe,SAASC,gBAAT,CAA0BC,YAA1B,EAAgD;EAC7D,MAAMC,OAAO,GAAGJ,KAAK,CAACK,MAAN,EAAhB;;EAEA,IAAID,OAAO,CAACE,OAAR,KAAoBC,SAAxB,EAAmC;IACjCH,OAAO,CAACE,OAAR,GAAkB,IAAIL,QAAQ,CAACO,KAAb,CAAmBL,YAAnB,CAAlB;EACD;;EAED,OAAOC,OAAO,CAACE,OAAf;AACD"}
@@ -36,6 +36,7 @@ export declare type Props<T extends Route> = SceneRendererProps & {
36
36
  labelStyle?: StyleProp<TextStyle>;
37
37
  contentContainerStyle?: StyleProp<ViewStyle>;
38
38
  style?: StyleProp<ViewStyle>;
39
+ gap?: number;
39
40
  };
40
41
  declare type State = {
41
42
  layout: Layout;
@@ -50,12 +51,13 @@ export default class TabBar<T extends Route> extends React.Component<Props<T>, S
50
51
  getAccessibilityLabel: ({ route }: Scene<Route>) => string | undefined;
51
52
  getTestID: ({ route }: Scene<Route>) => string | undefined;
52
53
  renderIndicator: (props: IndicatorProps<Route>) => JSX.Element;
54
+ gap: number;
53
55
  };
54
56
  state: State;
55
57
  componentDidUpdate(prevProps: Props<T>, prevState: State): void;
56
58
  private measuredTabWidths;
57
59
  private scrollAmount;
58
- private scrollViewRef;
60
+ private flatListRef;
59
61
  private getFlattenedTabWidth;
60
62
  private getComputedTabWidth;
61
63
  private getMaxScrollDistance;
@@ -7,6 +7,7 @@ export declare type Props<T extends Route> = SceneRendererProps & {
7
7
  width: string | number;
8
8
  style?: StyleProp<ViewStyle>;
9
9
  getTabWidth: GetTabWidth;
10
+ gap?: number;
10
11
  };
11
12
  export default class TabBarIndicator<T extends Route> extends React.Component<Props<T>> {
12
13
  componentDidMount(): void;
@@ -20,6 +20,7 @@ export declare type Props<T extends Route> = PagerProps & {
20
20
  }) => boolean) | boolean;
21
21
  lazyPreloadDistance?: number;
22
22
  sceneContainerStyle?: StyleProp<ViewStyle>;
23
+ pagerStyle?: StyleProp<ViewStyle>;
23
24
  style?: StyleProp<ViewStyle>;
24
25
  };
25
- export default function TabView<T extends Route>({ onIndexChange, navigationState, renderScene, initialLayout, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, sceneContainerStyle, style, swipeEnabled, tabBarPosition, }: Props<T>): JSX.Element;
26
+ export default function TabView<T extends Route>({ onIndexChange, navigationState, renderScene, initialLayout, keyboardDismissMode, lazy, lazyPreloadDistance, onSwipeStart, onSwipeEnd, renderLazyPlaceholder, renderTabBar, sceneContainerStyle, pagerStyle, style, swipeEnabled, tabBarPosition, }: Props<T>): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tab-view",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "Tab view component for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "react-native": "src/index.tsx",
@@ -44,26 +44,27 @@
44
44
  },
45
45
  "homepage": "https://github.com/satya164/react-native-tab-view#readme",
46
46
  "devDependencies": {
47
- "@commitlint/config-conventional": "^13.1.0",
48
- "@expo/vector-icons": "^12.0.5",
49
- "@release-it/conventional-changelog": "^3.0.1",
50
- "@types/react": "^17.0.15",
51
- "@types/react-native": "0.64.12",
52
- "babel-jest": "^27.0.6",
47
+ "@commitlint/config-conventional": "^17.1.0",
48
+ "@expo/vector-icons": "^13.0.0",
49
+ "@release-it/conventional-changelog": "^5.1.0",
50
+ "@types/react": "^18.0.14",
51
+ "@types/react-native": "0.69.5",
52
+ "babel-jest": "^29.0.1",
53
+ "babel-loader": "^8.2.5",
53
54
  "babel-preset-react-native": "^4.0.0",
54
- "commitlint": "^13.1.0",
55
- "eslint": "^7.31.0",
56
- "eslint-config-satya164": "^3.1.10",
55
+ "commitlint": "^17.1.2",
56
+ "eslint": "^8.23.0",
57
+ "eslint-config-satya164": "^3.1.11",
57
58
  "eslint-plugin-react-native-globals": "^0.1.2",
58
59
  "husky": "^4.2.5",
59
- "jest": "^27.0.6",
60
- "prettier": "^2.3.2",
61
- "react": "~16.13.1",
62
- "react-native": "~0.63.4",
63
- "react-native-builder-bob": "^0.18.1",
64
- "react-native-pager-view": "^5.0.12",
65
- "release-it": "^14.10.1",
66
- "typescript": "^4.3.5"
60
+ "jest": "^29.0.1",
61
+ "prettier": "^2.7.1",
62
+ "react": "18.0.0",
63
+ "react-native": "0.69.5",
64
+ "react-native-builder-bob": "^0.18.3",
65
+ "react-native-pager-view": "5.4.24",
66
+ "release-it": "^15.4.0",
67
+ "typescript": "^4.8.2"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "react": "*",
package/src/TabBar.tsx CHANGED
@@ -3,13 +3,14 @@ import {
3
3
  Animated,
4
4
  StyleSheet,
5
5
  View,
6
- ScrollView,
7
6
  StyleProp,
8
7
  ViewStyle,
9
8
  TextStyle,
10
9
  LayoutChangeEvent,
11
10
  I18nManager,
12
11
  Platform,
12
+ FlatList,
13
+ ListRenderItemInfo,
13
14
  } from 'react-native';
14
15
  import TabBarItem, { Props as TabBarItemProps } from './TabBarItem';
15
16
  import TabBarIndicator, { Props as IndicatorProps } from './TabBarIndicator';
@@ -59,6 +60,7 @@ export type Props<T extends Route> = SceneRendererProps & {
59
60
  labelStyle?: StyleProp<TextStyle>;
60
61
  contentContainerStyle?: StyleProp<ViewStyle>;
61
62
  style?: StyleProp<ViewStyle>;
63
+ gap?: number;
62
64
  };
63
65
 
64
66
  type State = {
@@ -66,6 +68,10 @@ type State = {
66
68
  tabWidths: { [key: string]: number };
67
69
  };
68
70
 
71
+ const Separator = ({ width }: { width: number }) => {
72
+ return <View style={{ width }} />;
73
+ };
74
+
69
75
  export default class TabBar<T extends Route> extends React.Component<
70
76
  Props<T>,
71
77
  State
@@ -84,6 +90,7 @@ export default class TabBar<T extends Route> extends React.Component<
84
90
  renderIndicator: (props: IndicatorProps<Route>) => (
85
91
  <TabBarIndicator {...props} />
86
92
  ),
93
+ gap: 0,
87
94
  };
88
95
 
89
96
  state: State = {
@@ -125,7 +132,7 @@ export default class TabBar<T extends Route> extends React.Component<
125
132
 
126
133
  private scrollAmount = new Animated.Value(0);
127
134
 
128
- private scrollViewRef = React.createRef<ScrollView>();
135
+ private flatListRef = React.createRef<FlatList>();
129
136
 
130
137
  private getFlattenedTabWidth = (style: StyleProp<ViewStyle>) => {
131
138
  const tabStyle = StyleSheet.flatten(style);
@@ -160,7 +167,6 @@ export default class TabBar<T extends Route> extends React.Component<
160
167
  if (scrollEnabled) {
161
168
  return (layout.width / 5) * 2;
162
169
  }
163
-
164
170
  return layout.width / routes.length;
165
171
  };
166
172
 
@@ -175,6 +181,7 @@ export default class TabBar<T extends Route> extends React.Component<
175
181
  return routes.reduce<number>(
176
182
  (acc, _, i) =>
177
183
  acc +
184
+ (i > 0 ? props.gap ?? 0 : 0) +
178
185
  this.getComputedTabWidth(
179
186
  i,
180
187
  layout,
@@ -224,7 +231,12 @@ export default class TabBar<T extends Route> extends React.Component<
224
231
 
225
232
  // To get the current index centered we adjust scroll amount by width of indexes
226
233
  // 0 through (i - 1) and add half the width of current index i
227
- return total + (index === i ? tabWidth / 2 : tabWidth);
234
+ return (
235
+ total +
236
+ (index === i
237
+ ? (tabWidth + (props.gap ?? 0)) / 2
238
+ : tabWidth + (props.gap ?? 0))
239
+ );
228
240
  },
229
241
  0
230
242
  );
@@ -236,8 +248,8 @@ export default class TabBar<T extends Route> extends React.Component<
236
248
 
237
249
  private resetScroll = (index: number) => {
238
250
  if (this.props.scrollEnabled) {
239
- this.scrollViewRef.current?.scrollTo({
240
- x: this.getScrollAmount(this.props, this.state, index),
251
+ this.flatListRef.current?.scrollToOffset({
252
+ offset: this.getScrollAmount(this.props, this.state, index),
241
253
  animated: true,
242
254
  });
243
255
  }
@@ -299,12 +311,16 @@ export default class TabBar<T extends Route> extends React.Component<
299
311
  contentContainerStyle,
300
312
  style,
301
313
  indicatorContainerStyle,
314
+ gap = 0,
302
315
  } = this.props;
303
316
  const { layout, tabWidths } = this.state;
304
317
  const { routes } = navigationState;
305
318
 
306
319
  const isWidthDynamic = this.getFlattenedTabWidth(tabStyle) === 'auto';
307
320
  const tabBarWidth = this.getTabBarWidth(this.props, this.state);
321
+ const separatorsWidth = Math.max(0, routes.length - 1) * gap;
322
+ const separatorPercent = (separatorsWidth / tabBarWidth) * 100;
323
+
308
324
  const tabBarWidthPercent = `${routes.length * 40}%`;
309
325
  const translateX = this.getTranslateX(
310
326
  this.scrollAmount,
@@ -321,8 +337,8 @@ export default class TabBar<T extends Route> extends React.Component<
321
337
  style={[
322
338
  styles.indicatorContainer,
323
339
  scrollEnabled ? { transform: [{ translateX }] as any } : null,
324
- tabBarWidth
325
- ? { width: tabBarWidth }
340
+ tabBarWidth > separatorsWidth
341
+ ? { width: tabBarWidth - separatorsWidth }
326
342
  : scrollEnabled
327
343
  ? { width: tabBarWidthPercent }
328
344
  : null,
@@ -334,7 +350,9 @@ export default class TabBar<T extends Route> extends React.Component<
334
350
  layout,
335
351
  navigationState,
336
352
  jumpTo,
337
- width: isWidthDynamic ? 'auto' : `${100 / routes.length}%`,
353
+ width: isWidthDynamic
354
+ ? 'auto'
355
+ : `${(100 - separatorPercent) / routes.length}%`,
338
356
  style: indicatorStyle,
339
357
  getTabWidth: (i: number) =>
340
358
  this.getComputedTabWidth(
@@ -345,10 +363,13 @@ export default class TabBar<T extends Route> extends React.Component<
345
363
  tabWidths,
346
364
  this.getFlattenedTabWidth(tabStyle)
347
365
  ),
366
+ gap,
348
367
  })}
349
368
  </Animated.View>
350
369
  <View style={styles.scroll}>
351
- <Animated.ScrollView
370
+ <Animated.FlatList
371
+ data={routes as Animated.WithAnimatedValue<T>[]}
372
+ keyExtractor={(item) => item.key}
352
373
  horizontal
353
374
  accessibilityRole="tablist"
354
375
  keyboardShouldPersistTaps="handled"
@@ -357,29 +378,23 @@ export default class TabBar<T extends Route> extends React.Component<
357
378
  alwaysBounceHorizontal={false}
358
379
  scrollsToTop={false}
359
380
  showsHorizontalScrollIndicator={false}
381
+ showsVerticalScrollIndicator={false}
360
382
  automaticallyAdjustContentInsets={false}
361
383
  overScrollMode="never"
362
384
  contentContainerStyle={[
363
385
  styles.tabContent,
364
386
  scrollEnabled
365
- ? { width: tabBarWidth || tabBarWidthPercent }
387
+ ? {
388
+ width:
389
+ tabBarWidth > separatorsWidth
390
+ ? tabBarWidth
391
+ : tabBarWidthPercent,
392
+ }
366
393
  : styles.container,
367
394
  contentContainerStyle,
368
395
  ]}
369
396
  scrollEventThrottle={16}
370
- onScroll={Animated.event(
371
- [
372
- {
373
- nativeEvent: {
374
- contentOffset: { x: this.scrollAmount },
375
- },
376
- },
377
- ],
378
- { useNativeDriver: true }
379
- )}
380
- ref={this.scrollViewRef}
381
- >
382
- {routes.map((route: T) => {
397
+ renderItem={({ item: route, index }: ListRenderItemInfo<T>) => {
383
398
  const props: TabBarItemProps<T> & { key: string } = {
384
399
  key: route.key,
385
400
  position: position,
@@ -434,16 +449,45 @@ export default class TabBar<T extends Route> extends React.Component<
434
449
  },
435
450
  onLongPress: () => onTabLongPress?.({ route }),
436
451
  labelStyle: labelStyle,
437
- style: tabStyle,
452
+ style: [
453
+ tabStyle,
454
+ // Calculate the deafult width for tab for FlatList to work.
455
+ this.getFlattenedTabWidth(tabStyle) === undefined && {
456
+ width: this.getComputedTabWidth(
457
+ index,
458
+ layout,
459
+ routes,
460
+ scrollEnabled,
461
+ tabWidths,
462
+ this.getFlattenedTabWidth(tabStyle)
463
+ ),
464
+ },
465
+ ],
438
466
  };
439
467
 
440
- return renderTabBarItem ? (
441
- renderTabBarItem(props)
442
- ) : (
443
- <TabBarItem {...props} />
468
+ return (
469
+ <React.Fragment key={route.key}>
470
+ {gap > 0 && index > 0 ? <Separator width={gap} /> : null}
471
+ {renderTabBarItem ? (
472
+ renderTabBarItem(props)
473
+ ) : (
474
+ <TabBarItem {...props} />
475
+ )}
476
+ </React.Fragment>
444
477
  );
445
- })}
446
- </Animated.ScrollView>
478
+ }}
479
+ onScroll={Animated.event(
480
+ [
481
+ {
482
+ nativeEvent: {
483
+ contentOffset: { x: this.scrollAmount },
484
+ },
485
+ },
486
+ ],
487
+ { useNativeDriver: true }
488
+ )}
489
+ ref={this.flatListRef}
490
+ />
447
491
  </View>
448
492
  </Animated.View>
449
493
  );
@@ -18,6 +18,7 @@ export type Props<T extends Route> = SceneRendererProps & {
18
18
  width: string | number;
19
19
  style?: StyleProp<ViewStyle>;
20
20
  getTabWidth: GetTabWidth;
21
+ gap?: number;
21
22
  };
22
23
 
23
24
  export default class TabBarIndicator<T extends Route> extends React.Component<
@@ -59,14 +60,15 @@ export default class TabBarIndicator<T extends Route> extends React.Component<
59
60
  private getTranslateX = (
60
61
  position: Animated.AnimatedInterpolation,
61
62
  routes: Route[],
62
- getTabWidth: GetTabWidth
63
+ getTabWidth: GetTabWidth,
64
+ gap?: number
63
65
  ) => {
64
66
  const inputRange = routes.map((_, i) => i);
65
67
 
66
68
  // every index contains widths at all previous indices
67
69
  const outputRange = routes.reduce<number[]>((acc, _, i) => {
68
70
  if (i === 0) return [0];
69
- return [...acc, acc[i - 1] + getTabWidth(i - 1)];
71
+ return [...acc, acc[i - 1] + getTabWidth(i - 1) + (gap ?? 0)];
70
72
  }, []);
71
73
 
72
74
  const translateX = position.interpolate({
@@ -79,8 +81,15 @@ export default class TabBarIndicator<T extends Route> extends React.Component<
79
81
  };
80
82
 
81
83
  render() {
82
- const { position, navigationState, getTabWidth, width, style, layout } =
83
- this.props;
84
+ const {
85
+ position,
86
+ navigationState,
87
+ getTabWidth,
88
+ width,
89
+ style,
90
+ layout,
91
+ gap,
92
+ } = this.props;
84
93
  const { routes } = navigationState;
85
94
 
86
95
  const transform = [];
@@ -88,7 +97,7 @@ export default class TabBarIndicator<T extends Route> extends React.Component<
88
97
  if (layout.width) {
89
98
  const translateX =
90
99
  routes.length > 1
91
- ? this.getTranslateX(position, routes, getTabWidth)
100
+ ? this.getTranslateX(position, routes, getTabWidth, gap)
92
101
  : 0;
93
102
 
94
103
  transform.push({ translateX });
package/src/TabView.tsx CHANGED
@@ -30,6 +30,7 @@ export type Props<T extends Route> = PagerProps & {
30
30
  lazy?: ((props: { route: T }) => boolean) | boolean;
31
31
  lazyPreloadDistance?: number;
32
32
  sceneContainerStyle?: StyleProp<ViewStyle>;
33
+ pagerStyle?: StyleProp<ViewStyle>;
33
34
  style?: StyleProp<ViewStyle>;
34
35
  };
35
36
 
@@ -46,6 +47,7 @@ export default function TabView<T extends Route>({
46
47
  renderLazyPlaceholder = () => null,
47
48
  renderTabBar = (props) => <TabBar {...props} />,
48
49
  sceneContainerStyle,
50
+ pagerStyle,
49
51
  style,
50
52
  swipeEnabled = true,
51
53
  tabBarPosition = 'top',
@@ -84,6 +86,7 @@ export default function TabView<T extends Route>({
84
86
  onSwipeStart={onSwipeStart}
85
87
  onSwipeEnd={onSwipeEnd}
86
88
  onIndexChange={jumpToIndex}
89
+ style={pagerStyle}
87
90
  >
88
91
  {({ position, render, addEnterListener, jumpTo }) => {
89
92
  // All of the props here must not change between re-renders