1
1
import { Appbar } from '#/Appbar/Appbar' ;
2
- import { FormSelectChip } from '#/fields/FormSelectChip' ;
3
2
import { FormSubmitButton } from '#/fields/FormSubmitButton' ;
4
3
import { FormTextField } from '#/fields/FormTextField' ;
5
4
import { Actions } from '#/layout/Actions' ;
6
- import { ScrollableScreenSurface } from '#/layout/ScrollableScreenSurface' ;
7
5
import { zodResolver } from '@hookform/resolvers/zod' ;
8
- import { CHAIN_ENTRIES } from '@network/chains' ;
9
6
import { createStyles } from '@theme/styles' ;
10
7
import { useRouter } from 'expo-router' ;
11
- import { asUAddress } from 'lib' ;
8
+ import { asChain , asUAddress } from 'lib' ;
12
9
import { useForm } from 'react-hook-form' ;
13
10
import { View } from 'react-native' ;
14
11
import { z } from 'zod' ;
15
- import { useSelectedChain } from '~/hooks/useSelectedAccount' ;
16
12
import { zAddress , zChain } from '~/lib/zod' ;
17
13
import { ADDRESS_FIELD_RULES } from '~/util/form.rules' ;
14
+ import { AccountParams } from '../_layout' ;
15
+ import { useLocalParams } from '~/hooks/useLocalParams' ;
16
+ import { Pane } from '#/layout/Pane' ;
17
+ import { Scrollable } from '#/Scrollable' ;
18
+ import { FormChainSelector } from '#/fields/FormChainSelector' ;
18
19
19
20
const scheme = z . object ( {
20
21
address : zAddress ( ) ,
21
22
chain : zChain ( ) ,
22
23
} ) ;
23
24
25
+ const Params = AccountParams ;
26
+
24
27
export default function AddTokenScreen ( ) {
28
+ const { account } = useLocalParams ( Params ) ;
25
29
const router = useRouter ( ) ;
26
30
27
31
const { control, handleSubmit } = useForm < z . infer < typeof scheme > > ( {
28
32
resolver : zodResolver ( scheme ) ,
29
- defaultValues : { chain : useSelectedChain ( ) } ,
33
+ defaultValues : { chain : asChain ( account ) } ,
30
34
} ) ;
31
35
32
36
return (
33
- < >
34
- < Appbar headline = "Add token" />
37
+ < Pane flex >
38
+ < Appbar mode = "large" headline = "Add token" />
35
39
36
- < ScrollableScreenSurface >
40
+ < Scrollable >
37
41
< View style = { styles . container } >
38
42
< FormTextField
39
43
label = "Address"
@@ -47,36 +51,30 @@ export default function AddTokenScreen() {
47
51
} }
48
52
/>
49
53
50
- < FormSelectChip
51
- name = "chain"
52
- control = { control }
53
- entries = { CHAIN_ENTRIES }
54
- chipProps = { { style : styles . chain } }
55
- />
54
+ < FormChainSelector name = "chain" control = { control } />
56
55
</ View >
57
56
58
- < Actions >
57
+ < Actions horizontal >
59
58
< FormSubmitButton
60
59
mode = "contained"
61
60
control = { control }
62
61
onPress = { handleSubmit ( ( { address, chain } ) =>
63
62
router . replace ( {
64
- pathname : '/(nav)/token /[address]' ,
65
- params : { address : asUAddress ( address , chain ) } ,
63
+ pathname : '/(nav)/[account]/tokens /[address]' ,
64
+ params : { account , address : asUAddress ( address , chain ) } ,
66
65
} ) ,
67
66
) }
68
67
>
69
68
Continue
70
69
</ FormSubmitButton >
71
70
</ Actions >
72
- </ ScrollableScreenSurface >
73
- </ >
71
+ </ Scrollable >
72
+ </ Pane >
74
73
) ;
75
74
}
76
75
77
76
const styles = createStyles ( {
78
77
container : {
79
- marginVertical : 16 ,
80
78
marginHorizontal : 16 ,
81
79
gap : 16 ,
82
80
} ,
0 commit comments