1
- import { StatusBar } from "expo-status-bar" ;
2
- import { StyleSheet , View , ScrollView } from "react-native" ;
3
- import { useRouter , Stack } from "expo-router" ;
4
- import { useState } from "react" ;
5
- import { useFacade } from "@/data/facades" ;
6
- import {
7
- Layout ,
8
- Text ,
9
- Card ,
10
- Button ,
11
- Input ,
12
- Modal ,
13
- Spinner ,
14
- } from "@ui-kitten/components" ;
1
+ import { Stack } from "expo-router" ;
2
+ import { useRouter } from "expo-router" ;
3
+ import { Layout } from "@ui-kitten/components" ;
4
+ import { StyleSheet } from "react-native" ;
5
+ import { EncodedImport } from "@/components/EncodedImport/EncodedImport" ;
15
6
16
- const LoadingIndicator = ( ) => (
17
- < View style = { styles . loadingContainer } >
18
- < Spinner size = "small" status = "basic" />
19
- </ View >
20
- ) ;
21
-
22
- export default function ImportEncoded ( ) {
7
+ export default function ImportEncodedScreen ( ) {
23
8
const router = useRouter ( ) ;
24
- const [ modalVisible , setModalVisible ] = useState ( false ) ;
25
- const [ accountName , setAccountName ] = useState ( "" ) ;
26
- const [ encodedAccount , setEncodedAccount ] = useState ( "" ) ;
27
-
28
- const facade = useFacade ( ) ;
29
- const importAccount = facade . importAccount . useMutation ( ) ;
30
9
31
10
return (
32
11
< >
@@ -38,88 +17,10 @@ export default function ImportEncoded() {
38
17
/>
39
18
40
19
< Layout style = { styles . container } level = "1" >
41
- < Modal
42
- visible = { modalVisible }
43
- backdropStyle = { styles . backdrop }
44
- onBackdropPress = { ( ) => setModalVisible ( false ) }
45
- >
46
- < Card disabled style = { styles . modalCard } >
47
- < Text category = "h6" style = { styles . modalTitle } >
48
- Account Imported!
49
- </ Text >
50
- < Text style = { styles . modalText } appearance = "hint" >
51
- Before you start managing your digital assets, we need to scan the
52
- blockchain. This may take some time.
53
- </ Text >
54
- < Button
55
- onPress = { async ( ) => {
56
- router . dismissAll ( ) ;
57
- setModalVisible ( false ) ;
58
- } }
59
- style = { styles . modalButton }
60
- >
61
- Let's go!
62
- </ Button >
63
- </ Card >
64
- </ Modal >
65
-
66
- < ScrollView
67
- contentContainerStyle = { styles . scrollContent }
68
- showsVerticalScrollIndicator = { false }
69
- >
70
- < Card disabled style = { styles . card } >
71
- < Text category = "h6" style = { styles . title } >
72
- Encoded Key Import
73
- </ Text >
74
-
75
- < Text appearance = "hint" style = { styles . description } >
76
- Paste the complete string into the provided text field below.
77
- </ Text >
78
-
79
- < Input
80
- label = "Account Name"
81
- placeholder = "Enter account name"
82
- value = { accountName }
83
- onChangeText = { setAccountName }
84
- style = { styles . input }
85
- size = "large"
86
- />
87
-
88
- < Input
89
- label = "Encoded Key"
90
- placeholder = "Paste your encoded key here"
91
- value = { encodedAccount }
92
- onChangeText = { setEncodedAccount }
93
- style = { styles . input }
94
- size = "large"
95
- multiline
96
- textStyle = { styles . encodedInput }
97
- maxLength = { 2000 }
98
- />
99
-
100
- < Button
101
- style = { styles . button }
102
- size = "large"
103
- onPress = { async ( ) => {
104
- await importAccount . mutateAsync ( {
105
- account : encodedAccount ,
106
- name : accountName ,
107
- } ) ;
108
- setModalVisible ( true ) ;
109
- } }
110
- accessoryLeft = {
111
- importAccount . isPending ? LoadingIndicator : undefined
112
- }
113
- disabled = {
114
- importAccount . isPending || ! encodedAccount || ! accountName
115
- }
116
- >
117
- { importAccount . isPending ? "Importing..." : "Import Account" }
118
- </ Button >
119
- </ Card >
120
- </ ScrollView >
121
-
122
- < StatusBar style = "auto" />
20
+ < EncodedImport
21
+ onSuccess = { ( ) => router . dismissAll ( ) }
22
+ showSuccessModal = { true }
23
+ />
123
24
</ Layout >
124
25
</ >
125
26
) ;
@@ -130,53 +31,4 @@ const styles = StyleSheet.create({
130
31
flex : 1 ,
131
32
padding : 16 ,
132
33
} ,
133
- card : {
134
- marginVertical : 8 ,
135
- borderRadius : 12 ,
136
- } ,
137
- title : {
138
- textAlign : "center" ,
139
- marginBottom : 8 ,
140
- } ,
141
- description : {
142
- textAlign : "center" ,
143
- marginBottom : 24 ,
144
- } ,
145
- input : {
146
- marginBottom : 16 ,
147
- } ,
148
- encodedInput : {
149
- minHeight : 120 ,
150
- maxHeight : 200 ,
151
- textAlignVertical : "top" ,
152
- } ,
153
- button : {
154
- marginTop : 8 ,
155
- } ,
156
- backdrop : {
157
- backgroundColor : "rgba(0, 0, 0, 0.5)" ,
158
- } ,
159
- modalCard : {
160
- borderRadius : 12 ,
161
- margin : 24 ,
162
- padding : 16 ,
163
- } ,
164
- modalTitle : {
165
- textAlign : "center" ,
166
- marginVertical : 16 ,
167
- } ,
168
- modalText : {
169
- textAlign : "center" ,
170
- marginBottom : 24 ,
171
- } ,
172
- modalButton : {
173
- marginTop : 8 ,
174
- } ,
175
- loadingContainer : {
176
- justifyContent : "center" ,
177
- alignItems : "center" ,
178
- } ,
179
- scrollContent : {
180
- flexGrow : 1 ,
181
- } ,
182
34
} ) ;
0 commit comments