Skip to content

Commit 889468d

Browse files
committed
backend screen changed to FlashList done
1 parent 6d950ec commit 889468d

1 file changed

Lines changed: 23 additions & 9 deletions

File tree

src/screens/DataFromBeScreen_EXAMPLE.tsx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { useArticlesControllerFindAll } from '@baca/api/query/articles/articles'
22
import { ArticleEntity } from '@baca/api/types'
33
import { Loader, Center, Text, Box, Spacer } from '@baca/design-system'
4-
import { useScreenOptions, useTranslation } from '@baca/hooks'
4+
import { useScreenOptions, useTranslation, useWindowDimensions } from '@baca/hooks'
55
import { FlashList } from '@shopify/flash-list'
66
import { useCallback } from 'react'
7+
import { Platform } from 'react-native'
78

89
export const DataFromBeScreen_EXAMPLE = () => {
910
const { t } = useTranslation()
11+
const { width } = useWindowDimensions()
1012

1113
useScreenOptions({
1214
title: t('navigation.screen_titles.data_from_be_screen_example'),
@@ -15,14 +17,26 @@ export const DataFromBeScreen_EXAMPLE = () => {
1517
const { data: articles, isInitialLoading: isInitialLoadingArticles } =
1618
useArticlesControllerFindAll({ page: 1, pageSize: 10 })
1719

18-
const renderItem = useCallback(({ item: { id, title } }: { item: ArticleEntity }) => {
19-
return (
20-
<Box mb="1" bg="fg.brand.primary" borderRadius={2} m={2}>
21-
<Text>{'id: ' + id}</Text>
22-
<Text.MdRegular mb={2}>{'title: ' + title}</Text.MdRegular>
23-
</Box>
24-
)
25-
}, [])
20+
const renderItem = useCallback(
21+
({ item: { id, title } }: { item: ArticleEntity }) => {
22+
const boxWidth = Platform.OS === 'web' ? Math.min(width * 0.8, 400) : width
23+
24+
return (
25+
<Box
26+
mb="1"
27+
bg="fg.brand.primary"
28+
borderRadius={2}
29+
m={2}
30+
width={boxWidth}
31+
alignSelf="center"
32+
>
33+
<Text>{'id: ' + id}</Text>
34+
<Text.MdRegular mb={2}>{'title: ' + title}</Text.MdRegular>
35+
</Box>
36+
)
37+
},
38+
[width]
39+
)
2640

2741
return (
2842
<Box flex={1}>

0 commit comments

Comments
 (0)