Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import BadgeWrapper from '../../../component-library/components/Badges/BadgeWrap
import Badge, {
BadgeVariant,
} from '../../../component-library/components/Badges/Badge';
import { AvatarSize } from '../../../component-library/components/Avatars/Avatar';
import { getNetworkImageSource } from '../../../util/networks';
import { parseCaipAssetType } from '@metamask/utils';
import { useAnalytics } from '../../hooks/useAnalytics/useAnalytics';
Expand Down Expand Up @@ -102,10 +103,13 @@ const MultichainBridgeTransactionListItem = ({
const networkImageSource = getNetworkImageSource({ chainId });
return (
<BadgeWrapper
badgePosition={{ bottom: -4, right: -4 }}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it bottom right, aligns with most avatars and extension

badgeElement={
<Badge
variant={BadgeVariant.Network}
imageSource={networkImageSource}
isScaled={false}
size={AvatarSize.Xs}
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import BadgeWrapper from '../../../component-library/components/Badges/BadgeWrap
import Badge, {
BadgeVariant,
} from '../../../component-library/components/Badges/Badge';
import { AvatarSize } from '../../../component-library/components/Avatars/Avatar';
import { getNetworkImageSource } from '../../../util/networks';
import Routes from '../../../constants/navigation/Routes';
import { useAnalytics } from '../../hooks/useAnalytics/useAnalytics';
Expand Down Expand Up @@ -91,10 +92,13 @@ const MultichainTransactionListItem = ({

return (
<BadgeWrapper
badgePosition={{ bottom: -4, right: -4 }}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it bottom right, aligns with most avatars and extension

badgeElement={
<Badge
variant={BadgeVariant.Network}
imageSource={networkImageSource}
isScaled={false}
size={AvatarSize.Xs}
/>
}
>
Expand Down
47 changes: 43 additions & 4 deletions app/components/UI/TransactionElement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import BadgeWrapper from '../../../component-library/components/Badges/BadgeWrap
import Badge, {
BadgeVariant,
} from '../../../component-library/components/Badges/Badge';
import { AvatarSize } from '../../../component-library/components/Avatars/Avatar';
import { NetworkBadgeSource } from '../AssetOverview/Balance/Balance';
import {
getFontFamily,
Expand Down Expand Up @@ -98,6 +99,10 @@ const createStyles = (colors, typography) =>
width: 32,
height: 32,
},
iconBadgePosition: {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI improvements: align network badge placement (bottom right)

bottom: -4,
right: -4,
},
importText: {
color: colors.text.alternative,
fontSize: 14,
Expand Down Expand Up @@ -264,13 +269,13 @@ class TransactionElement extends PureComponent {
mounted = false;

componentDidMount = async () => {
this.mounted = true;
const [transactionElement, transactionDetails] = await decodeTransaction({
...this.props,
swapsTransactions: this.props.swapsTransactions,
assetSymbol: this.props.assetSymbol,
ticker: this.props.ticker,
});
this.mounted = true;

this.mounted && this.setState({ transactionElement, transactionDetails });
};
Expand Down Expand Up @@ -461,10 +466,13 @@ class TransactionElement extends PureComponent {

return (
<BadgeWrapper
badgePosition={styles.iconBadgePosition}
badgeElement={
<Badge
variant={BadgeVariant.Network}
imageSource={NetworkBadgeSource(chainId)}
isScaled={false}
size={AvatarSize.Xs}
/>
}
>
Expand Down Expand Up @@ -707,14 +715,43 @@ class TransactionElement extends PureComponent {
);
};

renderPendingElement = () => {
const { i, tx } = this.props;
const { colors, typography } = this.context || mockTheme;
const styles = createStyles(colors, typography);

return (
<ListItem>
<ListItem.Date style={styles.listItemDate}>
{this.renderTxTime()}
</ListItem.Date>
<ListItem.Content style={styles.listItemContent}>
<ListItem.Icon>
<View style={styles.icon} />
</ListItem.Icon>
<ListItem.Body>
<ListItem.Title numberOfLines={1} style={styles.listItemTitle}>
...
</ListItem.Title>
<StatusText
testID={`transaction-status-${i}`}
status={tx.status}
style={styles.listItemStatus}
/>
</ListItem.Body>
</ListItem.Content>
</ListItem>
);
};

render() {
const { tx, selectedInternalAccount } = this.props;
const { transactionElement, transactionDetails } = this.state;

const { colors, typography } = this.context || mockTheme;
const styles = createStyles(colors, typography);

if (!transactionElement || !transactionDetails) return null;
const isReady = Boolean(transactionElement && transactionDetails);

const accountImportTime = selectedInternalAccount?.metadata.importTime;
const { time } = tx;
Expand All @@ -726,11 +763,13 @@ class TransactionElement extends PureComponent {
style={
this.props.showBottomBorder ? styles.rowWithBorder : styles.row
}
onPress={this.onPressItem}
onPress={isReady ? this.onPressItem : undefined}
underlayColor={colors.background.alternative}
activeOpacity={1}
>
{this.renderTxElement(transactionElement)}
{isReady
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI improvements: prefer a stable layout

? this.renderTxElement(transactionElement)
: this.renderPendingElement()}
</TouchableHighlight>
{accountImportTime <= time && this.renderImportTime()}
</>
Expand Down
Loading
Loading