11import { useArticlesControllerFindAll } from '@baca/api/query/articles/articles'
22import { ArticleEntity } from '@baca/api/types'
33import { Loader , Center , Text , Box , Spacer } from '@baca/design-system'
4- import { useScreenOptions , useTranslation } from '@baca/hooks'
4+ import { useScreenOptions , useTranslation , useWindowDimensions } from '@baca/hooks'
55import { FlashList } from '@shopify/flash-list'
66import { useCallback } from 'react'
7+ import { Platform } from 'react-native'
78
89export 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