Skip to content

Commit

Permalink
Merge branch 'main' into marketing-consent-tracking-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jonybur authored Jan 16, 2025
2 parents 6954b0c + 1f2c1a2 commit 1bb2e93
Show file tree
Hide file tree
Showing 267 changed files with 4,085 additions and 2,193 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ module.exports = {
files: [
'app/components/UI/Name/**/*.{js,ts,tsx}',
'app/components/UI/SimulationDetails/**/*.{js,ts,tsx}',
'app/components/hooks/DisplayName/**/*.{js,ts,tsx}'
'app/components/hooks/DisplayName/**/*.{js,ts,tsx}',
'app/components/Views/confirmations/components/Confirm/DataTree/**/*.{js,ts,tsx}',
'app/components/Views/confirmations/components/Confirm/Info/**/*.{js,ts,tsx}',
'app/components/Views/confirmations/components/PersonalSign/**/*.{js,ts,tsx}',
'app/components/Views/confirmations/components/SignatureRequest/**/*.{js,ts,tsx}',
'app/components/Views/confirmations/components/TypedSign/**/*.{js,ts,tsx}',
],
rules: {
'no-restricted-syntax': [
Expand All @@ -92,7 +97,7 @@ module.exports = {
'selectProviderType',
'selectRpcUrl',
'selectSelectedNetworkClientId',
'selectTicker'
'selectTicker',
]
.map((method) => `(${method})`)
.join('|')}/]`,
Expand Down
4 changes: 3 additions & 1 deletion app/__mocks__/pngMock.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export default { uri: 'MockImage' };
// When required, assets in React Native returns a number
// eslint-disable-next-line import/no-commonjs
module.exports = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Third party dependencies.
import { StyleSheet } from 'react-native';

// External dependencies.
import { Theme } from '../../../../util/theme/models';

/**
* Style sheet input parameters.
*/
export interface ButtonPillStyleSheetVars {
isDisabled: boolean;
isPressed: boolean;
}

/**
* Style sheet function for ButtonPill component
*
* @param params Style sheet params
* @param params.theme Theme object
* @param params.vars Arbitrary inputs this style sheet depends on
* @returns StyleSheet object
*/
const styleSheet = (params: {
theme: Theme;
vars: ButtonPillStyleSheetVars;
}) => {
const {
theme: { colors },
vars: { isDisabled, isPressed }
} = params;

return StyleSheet.create({
base: {
backgroundColor: colors.background.alternative,
color: colors.text.default,
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 8,
paddingVertical: 4,
borderRadius: 99,
opacity: isDisabled ? 0.5 : 1,
...(isPressed && {
backgroundColor: colors.background.alternativePressed,
}),
},
});
};

export default styleSheet;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Third party dependencies.
import React from 'react';
import { render } from '@testing-library/react-native';

// Internal dependencies.
import ButtonPill from './ButtonPill';

describe('ButtonPill', () => {
it('should render correctly', () => {
const { toJSON } = render(
<ButtonPill onPress={jest.fn} />,
);
expect(toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Third party dependencies.
import React, { useCallback, useState } from 'react';
import { GestureResponderEvent, TouchableOpacity, TouchableOpacityProps } from 'react-native';

// External dependencies.
import { useStyles } from '../../../hooks';

// Internal dependencies.
import stylesheet from './ButtonPill.styles';

/**
* ButtonPill component props.
*/
export interface ButtonPillProps extends TouchableOpacityProps {
/**
* Optional param to disable the button.
*/
isDisabled?: boolean;
}

const ButtonPill = ({
onPress,
onPressIn,
onPressOut,
style,
isDisabled = false,
children,
...props
}: ButtonPillProps) => {
const [isPressed, setIsPressed] = useState(false);
const { styles } = useStyles(stylesheet, {
style,
isPressed,
isDisabled,
});

const triggerOnPressedIn = useCallback(
(e: GestureResponderEvent) => {
setIsPressed(true);
onPressIn?.(e);
},
[setIsPressed, onPressIn],
);

const triggerOnPressedOut = useCallback(
(e: GestureResponderEvent) => {
setIsPressed(false);
onPressOut?.(e);
},
[setIsPressed, onPressOut],
);

return (
<TouchableOpacity
style={styles.base}
onPress={!isDisabled ? onPress : undefined}
onPressIn={!isDisabled ? triggerOnPressedIn : undefined}
onPressOut={!isDisabled ? triggerOnPressedOut : undefined}
accessible
activeOpacity={1}
disabled={isDisabled}
{...props}
>
{children}
</TouchableOpacity>
);
};

export default ButtonPill;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ButtonPill should render correctly 1`] = `
<TouchableOpacity
accessible={true}
activeOpacity={1}
disabled={false}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
style={
{
"alignItems": "center",
"backgroundColor": "#f2f4f6",
"borderRadius": 99,
"color": "#141618",
"justifyContent": "center",
"opacity": 1,
"paddingHorizontal": 8,
"paddingVertical": 4,
}
}
/>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ButtonPill';
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

exports[`Badge should render badge network given the badge network variant 1`] = `
<BadgeNetwork
imageSource={
{
"default": {
"uri": "MockImage",
},
}
}
imageSource={1}
isScaled={true}
name="Ethereum"
testID="badge-badgenetwork"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ exports[`BadgeNetwork should render BadgeNetwork 1`] = `
<Image
onError={[Function]}
resizeMode="contain"
source={
{
"default": {
"uri": "MockImage",
},
}
}
source={1}
style={
{
"height": 32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ exports[`BadgeWrapper should render BadgeWrapper correctly 1`] = `
}
>
<Badge
imageSource={
{
"default": {
"uri": "MockImage",
},
}
}
imageSource={1}
isScaled={true}
name="Ethereum"
variant="network"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ exports[`BannerTip should render default settings correctly 1`] = `
>
<Image
resizeMode="contain"
source={
{
"uri": "MockImage",
}
}
source={1}
style={
{
"height": 55,
Expand Down
3 changes: 2 additions & 1 deletion app/components/Base/StatusText.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const styles = StyleSheet.create({

export const ConfirmedText = (props) => (
<Text
testID={CommonSelectorsIDs.STATUS_CONFIRMED}
testID={CommonSelectorsIDs.TRANSACTION_STATUS}
bold
green
style={styles.status}
Expand All @@ -38,6 +38,7 @@ export const FailedText = (props) => {
const { colors } = useTheme();
return (
<Text
testID={CommonSelectorsIDs.TRANSACTION_STATUS}
bold
style={[styles.status, { color: colors.error.default }]}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,7 @@ exports[`AccountFromToInfoCard should match snapshot 1`] = `
<Image
onError={[Function]}
resizeMode="contain"
source={
{
"default": {
"uri": "MockImage",
},
}
}
source={1}
style={
{
"height": 32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,7 @@ exports[`AccountRightButton should render correctly 1`] = `
<Image
onError={[Function]}
resizeMode="contain"
source={
{
"default": {
"uri": "MockImage",
},
}
}
source={1}
style={
{
"height": 32,
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/AssetOverview/AssetOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ const AssetOverview: React.FC<AssetOverviewProps> = ({
}
} else {
mainBalance = `${balance} ${asset.isETH ? asset.ticker : asset.symbol}`;
secondaryBalance = exchangeRate ? asset.balanceFiat : '';
secondaryBalance = asset.balanceFiat || '';
}

let currentPrice = 0;
Expand Down
5 changes: 1 addition & 4 deletions app/components/UI/AssetOverview/Balance/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import Text, {
} from '../../../../component-library/components/Texts/Text';
import { TokenI } from '../../Tokens/types';
import { useNavigation } from '@react-navigation/native';
import { isPooledStakingFeatureEnabled } from '../../Stake/constants';
import StakingBalance from '../../Stake/components/StakingBalance/StakingBalance';
import {
PopularList,
Expand Down Expand Up @@ -167,9 +166,7 @@ const Balance = ({ asset, mainBalance, secondaryBalance }: BalanceProps) => {
{asset.name || asset.symbol}
</Text>
</AssetElement>
{isPooledStakingFeatureEnabled() && asset?.isETH && (
<StakingBalance asset={asset} />
)}
{asset?.isETH && <StakingBalance asset={asset} />}
</View>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ exports[`Balance should render correctly with a fiat balance 1`] = `
<Image
onError={[Function]}
resizeMode="contain"
source={
{
"uri": "MockImage",
}
}
source={1}
style={
{
"height": 32,
Expand Down Expand Up @@ -376,11 +372,7 @@ exports[`Balance should render correctly without a fiat balance 1`] = `
<Image
onError={[Function]}
resizeMode="contain"
source={
{
"uri": "MockImage",
}
}
source={1}
style={
{
"height": 32,
Expand Down
Loading

0 comments on commit 1bb2e93

Please sign in to comment.