diff --git a/apps/mobile/src/components/widgets/accounts/accounts-widget.tsx b/apps/mobile/src/components/widgets/accounts/accounts-widget.tsx index 4ee111fa3..85f011fa6 100644 --- a/apps/mobile/src/components/widgets/accounts/accounts-widget.tsx +++ b/apps/mobile/src/components/widgets/accounts/accounts-widget.tsx @@ -1,4 +1,5 @@ import { useRef } from 'react'; +import { ScrollView } from 'react-native-gesture-handler'; import { AddWalletSheet } from '@/components/add-wallet/'; import { AccountSelectorSheet } from '@/features/account-selector-sheet'; @@ -7,69 +8,78 @@ import { AppRoutes } from '@/routes'; import { useAccounts } from '@/store/accounts/accounts.read'; import { useWallets } from '@/store/wallets/wallets.read'; import { t } from '@lingui/macro'; +import { useTheme } from '@shopify/restyle'; import { useRouter } from 'expo-router'; -import { Box, SheetRef } from '@leather.io/ui/native'; +import { Box, SheetRef, Theme } from '@leather.io/ui/native'; import { Balance } from '../../balance/balance'; -import { Widget, WidgetHeader } from '../components/widget'; +import { Widget } from '../components/widget'; import { AccountCard } from './components/cards/account-card'; import { AddAccountCard } from './components/cards/add-account-card'; import { CreateWalletCard } from './components/cards/create-wallet-card'; import { AddAccountSheet } from './sheets/add-account-sheet'; export function AccountsWidget() { - const sheetRef = useRef(null); + const accountSelectorSheetRef = useRef(null); const addAccountSheetRef = useRef(null); const addWalletSheetRef = useRef(null); const router = useRouter(); const wallets = useWallets(); const accounts = useAccounts(); + const theme = useTheme(); const { totalBalance } = useTotalBalance(); return ( <> - - } - /> - {wallets.hasWallets && } - - } - > - {accounts.list.map(account => ( - { - router.navigate({ - pathname: AppRoutes.Account, - params: { - accountId: account.id, - }, - }); + + + accountSelectorSheetRef.current?.present()}> + + + {wallets.hasWallets && ( + + + + )} + + + - ))} + > + {accounts.list.map(account => ( + { + router.navigate({ + pathname: AppRoutes.Account, + params: { + accountId: account.id, + }, + }); + }} + /> + ))} - {accounts.hasAccounts ? ( - addAccountSheetRef.current?.present()} /> - ) : ( - addWalletSheetRef.current?.present()} /> - )} + {accounts.hasAccounts ? ( + addAccountSheetRef.current?.present()} /> + ) : ( + addWalletSheetRef.current?.present()} /> + )} + + + ); } diff --git a/apps/mobile/src/components/widgets/collectibles/collectibles-widget.tsx b/apps/mobile/src/components/widgets/collectibles/collectibles-widget.tsx index 981bfc906..3c46fc6ca 100644 --- a/apps/mobile/src/components/widgets/collectibles/collectibles-widget.tsx +++ b/apps/mobile/src/components/widgets/collectibles/collectibles-widget.tsx @@ -1,11 +1,13 @@ import React from 'react'; +import { ScrollView } from 'react-native-gesture-handler'; import { t } from '@lingui/macro'; +import { useTheme } from '@shopify/restyle'; import { Money } from '@leather.io/models'; -import { CollectibleCard, CollectibleCardProps } from '@leather.io/ui/native'; +import { CollectibleCard, CollectibleCardProps, Theme } from '@leather.io/ui/native'; -import { Widget, WidgetHeader } from '../components/widget'; +import { Widget } from '../components/widget'; interface CollectiblesWidgetProps { collectibles: CollectibleCardProps[]; @@ -13,22 +15,33 @@ interface CollectiblesWidgetProps { } export function CollectiblesWidget({ collectibles, totalBalance }: CollectiblesWidgetProps) { + const theme = useTheme(); + return ( - + + - } - scrollDirection="horizontal" - > - {collectibles.map((collectible: CollectibleCardProps, index) => ( - - ))} + + + + {collectibles.map((collectible: CollectibleCardProps, index) => ( + + ))} + + ); } diff --git a/apps/mobile/src/components/widgets/components/widget/widget-header.tsx b/apps/mobile/src/components/widgets/components/widget/widget-header.tsx index 777299bee..c6260339c 100644 --- a/apps/mobile/src/components/widgets/components/widget/widget-header.tsx +++ b/apps/mobile/src/components/widgets/components/widget/widget-header.tsx @@ -1,35 +1,26 @@ -import { Money } from '@leather.io/models'; -import { Box, SheetRef, TouchableOpacity } from '@leather.io/ui/native'; +import { ReactNode } from 'react'; -import { WidgetTitle } from './widget-title'; +import { Box, TouchableOpacity } from '@leather.io/ui/native'; interface WidgetHeaderProps { - title: string; - sheetRef?: React.RefObject; - sheet?: React.ReactNode; - totalBalance?: Money; + children: ReactNode; + onPress?(): void; } -export function WidgetHeader({ title, totalBalance, sheetRef, sheet }: WidgetHeaderProps) { - if (sheet && sheetRef) { +export function WidgetHeader({ children, onPress }: WidgetHeaderProps) { + if (onPress) { return ( - <> - sheetRef.current?.present()} - flexDirection="row" - gap="1" - alignItems="center" - > - - - - {sheet} - + + + {children} + + ); } + return ( - - + + {children} ); } diff --git a/apps/mobile/src/components/widgets/components/widget/widget.tsx b/apps/mobile/src/components/widgets/components/widget/widget.tsx index 419394382..6d4cd436b 100644 --- a/apps/mobile/src/components/widgets/components/widget/widget.tsx +++ b/apps/mobile/src/components/widgets/components/widget/widget.tsx @@ -1,30 +1,18 @@ -import { ScrollView } from 'react-native-gesture-handler'; +import { HasChildren } from '@/utils/types'; -import { useTheme } from '@shopify/restyle'; +import { Box } from '@leather.io/ui/native'; -import { Box, Theme } from '@leather.io/ui/native'; +import { WidgetHeader } from './widget-header'; +import { WidgetTitle } from './widget-title'; -interface WidgetProps { - children: React.ReactNode; - header?: React.ReactNode; - scrollDirection?: 'vertical' | 'horizontal'; -} - -export function Widget({ children, header, scrollDirection = 'vertical' }: WidgetProps) { - const theme = useTheme(); +export function Widget({ children }: HasChildren) { return ( - {header} - - {children} - + {children} ); } -// refactor to remove Pressable , fix balance display(reverse for Fiat) + line break -// check if I broke add account +Widget.Header = WidgetHeader; +Widget.Title = WidgetTitle; +Widget.Body = Box; diff --git a/apps/mobile/src/components/widgets/tokens/tokens-widget.tsx b/apps/mobile/src/components/widgets/tokens/tokens-widget.tsx index 3f7db2e00..5cf259b0b 100644 --- a/apps/mobile/src/components/widgets/tokens/tokens-widget.tsx +++ b/apps/mobile/src/components/widgets/tokens/tokens-widget.tsx @@ -7,14 +7,15 @@ import { AccountId } from '@/models/domain.model'; import { HasChildren } from '@/utils/types'; import { t } from '@lingui/macro'; -import { Widget, WidgetHeader } from '../components/widget'; +import { Widget } from '../components/widget'; export function TokensWidget({ children }: HasChildren) { return ( - } - > - {children} + + + + + {children} ); }