forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove interpolation from web platoform as animations are disabled
- Loading branch information
1 parent
7814eed
commit fba2945
Showing
7 changed files
with
92 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type {Animated} from 'react-native'; | ||
import type GetBackgroudColor from './types'; | ||
|
||
const getBackgroundColor: GetBackgroudColor = ({routesLength, tabIndex, affectedTabs, theme, position}) => { | ||
if (routesLength > 1) { | ||
const inputRange = Array.from({length: routesLength}, (v, i) => i); | ||
return position?.interpolate({ | ||
inputRange, | ||
outputRange: inputRange.map((i) => { | ||
return affectedTabs.includes(tabIndex) && i === tabIndex ? theme.border : theme.appBG; | ||
}), | ||
}) as unknown as Animated.AnimatedInterpolation<string>; | ||
} | ||
return theme.border; | ||
}; | ||
|
||
export default getBackgroundColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type {Animated} from 'react-native'; | ||
import type {ThemeColors} from '@styles/theme/types'; | ||
|
||
type GetBackgroudColorConfig = { | ||
routesLength: number; | ||
tabIndex: number; | ||
affectedTabs: number[]; | ||
theme: ThemeColors; | ||
position?: Animated.AnimatedInterpolation<number>; | ||
isActive?: boolean; | ||
}; | ||
|
||
type GetBackgroudColor = (args: GetBackgroudColorConfig) => Animated.AnimatedInterpolation<string> | string; | ||
|
||
export default GetBackgroudColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type GetOpacity from './types'; | ||
|
||
const getOpacity: GetOpacity = ({routesLength, tabIndex, active, affectedTabs, position, isActive}) => { | ||
const activeValue = active ? 1 : 0; | ||
const inactiveValue = active ? 0 : 1; | ||
|
||
if (routesLength > 1) { | ||
const inputRange = Array.from({length: routesLength}, (v, i) => i); | ||
|
||
return position?.interpolate({ | ||
inputRange, | ||
outputRange: inputRange.map((i) => (affectedTabs.includes(tabIndex) && i === tabIndex && isActive ? activeValue : inactiveValue)), | ||
}); | ||
} | ||
return activeValue; | ||
}; | ||
|
||
export default getOpacity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type {Animated} from 'react-native'; | ||
|
||
type GetOpacityConfig = { | ||
routesLength: number; | ||
tabIndex: number; | ||
active: boolean; | ||
affectedTabs: number[]; | ||
position?: Animated.AnimatedInterpolation<number>; | ||
isActive?: boolean; | ||
}; | ||
|
||
type GetOpacity = (args: GetOpacityConfig) => 1 | 0 | Animated.AnimatedInterpolation<number> | undefined; | ||
|
||
export default GetOpacity; |