diff --git a/src/components/TabSelector/getBackground/index.native.ts b/src/components/TabSelector/getBackground.ts similarity index 69% rename from src/components/TabSelector/getBackground/index.native.ts rename to src/components/TabSelector/getBackground.ts index dac0b49a5996..5d19e2f42ac8 100644 --- a/src/components/TabSelector/getBackground/index.native.ts +++ b/src/components/TabSelector/getBackground.ts @@ -1,10 +1,10 @@ // eslint-disable-next-line no-restricted-imports import type {Animated} from 'react-native'; -import type GetBackgroudColor from './types'; +import type {BackgroundColor, GetBackgroundColorConfig} from './types'; -const getBackgroundColor: GetBackgroudColor = ({routesLength, tabIndex, affectedTabs, theme, position, isActive}) => { +function getBackgroundColor({routesLength, tabIndex, affectedTabs, theme, position, isActive}: GetBackgroundColorConfig): BackgroundColor { if (routesLength > 1) { - const inputRange = Array.from({length: routesLength}, (v, i) => i); + const inputRange = Array.from({length: routesLength}, (_, i) => i); if (position) { return position.interpolate({ @@ -17,7 +17,8 @@ const getBackgroundColor: GetBackgroudColor = ({routesLength, tabIndex, affected return affectedTabs.includes(tabIndex) && isActive ? theme.border : theme.appBG; } + return theme.border; -}; +} export default getBackgroundColor; diff --git a/src/components/TabSelector/getBackground/index.ts b/src/components/TabSelector/getBackground/index.ts deleted file mode 100644 index 2eb60a5115a1..000000000000 --- a/src/components/TabSelector/getBackground/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type GetBackgroudColor from './types'; - -const getBackgroundColor: GetBackgroudColor = ({routesLength, tabIndex, affectedTabs, theme, isActive}) => { - if (routesLength > 1) { - return affectedTabs.includes(tabIndex) && isActive ? theme.border : theme.appBG; - } - return theme.border; -}; -export default getBackgroundColor; diff --git a/src/components/TabSelector/getOpacity/index.native.ts b/src/components/TabSelector/getOpacity.ts similarity index 68% rename from src/components/TabSelector/getOpacity/index.native.ts rename to src/components/TabSelector/getOpacity.ts index fcdb1d0fc31e..5bfaca8e9657 100644 --- a/src/components/TabSelector/getOpacity/index.native.ts +++ b/src/components/TabSelector/getOpacity.ts @@ -1,11 +1,11 @@ -import type GetOpacity from './types'; +import type {GetOpacityConfig, Opacity} from './types'; -const getOpacity: GetOpacity = ({routesLength, tabIndex, active, affectedTabs, position, isActive}) => { +function getOpacity({routesLength, tabIndex, active, affectedTabs, position, isActive}: GetOpacityConfig): Opacity { const activeValue = active ? 1 : 0; const inactiveValue = active ? 0 : 1; if (routesLength > 1) { - const inputRange = Array.from({length: routesLength}, (v, i) => i); + const inputRange = Array.from({length: routesLength}, (_, i) => i); if (position) { return position.interpolate({ @@ -16,7 +16,8 @@ const getOpacity: GetOpacity = ({routesLength, tabIndex, active, affectedTabs, p return affectedTabs.includes(tabIndex) && isActive ? activeValue : inactiveValue; } + return activeValue; -}; +} export default getOpacity; diff --git a/src/components/TabSelector/getOpacity/index.ts b/src/components/TabSelector/getOpacity/index.ts deleted file mode 100644 index d9f3a2eb6167..000000000000 --- a/src/components/TabSelector/getOpacity/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type GetOpacity from './types'; - -const getOpacity: GetOpacity = ({routesLength, tabIndex, active, affectedTabs, isActive}) => { - const activeValue = active ? 1 : 0; - const inactiveValue = active ? 0 : 1; - - if (routesLength > 1) { - return affectedTabs.includes(tabIndex) && isActive ? activeValue : inactiveValue; - } - return activeValue; -}; - -export default getOpacity; diff --git a/src/components/TabSelector/getOpacity/types.ts b/src/components/TabSelector/getOpacity/types.ts deleted file mode 100644 index ccef8cd018d0..000000000000 --- a/src/components/TabSelector/getOpacity/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -// eslint-disable-next-line no-restricted-imports -import type {Animated} from 'react-native'; - -/** - * Configuration for the getOpacity function. - */ -type GetOpacityConfig = { - /** - * The number of routes in the tab bar. - */ - routesLength: number; - - /** - * The index of the tab. - */ - tabIndex: number; - - /** - * Whether we are calculating the opacity for the active tab. - */ - active: boolean; - - /** - * The indexes of the tabs that are affected by the animation. - */ - affectedTabs: number[]; - - /** - * Scene's position, value which we would like to interpolate. - */ - position: Animated.AnimatedInterpolation | undefined; - - /** - * Whether the tab is active. - */ - isActive: boolean; -}; - -/** - * Function to get the opacity. - * @param args - The configuration for the opacity. - * @returns The interpolated opacity or a fixed value (1 or 0). - */ -type GetOpacity = (args: GetOpacityConfig) => 1 | 0 | Animated.AnimatedInterpolation; - -export default GetOpacity; diff --git a/src/components/TabSelector/getBackground/types.ts b/src/components/TabSelector/types.ts similarity index 58% rename from src/components/TabSelector/getBackground/types.ts rename to src/components/TabSelector/types.ts index e08006e8e9f5..f784a9f21c6e 100644 --- a/src/components/TabSelector/getBackground/types.ts +++ b/src/components/TabSelector/types.ts @@ -2,10 +2,7 @@ import type {Animated} from 'react-native'; import type {ThemeColors} from '@styles/theme/types'; -/** - * Configuration for the getBackgroundColor function. - */ -type GetBackgroudColorConfig = { +type AnimationConfigBase = { /** * The number of routes. */ @@ -21,11 +18,6 @@ type GetBackgroudColorConfig = { */ affectedTabs: number[]; - /** - * The theme colors. - */ - theme: ThemeColors; - /** * The animated position interpolation. */ @@ -37,11 +29,22 @@ type GetBackgroudColorConfig = { isActive: boolean; }; -/** - * Function to get the background color. - * @param args - The configuration for the background color. - * @returns The interpolated background color or a string. - */ -type GetBackgroudColor = (args: GetBackgroudColorConfig) => Animated.AnimatedInterpolation | string; +type GetBackgroundColorConfig = AnimationConfigBase & { + /** + * The theme colors. + */ + theme: ThemeColors; +}; + +type GetOpacityConfig = AnimationConfigBase & { + /** + * Whether we are calculating the opacity for the active tab. + */ + active: boolean; +}; + +type BackgroundColor = Animated.AnimatedInterpolation | string; + +type Opacity = 1 | 0 | Animated.AnimatedInterpolation; -export default GetBackgroudColor; +export type {BackgroundColor, GetBackgroundColorConfig, Opacity, GetOpacityConfig};