@react-navigation/material-top-tabs 8.0.0-alpha.2 → 8.0.0-alpha.21

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.
@@ -3,7 +3,7 @@
3
3
  import * as React from 'react';
4
4
  import { TabAnimationContext } from "./TabAnimationContext.js";
5
5
  export function useTabAnimation() {
6
- const animation = React.useContext(TabAnimationContext);
6
+ const animation = React.use(TabAnimationContext);
7
7
  if (animation === undefined) {
8
8
  throw new Error("Couldn't find values for tab animation. Are you inside a screen in Material Top Tab navigator?");
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","TabAnimationContext","useTabAnimation","animation","useContext","undefined","Error"],"sourceRoot":"../../../src","sources":["utils/useTabAnimation.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,mBAAmB,QAAQ,0BAAuB;AAE3D,OAAO,SAASC,eAAeA,CAAA,EAAG;EAChC,MAAMC,SAAS,GAAGH,KAAK,CAACI,UAAU,CAACH,mBAAmB,CAAC;EAEvD,IAAIE,SAAS,KAAKE,SAAS,EAAE;IAC3B,MAAM,IAAIC,KAAK,CACb,gGACF,CAAC;EACH;EAEA,OAAOH,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"names":["React","TabAnimationContext","useTabAnimation","animation","use","undefined","Error"],"sourceRoot":"../../../src","sources":["utils/useTabAnimation.tsx"],"mappings":";;AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,mBAAmB,QAAQ,0BAAuB;AAE3D,OAAO,SAASC,eAAeA,CAAA,EAAG;EAChC,MAAMC,SAAS,GAAGH,KAAK,CAACI,GAAG,CAACH,mBAAmB,CAAC;EAEhD,IAAIE,SAAS,KAAKE,SAAS,EAAE;IAC3B,MAAM,IAAIC,KAAK,CACb,gGACF,CAAC;EACH;EAEA,OAAOH,SAAS;AAClB","ignoreList":[]}
@@ -2,8 +2,9 @@
2
2
 
3
3
  import { Text } from '@react-navigation/elements';
4
4
  import { Color } from '@react-navigation/elements/internal';
5
- import { useLinkBuilder, useLocale, useTheme } from '@react-navigation/native';
6
- import { StyleSheet } from 'react-native';
5
+ import { MaterialSymbol, SFSymbol, useLinkBuilder, useLocale, useTheme } from '@react-navigation/native';
6
+ import React from 'react';
7
+ import { Image, StyleSheet } from 'react-native';
7
8
  import { TabBar, TabBarIndicator } from 'react-native-tab-view';
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
10
  const MaterialLabel = ({
@@ -61,12 +62,64 @@ export function MaterialTopTabBar({
61
62
  tabBarAllowFontScaling,
62
63
  tabBarLabelStyle
63
64
  } = options;
65
+ let icon;
66
+ if (tabBarShowIcon === false) {
67
+ icon = undefined;
68
+ } else if (tabBarIcon) {
69
+ icon = ({
70
+ focused,
71
+ color,
72
+ size
73
+ }) => {
74
+ const iconValue = typeof tabBarIcon === 'function' ? tabBarIcon({
75
+ focused,
76
+ color,
77
+ size
78
+ }) : tabBarIcon;
79
+ if (/*#__PURE__*/React.isValidElement(iconValue)) {
80
+ return iconValue;
81
+ }
82
+ if (typeof iconValue === 'object' && iconValue != null && 'type' in iconValue) {
83
+ switch (iconValue.type) {
84
+ case 'image':
85
+ return /*#__PURE__*/_jsx(Image, {
86
+ source: iconValue.source,
87
+ style: {
88
+ width: size,
89
+ height: size,
90
+ tintColor: iconValue.tinted === false ? undefined : color
91
+ }
92
+ });
93
+ case 'sfSymbol':
94
+ return /*#__PURE__*/_jsx(SFSymbol, {
95
+ name: iconValue.name,
96
+ size: size,
97
+ color: color
98
+ });
99
+ case 'materialSymbol':
100
+ return /*#__PURE__*/_jsx(MaterialSymbol, {
101
+ name: iconValue.name,
102
+ variant: iconValue.variant,
103
+ weight: iconValue.weight,
104
+ size: size,
105
+ color: color
106
+ });
107
+ default:
108
+ {
109
+ const _exhaustiveCheck = iconValue;
110
+ return _exhaustiveCheck;
111
+ }
112
+ }
113
+ }
114
+ return null;
115
+ };
116
+ }
64
117
  return [route.key, {
65
118
  href: buildHref(route.name, route.params),
66
119
  testID: tabBarButtonTestID,
67
120
  accessibilityLabel: tabBarAccessibilityLabel,
68
121
  badge: tabBarBadge,
69
- icon: tabBarShowIcon === false ? undefined : tabBarIcon,
122
+ icon,
70
123
  label: tabBarShowLabel === false ? undefined : typeof tabBarLabel === 'function' ? ({
71
124
  labelText,
72
125
  color
@@ -1 +1 @@
1
- {"version":3,"names":["Text","Color","useLinkBuilder","useLocale","useTheme","StyleSheet","TabBar","TabBarIndicator","jsx","_jsx","MaterialLabel","color","labelText","style","allowFontScaling","fonts","medium","styles","label","children","renderLabelDefault","props","MaterialTopTabBar","state","navigation","descriptors","rest","colors","dark","direction","buildHref","focusedOptions","routes","index","key","options","activeColor","tabBarActiveTintColor","text","inactiveColor","tabBarInactiveTintColor","alpha","string","tabBarOptions","Object","fromEntries","map","route","title","tabBarLabel","tabBarButtonTestID","tabBarAccessibilityLabel","tabBarBadge","tabBarShowIcon","tabBarShowLabel","tabBarIcon","tabBarAllowFontScaling","tabBarLabelStyle","href","name","params","testID","accessibilityLabel","badge","icon","undefined","focused","labelAllowFontScaling","labelStyle","navigationState","scrollEnabled","tabBarScrollEnabled","bounces","tabBarBounces","pressColor","tabBarPressColor","pressOpacity","tabBarPressOpacity","tabStyle","tabBarItemStyle","indicatorStyle","backgroundColor","primary","tabBarIndicatorStyle","gap","tabBarGap","android_ripple","tabBarAndroidRipple","indicatorContainerStyle","tabBarIndicatorContainerStyle","contentContainerStyle","tabBarContentContainerStyle","card","tabBarStyle","onTabPress","preventDefault","event","emit","type","target","canPreventDefault","defaultPrevented","onTabLongPress","renderIndicator","tabBarIndicator","create","textAlign","fontSize","margin"],"sourceRoot":"../../../src","sources":["views/MaterialTopTabBar.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,4BAA4B;AACjD,SAASC,KAAK,QAAQ,qCAAqC;AAC3D,SAGEC,cAAc,EACdC,SAAS,EACTC,QAAQ,QACH,0BAA0B;AACjC,SAA0B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;MACdC,IAAI,EAAE,cAAc;MACpBC,MAAM,EAAEpD,KAAK,CAACb;IAChB,CAAC,CACF;IACDqE,eAAe,EAAEA,CAAC;MAAElC,eAAe,EAAE9C,KAAK;MAAE,GAAGG;IAAK,CAAC,KAAK;MACxD,OAAOK,cAAc,CAACyE,eAAe,GACnCzE,cAAc,CAACyE,eAAe,CAAC;QAC7BjF,KAAK,EAAEA,KAA0C;QACjD,GAAGG;MACL,CAAC,CAAC,gBAEFjB,IAAA,CAACF,eAAe;QAAC8D,eAAe,EAAE9C,KAAM;QAAA,GAAKG;MAAI,CAAG,CACrD;IACH;EAAE,CACH,CAAC;AAEN;AAEA,MAAMT,MAAM,GAAGZ,UAAU,CAACoG,MAAM,CAAC;EAC/BvF,KAAK,EAAE;IACLwF,SAAS,EAAE,QAAQ;IACnBC,QAAQ,EAAE,EAAE;IACZC,MAAM,EAAE,CAAC;IACT3B,eAAe,EAAE;EACnB;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Text","Color","MaterialSymbol","SFSymbol","useLinkBuilder","useLocale","useTheme","React","Image","StyleSheet","TabBar","TabBarIndicator","jsx","_jsx","MaterialLabel","color","labelText","style","allowFontScaling","fonts","medium","styles","label","children","renderLabelDefault","props","MaterialTopTabBar","state","navigation","descriptors","rest","colors","dark","direction","buildHref","focusedOptions","routes","index","key","options","activeColor","tabBarActiveTintColor","text","inactiveColor","tabBarInactiveTintColor","alpha","string","tabBarOptions","Object","fromEntries","map","route","title","tabBarLabel","tabBarButtonTestID","tabBarAccessibilityLabel","tabBarBadge","tabBarShowIcon","tabBarShowLabel","tabBarIcon","tabBarAllowFontScaling","tabBarLabelStyle","icon","undefined","focused","size","iconValue","isValidElement","type","source","width","height","tintColor","tinted","name","variant","weight","_exhaustiveCheck","href","params","testID","accessibilityLabel","badge","labelAllowFontScaling","labelStyle","navigationState","scrollEnabled","tabBarScrollEnabled","bounces","tabBarBounces","pressColor","tabBarPressColor","pressOpacity","tabBarPressOpacity","tabStyle","tabBarItemStyle","indicatorStyle","backgroundColor","primary","tabBarIndicatorStyle","gap","tabBarGap","android_ripple","tabBarAndroidRipple","indicatorContainerStyle","tabBarIndicatorContainerStyle","contentContainerStyle","tabBarContentContainerStyle","card","tabBarStyle","onTabPress","preventDefault","event","emit","target","canPreventDefault","defaultPrevented","onTabLongPress","renderIndicator","tabBarIndicator","create","textAlign","fontSize","margin"],"sourceRoot":"../../../src","sources":["views/MaterialTopTabBar.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,4BAA4B;AACjD,SAASC,KAAK,QAAQ,qCAAqC;AAC3D,SACEC,cAAc,EAEdC,QAAQ,EAERC,cAAc,EACdC,SAAS,EACTC,QAAQ,QACH,0BAA0B;AACjC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAA0BC,KAAK,EAAEC,UAAU,QAAQ,cAAc;AACjE,SAEEC,MAAM,EACNC,eAAe,QAEV,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQ/B,MAAMC,aAAa,GAAGA,CAAC;EACrBC,KAAK;EACLC,SAAS;EACTC,KAAK;EACLC;AACkB,CAAC,KAAK;EACxB,MAAM;IAAEC;EAAM,CAAC,GAAGb,QAAQ,CAAC,CAAC;EAE5B,oBACEO,IAAA,CAACb,IAAI;IACHiB,KAAK,EAAE,CAAC;MAAEF;IAAM,CAAC,EAAEI,KAAK,CAACC,MAAM,EAAEC,MAAM,CAACC,KAAK,EAAEL,KAAK,CAAE;IACtDC,gBAAgB,EAAEA,gBAAiB;IAAAK,QAAA,EAElCP;EAAS,CACN,CAAC;AAEX,CAAC;AAED,MAAMQ,kBAAkB,GAAIC,KAAyB,iBACnDZ,IAAA,CAACC,aAAa;EAAA,GAAKW;AAAK,CAAG,CAC5B;AAED,OAAO,SAASC,iBAAiBA,CAAC;EAChCC,KAAK;EACLC,UAAU;EACVC,WAAW;EACX,GAAGC;AACmB,CAAC,EAAE;EACzB,MAAM;IAAEC,MAAM;IAAEC;EAAK,CAA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@react-navigation/elements/internal';
3
4
  import { CommonActions, useLocale, useTheme } from '@react-navigation/native';
5
+ import { useMemo, useState } from 'react';
6
+ import { StyleSheet } from 'react-native';
4
7
  import { TabView } from 'react-native-tab-view';
5
8
  import { TabAnimationContext } from "../utils/TabAnimationContext.js";
6
9
  import { MaterialTopTabBar } from "./MaterialTopTabBar.js";
@@ -48,10 +51,11 @@ export function MaterialTopTabView({
48
51
  renderScene: ({
49
52
  route,
50
53
  position
51
- }) => /*#__PURE__*/_jsx(TabAnimationContext.Provider, {
52
- value: {
53
- position
54
- },
54
+ }) => /*#__PURE__*/_jsx(SceneContent, {
55
+ focused: route.key === state.routes[state.index].key,
56
+ preloaded: state.preloadedRouteKeys.includes(route.key),
57
+ position: position,
58
+ options: descriptors[route.key].options,
55
59
  children: descriptors[route.key].render()
56
60
  }),
57
61
  navigationState: state,
@@ -82,4 +86,44 @@ export function MaterialTopTabView({
82
86
  }))
83
87
  });
84
88
  }
89
+ function SceneContent({
90
+ focused,
91
+ preloaded,
92
+ position,
93
+ options,
94
+ children
95
+ }) {
96
+ const {
97
+ inactiveBehavior = 'pause',
98
+ lazy
99
+ } = options;
100
+ const [loaded, setLoaded] = useState(focused);
101
+ if (focused && !loaded) {
102
+ setLoaded(true);
103
+ }
104
+ const animationContext = useMemo(() => ({
105
+ position
106
+ }), [position]);
107
+
108
+ // For preloaded screens and if lazy is false,
109
+ // Keep them active so that the effects can run
110
+ const isActive = inactiveBehavior === 'none' || focused || preloaded || lazy === false && !loaded;
111
+ return /*#__PURE__*/_jsx(TabAnimationContext.Provider, {
112
+ value: animationContext,
113
+ children: /*#__PURE__*/_jsx(ActivityView, {
114
+ mode: isActive ? 'normal' : 'paused',
115
+ visible:
116
+ // Tabs can be swiped quickly
117
+ // So we keep all tabs visible to avoid flash of blank screen
118
+ true,
119
+ style: styles.scene,
120
+ children: children
121
+ })
122
+ });
123
+ }
124
+ const styles = StyleSheet.create({
125
+ scene: {
126
+ flex: 1
127
+ }
128
+ });
85
129
  //# sourceMappingURL=MaterialTopTabView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CommonActions","useLocale","useTheme","TabView","TabAnimationContext","MaterialTopTabBar","jsx","_jsx","renderTabBarDefault","props","MaterialTopTabView","tabBar","state","navigation","descriptors","rest","colors","direction","renderTabBar","navigationState","options","focusedOptions","routes","index","key","onIndexChange","route","dispatch","navigate","target","renderScene","position","Provider","value","children","render","renderLazyPlaceholder","lazyPlaceholder","lazy","preloadedRouteKeys","includes","lazyPreloadDistance","swipeEnabled","animationEnabled","onSwipeStart","emit","type","onSwipeEnd","Object","fromEntries","map","sceneStyle","backgroundColor","background"],"sourceRoot":"../../../src","sources":["views/MaterialTopTabView.tsx"],"mappings":";;AAAA,SACEA,aAAa,EAIbC,SAAS,EACTC,QAAQ,QACH,0BAA0B;AACjC,SAASC,OAAO,QAAQ,uBAAuB;AAQ/C,SAASC,mBAAmB,QAAQ,iCAA8B;AAClE,SAASC,iBAAiB,QAAQ,wBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQxD,MAAMC,mBAAmB,GAAIC,KAA6B,iBACxDF,IAAA,CAACF,iBAAiB;EAAA,GAAKI;AAAK,CAAG,CAChC;AAED,OAAO,SAASC,kBAAkBA,CAAC;EACjCC,MAAM,GAAGH,mBAAmB;EAC5BI,KAAK;EACLC,UAAU;EACVC,WAAW;EACX,GAAGC;AACE,CAAC,EAAE;EACR,MAAM;IAAEC;EAAO,CAAC,GAAGd,QAAQ,CAAC,CAAC;EAC7B,MAAM;IAAEe;EAAU,CAAC,GAAGhB,SAAS,CAAC,CAAC;EAEjC,MAAMiB,YAEW,GAAGA,CAAC;IACnB;IACAC,eAAe;IACfC,OAAO;IACP;IACA,GAAGL;EACL,CAAC,KAAK;IACJ,OAAOJ,MAAM,CAAC;MACZ,GAAGI,IAAI;MACPH,KAAK,EAAEA,KAAK;MACZC,UAAU,EAAEA,UAAU;MACtBC,WAAW,EAAEA;IACf,CAAC,CAAC;EACJ,CA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B,UAAU,CAACgC,IAAI,CAAC;MAAEC,IAAI,EAAE;IAAa,CAAC,CAAE;IAC5DC,UAAU,EAAEA,CAAA,KAAMlC,UAAU,CAACgC,IAAI,CAAC;MAAEC,IAAI,EAAE;IAAW,CAAC,CAAE;IACxD7B,SAAS,EAAEA,SAAU;IACrBG,OAAO,EAAE4B,MAAM,CAACC,WAAW,CACzBrC,KAAK,CAACU,MAAM,CAAC4B,GAAG,CAAExB,KAAK,IAAK;MAC1B,MAAMN,OAAO,GAAGN,WAAW,CAACY,KAAK,CAACF,GAAG,CAAC,EAAEJ,OAAO;MAE/C,OAAO,CACLM,KAAK,CAACF,GAAG,EACT;QACE2B,UAAU,EAAE,CACV;UAAEC,eAAe,EAAEpC,MAAM,CAACqC;QAAW,CAAC,EACtCjC,OAAO,EAAE+B,UAAU;MAEvB,CAAC,CACF;IACH,CAAC,CACH;EAAE,CACH,CAAC;AAEN","ignoreList":[]}
1
+ {"version":3,"names":["ActivityView","CommonActions","useLocale","useTheme","useMemo","useState","StyleSheet","TabView","TabAnimationContext","MaterialTopTabBar","jsx","_jsx","renderTabBarDefault","props","MaterialTopTabView","tabBar","state","navigation","descriptors","rest","colors","direction","renderTabBar","navigationState","options","focusedOptions","routes","index","key","onIndexChange","route","dispatch","navigate","target","renderScene","position","SceneContent","focused","preloaded","preloadedRouteKeys","includes","children","render","renderLazyPlaceholder","lazyPlaceholder","lazy","lazyPreloadDistance","swipeEnabled","animationEnabled","onSwipeStart","emit","type","onSwipeEnd","Object","fromEntries","map","sceneStyle","backgroundColor","background","inactiveBehavior","loaded","setLoaded","animationContext","isActive","Provider","value","mode","visible","style","styles","scene","create","flex"],"sourceRoot":"../../../src","sources":["views/MaterialTopTabView.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,qCAAqC;AAClE,SACEC,aAAa,EAIbC,SAAS,EACTC,QAAQ,QACH,0BAA0B;AACjC,SAASC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACzC,SAAwBC,U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,CAAC;EAC/BD,KAAK,EAAE;IACLE,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import type { Icon } from '@react-navigation/elements';
1
2
  import type { DefaultNavigatorOptions, Descriptor, NavigationHelpers, NavigationProp, ParamListBase, Route, RouteProp, TabActionHelpers, TabNavigationState, TabRouterOptions, Theme } from '@react-navigation/native';
2
3
  import type React from 'react';
3
4
  import type { Animated, ColorValue, PressableAndroidRippleConfig, StyleProp, TextStyle, ViewStyle } from 'react-native';
@@ -42,7 +43,7 @@ export type MaterialTopTabNavigationOptions = {
42
43
  /**
43
44
  * Title text for the screen.
44
45
  */
45
- title?: string;
46
+ title?: string | undefined;
46
47
  /**
47
48
  * Title string of a tab displayed in the tab bar
48
49
  * or a function that given { focused: boolean, color: ColorValue } returns a React.Node, to display in tab bar.
@@ -53,116 +54,117 @@ export type MaterialTopTabNavigationOptions = {
53
54
  focused: boolean;
54
55
  color: ColorValue;
55
56
  children: string;
56
- }) => React.ReactNode);
57
+ }) => React.ReactNode) | undefined;
57
58
  /**
58
59
  * Accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
59
60
  * It's recommended to set this if you don't have a label for the tab.
60
61
  */
61
- tabBarAccessibilityLabel?: string;
62
+ tabBarAccessibilityLabel?: string | undefined;
62
63
  /**
63
64
  * Whether label font should scale to respect Text Size accessibility settings.
64
65
  */
65
- tabBarAllowFontScaling?: boolean;
66
+ tabBarAllowFontScaling?: boolean | undefined;
66
67
  /**
67
68
  * Whether the tab label should be visible. Defaults to `true`.
68
69
  */
69
- tabBarShowLabel?: boolean;
70
+ tabBarShowLabel?: boolean | undefined;
70
71
  /**
71
- * A function that given { focused: boolean, color: ColorValue } returns a React.Node to display in the tab bar.
72
+ * Icon to display for the tab.
72
73
  */
73
- tabBarIcon?: (props: {
74
+ tabBarIcon?: Icon | ((props: {
74
75
  focused: boolean;
75
76
  color: ColorValue;
76
- }) => React.ReactElement;
77
+ size: number;
78
+ }) => Icon | React.ReactNode);
77
79
  /**
78
80
  * Whether the tab icon should be visible. Defaults to `false`.
79
81
  */
80
- tabBarShowIcon?: boolean;
82
+ tabBarShowIcon?: boolean | undefined;
81
83
  /**
82
84
  * Function that returns a React element to use as a badge for the tab.
83
85
  */
84
- tabBarBadge?: () => React.ReactElement;
86
+ tabBarBadge?: (() => React.ReactElement) | undefined;
85
87
  /**
86
88
  * Function that returns a React element as the tab bar indicator.
87
89
  */
88
- tabBarIndicator?: (props: Omit<Parameters<NonNullable<React.ComponentProps<typeof TabBar>['renderIndicator']>>[0], 'navigationState'> & {
90
+ tabBarIndicator?: ((props: Omit<Parameters<NonNullable<React.ComponentProps<typeof TabBar>['renderIndicator']>>[0], 'navigationState'> & {
89
91
  state: TabNavigationState<ParamListBase>;
90
- }) => React.ReactNode;
92
+ }) => React.ReactNode) | undefined;
91
93
  /**
92
94
  * Style object for the tab bar indicator.
93
95
  */
94
- tabBarIndicatorStyle?: StyleProp<ViewStyle>;
96
+ tabBarIndicatorStyle?: StyleProp<ViewStyle> | undefined;
95
97
  /**
96
98
  * Style object for the view containing the tab bar indicator.
97
99
  */
98
- tabBarIndicatorContainerStyle?: StyleProp<ViewStyle>;
100
+ tabBarIndicatorContainerStyle?: StyleProp<ViewStyle> | undefined;
99
101
  /**
100
102
  * ID to locate this tab button in tests.
101
103
  */
102
- tabBarButtonTestID?: string;
104
+ tabBarButtonTestID?: string | undefined;
103
105
  /**
104
106
  * Color for the icon and label in the active tab.
105
107
  */
106
- tabBarActiveTintColor?: ColorValue;
108
+ tabBarActiveTintColor?: ColorValue | undefined;
107
109
  /**
108
110
  * Color for the icon and label in the inactive tabs.
109
111
  */
110
- tabBarInactiveTintColor?: ColorValue;
112
+ tabBarInactiveTintColor?: ColorValue | undefined;
111
113
  /**
112
114
  * Color for material ripple (Android >= 5.0 only).
113
115
  */
114
- tabBarPressColor?: ColorValue;
116
+ tabBarPressColor?: ColorValue | undefined;
115
117
  /**
116
118
  * Opacity for pressed tab (iOS and Android < 5.0 only).
117
119
  */
118
- tabBarPressOpacity?: number;
120
+ tabBarPressOpacity?: number | undefined;
119
121
  /**
120
122
  * Boolean indicating whether the tab bar bounces when overscrolling.
121
123
  */
122
- tabBarBounces?: boolean;
124
+ tabBarBounces?: boolean | undefined;
123
125
  /**
124
126
  * Boolean indicating whether to make the tab bar scrollable.
125
127
  *
126
128
  * If you set this to `true`, you should also specify a width in `tabBarItemStyle` to improve the performance of initial render.
127
129
  */
128
- tabBarScrollEnabled?: boolean;
130
+ tabBarScrollEnabled?: boolean | undefined;
129
131
  /**
130
132
  * Style object for the tab label.
131
133
  */
132
- tabBarLabelStyle?: StyleProp<TextStyle>;
134
+ tabBarLabelStyle?: StyleProp<TextStyle> | undefined;
133
135
  /**
134
136
  * Style object for the individual tab items.
135
137
  */
136
- tabBarItemStyle?: StyleProp<ViewStyle>;
138
+ tabBarItemStyle?: StyleProp<ViewStyle> | undefined;
137
139
  /**
138
140
  * Style object for the view containing the tab items.
139
141
  */
140
- tabBarContentContainerStyle?: StyleProp<ViewStyle>;
142
+ tabBarContentContainerStyle?: StyleProp<ViewStyle> | undefined;
141
143
  /**
142
144
  * Style object for the the tab bar.
143
145
  */
144
- tabBarStyle?: StyleProp<ViewStyle>;
146
+ tabBarStyle?: StyleProp<ViewStyle> | undefined;
145
147
  /**
146
148
  * Gap between tabs
147
149
  */
148
- tabBarGap?: number;
150
+ tabBarGap?: number | undefined;
149
151
  /**
150
152
  * Allows to customize the android ripple effect (Android >= 5.0 only).
151
153
  *
152
154
  * Default: `{ borderless: true }`
153
155
  */
154
- tabBarAndroidRipple?: PressableAndroidRippleConfig;
156
+ tabBarAndroidRipple?: PressableAndroidRippleConfig | undefined;
155
157
  /**
156
158
  * Whether to enable swipe gestures when this screen is focused.
157
159
  * Swipe gestures are enabled by default. Passing `false` will disable swipe gestures,
158
160
  * but the user can still switch tabs by pressing the tab bar.
159
161
  */
160
- swipeEnabled?: boolean;
162
+ swipeEnabled?: boolean | undefined;
161
163
  /**
162
164
  * Whether to enable animations when switching between tabs by pressing on the tab bar or programmatically.
163
165
  * Switching tab via swipe gesture will still result in an animation.
164
166
  */
165
- animationEnabled?: boolean;
167
+ animationEnabled?: boolean | undefined;
166
168
  /**
167
169
  * Whether this screen should be lazily rendered. When this is set to `true`,
168
170
  * the screen will be rendered as it comes into the viewport.
@@ -174,12 +176,12 @@ export type MaterialTopTabNavigationOptions = {
174
176
  * when they come into the viewport. You can use the `lazyPlaceholder` prop to customize
175
177
  * what the user sees during this short period.
176
178
  */
177
- lazy?: boolean;
179
+ lazy?: boolean | undefined;
178
180
  /**
179
181
  * When `lazy` is enabled, you can specify how many adjacent screens should be preloaded in advance with this prop.
180
182
  * This value defaults to `0` which means lazy pages are loaded as they come into the viewport.
181
183
  */
182
- lazyPreloadDistance?: number;
184
+ lazyPreloadDistance?: number | undefined;
183
185
  /**
184
186
  * Function that returns a React element to render if this screen hasn't been rendered yet.
185
187
  * The `lazy` option also needs to be enabled for this to work.
@@ -188,11 +190,23 @@ export type MaterialTopTabNavigationOptions = {
188
190
  *
189
191
  * By default, this renders `null`.
190
192
  */
191
- lazyPlaceholder?: () => React.ReactNode;
193
+ lazyPlaceholder?: (() => React.ReactNode) | undefined;
192
194
  /**
193
195
  * Style object for the component wrapping the screen content.
194
196
  */
195
- sceneStyle?: StyleProp<ViewStyle>;
197
+ sceneStyle?: StyleProp<ViewStyle> | undefined;
198
+ /**
199
+ * What should happen when screens become inactive.
200
+ * - `pause`: Effects are cleaned up.
201
+ * - `none`: Screen renders normally
202
+ *
203
+ * Defaults to `pause`.
204
+ *
205
+ * If you set `lazy: false` or preload a screen,
206
+ * It won't be paused until after the first time it becomes focused.
207
+ * This makes sure that effects are run to initialize the screen.
208
+ */
209
+ inactiveBehavior?: ('pause' | 'none') | undefined;
196
210
  };
197
211
  export type MaterialTopTabDescriptor = Descriptor<MaterialTopTabNavigationOptions, MaterialTopTabNavigationProp<ParamListBase>, RouteProp<ParamListBase>>;
198
212
  export type MaterialTopTabDescriptorMap = Record<string, MaterialTopTabDescriptor>;
@@ -200,11 +214,11 @@ export type MaterialTopTabNavigationConfig = Omit<TabViewProps<Route<string>>, '
200
214
  /**
201
215
  * Function that returns a React element to display as the tab bar.
202
216
  */
203
- tabBar?: (props: MaterialTopTabBarProps) => React.ReactNode;
217
+ tabBar?: ((props: MaterialTopTabBarProps) => React.ReactNode) | undefined;
204
218
  /**
205
219
  * Function that returns a React element to override the underlying adapter.
206
220
  */
207
- adapter?: TabViewProps<Route<string>>['renderAdapter'];
221
+ adapter?: TabViewProps<Route<string>>['renderAdapter'] | undefined;
208
222
  };
209
223
  export type MaterialTopTabBarProps = Pick<TabBarProps<Route<string>>, 'position' | 'subscribe' | 'jumpTo'> & {
210
224
  state: TabNavigationState<ParamListBase>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACN,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,4BAA4B,EAC5B,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE/E,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,QAAQ,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,iBAAiB,EAAE,IAAI,CAAA;KAAE,CAAC;IACvD;;OAEG;IACH,YAAY,EAAE;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC;IAClC;;OAEG;IACH,UAA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,CAC3B,aAAa,EACb,gCAAgC,CACjC,CAAC;IACF,WAAW,EAAE,2BAA2B,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,QAAQ,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,uBAAuB,CAChE,aAAa,EACb,kBAAkB,CAAC,aAAa,CAAC,EACjC,+BAA+B,EAC/B,gCAAgC,EAChC,4BAA4B,CAAC,aAAa,CAAC,CAC5C,GACC,gBAAgB,GAChB,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialTopTabBar.d.ts","sourceRoot":"","sources":["../../../../src/views/MaterialTopTabBar.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AA4BvD,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,IAAI,EACR,EAAE,sBAAsB,2CAoHxB"}
1
+ {"version":3,"file":"MaterialTopTabBar.d.ts","sourceRoot":"","sources":["../../../../src/views/MaterialTopTabBar.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AA4BvD,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,IAAI,EACR,EAAE,sBAAsB,2CAsLxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialTopTabView.d.ts","sourceRoot":"","sources":["../../../../src/views/MaterialTopTabView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,kBAAkB,EAGxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAEV,2BAA2B,EAC3B,8BAA8B,EAC9B,+BAA+B,EAChC,MAAM,UAAU,CAAC;AAIlB,KAAK,KAAK,GAAG,8BAA8B,GAAG;IAC5C,KAAK,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACzC,UAAU,EAAE,+BAA+B,CAAC;IAC5C,WAAW,EAAE,2BAA2B,CAAC;CAC1C,CAAC;AAMF,wBAAgB,kBAAkB,CAAC,EACjC,MAA4B,EAC5B,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,IAAI,EACR,EAAE,KAAK,2CAuEP"}
1
+ {"version":3,"file":"MaterialTopTabView.d.ts","sourceRoot":"","sources":["../../../../src/views/MaterialTopTabView.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,kBAAkB,EAGxB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAEV,2BAA2B,EAC3B,8BAA8B,EAC9B,+BAA+B,EAEhC,MAAM,UAAU,CAAC;AAIlB,KAAK,KAAK,GAAG,8BAA8B,GAAG;IAC5C,KAAK,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACzC,UAAU,EAAE,+BAA+B,CAAC;IAC5C,WAAW,EAAE,2BAA2B,CAAC;CAC1C,CAAC;AAMF,wBAAgB,kBAAkB,CAAC,EACjC,MAA4B,EAC5B,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,IAAI,EACR,EAAE,KAAK,2CA4EP"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/material-top-tabs",
3
3
  "description": "Integration for the animated tab view component from react-native-tab-view",
4
- "version": "8.0.0-alpha.2",
4
+ "version": "8.0.0-alpha.21",
5
5
  "keywords": [
6
6
  "react-native-component",
7
7
  "react-component",
@@ -46,27 +46,27 @@
46
46
  "clean": "del lib"
47
47
  },
48
48
  "dependencies": {
49
- "@react-navigation/elements": "^3.0.0-alpha.2",
50
- "color": "^4.2.3",
51
- "react-native-tab-view": "^5.0.0-alpha.0"
49
+ "@react-navigation/elements": "^3.0.0-alpha.21",
50
+ "color": "^5.0.3",
51
+ "react-native-tab-view": "^5.0.0-alpha.6"
52
52
  },
53
53
  "devDependencies": {
54
- "@jest/globals": "^30.0.0",
55
- "@react-navigation/native": "^8.0.0-alpha.2",
56
- "@testing-library/react-native": "^13.2.1",
57
- "@types/react": "~19.1.10",
58
- "del-cli": "^6.0.0",
59
- "react": "19.1.0",
60
- "react-native": "0.81.4",
61
- "react-native-builder-bob": "^0.40.12",
54
+ "@jest/globals": "^30.3.0",
55
+ "@react-navigation/native": "^8.0.0-alpha.18",
56
+ "@testing-library/react-native": "^13.3.3",
57
+ "@types/react": "~19.2.2",
58
+ "del-cli": "^7.0.0",
59
+ "react": "19.2.0",
60
+ "react-native": "0.83.4",
61
+ "react-native-builder-bob": "^0.41.0",
62
62
  "react-native-pager-view": "^8.0.0",
63
- "react-native-safe-area-context": "~5.6.0",
64
- "react-test-renderer": "19.1.0",
65
- "typescript": "^5.9.2"
63
+ "react-native-safe-area-context": "~5.6.2",
64
+ "react-test-renderer": "19.2.0",
65
+ "typescript": "^6.0.2"
66
66
  },
67
67
  "peerDependencies": {
68
- "@react-navigation/native": "^8.0.0-alpha.2",
69
- "react": ">= 19.0.0",
68
+ "@react-navigation/native": "^8.0.0-alpha.18",
69
+ "react": ">= 19.2.0",
70
70
  "react-native": "*",
71
71
  "react-native-pager-view": ">= 7.0.0",
72
72
  "react-native-safe-area-context": ">= 5.5.0"
@@ -89,5 +89,5 @@
89
89
  ]
90
90
  ]
91
91
  },
92
- "gitHead": "9664da8fff3bd7ed575bf12ddfcc47b3a42be997"
92
+ "gitHead": "18da535b07fc86a30700efc4d824ef58271d2b8f"
93
93
  }
package/src/types.tsx CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Icon } from '@react-navigation/elements';
1
2
  import type {
2
3
  DefaultNavigatorOptions,
3
4
  Descriptor,
@@ -78,7 +79,7 @@ export type MaterialTopTabNavigationOptions = {
78
79
  /**
79
80
  * Title text for the screen.
80
81
  */
81
- title?: string;
82
+ title?: string | undefined;
82
83
 
83
84
  /**
84
85
  * Title string of a tab displayed in the tab bar
@@ -92,145 +93,151 @@ export type MaterialTopTabNavigationOptions = {
92
93
  focused: boolean;
93
94
  color: ColorValue;
94
95
  children: string;
95
- }) => React.ReactNode);
96
+ }) => React.ReactNode)
97
+ | undefined;
96
98
 
97
99
  /**
98
100
  * Accessibility label for the tab button. This is read by the screen reader when the user taps the tab.
99
101
  * It's recommended to set this if you don't have a label for the tab.
100
102
  */
101
- tabBarAccessibilityLabel?: string;
103
+ tabBarAccessibilityLabel?: string | undefined;
102
104
 
103
105
  /**
104
106
  * Whether label font should scale to respect Text Size accessibility settings.
105
107
  */
106
- tabBarAllowFontScaling?: boolean;
108
+ tabBarAllowFontScaling?: boolean | undefined;
107
109
 
108
110
  /**
109
111
  * Whether the tab label should be visible. Defaults to `true`.
110
112
  */
111
- tabBarShowLabel?: boolean;
113
+ tabBarShowLabel?: boolean | undefined;
112
114
 
113
115
  /**
114
- * A function that given { focused: boolean, color: ColorValue } returns a React.Node to display in the tab bar.
116
+ * Icon to display for the tab.
115
117
  */
116
- tabBarIcon?: (props: {
117
- focused: boolean;
118
- color: ColorValue;
119
- }) => React.ReactElement;
118
+ tabBarIcon?:
119
+ | Icon
120
+ | ((props: {
121
+ focused: boolean;
122
+ color: ColorValue;
123
+ size: number;
124
+ }) => Icon | React.ReactNode);
120
125
 
121
126
  /**
122
127
  * Whether the tab icon should be visible. Defaults to `false`.
123
128
  */
124
- tabBarShowIcon?: boolean;
129
+ tabBarShowIcon?: boolean | undefined;
125
130
 
126
131
  /**
127
132
  * Function that returns a React element to use as a badge for the tab.
128
133
  */
129
- tabBarBadge?: () => React.ReactElement;
134
+ tabBarBadge?: (() => React.ReactElement) | undefined;
130
135
 
131
136
  /**
132
137
  * Function that returns a React element as the tab bar indicator.
133
138
  */
134
- tabBarIndicator?: (
135
- props: Omit<
136
- Parameters<
137
- NonNullable<React.ComponentProps<typeof TabBar>['renderIndicator']>
138
- >[0],
139
- 'navigationState'
140
- > & { state: TabNavigationState<ParamListBase> }
141
- ) => React.ReactNode;
139
+ tabBarIndicator?:
140
+ | ((
141
+ props: Omit<
142
+ Parameters<
143
+ NonNullable<React.ComponentProps<typeof TabBar>['renderIndicator']>
144
+ >[0],
145
+ 'navigationState'
146
+ > & { state: TabNavigationState<ParamListBase> }
147
+ ) => React.ReactNode)
148
+ | undefined;
142
149
 
143
150
  /**
144
151
  * Style object for the tab bar indicator.
145
152
  */
146
- tabBarIndicatorStyle?: StyleProp<ViewStyle>;
153
+ tabBarIndicatorStyle?: StyleProp<ViewStyle> | undefined;
147
154
 
148
155
  /**
149
156
  * Style object for the view containing the tab bar indicator.
150
157
  */
151
- tabBarIndicatorContainerStyle?: StyleProp<ViewStyle>;
158
+ tabBarIndicatorContainerStyle?: StyleProp<ViewStyle> | undefined;
152
159
 
153
160
  /**
154
161
  * ID to locate this tab button in tests.
155
162
  */
156
- tabBarButtonTestID?: string;
163
+ tabBarButtonTestID?: string | undefined;
157
164
 
158
165
  /**
159
166
  * Color for the icon and label in the active tab.
160
167
  */
161
- tabBarActiveTintColor?: ColorValue;
168
+ tabBarActiveTintColor?: ColorValue | undefined;
162
169
 
163
170
  /**
164
171
  * Color for the icon and label in the inactive tabs.
165
172
  */
166
- tabBarInactiveTintColor?: ColorValue;
173
+ tabBarInactiveTintColor?: ColorValue | undefined;
167
174
 
168
175
  /**
169
176
  * Color for material ripple (Android >= 5.0 only).
170
177
  */
171
- tabBarPressColor?: ColorValue;
178
+ tabBarPressColor?: ColorValue | undefined;
172
179
 
173
180
  /**
174
181
  * Opacity for pressed tab (iOS and Android < 5.0 only).
175
182
  */
176
- tabBarPressOpacity?: number;
183
+ tabBarPressOpacity?: number | undefined;
177
184
 
178
185
  /**
179
186
  * Boolean indicating whether the tab bar bounces when overscrolling.
180
187
  */
181
- tabBarBounces?: boolean;
188
+ tabBarBounces?: boolean | undefined;
182
189
 
183
190
  /**
184
191
  * Boolean indicating whether to make the tab bar scrollable.
185
192
  *
186
193
  * If you set this to `true`, you should also specify a width in `tabBarItemStyle` to improve the performance of initial render.
187
194
  */
188
- tabBarScrollEnabled?: boolean;
195
+ tabBarScrollEnabled?: boolean | undefined;
189
196
 
190
197
  /**
191
198
  * Style object for the tab label.
192
199
  */
193
- tabBarLabelStyle?: StyleProp<TextStyle>;
200
+ tabBarLabelStyle?: StyleProp<TextStyle> | undefined;
194
201
 
195
202
  /**
196
203
  * Style object for the individual tab items.
197
204
  */
198
- tabBarItemStyle?: StyleProp<ViewStyle>;
205
+ tabBarItemStyle?: StyleProp<ViewStyle> | undefined;
199
206
 
200
207
  /**
201
208
  * Style object for the view containing the tab items.
202
209
  */
203
- tabBarContentContainerStyle?: StyleProp<ViewStyle>;
210
+ tabBarContentContainerStyle?: StyleProp<ViewStyle> | undefined;
204
211
 
205
212
  /**
206
213
  * Style object for the the tab bar.
207
214
  */
208
- tabBarStyle?: StyleProp<ViewStyle>;
215
+ tabBarStyle?: StyleProp<ViewStyle> | undefined;
209
216
 
210
217
  /**
211
218
  * Gap between tabs
212
219
  */
213
- tabBarGap?: number;
220
+ tabBarGap?: number | undefined;
214
221
 
215
222
  /**
216
223
  * Allows to customize the android ripple effect (Android >= 5.0 only).
217
224
  *
218
225
  * Default: `{ borderless: true }`
219
226
  */
220
- tabBarAndroidRipple?: PressableAndroidRippleConfig;
227
+ tabBarAndroidRipple?: PressableAndroidRippleConfig | undefined;
221
228
 
222
229
  /**
223
230
  * Whether to enable swipe gestures when this screen is focused.
224
231
  * Swipe gestures are enabled by default. Passing `false` will disable swipe gestures,
225
232
  * but the user can still switch tabs by pressing the tab bar.
226
233
  */
227
- swipeEnabled?: boolean;
234
+ swipeEnabled?: boolean | undefined;
228
235
 
229
236
  /**
230
237
  * Whether to enable animations when switching between tabs by pressing on the tab bar or programmatically.
231
238
  * Switching tab via swipe gesture will still result in an animation.
232
239
  */
233
- animationEnabled?: boolean;
240
+ animationEnabled?: boolean | undefined;
234
241
 
235
242
  /**
236
243
  * Whether this screen should be lazily rendered. When this is set to `true`,
@@ -243,13 +250,13 @@ export type MaterialTopTabNavigationOptions = {
243
250
  * when they come into the viewport. You can use the `lazyPlaceholder` prop to customize
244
251
  * what the user sees during this short period.
245
252
  */
246
- lazy?: boolean;
253
+ lazy?: boolean | undefined;
247
254
 
248
255
  /**
249
256
  * When `lazy` is enabled, you can specify how many adjacent screens should be preloaded in advance with this prop.
250
257
  * This value defaults to `0` which means lazy pages are loaded as they come into the viewport.
251
258
  */
252
- lazyPreloadDistance?: number;
259
+ lazyPreloadDistance?: number | undefined;
253
260
 
254
261
  /**
255
262
  * Function that returns a React element to render if this screen hasn't been rendered yet.
@@ -259,12 +266,25 @@ export type MaterialTopTabNavigationOptions = {
259
266
  *
260
267
  * By default, this renders `null`.
261
268
  */
262
- lazyPlaceholder?: () => React.ReactNode;
269
+ lazyPlaceholder?: (() => React.ReactNode) | undefined;
263
270
 
264
271
  /**
265
272
  * Style object for the component wrapping the screen content.
266
273
  */
267
- sceneStyle?: StyleProp<ViewStyle>;
274
+ sceneStyle?: StyleProp<ViewStyle> | undefined;
275
+
276
+ /**
277
+ * What should happen when screens become inactive.
278
+ * - `pause`: Effects are cleaned up.
279
+ * - `none`: Screen renders normally
280
+ *
281
+ * Defaults to `pause`.
282
+ *
283
+ * If you set `lazy: false` or preload a screen,
284
+ * It won't be paused until after the first time it becomes focused.
285
+ * This makes sure that effects are run to initialize the screen.
286
+ */
287
+ inactiveBehavior?: ('pause' | 'none') | undefined;
268
288
  };
269
289
 
270
290
  export type MaterialTopTabDescriptor = Descriptor<
@@ -297,11 +317,11 @@ export type MaterialTopTabNavigationConfig = Omit<
297
317
  /**
298
318
  * Function that returns a React element to display as the tab bar.
299
319
  */
300
- tabBar?: (props: MaterialTopTabBarProps) => React.ReactNode;
320
+ tabBar?: ((props: MaterialTopTabBarProps) => React.ReactNode) | undefined;
301
321
  /**
302
322
  * Function that returns a React element to override the underlying adapter.
303
323
  */
304
- adapter?: TabViewProps<Route<string>>['renderAdapter'];
324
+ adapter?: TabViewProps<Route<string>>['renderAdapter'] | undefined;
305
325
  };
306
326
 
307
327
  export type MaterialTopTabBarProps = Pick<
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { TabAnimationContext } from './TabAnimationContext';
4
4
 
5
5
  export function useTabAnimation() {
6
- const animation = React.useContext(TabAnimationContext);
6
+ const animation = React.use(TabAnimationContext);
7
7
 
8
8
  if (animation === undefined) {
9
9
  throw new Error(
@@ -1,13 +1,16 @@
1
1
  import { Text } from '@react-navigation/elements';
2
2
  import { Color } from '@react-navigation/elements/internal';
3
3
  import {
4
+ MaterialSymbol,
4
5
  type ParamListBase,
6
+ SFSymbol,
5
7
  type TabNavigationState,
6
8
  useLinkBuilder,
7
9
  useLocale,
8
10
  useTheme,
9
11
  } from '@react-navigation/native';
10
- import { type ColorValue, StyleSheet } from 'react-native';
12
+ import React from 'react';
13
+ import { type ColorValue, Image, StyleSheet } from 'react-native';
11
14
  import {
12
15
  type Route,
13
16
  TabBar,
@@ -79,6 +82,72 @@ export function MaterialTopTabBar({
79
82
  tabBarLabelStyle,
80
83
  } = options;
81
84
 
85
+ let icon;
86
+
87
+ if (tabBarShowIcon === false) {
88
+ icon = undefined;
89
+ } else if (tabBarIcon) {
90
+ icon = ({
91
+ focused,
92
+ color,
93
+ size,
94
+ }: {
95
+ focused: boolean;
96
+ color: ColorValue;
97
+ size: number;
98
+ }) => {
99
+ const iconValue =
100
+ typeof tabBarIcon === 'function'
101
+ ? tabBarIcon({ focused, color, size })
102
+ : tabBarIcon;
103
+
104
+ if (React.isValidElement(iconValue)) {
105
+ return iconValue;
106
+ }
107
+
108
+ if (
109
+ typeof iconValue === 'object' &&
110
+ iconValue != null &&
111
+ 'type' in iconValue
112
+ ) {
113
+ switch (iconValue.type) {
114
+ case 'image':
115
+ return (
116
+ <Image
117
+ source={iconValue.source}
118
+ style={{
119
+ width: size,
120
+ height: size,
121
+ tintColor: iconValue.tinted === false ? undefined : color,
122
+ }}
123
+ />
124
+ );
125
+ case 'sfSymbol':
126
+ return (
127
+ <SFSymbol name={iconValue.name} size={size} color={color} />
128
+ );
129
+ case 'materialSymbol':
130
+ return (
131
+ <MaterialSymbol
132
+ name={iconValue.name}
133
+ variant={iconValue.variant}
134
+ weight={iconValue.weight}
135
+ size={size}
136
+ color={color}
137
+ />
138
+ );
139
+ default: {
140
+ const _exhaustiveCheck: never = iconValue;
141
+
142
+ return _exhaustiveCheck;
143
+ }
144
+ }
145
+ }
146
+
147
+ return null;
148
+ };
149
+ }
150
+
82
151
  return [
83
152
  route.key,
84
153
  {
@@ -86,7 +155,7 @@ export function MaterialTopTabBar({
86
155
  testID: tabBarButtonTestID,
87
156
  accessibilityLabel: tabBarAccessibilityLabel,
88
157
  badge: tabBarBadge,
89
- icon: tabBarShowIcon === false ? undefined : tabBarIcon,
158
+ icon,
90
159
  label:
91
160
  tabBarShowLabel === false
92
161
  ? undefined
@@ -1,3 +1,4 @@
1
+ import { ActivityView } from '@react-navigation/elements/internal';
1
2
  import {
2
3
  CommonActions,
3
4
  type ParamListBase,
@@ -6,6 +7,8 @@ import {
6
7
  useLocale,
7
8
  useTheme,
8
9
  } from '@react-navigation/native';
10
+ import { useMemo, useState } from 'react';
11
+ import { type Animated, StyleSheet } from 'react-native';
9
12
  import { TabView } from 'react-native-tab-view';
10
13
 
11
14
  import type {
@@ -13,6 +16,7 @@ import type {
13
16
  MaterialTopTabDescriptorMap,
14
17
  MaterialTopTabNavigationConfig,
15
18
  MaterialTopTabNavigationHelpers,
19
+ MaterialTopTabNavigationOptions,
16
20
  } from '../types';
17
21
  import { TabAnimationContext } from '../utils/TabAnimationContext';
18
22
  import { MaterialTopTabBar } from './MaterialTopTabBar';
@@ -68,9 +72,14 @@ export function MaterialTopTabView({
68
72
  });
69
73
  }}
70
74
  renderScene={({ route, position }) => (
71
- <TabAnimationContext.Provider value={{ position }}>
75
+ <SceneContent
76
+ focused={route.key === state.routes[state.index].key}
77
+ preloaded={state.preloadedRouteKeys.includes(route.key)}
78
+ position={position}
79
+ options={descriptors[route.key].options}
80
+ >
72
81
  {descriptors[route.key].render()}
73
- </TabAnimationContext.Provider>
82
+ </SceneContent>
74
83
  )}
75
84
  navigationState={state}
76
85
  renderTabBar={renderTabBar}
@@ -105,3 +114,57 @@ export function MaterialTopTabView({
105
114
  />
106
115
  );
107
116
  }
117
+
118
+ function SceneContent({
119
+ focused,
120
+ preloaded,
121
+ position,
122
+ options,
123
+ children,
124
+ }: {
125
+ focused: boolean;
126
+ preloaded: boolean;
127
+ position: Animated.AnimatedInterpolation<number>;
128
+ options: MaterialTopTabNavigationOptions;
129
+ children: React.ReactNode;
130
+ }) {
131
+ const { inactiveBehavior = 'pause', lazy } = options;
132
+
133
+ const [loaded, setLoaded] = useState(focused);
134
+
135
+ if (focused && !loaded) {
136
+ setLoaded(true);
137
+ }
138
+
139
+ const animationContext = useMemo(() => ({ position }), [position]);
140
+
141
+ // For preloaded screens and if lazy is false,
142
+ // Keep them active so that the effects can run
143
+ const isActive =
144
+ inactiveBehavior === 'none' ||
145
+ focused ||
146
+ preloaded ||
147
+ (lazy === false && !loaded);
148
+
149
+ return (
150
+ <TabAnimationContext.Provider value={animationContext}>
151
+ <ActivityView
152
+ mode={isActive ? 'normal' : 'paused'}
153
+ visible={
154
+ // Tabs can be swiped quickly
155
+ // So we keep all tabs visible to avoid flash of blank screen
156
+ true
157
+ }
158
+ style={styles.scene}
159
+ >
160
+ {children}
161
+ </ActivityView>
162
+ </TabAnimationContext.Provider>
163
+ );
164
+ }
165
+
166
+ const styles = StyleSheet.create({
167
+ scene: {
168
+ flex: 1,
169
+ },
170
+ });