-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build out the transactions screen (#14)
* Create <List /> component * Extract PraxDripsyProvider * Set up Storybook to work with i18n; Install testing libs * Add XS icon size * Truncate text in ListItem * Create factories * Create TransactionList * Fix text overflow * Add screenHorizontalMargin * Create transactions state * Add transactions list to home screen * Add a primaryAction prop to List * Remove unused props * Remove unused var * Rework header components * Build out TransactionsScreen * Tweak comments * Add comments * Fix suffix * Add comment * Add RN Jest matchers * Update tests * Update args * Add comment * Reorganize and add comments * Early return * Create initial portfolio screen (#15) * Rename header * Extract BalanceAndActions component; use it in PortfolioScreen * Create store/type/factory for balances * Create balance UI in portfolio screen * Use more precise naming * Tweak factories * Wrap Storybook stories in <ReduxProvider /> * Fix ATOM mock data * Delete BalanceList stories for now * Build a simple AssetActionSheet * Add comment
- Loading branch information
1 parent
cedf501
commit 39cbe81
Showing
52 changed files
with
1,284 additions
and
113 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
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,5 @@ | ||
import TransactionsScreen from '@/components/TransactionsScreen'; | ||
|
||
export default function TransactionsRoute() { | ||
return <TransactionsScreen />; | ||
} |
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,19 @@ | ||
import { Pressable } from 'dripsy'; | ||
import Header from '../Header'; | ||
import Icon from '../Icon'; | ||
import { ArrowLeftCircle } from 'lucide-react-native'; | ||
import { useRouter } from 'expo-router'; | ||
|
||
export default function BackButtonHeader() { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<Header | ||
left={ | ||
<Pressable onPress={() => router.back()}> | ||
<Icon IconComponent={ArrowLeftCircle} size='md' /> | ||
</Pressable> | ||
} | ||
/> | ||
); | ||
} |
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,71 @@ | ||
import { Trans } from '@lingui/react/macro'; | ||
import { Sx, Text, View } from 'dripsy'; | ||
import Button from '../Button'; | ||
import { useAppDispatch, useAppSelector } from '@/store/hooks'; | ||
import { close, open } from '@/store/depositFlow'; | ||
import DepositFlow from '../DepositFlow'; | ||
|
||
/** | ||
* Renders the user's current balance, as well as buttons for actions related to | ||
* their balance (such as Send/Deposit/Request). | ||
*/ | ||
export default function BalanceAndActions() { | ||
const dispatch = useAppDispatch(); | ||
const isOpen = useAppSelector(state => state.depositFlow.isOpen); | ||
|
||
return ( | ||
<> | ||
<View sx={sx.root}> | ||
<View sx={sx.balanceWrapper}> | ||
<Text sx={sx.balanceLabel}> | ||
<Trans>Balance</Trans> | ||
</Text> | ||
<Text sx={sx.balance}>0.00 USDC</Text> | ||
</View> | ||
|
||
<View sx={sx.buttons}> | ||
<Button actionType='accent' onPress={() => dispatch(open())}> | ||
<Trans>Deposit</Trans> | ||
</Button> | ||
<Button> | ||
<Trans>Request</Trans> | ||
</Button> | ||
</View> | ||
</View> | ||
|
||
<DepositFlow isOpen={isOpen} onClose={() => dispatch(close())} /> | ||
</> | ||
); | ||
} | ||
|
||
const sx = { | ||
balance: { | ||
variant: 'text.h4', | ||
}, | ||
|
||
balanceLabel: { | ||
variant: 'text.small', | ||
|
||
color: 'neutralLight', | ||
}, | ||
|
||
balanceWrapper: { | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexGrow: 1, | ||
}, | ||
|
||
buttons: { | ||
flexDirection: 'row', | ||
flexGrow: 0, | ||
gap: '$2', | ||
px: '$4', | ||
pb: '$4', | ||
}, | ||
|
||
root: { | ||
flexGrow: 1, | ||
flexDirection: 'column', | ||
}, | ||
} satisfies Record<string, Sx>; |
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
37 changes: 37 additions & 0 deletions
37
react-native-expo/components/HomeScreen/HomeScreenTransactionsList.tsx
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,37 @@ | ||
import { useAppSelector } from '@/store/hooks'; | ||
import TransactionList from '../TransactionList'; | ||
import { shallowEqual } from 'react-redux'; | ||
import { Sx, Text } from 'dripsy'; | ||
import { Trans } from '@lingui/react/macro'; | ||
import { Link } from 'expo-router'; | ||
|
||
function SeeAllButton() { | ||
return ( | ||
<Link href='/transactions'> | ||
<Text sx={sx.seeAllButtonLabel}> | ||
<Trans>See all</Trans> | ||
</Text> | ||
</Link> | ||
); | ||
} | ||
|
||
/** | ||
* A preview of the latest few transactions a user has, with a button to view | ||
* them all. | ||
*/ | ||
export default function HomeScreenTransactionsList() { | ||
const first5Transactions = useAppSelector( | ||
state => state.transactions.transactions.slice(0, 5), | ||
shallowEqual, | ||
); | ||
|
||
return ( | ||
<TransactionList transactions={first5Transactions} primaryAction={<SeeAllButton />} showTitle /> | ||
); | ||
} | ||
|
||
const sx = { | ||
seeAllButtonLabel: { | ||
textDecorationLine: 'underline', | ||
}, | ||
} satisfies Record<string, Sx>; |
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 |
---|---|---|
@@ -1,69 +1,21 @@ | ||
import Button from '../Button'; | ||
import { Sx, Text, View } from 'dripsy'; | ||
import DepositFlow from '../DepositFlow'; | ||
import { useAppDispatch, useAppSelector } from '@/store/hooks'; | ||
import { close, open } from '@/store/depositFlow'; | ||
import { Trans } from '@lingui/react/macro'; | ||
|
||
export interface HomeScreenProps {} | ||
import { Sx, View } from 'dripsy'; | ||
import HomeScreenTransactionsList from './HomeScreenTransactionsList'; | ||
import BalanceAndActions from '../BalanceAndActions'; | ||
|
||
export default function HomeScreen() { | ||
const dispatch = useAppDispatch(); | ||
const isOpen = useAppSelector(state => state.depositFlow.isOpen); | ||
|
||
return ( | ||
<> | ||
<View sx={sx.root}> | ||
<View sx={sx.balanceWrapper}> | ||
<Text sx={sx.balanceLabel}> | ||
<Trans>Balance</Trans> | ||
</Text> | ||
<Text sx={sx.balance}>0.00 USDC</Text> | ||
</View> | ||
<View sx={sx.root}> | ||
{/** @todo: Make this a `ScrollView`. */} | ||
<BalanceAndActions /> | ||
|
||
<View sx={sx.buttons}> | ||
<Button actionType='accent' onPress={() => dispatch(open())}> | ||
<Trans>Deposit</Trans> | ||
</Button> | ||
<Button> | ||
<Trans>Request</Trans> | ||
</Button> | ||
</View> | ||
</View> | ||
|
||
<DepositFlow isOpen={isOpen} onClose={() => dispatch(close())} /> | ||
</> | ||
<HomeScreenTransactionsList /> | ||
</View> | ||
); | ||
} | ||
|
||
const sx = { | ||
balance: { | ||
variant: 'text.h4', | ||
}, | ||
|
||
balanceLabel: { | ||
variant: 'text.small', | ||
|
||
color: 'neutralLight', | ||
}, | ||
|
||
balanceWrapper: { | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexGrow: 1, | ||
}, | ||
|
||
buttons: { | ||
flexDirection: 'row', | ||
flexGrow: 0, | ||
gap: '$2', | ||
px: '$4', | ||
pb: '$4', | ||
}, | ||
|
||
root: { | ||
flexGrow: 1, | ||
flexDirection: 'column', | ||
px: 'screenHorizontalMargin', | ||
}, | ||
} satisfies Record<string, Sx>; |
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,32 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import List from '.'; | ||
import ListItem from '../ListItem'; | ||
import AssetIcon from '../AssetIcon'; | ||
import { Text } from 'dripsy'; | ||
|
||
const meta: Meta<typeof List> = { | ||
component: List, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
children: { control: false }, | ||
primaryAction: { control: false }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Basic: StoryObj<typeof List> = { | ||
args: { | ||
title: 'Assets', | ||
children: ( | ||
<> | ||
<ListItem primaryText='ETH' secondaryText='Ethereum' avatar={<AssetIcon />} /> | ||
<ListItem primaryText='ATOM' secondaryText='Cosmos' avatar={<AssetIcon />} /> | ||
<ListItem primaryText='UM' secondaryText='Penumbra' avatar={<AssetIcon />} /> | ||
<ListItem primaryText='USDC' secondaryText='USD Coin' avatar={<AssetIcon />} /> | ||
</> | ||
), | ||
primaryAction: <Text sx={{ textDecorationLine: 'underline' }}>See all</Text>, | ||
}, | ||
}; |
Oops, something went wrong.