-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add collectibles widget, ref leather-io/issues#222
- Loading branch information
1 parent
69e4377
commit b780ee4
Showing
14 changed files
with
532 additions
and
7 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
32 changes: 32 additions & 0 deletions
32
apps/mobile/src/components/widgets/collectibles/collectibles-header.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,32 @@ | ||
import React from 'react'; | ||
|
||
import { t } from '@lingui/macro'; | ||
|
||
import { Box, ChevronRightIcon, Chip, SheetRef, Text } from '@leather.io/ui/native'; | ||
|
||
import { FiatBalance } from '../components/balance/fiat-balance'; | ||
|
||
interface CollectiblesHeaderProps { | ||
collectibleCount: number; | ||
sheetRef: React.RefObject<SheetRef>; | ||
totalBalance: string; | ||
} | ||
|
||
function CollectiblesHeaderText() { | ||
return <Text variant="heading05">{t`My collectibles`}</Text>; | ||
} | ||
|
||
export function CollectiblesHeader({ collectibleCount, totalBalance }: CollectiblesHeaderProps) { | ||
const hasCollectibles = collectibleCount > 0; | ||
if (!hasCollectibles) return <CollectiblesHeaderText />; | ||
return ( | ||
<Box flexDirection="row" gap="1" alignItems="center" marginHorizontal="5"> | ||
<CollectiblesHeaderText /> | ||
<Chip label={collectibleCount} /> | ||
<ChevronRightIcon variant="small" /> | ||
<Box flex={1} justifyContent="flex-end" alignItems="flex-end"> | ||
<FiatBalance balance={totalBalance} color="ink.text-subdued" /> | ||
</Box> | ||
</Box> | ||
); | ||
} |
31 changes: 31 additions & 0 deletions
31
apps/mobile/src/components/widgets/collectibles/collectibles-widget.layout.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,31 @@ | ||
import React from 'react'; | ||
import { ScrollView } from 'react-native-gesture-handler'; | ||
|
||
import { useTheme } from '@shopify/restyle'; | ||
|
||
import { Box, SheetRef, Theme } from '@leather.io/ui/native'; | ||
|
||
import { Widget } from '../widget'; | ||
|
||
interface CollectiblesWidgetProps { | ||
balance?: React.ReactNode; | ||
children: React.ReactNode; | ||
header?: React.ReactNode; | ||
sheetRef?: React.RefObject<SheetRef>; | ||
} | ||
|
||
export function CollectiblesWidgetLayout({ children, header }: CollectiblesWidgetProps) { | ||
const theme = useTheme<Theme>(); | ||
return ( | ||
<Widget> | ||
<Box>{header}</Box> | ||
<ScrollView | ||
showsHorizontalScrollIndicator={false} | ||
horizontal | ||
contentContainerStyle={{ gap: theme.spacing['3'], marginHorizontal: theme.spacing['5'] }} | ||
> | ||
{children} | ||
</ScrollView> | ||
</Widget> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/mobile/src/components/widgets/collectibles/collectibles-widget.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,35 @@ | ||
import React, { useRef } from 'react'; | ||
|
||
import { SheetRef } from '@leather.io/ui/native'; | ||
|
||
import { TokenBalance } from '../components/balance/token-balance'; | ||
import { CollectiblesHeader } from './collectibles-header'; | ||
import { CollectiblesWidgetLayout } from './collectibles-widget.layout'; | ||
import { type Collectible } from './collectibles.mocks'; | ||
import { CollectiblesCard } from './components/collectible-card'; | ||
|
||
interface CollectiblesWidgetProps { | ||
collectibles: Collectible[]; | ||
totalBalance: string; | ||
} | ||
|
||
export function CollectiblesWidget({ collectibles, totalBalance }: CollectiblesWidgetProps) { | ||
const sheetRef = useRef<SheetRef>(null); | ||
|
||
return ( | ||
<CollectiblesWidgetLayout | ||
header={ | ||
<CollectiblesHeader | ||
collectibleCount={collectibles.length} | ||
totalBalance={totalBalance} | ||
sheetRef={sheetRef} | ||
/> | ||
} | ||
balance={collectibles.length > 0 && <TokenBalance balance={totalBalance} />} | ||
> | ||
{collectibles.map((collectible: Collectible) => ( | ||
<CollectiblesCard collectible={collectible} /> | ||
))} | ||
</CollectiblesWidgetLayout> | ||
); | ||
} |
Oops, something went wrong.