1- import React , { memo , ReactElement , useMemo , useState , useEffect } from 'react' ;
1+ import React , { memo , ReactElement , useState , useEffect } from 'react' ;
22import { StyleSheet , View , Platform , TouchableOpacity } from 'react-native' ;
33import { Trans , useTranslation } from 'react-i18next' ;
44import Clipboard from '@react-native-clipboard/clipboard' ;
@@ -46,7 +46,7 @@ const ShowMnemonic = ({
4646 useEffect ( ( ) => {
4747 getMnemonicPhrase ( ) . then ( ( res ) => {
4848 if ( res . isErr ( ) ) {
49- console . log ( res . error . message ) ;
49+ console . log ( 'getMnemonicPhrase error:' , res . error . message ) ;
5050 showToast ( {
5151 type : 'warning' ,
5252 title : t ( 'mnemonic_error' ) ,
@@ -59,10 +59,21 @@ const ShowMnemonic = ({
5959 getBip39Passphrase ( ) . then ( setPassphrase ) ;
6060 } , [ t ] ) ;
6161
62- const seedToShow = useMemo (
63- ( ) => ( Platform . OS === 'android' && ! show ? dummySeed : seed ) ,
64- [ seed , show ] ,
65- ) ;
62+ const revealMnemonic = ( ) : void => {
63+ setShow ( true ) ;
64+ } ;
65+
66+ const copyMnemonic = ( ) : void => {
67+ Clipboard . setString ( seed . join ( ' ' ) ) ;
68+ vibrate ( ) ;
69+ } ;
70+
71+ const ready = show && seed . length !== 0 ;
72+
73+ const seedToShow =
74+ seed . length === 0 || ( Platform . OS === 'android' && ! show )
75+ ? dummySeed
76+ : seed ;
6677
6778 return (
6879 < View style = { styles . container } >
@@ -72,23 +83,20 @@ const ShowMnemonic = ({
7283 />
7384
7485 < BodyM color = "secondary" >
75- { show
86+ { ready
7687 ? t ( 'mnemonic_write' , { length : seedToShow . length } )
7788 : t ( 'mnemonic_use' ) }
7889 </ BodyM >
7990
8091 < View
8192 style = { styles . seedContainer }
82- testID = " SeedContaider"
93+ testID = { ready ? ' SeedContaider' : undefined }
8394 accessibilityLabel = { seed . join ( ' ' ) } >
8495 < ThemedView color = "white10" style = { styles . seed } >
8596 < TouchableOpacity
8697 style = { styles . seed2 }
8798 activeOpacity = { 1 }
88- onLongPress = { ( ) : void => {
89- Clipboard . setString ( seed . join ( ' ' ) ) ;
90- vibrate ( ) ;
91- } } >
99+ onLongPress = { copyMnemonic } >
92100 < View style = { styles . col } >
93101 { seedToShow . slice ( 0 , seedToShow . length / 2 ) . map ( ( w , i ) => (
94102 < Word key = { i } word = { w } number = { i + 1 } />
@@ -102,14 +110,15 @@ const ShowMnemonic = ({
102110 </ TouchableOpacity >
103111 </ ThemedView >
104112
105- { ! show && (
113+ { ! ready && (
106114 < BlurView style = { styles . blur } >
107115 < Button
108116 size = "large"
109- text = { t ( 'mnemonic_reveal' ) }
117+ text = { show ? t ( 'mnemonic_loading' ) : t ( 'mnemonic_reveal' ) }
110118 color = "black50"
111- onPress = { ( ) : void => setShow ( true ) }
119+ onPress = { revealMnemonic }
112120 testID = "TapToReveal"
121+ disabled = { show }
113122 />
114123 </ BlurView >
115124 ) }
@@ -127,7 +136,7 @@ const ShowMnemonic = ({
127136 < Button
128137 size = "large"
129138 text = { t ( 'continue' ) }
130- disabled = { ! show }
139+ disabled = { ! ready }
131140 testID = "ContinueShowMnemonic"
132141 onPress = { ( ) : void => {
133142 navigation . navigate (
0 commit comments