-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Submit expense - Highlight jumps to manual when clicking back from start/stop #51020
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; |
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; |
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; |
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)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, this caused the following issue: #51297 |
||
}); | ||
} | ||
return activeValue; | ||
}; | ||
|
||
export default getOpacity; |
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; |
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #51821.
For the mWeb platform, removing these interpolations also stops the listener in
useTabNavigatorFocus
from being triggered. As a result,isTabActive
doesn't update as expected, causing infinite loading in the scan option page.