Skip to content

Commit efcdf6f

Browse files
committed
Ref: show Archax banner for UK location
1 parent 9395171 commit efcdf6f

21 files changed

+257
-42
lines changed

src/Root.tsx

+42-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {createNativeStackNavigator} from '@react-navigation/native-stack';
88
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
99
import debounce from 'lodash.debounce';
1010
import Braze from '@braze/react-native-sdk';
11-
import React, {useEffect, useMemo, useState} from 'react';
11+
import React, {useEffect, useMemo, useState, useCallback} from 'react';
1212
import {
1313
Appearance,
1414
AppState,
@@ -29,6 +29,7 @@ import {DeviceEmitterEvents} from './constants/device-emitter-events';
2929
import {baseNavigatorOptions} from './constants/NavigationOptions';
3030
import {LOCK_AUTHORIZED_TIME} from './constants/Lock';
3131
import BiometricModal from './components/modal/biometric/BiometricModal';
32+
import ArchaxBanner from './components/archax/archax-banner';
3233
import {AppEffects, AppActions} from './store/app';
3334
import {BitPayDarkTheme, BitPayLightTheme} from './themes/bitpay';
3435
import {LogActions} from './store/log';
@@ -70,9 +71,11 @@ import AboutGroup, {
7071
} from './navigation/tabs/settings/about/AboutGroup';
7172
import AuthGroup, {AuthGroupParamList} from './navigation/auth/AuthGroup';
7273
import BuyCryptoGroup, {
74+
BuyCryptoScreens,
7375
BuyCryptoGroupParamList,
7476
} from './navigation/services/buy-crypto/BuyCryptoGroup';
7577
import SellCryptoGroup, {
78+
SellCryptoScreens,
7679
SellCryptoGroupParamList,
7780
} from './navigation/services/sell-crypto/SellCryptoGroup';
7881
import SwapCryptoGroup, {
@@ -285,6 +288,9 @@ export default () => {
285288
({WALLET}) => WALLET.accountEvmCreationMigrationComplete,
286289
);
287290
const notificationsState = useAppSelector(selectSettingsNotificationState);
291+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
292+
const [archaxBannerVisible, setArchaxBannerVisible] =
293+
useState(showArchaxBanner);
288294

289295
const blurScreenList: string[] = [
290296
OnboardingScreens.IMPORT,
@@ -303,6 +309,38 @@ export default () => {
303309
WalletScreens.WALLET_DETAILS,
304310
];
305311

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+
306344
const debouncedOnStateChange = useMemo(
307345
() =>
308346
debounce((state: NavigationState | undefined) => {
@@ -335,6 +373,8 @@ export default () => {
335373
dispatch(Analytics.screen(stackName, {screen: screenName || ''}));
336374
}
337375
}
376+
// Show Archax Banner if enabled
377+
_showArchaxBanner();
338378
}
339379
}, 300),
340380
[dispatch],
@@ -564,6 +604,7 @@ export default () => {
564604
<ThemeProvider theme={theme}>
565605
<GestureHandlerRootView style={{flex: 1}}>
566606
<BottomSheetModalProvider>
607+
{archaxBannerVisible && <ArchaxBanner />}
567608
<NavigationContainer
568609
ref={navigationRef}
569610
theme={theme}

src/components/amount/Amount.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import CurrencySymbol from '../icons/currency-symbol/CurrencySymbol';
2525
import {useLogger} from '../../utils/hooks/useLogger';
2626
import {getBuyCryptoFiatLimits} from '../../store/buy-crypto/buy-crypto.effects';
2727
import KeyEvent from 'react-native-keyevent';
28+
import ArchaxFooter from '../archax/archax-footer';
2829

2930
const AmountContainer = styled.SafeAreaView`
3031
flex: 1;
@@ -150,6 +151,7 @@ const Amount: React.FC<AmountProps> = ({
150151
const defaultAltCurrency = useAppSelector(({APP}) => APP.defaultAltCurrency);
151152
const allRates = useAppSelector(({RATE}) => RATE.rates);
152153
const curValRef = useRef('');
154+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
153155

154156
const fiatCurrency = useMemo(() => {
155157
if (fiatCurrencyAbbreviation) {
@@ -519,6 +521,7 @@ const Amount: React.FC<AmountProps> = ({
519521
{t('Continue')}
520522
</Button>
521523
</ButtonContainer>
524+
{showArchaxBanner && <ArchaxFooter />}
522525
</ActionContainer>
523526
</ViewContainer>
524527
</AmountContainer>

src/components/amount/AmountModal.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import SheetModal from '../modal/base/sheet/SheetModal';
1010
import Amount, {AmountProps, LimitsOpts} from './Amount';
1111
import {Platform} from 'react-native';
1212
import {TouchableOpacity} from 'react-native-gesture-handler';
13+
import {useAppSelector} from '../../utils/hooks';
14+
import ArchaxBanner from '../archax/archax-banner';
1315

1416
const ModalHeaderText = styled(BaseText)`
1517
font-size: 18px;
@@ -39,7 +41,7 @@ const ModalHeaderRight = styled(BaseText)`
3941
const StyledAmountModalContainer = styled.SafeAreaView<{platform: string}>`
4042
background-color: ${({theme}) => (theme.dark ? Black : White)};
4143
flex: 1;
42-
margin-bottom: ${({platform}) => platform === 'ios' ? 25 : 10}px;
44+
margin-bottom: ${({platform}) => (platform === 'ios' ? 25 : 10)}px;
4345
`;
4446

4547
type AmountModalProps = AmountProps & {
@@ -52,7 +54,9 @@ type AmountModalProps = AmountProps & {
5254

5355
const AmountModalContainerHOC = gestureHandlerRootHOC(props => {
5456
return (
55-
<StyledAmountModalContainer platform={Platform.OS}>{props.children}</StyledAmountModalContainer>
57+
<StyledAmountModalContainer platform={Platform.OS}>
58+
{props.children}
59+
</StyledAmountModalContainer>
5660
);
5761
});
5862

@@ -66,6 +70,7 @@ const AmountModal: React.VFC<AmountModalProps> = props => {
6670
...amountProps
6771
} = props;
6872
const theme = useTheme();
73+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
6974

7075
return (
7176
<SheetModal
@@ -74,6 +79,7 @@ const AmountModal: React.VFC<AmountModalProps> = props => {
7479
onBackdropPress={onClose}
7580
fullscreen>
7681
<AmountModalContainerHOC>
82+
{showArchaxBanner && <ArchaxBanner removeMarginTop={true} />}
7783
<ModalHeader>
7884
<CloseModalButton
7985
onPress={() => {
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, {useMemo} from 'react';
2+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
3+
import styled from 'styled-components/native';
4+
import {Black} from '../../styles/colors';
5+
import {H7, Link} from '../styled/Text';
6+
import {ActiveOpacity} from '../styled/Containers';
7+
import {TouchableOpacity} from 'react-native';
8+
9+
const ArchaxBanner: React.FC<{removeMarginTop?: boolean}> = ({
10+
removeMarginTop,
11+
}) => {
12+
const insets = useSafeAreaInsets();
13+
const Container = useMemo(
14+
() => styled.View`
15+
background-color: #ffedc9;
16+
padding: 20px;
17+
margin-top: ${!removeMarginTop ? insets.top : 0}px;
18+
`,
19+
[insets.top, removeMarginTop],
20+
);
21+
return (
22+
<Container>
23+
<H7 style={{color: Black}}>
24+
Don't invest unless you're prepared to lose all the money you invest.
25+
This is a high-risk investment and you should not expect to be protected
26+
if something goes worng.
27+
<TouchableOpacity activeOpacity={ActiveOpacity} onPress={() => {}}>
28+
<Link>Take 2 mins to learn more.</Link>
29+
</TouchableOpacity>
30+
</H7>
31+
</Container>
32+
);
33+
};
34+
35+
export default ArchaxBanner;
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import styled from 'styled-components/native';
3+
import {Black} from '../../styles/colors';
4+
import {H7} from '../styled/Text';
5+
6+
const Container = styled.View`
7+
border: 1px solid blue;
8+
border-radius: 30px;
9+
padding: 15px;
10+
margin: 15px 15px 20px 15px;
11+
`;
12+
13+
const ArchaxFooter = () => {
14+
return (
15+
<Container>
16+
<H7 style={{color: Black, textAlign: 'center'}}>
17+
This Financial Promotion has been approved by Archax LTD on November 28,
18+
2024.
19+
</H7>
20+
</Container>
21+
);
22+
};
23+
24+
export default ArchaxFooter;

src/navigation/services/buy-crypto/screens/BuyCryptoOffers.tsx

+38-10
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ import RampTerms from '../components/terms/RampTerms';
121121
import SardineTerms from '../components/terms/SardineTerms';
122122
import SimplexTerms from '../components/terms/SimplexTerms';
123123
import TransakTerms from '../components/terms/TransakTerms';
124-
import {TermsContainer, TermsText} from '../styled/BuyCryptoTerms';
124+
import {
125+
TermsContainer,
126+
TermsContainerOffer,
127+
TermsText,
128+
} from '../styled/BuyCryptoTerms';
125129
import {BuyCryptoConfig} from '../../../../store/external-services/external-services.types';
126130
import {Analytics} from '../../../../store/analytics/analytics.effects';
127131
import {AppActions} from '../../../../store/app';
@@ -147,6 +151,7 @@ import {
147151
getTransakSelectedPaymentMethodData,
148152
transakEnv,
149153
} from '../utils/transak-utils';
154+
import ArchaxFooter from '../../../../components/archax/archax-footer';
150155

151156
export type BuyCryptoOffersScreenParams = {
152157
amount: number;
@@ -201,6 +206,11 @@ const SummaryRow = styled.View`
201206
padding: 0px 14px;
202207
`;
203208

209+
const SummaryNote = styled.View`
210+
margin-top: 5px;
211+
padding: 0 14px;
212+
`;
213+
204214
const SummaryItemContainer = styled.View`
205215
display: flex;
206216
flex-direction: column;
@@ -448,6 +458,7 @@ const BuyCryptoOffers: React.FC = () => {
448458
const logger = useLogger();
449459
const navigation = useNavigation();
450460
const dispatch = useAppDispatch();
461+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
451462
const createdOn = useAppSelector(({WALLET}: RootState) => WALLET.createdOn);
452463
const user = useAppSelector(
453464
({APP, BITPAY_ID}) => BITPAY_ID.user[APP.network],
@@ -2433,6 +2444,11 @@ const BuyCryptoOffers: React.FC = () => {
24332444
</Button>
24342445
</SummaryCtaContainer>
24352446
</SummaryRow>
2447+
{showArchaxBanner && (
2448+
<SummaryNote>
2449+
<SummaryTitle>Additional third-party fees may apply</SummaryTitle>
2450+
</SummaryNote>
2451+
)}
24362452

24372453
{Object.values(offers)
24382454
.sort(
@@ -2476,7 +2492,7 @@ const BuyCryptoOffers: React.FC = () => {
24762492
<BestOfferTagContainer>
24772493
<BestOfferTag>
24782494
<BestOfferTagText>
2479-
{t('Best Offer')}
2495+
{t('Our Best Offer')}
24802496
</BestOfferTagText>
24812497
</BestOfferTag>
24822498
</BestOfferTagContainer>
@@ -2606,18 +2622,30 @@ const BuyCryptoOffers: React.FC = () => {
26062622
) : null}
26072623
</>
26082624
) : null}
2625+
{showArchaxBanner && (
2626+
<TermsContainerOffer>
2627+
<TermsText>
2628+
{t(
2629+
'The final crypto amount you receive when the transaction is complete may differ because it is based on the exchange rates of the providers.',
2630+
)}
2631+
</TermsText>
2632+
</TermsContainerOffer>
2633+
)}
26092634
</BuyCryptoExpandibleCard>
26102635
) : null;
26112636
})}
26122637

2613-
<TermsContainer>
2614-
<TermsText>
2615-
{t(
2616-
'The final crypto amount you receive when the transaction is complete may differ because it is based on the exchange rates of the providers.',
2617-
)}
2618-
</TermsText>
2619-
<TermsText>{t('Additional third-party fees may apply.')}</TermsText>
2620-
</TermsContainer>
2638+
{!showArchaxBanner && (
2639+
<TermsContainer>
2640+
<TermsText>
2641+
{t(
2642+
'The final crypto amount you receive when the transaction is complete may differ because it is based on the exchange rates of the providers.',
2643+
)}
2644+
</TermsText>
2645+
<TermsText>{t('Additional third-party fees may apply.')}</TermsText>
2646+
</TermsContainer>
2647+
)}
2648+
{showArchaxBanner && <ArchaxFooter />}
26212649
</ScrollView>
26222650
</BuyCryptoOffersContainer>
26232651
);

src/navigation/services/buy-crypto/screens/BuyCryptoRoot.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ import {
9191
} from '../../../../components/styled/Containers';
9292
import {H5, H7, ListItemSubText} from '../../../../components/styled/Text';
9393
import Blockie from '../../../../components/blockie/Blockie';
94+
import ArchaxFooter from '../../../../components/archax/archax-footer';
9495

9596
export type BuyCryptoRootScreenParams =
9697
| {
@@ -129,6 +130,7 @@ const BuyCryptoRoot = ({
129130
const dispatch = useAppDispatch();
130131
const theme = useTheme();
131132
const logger = useLogger();
133+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
132134
const allKeys = useAppSelector(({WALLET}: RootState) => WALLET.keys);
133135
const tokenDataByAddress = useAppSelector(
134136
({WALLET}: RootState) => WALLET.tokenDataByAddress,
@@ -1035,6 +1037,7 @@ const BuyCryptoRoot = ({
10351037
</Button>
10361038
</CtaContainer>
10371039
</ScrollView>
1040+
{showArchaxBanner && <ArchaxFooter />}
10381041

10391042
<AmountModal
10401043
isVisible={amountModalVisible}

src/navigation/services/buy-crypto/styled/BuyCryptoTerms.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export const TermsContainer = styled.View`
88
margin-bottom: 40px;
99
`;
1010

11+
export const TermsContainerOffer = styled.View`
12+
margin-top: 20px;
13+
`;
14+
1115
export const ExchangeTermsContainer = styled.View`
1216
padding: 0 0 10px 0;
1317
`;

0 commit comments

Comments
 (0)