Skip to content

Commit

Permalink
feat(onboarding): add geoblock footnote (#2403)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr authored Dec 13, 2024
1 parent afc3938 commit 8529ce2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 19 deletions.
37 changes: 24 additions & 13 deletions src/screens/Onboarding/Slideshow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ import Animated, {
} from 'react-native-reanimated';
import Carousel, { ICarouselInstance } from 'react-native-reanimated-carousel';

import { IThemeColors } from '../../styles/themes';
import { View as ThemedView } from '../../styles/components';
import { BodyM, BodyMB, Display, Footnote } from '../../styles/text';
import SafeAreaInset from '../../components/SafeAreaInset';
import Dot from '../../components/SliderDots';
import Button from '../../components/buttons/Button';
import ButtonTertiary from '../../components/buttons/ButtonTertiary';
import { useAppDispatch } from '../../hooks/redux';
import { useAppDispatch, useAppSelector } from '../../hooks/redux';
import type { OnboardingStackScreenProps } from '../../navigation/types';
import { updateUser } from '../../store/slices/user';
import { View as ThemedView } from '../../styles/components';
import { BodyM, BodyMB, Display } from '../../styles/text';
import { IThemeColors } from '../../styles/themes';
import { isGeoBlockedSelector } from '../../store/reselect/user';

type Slide = {
color: keyof IThemeColors;
Expand Down Expand Up @@ -68,6 +69,7 @@ const Slide = ({
}: SlideProps): ReactElement => {
const { t } = useTranslation('onboarding');
const dimensions = useWindowDimensions();
const isGeoBlocked = useAppSelector(isGeoBlockedSelector);

// because we can't properly scala image inside the <Swiper let's calculate with by hand
const imageStyles = useMemo(
Expand All @@ -93,14 +95,20 @@ const Slide = ({
parent={Display}
components={{ accent: <Display color={color} /> }}
/>
<Trans
style={styles.text}
t={t}
i18nKey={`slide${index}_text`}
parent={BodyM}
color="secondary"
components={{ accent: <BodyMB color="primary" /> }}
/>

<View style={styles.text}>
<Trans
t={t}
i18nKey={`slide${index}_text`}
parent={BodyM}
color="secondary"
components={{ accent: <BodyMB color="primary" /> }}
/>

{index === 1 && isGeoBlocked && (
<Footnote style={styles.note}>{t('slide1_note')}</Footnote>
)}
</View>

{isLast ? (
<View style={styles.buttonsContainer}>
Expand Down Expand Up @@ -276,7 +284,10 @@ const styles = StyleSheet.create({
},
text: {
marginTop: 4,
minHeight: 90,
minHeight: 110,
},
note: {
marginTop: 6,
},
buttonsContainer: {
flexDirection: 'row',
Expand Down
2 changes: 2 additions & 0 deletions src/screens/Onboarding/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Display, BodyM } from '../../styles/text';
import SafeAreaInset from '../../components/SafeAreaInset';
import Button from '../../components/buttons/Button';
import DetectSwipe from '../../components/DetectSwipe';
import { setGeoBlock } from '../../store/utils/user';
import type { OnboardingStackScreenProps } from '../../navigation/types';

const backgroundSrc = require('../../assets/illustrations/figures.png');
Expand All @@ -19,6 +20,7 @@ const OnboardingWelcomeScreen = ({
const { t } = useTranslation('onboarding');

const onGetStarted = (): void => {
setGeoBlock();
navigation.navigate('Slideshow');
};

Expand Down
6 changes: 3 additions & 3 deletions src/store/utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { updateUser } from '../slices/user';
import { isGeoBlocked } from '../../utils/blocktank';

export const setGeoBlock = async (): Promise<boolean> => {
const response = await isGeoBlocked();
dispatch(updateUser({ isGeoBlocked: response }));
return response;
const isBlocked = await isGeoBlocked();
dispatch(updateUser({ isGeoBlocked: isBlocked }));
return isBlocked;
};
8 changes: 8 additions & 0 deletions src/styles/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,11 @@ export const Caption13Up = styled.Text<TextProps>(({ theme, color }) => ({
color: theme.colors[color ?? 'primary'],
letterSpacing: Platform.OS === 'ios' ? 0.8 : undefined,
}));

export const Footnote = styled.Text<TextProps>(({ theme, color }) => ({
...theme.fonts.medium,
fontSize: '12px',
lineHeight: '16px',
color: theme.colors[color ?? 'white32'],
letterSpacing: Platform.OS === 'ios' ? 0.4 : undefined,
}));
2 changes: 1 addition & 1 deletion src/utils/blocktank/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export const isGeoBlocked = async (fromStorage = false): Promise<boolean> => {
try {
let geoBlocked: boolean | undefined;
if (fromStorage) {
geoBlocked = getUserStore()?.isGeoBlocked;
geoBlocked = getUserStore().isGeoBlocked;
if (geoBlocked !== undefined) {
return geoBlocked;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/i18n/locales/en/lightning.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"string": "You can use your Bitkit savings or send bitcoin from a different wallet."
},
"text_blocked": {
"string": "At this time, Bitkit cannot provide automatic Lightning connections to residents of the United States and Canada."
"string": "Bitkit does not currently provide Lightning services in your country, but you can still connect to other nodes directly."
},
"text_blocked_cjit": {
"string": "Bitkit does not currently provide Lightning services to the USA or Canada, but you can still connect to other nodes directly."
"string": "Bitkit does not currently provide Lightning services in your country, but you can still connect to other nodes directly."
},
"button1": {
"string": "Transfer from Savings"
Expand Down
3 changes: 3 additions & 0 deletions src/utils/i18n/locales/en/onboarding.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"slide1_text": {
"string": "Spend bitcoin faster than ever. Enjoy instant and cheap payments with friends, family, and merchants."
},
"slide1_note": {
"string": "*Bitkit does not currently provide Lightning services in your country, but you can still connect to other nodes."
},
"slide2_header": {
"string": "Bitcoiners,\n<accent>borderless</accent>"
},
Expand Down

0 comments on commit 8529ce2

Please sign in to comment.