-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(suite-native): use correct receive flow screens for connected device
- Loading branch information
Showing
21 changed files
with
244 additions
and
125 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
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
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
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
81 changes: 81 additions & 0 deletions
81
suite-native/receive/src/components/ReceiveScreenHeader.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,81 @@ | ||
import { useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'; | ||
|
||
import { AccountKey, TokenAddress } from '@suite-common/wallet-types'; | ||
import { | ||
AccountsRootState, | ||
selectAccountLabel, | ||
selectAccountNetworkSymbol, | ||
} from '@suite-common/wallet-core'; | ||
import { HStack, Text } from '@suite-native/atoms'; | ||
import { CryptoIcon } from '@suite-native/icons'; | ||
import { Translation } from '@suite-native/intl'; | ||
import { | ||
GoBackIcon, | ||
RootStackParamList, | ||
RootStackRoutes, | ||
ScreenSubHeader, | ||
} from '@suite-native/navigation'; | ||
import { selectAccountTokenSymbol, TokensRootState } from '@suite-native/tokens'; | ||
import TrezorConnect from '@trezor/connect'; | ||
|
||
type ReceiveScreenHeaderProps = { | ||
accountKey?: AccountKey; | ||
tokenContract?: TokenAddress; | ||
}; | ||
|
||
export const ReceiveScreenHeader = ({ accountKey, tokenContract }: ReceiveScreenHeaderProps) => { | ||
const { | ||
params: { closeActionType }, | ||
} = useRoute<RouteProp<RootStackParamList, RootStackRoutes.ReceiveModal>>(); | ||
const navigation = useNavigation(); | ||
const accountLabel = useSelector((state: AccountsRootState) => | ||
selectAccountLabel(state, accountKey), | ||
); | ||
const symbol = useSelector((state: AccountsRootState) => | ||
selectAccountNetworkSymbol(state, accountKey), | ||
); | ||
const tokenSymbol = useSelector((state: TokensRootState) => | ||
selectAccountTokenSymbol(state, accountKey, tokenContract), | ||
); | ||
|
||
useEffect(() => { | ||
const unsubscribe = navigation.addListener('beforeRemove', () => { | ||
// When leaving the screen, cancel the request for address on trezor device | ||
TrezorConnect.cancel(); | ||
}); | ||
|
||
return unsubscribe; | ||
}, [navigation]); | ||
|
||
return ( | ||
<ScreenSubHeader | ||
content={ | ||
<> | ||
<Text variant="highlight"> | ||
{symbol ? ( | ||
<Translation | ||
id="moduleReceive.screenTitle" | ||
values={{ coinSymbol: symbol.toUpperCase() }} | ||
/> | ||
) : ( | ||
<Translation id="moduleReceive.receiveTitle" /> | ||
)} | ||
</Text> | ||
<HStack spacing="sp8" alignItems="center"> | ||
{symbol && <CryptoIcon symbol={symbol} size="extraSmall" />} | ||
{accountLabel && ( | ||
<Text variant="highlight"> | ||
{accountLabel} | ||
{tokenSymbol && ` - ${tokenSymbol}`} | ||
</Text> | ||
)} | ||
</HStack> | ||
</> | ||
} | ||
leftIcon={<GoBackIcon closeActionType={closeActionType} />} | ||
/> | ||
); | ||
}; |
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,2 +1,3 @@ | ||
export * from './components/ReceiveAccount'; | ||
export * from './navigation/ReceiveStackNavigator'; | ||
export * from './screens/ReceiveAccountScreen'; | ||
export * from './screens/ReceiveModalScreen'; |
23 changes: 23 additions & 0 deletions
23
suite-native/receive/src/navigation/ReceiveStackNavigator.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,23 @@ | ||
import { createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
|
||
import { | ||
ReceiveStackParamList, | ||
ReceiveStackRoutes, | ||
stackNavigationOptionsConfig, | ||
} from '@suite-native/navigation'; | ||
|
||
import { ReceiveAccountsScreen } from '../screens/ReceiveAccountsScreen'; | ||
|
||
const ReceiveStack = createNativeStackNavigator<ReceiveStackParamList>(); | ||
|
||
export const ReceiveStackNavigator = () => ( | ||
<ReceiveStack.Navigator | ||
initialRouteName={ReceiveStackRoutes.ReceiveAccounts} | ||
screenOptions={stackNavigationOptionsConfig} | ||
> | ||
<ReceiveStack.Screen | ||
name={ReceiveStackRoutes.ReceiveAccounts} | ||
component={ReceiveAccountsScreen} | ||
/> | ||
</ReceiveStack.Navigator> | ||
); |
Oops, something went wrong.