|
1 | | -import { Button, Center, Text } from '@baca/design-system' |
2 | | -import { useCallback, useScreenOptions, useTranslation } from '@baca/hooks' |
3 | | -import { View, Linking, StyleSheet } from 'react-native' |
| 1 | +import { BACA_APP_URL, BACA_DOCS_URL } from '@baca/constants' |
| 2 | +import { Box, Button, Center, Text, ScrollView } from '@baca/design-system' |
| 3 | +import { useScreenOptions, useTranslation, useViewportDimensions } from '@baca/hooks' |
| 4 | +import { draftImages } from '@baca/screens' |
| 5 | +import { useCallback } from 'react' |
| 6 | +import { Linking, Image, ImageSourcePropType, StyleSheet } from 'react-native' |
4 | 7 |
|
5 | 8 | export const HomeScreen = () => { |
6 | 9 | const { t } = useTranslation() |
| 10 | + const { viewportWidth, viewportHeight } = useViewportDimensions() |
7 | 11 |
|
8 | | - useScreenOptions({ |
9 | | - title: t('navigation.screen_titles.home'), |
10 | | - }) |
| 12 | + useScreenOptions({ title: t('navigation.screen_titles.home') }) |
11 | 13 |
|
12 | | - const openLink = useCallback((url: string) => { |
13 | | - Linking.openURL(url) |
14 | | - }, []) |
| 14 | + const openLink = useCallback((url: string) => Linking.openURL(url), []) |
| 15 | + |
| 16 | + const renderItem = (item: ImageSourcePropType, index: number) => ( |
| 17 | + <Box key={index} height={viewportHeight * 0.6} width={viewportWidth * 0.6}> |
| 18 | + <Image source={item} resizeMode="contain" style={styles.imageSize} /> |
| 19 | + </Box> |
| 20 | + ) |
15 | 21 |
|
16 | 22 | return ( |
17 | 23 | <Center flex={1} px={4}> |
18 | | - <Text.XxlBold textAlign="center">{t('home_header_title')}</Text.XxlBold> |
19 | | - <Text.LgRegular textAlign="center">{t('home_header_subtitle')}</Text.LgRegular> |
| 24 | + <Text.XxlBold textAlign="center">{t('home_screen.header_title')}</Text.XxlBold> |
| 25 | + <Text.LgRegular textAlign="center">{t('home_screen.header_subtitle')}</Text.LgRegular> |
20 | 26 |
|
21 | | - <View style={styles.buttonsContainer}> |
22 | | - <Button |
23 | | - m={3} |
24 | | - h={12} |
25 | | - minWidth={160} |
26 | | - maxWidth={160} |
27 | | - onPress={() => openLink('https://baca-docs.vercel.app/docs/overview')} |
28 | | - > |
29 | | - <Text.MdBold>Read docs</Text.MdBold> |
| 27 | + <Box |
| 28 | + alignItems={'center'} |
| 29 | + flexDirection={'row'} |
| 30 | + flexWrap={'wrap'} |
| 31 | + justifyContent={'center'} |
| 32 | + mt={4} |
| 33 | + > |
| 34 | + <Button m={3} h={12} minWidth={160} maxWidth={160} onPress={() => openLink(BACA_DOCS_URL)}> |
| 35 | + {t('home_screen.read_docs')} |
30 | 36 | </Button> |
31 | 37 | <Button.SecondaryColor |
32 | 38 | m={3} |
33 | 39 | h={12} |
34 | 40 | minWidth={160} |
35 | 41 | maxWidth={160} |
36 | | - onPress={() => openLink('https://binarapps.online/sign-in')} |
| 42 | + onPress={() => openLink(BACA_APP_URL)} |
37 | 43 | > |
38 | | - <Text.MdBold>Try it</Text.MdBold> |
| 44 | + {t('home_screen.try_it')} |
39 | 45 | </Button.SecondaryColor> |
40 | | - </View> |
| 46 | + </Box> |
| 47 | + |
| 48 | + <ScrollView |
| 49 | + height={viewportHeight * 0.6} |
| 50 | + horizontal |
| 51 | + mt={8} |
| 52 | + pagingEnabled |
| 53 | + scrollEventThrottle={16} |
| 54 | + showsHorizontalScrollIndicator={false} |
| 55 | + width={viewportWidth * 0.6} |
| 56 | + > |
| 57 | + {draftImages.map(renderItem)} |
| 58 | + </ScrollView> |
41 | 59 | </Center> |
42 | 60 | ) |
43 | 61 | } |
44 | 62 |
|
45 | 63 | const styles = StyleSheet.create({ |
46 | | - buttonsContainer: { |
47 | | - alignItems: 'center', |
48 | | - flexDirection: 'row', |
49 | | - flexWrap: 'wrap', |
50 | | - justifyContent: 'center', |
51 | | - marginTop: 16, |
| 64 | + imageSize: { |
| 65 | + height: '100%', |
| 66 | + width: '100%', |
52 | 67 | }, |
53 | 68 | }) |
0 commit comments