Skip to content

Commit

Permalink
Merge pull request #216 from GoodDollar/188-transaction-list-icons
Browse files Browse the repository at this point in the history
188 transaction list icons
  • Loading branch information
sirpy authored Jul 15, 2024
2 parents ddbd7e6 + 0f2a45f commit 567fe74
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 26 deletions.
4 changes: 4 additions & 0 deletions packages/app/src/assets/ClaimTX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/app/src/assets/ClaimTx.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packages/app/src/assets/DonationTX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/app/src/assets/PayoutTX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/app/src/assets/StreamStopTX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/app/src/assets/StreamTX.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/app/src/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ export { default as empty } from './empty.svg';
export { default as MetaMaskLogo } from './MetaMask_Fox.svg';
export { default as WalletConnectLogo } from './WalletConnectLogo.svg';
export { default as WalletConnectLogoWhite } from './WalletConnectLogoWhite.svg';
export { default as StreamTX } from './StreamTX.svg';
export { default as StreamStopTX } from './StreamStopTX.svg';
export { default as DonationTX } from './DonationTX.svg';
export { default as ClaimTX } from './ClaimTX.svg';
export { default as PayoutTX } from './PayoutTX.svg';
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import { formatGoodDollarAmount } from '../../lib/calculateGoodDollarAmounts';
import { Text } from 'react-native';
import { useMemo } from 'react';
import { styles } from './styles';
import { ClaimTX, PayoutTX } from '../../assets';

interface ClaimTransactionListItemProps {
transaction: ClaimTx;
}

const getTxIcon = (transaction: ClaimTx) => {
if (transaction.type === 'ubi') {
return ClaimTX;
}
return PayoutTX;
};
export function ClaimTransactionListItem({ transaction }: ClaimTransactionListItemProps) {
const { hash, networkFee, stewards, totalRewards } = transaction;

Expand All @@ -35,6 +42,7 @@ export function ClaimTransactionListItem({ transaction }: ClaimTransactionListIt

return (
<TransactionListItem
icon={getTxIcon(transaction)}
userIdentifier={userIdentifier}
isDonation={false}
amount={amount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ import { formatGoodDollarAmount } from '../../lib/calculateGoodDollarAmounts';
import { Text } from 'react-native';
import { useMemo } from 'react';
import { styles } from './styles';
import { DonationTX, StreamStopTX, StreamTX } from '../../assets';
import { totalDurationInSeconds } from '../../lib/totalDurationInSeconds';
import { Frequency } from '../../models/constants';
import env from '../../lib/env';

interface SupportTransactionListItemProps {
transaction: SupportTx;
}

const getTxIcon = (transaction: SupportTx) => {
if (transaction.isFlowUpdate) {
if (transaction.flowRate === '0') return StreamStopTX;
else return StreamTX;
}
return DonationTX;
};
export function SupportTransactionListItem({ transaction }: SupportTransactionListItemProps) {
const { hash, networkFee, donor } = transaction;

Expand Down Expand Up @@ -54,6 +63,12 @@ export function SupportTransactionListItem({ transaction }: SupportTransactionLi

return (
<TransactionListItem
isStream={transaction.isFlowUpdate}
explorerLink={
// ? `${env.REACT_APP_SUPERFLUID_EXPLORER}/streams/${donor}-${transaction.collective}-${transaction.rewardToken}-0.0`
transaction.isFlowUpdate ? `${env.REACT_APP_SUPERFLUID_EXPLORER}/accounts/${donor}?tab=streams` : undefined
}
icon={getTxIcon(transaction)}
userIdentifier={userIdentifier}
isDonation={true}
amount={flowingAmount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { isSupportTx } from '../../models/typeUtil';
import { ClaimTransactionListItem } from './ClaimTransactionListItem';
import { SupportTransactionListItem } from './SupportTransactionListItem';
import { SUBGRAPH_POLL_INTERVAL } from '../../models/constants';
import env from '../../lib/env';

interface TransactionListProps {
collective: `0x${string}`;
Expand Down Expand Up @@ -41,7 +42,7 @@ function TransactionList({ collective }: TransactionListProps) {
)}
</View>
{isDesktopResolution && transactions.length > 5 && (
<Link href={`https://explorer.celo.org/mainnet/address/${collective}`} isExternal style={styles.showMoreButton}>
<Link href={`${env.REACT_APP_CELO_EXPLORER}/address/${collective}`} isExternal style={styles.showMoreButton}>
<Text style={styles.showMoreText}>Show more</Text>
<Image source={chevronDown} style={styles.showMoreIcon} />
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { Image, Text, View } from 'react-native';
import { Colors } from '../../utils/colors';
import { ReceiveIcon, SendIcon } from '../../assets';
import { Link } from 'native-base';
import { styles } from './styles';
import { formatEther } from 'viem';
import env from '../../lib/env';

interface TransactionListItemProps {
userIdentifier: string;
isDonation?: boolean;
isStream?: boolean;
amount: JSX.Element;
txHash: string;
explorerLink?: string;
rawNetworkFee: string;
icon: any;
}

function TransactionListItem({ userIdentifier, isDonation, amount, txHash, rawNetworkFee }: TransactionListItemProps) {
function TransactionListItem({
userIdentifier,
isDonation,
amount,
txHash,
explorerLink,
rawNetworkFee,
icon,
}: TransactionListItemProps) {
const formattedFee: string = formatEther(BigInt(rawNetworkFee ?? 0)).toString();
const formattedHash = txHash.slice(0, 40) + '...';

Expand All @@ -25,9 +36,9 @@ function TransactionListItem({ userIdentifier, isDonation, amount, txHash, rawNe
<View style={[styles.bar, { backgroundColor: Colors.orange[100] }]} />
)}
{isDonation ? (
<Image source={{ uri: ReceiveIcon }} style={styles.rowIcon} />
<Image source={{ uri: icon }} style={styles.rowIcon} />
) : (
<Image source={{ uri: SendIcon }} style={styles.rowIcon} />
<Image source={{ uri: icon }} style={styles.rowIcon} />
)}
<View style={{ flex: 1 }}>
<View style={styles.txDetails}>
Expand All @@ -37,7 +48,7 @@ function TransactionListItem({ userIdentifier, isDonation, amount, txHash, rawNe
{amount}
</View>
</View>
<Link href={`https://explorer.celo.org/mainnet/tx/${txHash}`} isExternal>
<Link href={explorerLink ?? `${env.REACT_APP_CELO_EXPLORER}/tx/${txHash}`} isExternal>
<Text style={styles.hash}>{formattedHash}</Text>
</Link>
<View>
Expand Down
Loading

0 comments on commit 567fe74

Please sign in to comment.