@@ -8,7 +8,7 @@ import {createNativeStackNavigator} from '@react-navigation/native-stack';
8
8
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet' ;
9
9
import debounce from 'lodash.debounce' ;
10
10
import Braze from '@braze/react-native-sdk' ;
11
- import React , { useEffect , useMemo , useState } from 'react' ;
11
+ import React , { useEffect , useMemo , useState , useCallback } from 'react' ;
12
12
import {
13
13
Appearance ,
14
14
AppState ,
@@ -29,6 +29,7 @@ import {DeviceEmitterEvents} from './constants/device-emitter-events';
29
29
import { baseNavigatorOptions } from './constants/NavigationOptions' ;
30
30
import { LOCK_AUTHORIZED_TIME } from './constants/Lock' ;
31
31
import BiometricModal from './components/modal/biometric/BiometricModal' ;
32
+ import ArchaxBanner from './components/archax/archax-banner' ;
32
33
import { AppEffects , AppActions } from './store/app' ;
33
34
import { BitPayDarkTheme , BitPayLightTheme } from './themes/bitpay' ;
34
35
import { LogActions } from './store/log' ;
@@ -70,9 +71,11 @@ import AboutGroup, {
70
71
} from './navigation/tabs/settings/about/AboutGroup' ;
71
72
import AuthGroup , { AuthGroupParamList } from './navigation/auth/AuthGroup' ;
72
73
import BuyCryptoGroup , {
74
+ BuyCryptoScreens ,
73
75
BuyCryptoGroupParamList ,
74
76
} from './navigation/services/buy-crypto/BuyCryptoGroup' ;
75
77
import SellCryptoGroup , {
78
+ SellCryptoScreens ,
76
79
SellCryptoGroupParamList ,
77
80
} from './navigation/services/sell-crypto/SellCryptoGroup' ;
78
81
import SwapCryptoGroup , {
@@ -285,6 +288,9 @@ export default () => {
285
288
( { WALLET } ) => WALLET . accountEvmCreationMigrationComplete ,
286
289
) ;
287
290
const notificationsState = useAppSelector ( selectSettingsNotificationState ) ;
291
+ const showArchaxBanner = useAppSelector ( ( { APP } ) => APP . showArchaxBanner ) ;
292
+ const [ archaxBannerVisible , setArchaxBannerVisible ] =
293
+ useState ( showArchaxBanner ) ;
288
294
289
295
const blurScreenList : string [ ] = [
290
296
OnboardingScreens . IMPORT ,
@@ -303,6 +309,38 @@ export default () => {
303
309
WalletScreens . WALLET_DETAILS ,
304
310
] ;
305
311
312
+ const _showArchaxBanner = useCallback ( ( ) => {
313
+ const archaxScreenList : string [ ] = [
314
+ TabsScreens . HOME ,
315
+ WalletScreens . PRICE_CHARTS ,
316
+ WalletScreens . KEY_OVERVIEW ,
317
+ WalletScreens . WALLET_DETAILS ,
318
+ BuyCryptoScreens . ROOT ,
319
+ BuyCryptoScreens . OFFERS ,
320
+ SellCryptoScreens . ROOT ,
321
+ ] ;
322
+ if ( showArchaxBanner ) {
323
+ if ( navigationRef . isReady ( ) ) {
324
+ const currentNavState = navigationRef . getState ( ) ?. routes ?. slice ( - 1 ) [ 0 ] ;
325
+ const currentScreen : string | undefined =
326
+ currentNavState ?. name ?? navigationRef . getCurrentRoute ( ) ?. name ;
327
+ const currentTab : number | undefined = currentNavState ?. state ?. index ;
328
+ if (
329
+ ( currentScreen && archaxScreenList . includes ( currentScreen ) ) ||
330
+ ( currentScreen === 'Tabs' && ( ! currentTab || currentTab === 0 ) )
331
+ ) {
332
+ setArchaxBannerVisible ( true ) ;
333
+ } else {
334
+ setArchaxBannerVisible ( false ) ;
335
+ }
336
+ }
337
+ }
338
+ } , [ showArchaxBanner ] ) ;
339
+
340
+ useEffect ( ( ) => {
341
+ setArchaxBannerVisible ( showArchaxBanner ) ;
342
+ } , [ showArchaxBanner ] ) ;
343
+
306
344
const debouncedOnStateChange = useMemo (
307
345
( ) =>
308
346
debounce ( ( state : NavigationState | undefined ) => {
@@ -335,6 +373,8 @@ export default () => {
335
373
dispatch ( Analytics . screen ( stackName , { screen : screenName || '' } ) ) ;
336
374
}
337
375
}
376
+ // Show Archax Banner if enabled
377
+ _showArchaxBanner ( ) ;
338
378
}
339
379
} , 300 ) ,
340
380
[ dispatch ] ,
@@ -564,6 +604,7 @@ export default () => {
564
604
< ThemeProvider theme = { theme } >
565
605
< GestureHandlerRootView style = { { flex : 1 } } >
566
606
< BottomSheetModalProvider >
607
+ { archaxBannerVisible && < ArchaxBanner /> }
567
608
< NavigationContainer
568
609
ref = { navigationRef }
569
610
theme = { theme }
0 commit comments