Skip to content

Commit 7aa3a5b

Browse files
committed
Ref: show Archax banner for UK location
1 parent 9e30bdc commit 7aa3a5b

30 files changed

+359
-136
lines changed

src/Root.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -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';
@@ -285,6 +286,7 @@ export default () => {
285286
({WALLET}) => WALLET.accountEvmCreationMigrationComplete,
286287
);
287288
const notificationsState = useAppSelector(selectSettingsNotificationState);
289+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
288290

289291
const blurScreenList: string[] = [
290292
OnboardingScreens.IMPORT,
@@ -564,6 +566,7 @@ export default () => {
564566
<ThemeProvider theme={theme}>
565567
<GestureHandlerRootView style={{flex: 1}}>
566568
<BottomSheetModalProvider>
569+
{showArchaxBanner && <ArchaxBanner />}
567570
<NavigationContainer
568571
ref={navigationRef}
569572
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={() => {
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
3+
import {SubText, UnderlineLink} from '../styled/Text';
4+
import {openUrlWithInAppBrowser} from '../../store/app/app.effects';
5+
import {useAppDispatch} from '../../utils/hooks';
6+
import {ArchaxBannerContainer} from '../../components/styled/Containers';
7+
8+
const ArchaxBanner: React.FC<{removeMarginTop?: boolean}> = ({
9+
removeMarginTop,
10+
}) => {
11+
const dispatch = useAppDispatch();
12+
const insets = useSafeAreaInsets();
13+
return (
14+
<ArchaxBannerContainer removeMarginTop={removeMarginTop} inset={insets}>
15+
<SubText>
16+
Don't invest unless you're prepared to lose all the money you invest.
17+
This is a high-risk investment and you should not expect to be protected
18+
if something goes worng.
19+
<UnderlineLink
20+
onPress={() => {
21+
dispatch(openUrlWithInAppBrowser('http://localhost:8080')); // TODO: Update URL
22+
}}>
23+
Take 2 mins to learn more.
24+
</UnderlineLink>
25+
</SubText>
26+
</ArchaxBannerContainer>
27+
);
28+
};
29+
30+
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 {LinkBlue} from '../../styles/colors';
4+
import {SubText} from '../styled/Text';
5+
6+
const Container = styled.View`
7+
border: 1px solid ${LinkBlue};
8+
border-radius: 30px;
9+
padding: 15px;
10+
margin: 15px 15px 20px 15px;
11+
`;
12+
13+
const ArchaxFooter = () => {
14+
return (
15+
<Container>
16+
<SubText style={{textAlign: 'center'}}>
17+
This Financial Promotion has been approved by Archax LTD on November 28,
18+
2024.
19+
</SubText>
20+
</Container>
21+
);
22+
};
23+
24+
export default ArchaxFooter;

src/components/styled/Containers.tsx

+16-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import {BaseText} from './Text';
1717
import {TouchableOpacity} from '@components/base/TouchableOpacity';
1818
export {ActiveOpacity} from '@components/base/TouchableOpacity';
19+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
1920

2021
export const {height: HEIGHT, width: WIDTH} = Dimensions.get('window');
2122
export const isNotMobile = HEIGHT / WIDTH < 1.6;
@@ -115,7 +116,9 @@ export const RowContainer = styled(TouchableOpacity)<RowContainerProps>`
115116
isLast || noBorder ? 0 : 1}px;
116117
`;
117118

118-
export const RowContainerWithoutBorders = styled(TouchableOpacity)<RowContainerProps>`
119+
export const RowContainerWithoutBorders = styled(
120+
TouchableOpacity,
121+
)<RowContainerProps>`
119122
flex-direction: row;
120123
align-items: center;
121124
padding: 10px 0px;
@@ -532,4 +535,15 @@ export const CloseButtonContainer = styled(TouchableOpacity)`
532535
display: flex;
533536
justify-content: center;
534537
align-items: center;
535-
`;
538+
`;
539+
540+
export const ArchaxBannerContainer = styled.View<{
541+
removeMarginTop?: boolean;
542+
inset: any;
543+
}>`
544+
background: ${({theme}) => (theme.dark ? '#a25718' : '#ffedc9')};
545+
overflow: hidden;
546+
padding: 20px;
547+
margin-top: ${({removeMarginTop}) =>
548+
!removeMarginTop ? ({inset}) => inset.top : 0}px;
549+
`;

src/components/virtual-keyboard/VirtualKeyboard.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import {BaseText} from '../styled/Text';
55
import DeleteIcon from '../icons/delete/Delete';
66
import {PixelRatio} from 'react-native';
77
import VirtualKeyboardButtonAnimation from './VirtualKeyboardButtonAnimation';
8+
import useAppSelector from '../../utils/hooks/useAppSelector';
89
const PIXEL_DENSITY_LIMIT = 3;
9-
export const VIRTUAL_KEYBOARD_BUTTON_SIZE =
10-
PixelRatio.get() < PIXEL_DENSITY_LIMIT ? 65 : 85;
1110

1211
interface SymbolContainerProps {
1312
showLetters?: boolean;
1413
}
1514

16-
const KeyboardContainer = styled.View<{isSmallScreen?: boolean;}>`
15+
const KeyboardContainer = styled.View<{isSmallScreen?: boolean}>`
1716
margin: ${({isSmallScreen}) => (isSmallScreen ? 7 : 10)}px 0;
1817
`;
1918

@@ -79,16 +78,19 @@ const Cell: React.FC<CellProps> = ({
7978
backgroundColor,
8079
darkModeOnly,
8180
}) => {
81+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
82+
const _isSmallScreen = showArchaxBanner
83+
? true
84+
: PixelRatio.get() < PIXEL_DENSITY_LIMIT;
8285
const accessibilityLabel = `${value}-button`;
8386
return (
8487
<CellContainer accessibilityLabel={accessibilityLabel}>
8588
<VirtualKeyboardButtonAnimation
89+
isSmallScreen={_isSmallScreen}
8690
onPress={() => onCellPress?.(value)}
8791
backgroundColor={backgroundColor}>
8892
<>
89-
<CellValue
90-
darkModeOnly={darkModeOnly}
91-
isSmallScreen={PixelRatio.get() < PIXEL_DENSITY_LIMIT}>
93+
<CellValue darkModeOnly={darkModeOnly} isSmallScreen={_isSmallScreen}>
9294
{value}
9395
</CellValue>
9496
{letters ? <CellLetter>{letters}</CellLetter> : null}
@@ -142,8 +144,12 @@ const VirtualKeyboard: React.FC<VirtualKeyboardProps> = ({
142144
? 'rgba(255, 255, 255, 0.2)'
143145
: 'rgba(0, 0, 0, 0.1)';
144146
const bgColor = darkModeOnly || theme.dark ? White : '#4A4A4A';
147+
const showArchaxBanner = useAppSelector(({APP}) => APP.showArchaxBanner);
148+
const _isSmallScreen = showArchaxBanner
149+
? true
150+
: PixelRatio.get() < PIXEL_DENSITY_LIMIT;
145151
return (
146-
<KeyboardContainer isSmallScreen={PixelRatio.get() < PIXEL_DENSITY_LIMIT}>
152+
<KeyboardContainer isSmallScreen={_isSmallScreen}>
147153
<Row
148154
numArray={[
149155
{

src/components/virtual-keyboard/VirtualKeyboardButtonAnimation.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View} from 'react-native';
2+
import {PixelRatio, View} from 'react-native';
33
import {
44
LongPressGestureHandler,
55
TapGestureHandler,
@@ -13,21 +13,23 @@ import Animated, {
1313
useSharedValue,
1414
withTiming,
1515
} from 'react-native-reanimated';
16-
import {VIRTUAL_KEYBOARD_BUTTON_SIZE} from './VirtualKeyboard';
1716

1817
interface RippleProps {
1918
onPress: () => void;
2019
backgroundColor?: string;
2120
onLongPress?: () => void;
21+
isSmallScreen?: boolean;
2222
children: React.ReactNode;
2323
}
2424

2525
const VirtualKeyboardButtonAnimation: React.FC<RippleProps> = ({
2626
onPress,
2727
backgroundColor,
2828
onLongPress,
29+
isSmallScreen,
2930
children,
3031
}) => {
32+
const virtualKeyboardButtonSize = isSmallScreen ? 65 : 85;
3133
onLongPress = onLongPress || onPress;
3234
const centerX = useSharedValue(0);
3335
const centerY = useSharedValue(0);
@@ -38,8 +40,8 @@ const VirtualKeyboardButtonAnimation: React.FC<RippleProps> = ({
3840
const tapGestureEvent =
3941
useAnimatedGestureHandler<TapGestureHandlerGestureEvent>({
4042
onStart: tapEvent => {
41-
centerX.value = VIRTUAL_KEYBOARD_BUTTON_SIZE / 2;
42-
centerY.value = VIRTUAL_KEYBOARD_BUTTON_SIZE / 2;
43+
centerX.value = virtualKeyboardButtonSize / 2;
44+
centerY.value = virtualKeyboardButtonSize / 2;
4345

4446
rippleOpacity.value = 1;
4547
scale.value = 0;
@@ -56,7 +58,7 @@ const VirtualKeyboardButtonAnimation: React.FC<RippleProps> = ({
5658
});
5759

5860
const rStyle = useAnimatedStyle(() => {
59-
const circleRadius = Math.sqrt(VIRTUAL_KEYBOARD_BUTTON_SIZE ** 3.2 * 2);
61+
const circleRadius = Math.sqrt(virtualKeyboardButtonSize ** 3.2 * 2);
6062

6163
const translateX = centerX.value - circleRadius;
6264
const translateY = centerY.value - circleRadius;
@@ -94,8 +96,8 @@ const VirtualKeyboardButtonAnimation: React.FC<RippleProps> = ({
9496
style={[
9597
{
9698
overflow: 'hidden',
97-
height: VIRTUAL_KEYBOARD_BUTTON_SIZE,
98-
width: VIRTUAL_KEYBOARD_BUTTON_SIZE,
99+
height: virtualKeyboardButtonSize,
100+
width: virtualKeyboardButtonSize,
99101
borderRadius: 50,
100102
alignItems: 'center',
101103
justifyContent: 'center',

0 commit comments

Comments
 (0)