1- import React , { useEffect } from "react" ;
1+ import React , { useEffect , useRef } from "react" ;
22import { useAtom } from "jotai" ;
33import { StyleSheet , Text , View , TouchableOpacity } from "react-native" ;
44import { FlashList } from "@shopify/flash-list" ;
55import { useRouter } from "expo-router" ;
66import { MaterialCommunityIcons , MaterialIcons } from "@expo/vector-icons" ;
7+ import { CopilotStep , walkthroughable , useCopilot } from "react-native-copilot" ;
78import Heading from "@common/Heading" ;
89import WalletSummary from "@components/ui/WalletSummary" ;
910import { THEME , TypographyWeight } from "@/theme" ;
@@ -23,10 +24,14 @@ export const balanceData = [
2324 { id : 2 , value : "2" , label : "Wallets" , icon : "wallet-outline" } ,
2425] ;
2526
27+ const WalkthroughableView = walkthroughable ( View ) ;
28+
2629export default function Home ( ) {
2730 const [ isSearching ] = useAtom ( isSearchingAtom ) ;
2831 const [ isLoading ] = useAtom ( searchLoadingAtom ) ;
2932 const [ , selectCategory ] = useAtom ( selectCategoryAtom ) ;
33+ const { start } = useCopilot ( ) ;
34+ const hasStartedRef = useRef ( false ) ;
3035
3136 const router = useRouter ( ) ;
3237
@@ -41,6 +46,19 @@ export default function Home() {
4146 }
4247 } , [ selectCategory , isSearching ] ) ;
4348
49+ useEffect ( ( ) => {
50+ if ( isSearching || isLoading || hasStartedRef . current ) {
51+ return ;
52+ }
53+
54+ const timeout = setTimeout ( ( ) => {
55+ hasStartedRef . current = true ;
56+ start ( ) ;
57+ } , 300 ) ;
58+
59+ return ( ) => clearTimeout ( timeout ) ;
60+ } , [ isLoading , isSearching , start ] ) ;
61+
4462 const ActivityHeader = ( ) => (
4563 < View
4664 style = { {
@@ -50,25 +68,10 @@ export default function Home() {
5068 >
5169 < View style = { [ styles . balancesContainer , { gap : spacing . md } ] } >
5270 { balanceData . map ( ( item ) => (
53- < WalletSummary
71+ < BalanceCard
5472 key = { item . id }
55- value = { item . value }
56- icon = {
57- item . label === "Tokens" ? (
58- < MaterialIcons name = "toll" size = { 24 } color = { colors . primary } />
59- ) : (
60- < MaterialCommunityIcons
61- name = "wallet-outline"
62- size = { 24 }
63- color = { colors . gray700 }
64- />
65- )
66- }
67- label = { item . label }
68- style = { [
69- styles . balanceCard ,
70- { width : Math . max ( layout . screenPadding * 8 , 140 ) } ,
71- ] }
73+ item = { item }
74+ cardWidth = { Math . max ( layout . screenPadding * 8 , 140 ) }
7275 />
7376 ) ) }
7477 </ View >
@@ -150,6 +153,65 @@ export default function Home() {
150153 ) ;
151154}
152155
156+ function BalanceCard ( {
157+ item,
158+ cardWidth,
159+ } : {
160+ item : ( typeof balanceData ) [ number ] ;
161+ cardWidth : number ;
162+ } ) {
163+ const { colors } = THEME ;
164+
165+ const content = (
166+ < WalletSummary
167+ value = { item . value }
168+ icon = {
169+ item . label === "Tokens" ? (
170+ < MaterialIcons name = "toll" size = { 24 } color = { colors . primary } />
171+ ) : (
172+ < MaterialCommunityIcons
173+ name = "wallet-outline"
174+ size = { 24 }
175+ color = { colors . gray700 }
176+ />
177+ )
178+ }
179+ label = { item . label }
180+ style = { [ styles . balanceCard , { width : cardWidth } ] }
181+ />
182+ ) ;
183+
184+ if ( item . label === "Tokens" ) {
185+ return (
186+ < CopilotStep
187+ text = {
188+ "Here you can view the total amount of tokens (a digital asset representing your contributions)."
189+ }
190+ order = { 1 }
191+ name = "homeTokens"
192+ >
193+ < WalkthroughableView > { content } </ WalkthroughableView >
194+ </ CopilotStep >
195+ ) ;
196+ }
197+
198+ if ( item . label === "Wallets" ) {
199+ return (
200+ < CopilotStep
201+ text = {
202+ "Here you can see the total amount of wallets (restricted to max 2 at this time)."
203+ }
204+ order = { 2 }
205+ name = "homeWallets"
206+ >
207+ < WalkthroughableView > { content } </ WalkthroughableView >
208+ </ CopilotStep >
209+ ) ;
210+ }
211+
212+ return content ;
213+ }
214+
153215const styles = StyleSheet . create ( {
154216 container : {
155217 flex : 1 ,
0 commit comments