-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: example of non virtualized manual grid
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { DefaultFocus, SpatialNavigationNode } from 'react-tv-space-navigation'; | ||
import { Page } from '../components/Page'; | ||
import '../components/configureRemoteControl'; | ||
import { getPrograms } from '../modules/program/infra/programInfos'; | ||
import { useNavigation } from '@react-navigation/native'; | ||
import { NativeStackNavigationProp } from '@react-navigation/native-stack'; | ||
import { RootStackParamList } from '../../App'; | ||
import styled from '@emotion/native'; | ||
import { Fragment } from 'react'; | ||
import { scaledPixels } from '../design-system/helpers/scaledPixels'; | ||
import { ProgramNode } from '../modules/program/view/ProgramNode'; | ||
|
||
export const NonVirtualizedGridPage = () => { | ||
return ( | ||
<Page> | ||
<Container> | ||
<SpatialNavigationNode alignInGrid> | ||
<Fragment> | ||
<DefaultFocus> | ||
<ShortProgramList /> | ||
</DefaultFocus> | ||
<ShortProgramList /> | ||
<ShortProgramList /> | ||
</Fragment> | ||
</SpatialNavigationNode> | ||
</Container> | ||
</Page> | ||
); | ||
}; | ||
|
||
const ShortProgramList = () => { | ||
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>(); | ||
const programs = getPrograms().slice(0, 6); | ||
return ( | ||
<SpatialNavigationNode orientation="horizontal"> | ||
<ListContainer> | ||
{programs.map((program) => { | ||
return ( | ||
<ProgramNode | ||
programInfo={program} | ||
onSelect={() => navigation.push('ProgramDetail', { programInfo: program })} | ||
key={program.id} | ||
/> | ||
); | ||
})} | ||
</ListContainer> | ||
</SpatialNavigationNode> | ||
); | ||
}; | ||
|
||
const ListContainer = styled.View(({ theme }) => ({ | ||
flexDirection: 'row', | ||
flexWrap: 'wrap', | ||
justifyContent: 'center', | ||
gap: theme.spacings.$4, | ||
padding: theme.spacings.$4, | ||
})); | ||
|
||
const Container = styled.View({ | ||
backgroundColor: '#222', | ||
margin: 'auto', | ||
borderRadius: scaledPixels(20), | ||
padding: scaledPixels(30), | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}); |