Skip to content

Commit a68feec

Browse files
committed
feat: show geoblock screen during CJIT
1 parent 6e3f194 commit a68feec

File tree

5 files changed

+104
-13
lines changed

5 files changed

+104
-13
lines changed

src/assets/illustrations/globe.png

241 KB
Loading

src/navigation/bottom-sheet/ReceiveNavigation.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ReceiveQR from '../../screens/Wallets/Receive/ReceiveQR';
1111
import ReceiveDetails from '../../screens/Wallets/Receive/ReceiveDetails';
1212
import Tags from '../../screens/Wallets/Receive/Tags';
1313
import ReceiveAmount from '../../screens/Wallets/Receive/ReceiveAmount';
14+
import ReceiveGeoBlocked from '../../screens/Wallets/Receive/ReceiveGeoBlocked';
1415
import ReceiveConnect from '../../screens/Wallets/Receive/ReceiveConnect';
1516
import Liquidity from '../../screens/Wallets/Receive/Liquidity';
1617
import { useSnapPoints } from '../../hooks/bottomSheet';
@@ -31,6 +32,7 @@ export type ReceiveStackParamList = {
3132
};
3233
Tags: undefined;
3334
ReceiveAmount: undefined;
35+
ReceiveGeoBlocked: undefined;
3436
ReceiveConnect: { isAdditional: boolean } | undefined;
3537
Liquidity: {
3638
channelSize: number;
@@ -73,6 +75,10 @@ const ReceiveNavigation = (): ReactElement => {
7375
<Stack.Screen name="ReceiveDetails" component={ReceiveDetails} />
7476
<Stack.Screen name="Tags" component={Tags} />
7577
<Stack.Screen name="ReceiveAmount" component={ReceiveAmount} />
78+
<Stack.Screen
79+
name="ReceiveGeoBlocked"
80+
component={ReceiveGeoBlocked}
81+
/>
7682
<Stack.Screen name="ReceiveConnect" component={ReceiveConnect} />
7783
<Stack.Screen name="Liquidity" component={Liquidity} />
7884
</Stack.Navigator>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import React, { memo, ReactElement } from 'react';
2+
import { StyleSheet, View, Image } from 'react-native';
3+
import { useTranslation } from 'react-i18next';
4+
5+
import BottomSheetNavigationHeader from '../../../components/BottomSheetNavigationHeader';
6+
import SafeAreaInset from '../../../components/SafeAreaInset';
7+
import GradientView from '../../../components/GradientView';
8+
import Button from '../../../components/buttons/Button';
9+
import { useAppDispatch } from '../../../hooks/redux';
10+
import { closeSheet } from '../../../store/slices/ui';
11+
import { rootNavigation } from '../../../navigation/root/RootNavigator';
12+
import type { ReceiveScreenProps } from '../../../navigation/types';
13+
import { BodyM } from '../../../styles/text';
14+
15+
const imageSrc = require('../../../assets/illustrations/globe.png');
16+
17+
const ReceiveGeoBlocked =
18+
({}: ReceiveScreenProps<'ReceiveGeoBlocked'>): ReactElement => {
19+
const { t } = useTranslation('lightning');
20+
const dispatch = useAppDispatch();
21+
const handleManual = (): void => {
22+
dispatch(closeSheet('receiveNavigation'));
23+
rootNavigation.navigate('TransferRoot', { screen: 'FundingAdvanced' });
24+
};
25+
26+
return (
27+
<GradientView style={styles.root}>
28+
<BottomSheetNavigationHeader
29+
title={t('wallet:receive_bitcoin')}
30+
displayBackButton={true}
31+
/>
32+
33+
<View style={styles.content}>
34+
<BodyM color="white64">{t('funding.text_blocked_cjit')}</BodyM>
35+
36+
<View style={styles.imageContainer}>
37+
<Image style={styles.image} source={imageSrc} />
38+
</View>
39+
40+
<View style={styles.buttonContainer}>
41+
<Button
42+
style={styles.button}
43+
size="large"
44+
text={t('funding_advanced.button2')}
45+
testID="Close"
46+
onPress={handleManual}
47+
/>
48+
</View>
49+
</View>
50+
<SafeAreaInset type="bottom" minPadding={16} />
51+
</GradientView>
52+
);
53+
};
54+
55+
const styles = StyleSheet.create({
56+
root: {
57+
flex: 1,
58+
},
59+
content: {
60+
flex: 1,
61+
paddingHorizontal: 16,
62+
},
63+
imageContainer: {
64+
flexShrink: 1,
65+
justifyContent: 'center',
66+
alignItems: 'center',
67+
alignSelf: 'center',
68+
width: 256,
69+
aspectRatio: 1,
70+
marginTop: 'auto',
71+
},
72+
image: {
73+
flex: 1,
74+
resizeMode: 'contain',
75+
},
76+
buttonContainer: {
77+
flexDirection: 'row',
78+
justifyContent: 'center',
79+
marginTop: 'auto',
80+
gap: 16,
81+
},
82+
button: {
83+
flex: 1,
84+
},
85+
});
86+
87+
export default memo(ReceiveGeoBlocked);

src/screens/Wallets/Receive/ReceiveQR.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,13 @@ const ReceiveQR = ({
280280
]);
281281

282282
const onToggleInstant = useCallback((): void => {
283-
if (!isGeoBlocked && !jitInvoice && lightningBalance.remoteBalance === 0) {
283+
if (isGeoBlocked && lightningBalance.remoteBalance === 0) {
284+
navigation.navigate('ReceiveGeoBlocked');
285+
} else if (
286+
!isGeoBlocked &&
287+
!jitInvoice &&
288+
lightningBalance.remoteBalance === 0
289+
) {
284290
navigation.navigate('ReceiveAmount');
285291
} else {
286292
setEnableInstant(!enableInstant);
@@ -582,10 +588,6 @@ const ReceiveQR = ({
582588
const slides = useMemo((): Slide[] => [Slide1, Slide2], [Slide1, Slide2]);
583589

584590
const ReceiveInstantlySwitch = useCallback((): ReactElement => {
585-
if (isGeoBlocked && !lightningBalance.remoteBalance) {
586-
return <></>;
587-
}
588-
589591
if (!isLDKReady) {
590592
return (
591593
<View style={styles.buttonContainer}>
@@ -622,14 +624,7 @@ const ReceiveQR = ({
622624
</SwitchRow>
623625
</View>
624626
);
625-
}, [
626-
t,
627-
isLDKReady,
628-
enableInstant,
629-
onToggleInstant,
630-
isGeoBlocked,
631-
lightningBalance.remoteBalance,
632-
]);
627+
}, [t, isLDKReady, enableInstant, onToggleInstant]);
633628

634629
return (
635630
<>

src/utils/i18n/locales/en/lightning.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"text_blocked": {
2424
"string": "At this time, Bitkit cannot provide automatic Lightning connections to residents of the United States and Canada."
2525
},
26+
"text_blocked_cjit": {
27+
"string": "Bitkit does not currently provide Lightning services to the USA or Canada, but you can still connect to other nodes directly."
28+
},
2629
"button1": {
2730
"string": "Transfer from Savings"
2831
},

0 commit comments

Comments
 (0)