-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create account management functionality (#60)
* feat: create useSign hook * feat: add react-native-quick-crypto back * feat: create chainsDisplay component to show the grouped chains images * chore: move redux provider to the top of the react three to make the bottomSheet provider able to read values from redux selectors * feat: create badge variant for using the badge component in the chainsDisplay component according to figma * feat: add testIDs in the chainsDisplay component * feat: allow user to provider a footer to the dropdown component * chore: make the logo size dynamically * feat: create AccountCard component * feat: create AccountItem component to handle the dropdown events and specific layout * feat: replace the image component by the chainsDisplay component in the Balances component * feat: change the color of the active chain in the chain selection dropdown * feat: create a footer for MyAccounts dropdown * feat: remove unnecessary tests * feat: add accounts management feature inside the navbar dropdown * feat: create useInfiniteScroll hook to handle infinite scroll functionality * feat: use activeChain information into the tokens container * feat: make the Identicon component to be more extensible * feat: add mocked constants inside the store folder * feat: create safes slice to store all safes added into the app * feat: add possibility to get all supported chains ids and get them also by id * chore: auto generated types * chore: remove unused types * feat: create MyAccounts container * feat: use isFetching instead isLoading to avoid cached result while query is being revalidated * chore: memoize the chains manipulation in the chainsDisplay component * chore: create an useMyAccountsService hook to handle pos-fetch logic outside the container (cherry picked from commit be1a137b30984b8fcc866fd6767824f5f67ec659)
- Loading branch information
1 parent
1068919
commit 576bd47
Showing
49 changed files
with
2,491 additions
and
383 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
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
45 changes: 45 additions & 0 deletions
45
apps/mobile/src/components/ChainsDisplay/ChainsDisplay.stories.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,45 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { ChainsDisplay } from '@/src/components/ChainsDisplay' | ||
import { mockedChains } from '@/src/store/constants' | ||
import { Chain } from '@safe-global/store/gateway/AUTO_GENERATED/chains' | ||
|
||
const meta: Meta<typeof ChainsDisplay> = { | ||
title: 'ChainsDisplay', | ||
component: ChainsDisplay, | ||
argTypes: {}, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof ChainsDisplay> | ||
|
||
export const Default: Story = { | ||
args: { | ||
chains: mockedChains as unknown as Chain[], | ||
max: 3, | ||
}, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} | ||
|
||
export const Truncated: Story = { | ||
args: { | ||
chains: mockedChains as unknown as Chain[], | ||
max: 1, | ||
}, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} | ||
|
||
export const ActiveChain: Story = { | ||
args: { | ||
chains: mockedChains as unknown as Chain[], | ||
activeChainId: mockedChains[1].chainId, | ||
max: 1, | ||
}, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} |
30 changes: 30 additions & 0 deletions
30
apps/mobile/src/components/ChainsDisplay/ChainsDisplay.test.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,30 @@ | ||
import { mockedChains } from '@/src/store/constants' | ||
import { ChainsDisplay } from './ChainsDisplay' | ||
import { render } from '@testing-library/react-native' | ||
import { Chain } from '@safe-global/store/gateway/AUTO_GENERATED/chains' | ||
|
||
describe('ChainsDisplay', () => { | ||
it('should render all chains next each other', () => { | ||
const container = render(<ChainsDisplay chains={mockedChains as unknown as Chain[]} max={mockedChains.length} />) | ||
|
||
expect(container.getAllByTestId('chain-display')).toHaveLength(3) | ||
}) | ||
it('should truncate the chains when the provided chains length is greatter than the max', () => { | ||
const container = render(<ChainsDisplay chains={mockedChains as unknown as Chain[]} max={2} />) | ||
const moreChainsBadge = container.getByTestId('more-chains-badge') | ||
|
||
expect(container.getAllByTestId('chain-display')).toHaveLength(2) | ||
expect(moreChainsBadge).toBeVisible() | ||
expect(moreChainsBadge).toHaveTextContent('+1') | ||
}) | ||
|
||
it('should always show the selected chain as the first column of the row', () => { | ||
const container = render( | ||
<ChainsDisplay chains={mockedChains as unknown as Chain[]} max={2} activeChainId={mockedChains[2].chainId} />, | ||
) | ||
|
||
expect(container.getAllByTestId('chain-display')[0].children[0].props.accessibilityLabel).toBe( | ||
mockedChains[2].chainName, | ||
) | ||
}) | ||
}) |
34 changes: 34 additions & 0 deletions
34
apps/mobile/src/components/ChainsDisplay/ChainsDisplay.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,34 @@ | ||
import { Chain } from '@safe-global/store/gateway/AUTO_GENERATED/chains' | ||
import React, { useMemo } from 'react' | ||
import { View } from 'tamagui' | ||
import { Logo } from '../Logo' | ||
import { Badge } from '../Badge' | ||
|
||
interface ChainsDisplayProps { | ||
chains: Chain[] | ||
max?: number | ||
activeChainId?: string | ||
} | ||
|
||
export function ChainsDisplay({ chains, activeChainId, max }: ChainsDisplayProps) { | ||
const orderedChains = useMemo( | ||
() => [...chains].sort((a, b) => (a.chainId === activeChainId ? -1 : b.chainId === activeChainId ? 1 : 0)), | ||
[chains], | ||
) | ||
const slicedChains = max ? orderedChains.slice(0, max) : chains | ||
const showBadge = max && chains.length > max | ||
|
||
return ( | ||
<View flexDirection="row"> | ||
{slicedChains.map(({ chainLogoUri, chainName, chainId }, index) => ( | ||
<View key={chainId} testID="chain-display" marginRight={(showBadge || index !== slicedChains.length - 1) && -8}> | ||
<Logo size="$7" logoUri={chainLogoUri} accessibilityLabel={chainName} /> | ||
</View> | ||
))} | ||
|
||
{showBadge && ( | ||
<Badge testID="more-chains-badge" content={`+${chains.length - max}`} themeName="badge_background" /> | ||
)} | ||
</View> | ||
) | ||
} |
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 @@ | ||
export { ChainsDisplay } from './ChainsDisplay' |
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
46 changes: 46 additions & 0 deletions
46
apps/mobile/src/components/transactions-list/Card/AccountCard/AccountCard.stories.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,46 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { AccountCard } from '@/src/components/transactions-list/Card/AccountCard' | ||
import { mockedActiveSafeInfo, mockedChains } from '@/src/store/constants' | ||
import { Chain } from '@safe-global/store/gateway/AUTO_GENERATED/chains' | ||
import { Address } from '@/src/types/address' | ||
import { SafeFontIcon } from '@/src/components/SafeFontIcon' | ||
|
||
const meta: Meta<typeof AccountCard> = { | ||
title: 'TransactionsList/AccountCard', | ||
component: AccountCard, | ||
argTypes: {}, | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof AccountCard> | ||
|
||
export const Default: Story = { | ||
args: { | ||
name: 'This is my account', | ||
chains: mockedChains as unknown as Chain[], | ||
owners: 5, | ||
balance: mockedActiveSafeInfo.fiatTotal, | ||
address: mockedActiveSafeInfo.address.value as Address, | ||
threshold: 2, | ||
}, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
render: ({ ...args }) => <AccountCard {...args} rightNode={<SafeFontIcon name="check" />} />, | ||
} | ||
|
||
export const TruncatedAccount: Story = { | ||
args: { | ||
name: 'This is my account with a very long text in one more test', | ||
chains: mockedChains as unknown as Chain[], | ||
owners: 5, | ||
balance: mockedActiveSafeInfo.fiatTotal, | ||
address: mockedActiveSafeInfo.address.value as Address, | ||
threshold: 2, | ||
}, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
render: ({ ...args }) => <AccountCard {...args} rightNode={<SafeFontIcon name="check" />} />, | ||
} |
Oops, something went wrong.