-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51020 from callstack-internal/fix/50265
Fix: Submit expense - Highlight jumps to manual when clicking back from start/stop
- Loading branch information
Showing
7 changed files
with
154 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,46 @@ | ||
import type {Animated} from 'react-native'; | ||
import type {ThemeColors} from '@styles/theme/types'; | ||
|
||
/** | ||
* Configuration for the getBackgroundColor function. | ||
*/ | ||
type GetBackgroudColorConfig = { | ||
/** | ||
* The number of routes. | ||
*/ | ||
routesLength: number; | ||
|
||
/** | ||
* The index of the current tab. | ||
*/ | ||
tabIndex: number; | ||
|
||
/** | ||
* The indices of the affected tabs. | ||
*/ | ||
affectedTabs: number[]; | ||
|
||
/** | ||
* The theme colors. | ||
*/ | ||
theme: ThemeColors; | ||
|
||
/** | ||
* The animated position interpolation. | ||
*/ | ||
position: Animated.AnimatedInterpolation<number>; | ||
|
||
/** | ||
* Whether the tab is active. | ||
*/ | ||
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> | 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,45 @@ | ||
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<number>; | ||
|
||
/** | ||
* 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<number>; | ||
|
||
export default GetOpacity; |