1
- import React , { useState , useEffect } from "react" ;
2
- import { Image , StyleSheet , Text , View } from "react-native" ;
3
- import { FlashList } from "@shopify/flash-list" ;
1
+ import React from "react" ;
2
+ import { StyleSheet , View } from "react-native" ;
4
3
import MaterialIcons from "@expo/vector-icons/MaterialIcons" ;
5
4
import BalanceCard from "@/components/ui/BalanceCard" ;
6
5
import { WIDTH } from "../../utils/dimensions" ;
7
- import useWalletList from "wallet_state/src/hooks/wallet" ;
8
- import { Colors } from "@/constants/Colors" ;
9
- import Title from "@/components/ui/common/Title" ;
10
6
11
- const balanceData = [
12
- { value : "1000" , label : "Tokens" , icon : "toll" , color : "#2E7D32" } ,
13
- {
14
- value : "2" ,
15
- label : "Wallets" ,
16
- icon : "account-balance-wallet" ,
17
- color : "#1A237E" ,
18
- } ,
7
+ const data = [
8
+ { value : "1000" , label : "Tokens" } ,
9
+ { value : "2" , label : "Wallets" } ,
19
10
] ;
20
11
21
- type ItemProps = {
22
- id : string ;
23
- logo : string ;
24
- name : string ;
25
- status : string ;
26
- balance : number ;
12
+ const iconMapping = {
13
+ Tokens : < MaterialIcons name = "toll" size = { 24 } color = "#2E7D32" /> ,
14
+ Wallets : (
15
+ < MaterialIcons name = "account-balance-wallet" size = { 24 } color = "#1A237E" />
16
+ ) ,
27
17
} ;
28
18
29
19
export default function Home ( ) {
30
- const [ user , setUser ] = useState < { userId : string } > ( {
31
- userId : "default-user" ,
32
- } ) ;
33
-
34
- const walletList = useWalletList ( user ?. userId ) ;
35
-
36
20
return (
37
21
< View style = { styles . container } >
38
- < View style = { [ styles . row , { gap : WIDTH * 0.05 , marginTop : 30 } ] } >
39
- { balanceData . map ( item => (
22
+ < View style = { [ styles . row , { gap : WIDTH * 0.05 } ] } >
23
+ { data . map ( ( item , index ) => (
40
24
< BalanceCard
41
- key = { item . label }
25
+ key = { index }
42
26
value = { item . value }
43
- icon = {
44
- < MaterialIcons name = { item . icon } size = { 24 } color = { item . color } />
45
- }
27
+ icon = { iconMapping [ item . label ] }
46
28
label = { item . label }
47
29
/>
48
30
) ) }
49
31
</ View >
50
-
51
- < View style = { styles . activityContainer } >
52
- < View style = { styles . activityHeader } >
53
- < Title title = "Recent activity" />
54
- < Text style = { styles . activityLink } > View all</ Text >
55
- </ View >
56
- </ View >
57
- < FlashList
58
- data = { walletList ?. list || [ ] }
59
- keyExtractor = { item => item . id }
60
- renderItem = { ( { item } ) => < ActivityItem item = { item } /> }
61
- estimatedItemSize = { 50 }
62
- />
63
32
</ View >
64
33
) ;
65
34
}
66
35
67
- const ActivityItem = ( { item } : { item : ItemProps } ) => (
68
- < View style = { styles . itemContainer } >
69
- < View style = { styles . leftColumn } >
70
- < Image source = { { uri : item . logo } } style = { styles . icon } />
71
- < View >
72
- < Text style = { styles . title } > { item . name } </ Text >
73
- < Text style = { styles . status } > { item . status } </ Text >
74
- </ View >
75
- </ View >
76
- < Text
77
- style = { [
78
- styles . value ,
79
- {
80
- color :
81
- item . status === "Received" ? Colors . green : Colors . blackOverlay ,
82
- } ,
83
- ] } >
84
- { item . balance }
85
- </ Text >
86
- </ View >
87
- ) ;
88
-
89
36
const styles = StyleSheet . create ( {
90
37
container : {
91
38
flex : 1 ,
@@ -97,55 +44,4 @@ const styles = StyleSheet.create({
97
44
justifyContent : "center" ,
98
45
flexWrap : "wrap" ,
99
46
} ,
100
- activityContainer : {
101
- marginTop : 30 ,
102
- marginVertical : 8 ,
103
- paddingTop : 24 ,
104
- } ,
105
- activityHeader : {
106
- flexDirection : "row" ,
107
- justifyContent : "space-between" ,
108
- width : "100%" ,
109
- } ,
110
- activityTitle : {
111
- fontSize : 20 ,
112
- color : "black" ,
113
- fontWeight : "bold" ,
114
- } ,
115
- activityLink : {
116
- fontSize : 16 ,
117
- color : Colors . green ,
118
- textDecorationLine : "underline" ,
119
- } ,
120
- itemContainer : {
121
- flexDirection : "row" ,
122
- justifyContent : "space-between" ,
123
- alignItems : "center" ,
124
- padding : 16 ,
125
- borderBottomWidth : 1 ,
126
- borderBottomColor : "#ddd" ,
127
- backgroundColor : "#fff" ,
128
- } ,
129
- leftColumn : {
130
- flexDirection : "row" ,
131
- alignItems : "center" ,
132
- gap : 10 ,
133
- } ,
134
- icon : {
135
- width : 40 ,
136
- height : 40 ,
137
- borderRadius : 20 ,
138
- } ,
139
- title : {
140
- fontSize : 16 ,
141
- fontWeight : "500" ,
142
- } ,
143
- status : {
144
- fontSize : 14 ,
145
- color : Colors . darkGray ,
146
- } ,
147
- value : {
148
- fontSize : 18 ,
149
- fontWeight : "bold" ,
150
- } ,
151
47
} ) ;
0 commit comments