-
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: receive sheet navigator, closes LEA-1699
- Loading branch information
Showing
18 changed files
with
246 additions
and
78 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
15 changes: 15 additions & 0 deletions
15
apps/mobile/src/common/sheet-navigator/sheet-navigation-container.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,15 @@ | ||
import { useWindowDimensions } from 'react-native'; | ||
|
||
import { HasChildren } from '@/utils/types'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
|
||
import { Box } from '@leather.io/ui/native'; | ||
|
||
export function SheetNavigationContainer({ children }: HasChildren) { | ||
const { height } = useWindowDimensions(); | ||
return ( | ||
<Box flex={1} height={height}> | ||
<NavigationContainer independent>{children}</NavigationContainer> | ||
</Box> | ||
); | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/mobile/src/common/sheet-navigator/sheet-navigator-provider.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,19 @@ | ||
import { createContext, useContext } from 'react'; | ||
|
||
import { SheetRef } from '@leather.io/ui/native'; | ||
|
||
export interface SheetNavigatorContext { | ||
sendSheetRef: React.RefObject<SheetRef>; | ||
receiveSheetRef: React.RefObject<SheetRef>; | ||
} | ||
|
||
const sheetNavigatorContext = createContext<SheetNavigatorContext | null>(null); | ||
|
||
export const SheetNavigatorProvider = sheetNavigatorContext.Provider; | ||
|
||
export function useSheetNavigatorContext() { | ||
const context = useContext(sheetNavigatorContext); | ||
if (!context) | ||
throw new Error('`useSheetNavigatorContext` must be used within a `SheetNavigatorProvider`'); | ||
return context; | ||
} |
18 changes: 18 additions & 0 deletions
18
apps/mobile/src/common/sheet-navigator/sheet-navigator-wrapper.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,18 @@ | ||
import { useRef } from 'react'; | ||
|
||
import { HasChildren } from '@/utils/types'; | ||
|
||
import { SheetRef } from '@leather.io/ui/native'; | ||
|
||
import { SheetNavigatorProvider } from './sheet-navigator-provider'; | ||
|
||
export default function SheetNavigatorWrapper({ children }: HasChildren) { | ||
const sendSheetRef = useRef<SheetRef>(null); | ||
const receiveSheetRef = useRef<SheetRef>(null); | ||
|
||
return ( | ||
<SheetNavigatorProvider value={{ sendSheetRef, receiveSheetRef }}> | ||
{children} | ||
</SheetNavigatorProvider> | ||
); | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...ents/headers/full-height-sheet-header.tsx → ...height-sheet/full-height-sheet-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
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
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
apps/mobile/src/features/receive/receive-sheet-navigator.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 { Account } from '@/store/accounts/accounts'; | ||
import { ParamListBase } from '@react-navigation/native'; | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
import { useTheme } from '@shopify/restyle'; | ||
|
||
import { Theme } from '@leather.io/ui/native'; | ||
|
||
import { SelectAccount } from './receive-sheets/select-account'; | ||
import { SelectAsset } from './receive-sheets/select-asset'; | ||
|
||
export interface ReceiveSheetNavigatorParamList extends ParamListBase { | ||
'receive-select-account': undefined; | ||
'receive-select-asset': { account: Account }; | ||
} | ||
|
||
const Stack = createStackNavigator<ReceiveSheetNavigatorParamList>(); | ||
|
||
export function ReceiveSheetNavigator() { | ||
const theme = useTheme<Theme>(); | ||
return ( | ||
<Stack.Navigator | ||
initialRouteName="receive-select-account" | ||
screenOptions={{ | ||
headerShown: false, | ||
cardStyle: { | ||
backgroundColor: theme.colors['ink.background-primary'], | ||
overflow: 'visible', | ||
}, | ||
}} | ||
> | ||
<Stack.Screen name="receive-select-account" component={SelectAccount} /> | ||
<Stack.Screen name="receive-select-asset" component={SelectAsset} /> | ||
</Stack.Navigator> | ||
); | ||
} |
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,16 @@ | ||
import { SheetNavigationContainer } from '@/common/sheet-navigator/sheet-navigation-container'; | ||
import { useSheetNavigatorContext } from '@/common/sheet-navigator/sheet-navigator-provider'; | ||
import { FullHeightSheet } from '@/components/full-height-sheet/full-height-sheet'; | ||
|
||
import { ReceiveSheetNavigator } from './receive-sheet-navigator'; | ||
|
||
export function ReceiveSheet() { | ||
const { receiveSheetRef } = useSheetNavigatorContext(); | ||
return ( | ||
<FullHeightSheet sheetRef={receiveSheetRef}> | ||
<SheetNavigationContainer> | ||
<ReceiveSheetNavigator /> | ||
</SheetNavigationContainer> | ||
</FullHeightSheet> | ||
); | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/mobile/src/features/receive/receive-sheets/select-account.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 { FullHeightSheetHeader } from '@/components/full-height-sheet/full-height-sheet-header'; | ||
import { FullHeightSheetLayout } from '@/components/full-height-sheet/full-height-sheet.layout'; | ||
import { NetworkBadge } from '@/components/network-badge'; | ||
import { AccountList } from '@/features/account-list/account-list'; | ||
import { Account } from '@/store/accounts/accounts'; | ||
import { useAccounts } from '@/store/accounts/accounts.read'; | ||
import { t } from '@lingui/macro'; | ||
import { NavigationProp, useNavigation } from '@react-navigation/native'; | ||
|
||
import { ReceiveSheetNavigatorParamList } from '../receive-sheet-navigator'; | ||
|
||
export function SelectAccount() { | ||
const navigation = useNavigation<NavigationProp<ReceiveSheetNavigatorParamList>>(); | ||
const accounts = useAccounts(); | ||
|
||
function onSelectAccount(account: Account) { | ||
navigation.navigate('receive-select-asset', { account }); | ||
} | ||
|
||
return ( | ||
<FullHeightSheetLayout | ||
header={ | ||
<FullHeightSheetHeader | ||
title={t({ | ||
id: 'select_account.header_title', | ||
message: 'Select account', | ||
})} | ||
rightElement={<NetworkBadge />} | ||
/> | ||
} | ||
> | ||
<AccountList accounts={accounts.list} onPress={onSelectAccount} showWalletInfo /> | ||
</FullHeightSheetLayout> | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
apps/mobile/src/features/receive/receive-sheets/select-asset.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,39 @@ | ||
import { FullHeightSheetHeader } from '@/components/full-height-sheet/full-height-sheet-header'; | ||
import { FullHeightSheetLayout } from '@/components/full-height-sheet/full-height-sheet.layout'; | ||
import { NetworkBadge } from '@/components/network-badge'; | ||
import { t } from '@lingui/macro'; | ||
import { useLingui } from '@lingui/react'; | ||
import { RouteProp, useRoute } from '@react-navigation/native'; | ||
|
||
import { Text } from '@leather.io/ui/native'; | ||
|
||
import { ReceiveSheetNavigatorParamList } from '../receive-sheet-navigator'; | ||
|
||
type SelectAssetScreenRouteProp = RouteProp<ReceiveSheetNavigatorParamList, 'receive-select-asset'>; | ||
|
||
export function SelectAsset() { | ||
const { i18n } = useLingui(); | ||
const route = useRoute<SelectAssetScreenRouteProp>(); | ||
const subtitle = route.params?.account?.name; | ||
|
||
return ( | ||
<FullHeightSheetLayout | ||
header={ | ||
<FullHeightSheetHeader | ||
title={t({ | ||
id: 'select_asset.header_title', | ||
message: 'Select asset', | ||
})} | ||
subtitle={i18n._({ | ||
id: 'select_asset.header_subtitle', | ||
message: '{subtitle}', | ||
values: { subtitle }, | ||
})} | ||
rightElement={<NetworkBadge />} | ||
/> | ||
} | ||
> | ||
<Text>{t`Token list`}</Text> | ||
</FullHeightSheetLayout> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
import { useWindowDimensions } from 'react-native'; | ||
|
||
import { FullHeightSheet } from '@/components/sheets/full-height-sheet'; | ||
import { useSendSheetContext } from '@/features/send/send-sheet-context'; | ||
|
||
import { Box } from '@leather.io/ui/native'; | ||
import { SheetNavigationContainer } from '@/common/sheet-navigator/sheet-navigation-container'; | ||
import { useSheetNavigatorContext } from '@/common/sheet-navigator/sheet-navigator-provider'; | ||
import { FullHeightSheet } from '@/components/full-height-sheet/full-height-sheet'; | ||
|
||
import { SendSheetNavigator } from './send-sheet-navigator'; | ||
|
||
export function SendSheet() { | ||
const { height } = useWindowDimensions(); | ||
const { sendSheetRef } = useSendSheetContext(); | ||
const { sendSheetRef } = useSheetNavigatorContext(); | ||
return ( | ||
<FullHeightSheet sheetRef={sendSheetRef}> | ||
<Box flex={1} height={height}> | ||
<SheetNavigationContainer> | ||
<SendSheetNavigator /> | ||
</Box> | ||
</SheetNavigationContainer> | ||
</FullHeightSheet> | ||
); | ||
} |
Oops, something went wrong.