-
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.
Merge pull request #58 from bamlab/feat/adding-indexRange
Feat: add indexRange on SpatialNavigationNode
- Loading branch information
Showing
7 changed files
with
160 additions
and
2 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
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,50 @@ | ||
import styled from '@emotion/native'; | ||
import React from 'react'; | ||
import { Animated, Image, View } from 'react-native'; | ||
import { ProgramInfo } from '../domain/programInfo'; | ||
import { useFocusAnimation } from '../../../design-system/helpers/useFocusAnimation'; | ||
import { useSpatialNavigatorFocusableAccessibilityProps } from 'react-tv-space-navigation'; | ||
|
||
type LongProgramProps = { | ||
isFocused?: boolean; | ||
programInfo: ProgramInfo; | ||
}; | ||
|
||
export const LongProgram = React.forwardRef<View, LongProgramProps>( | ||
({ isFocused = false, programInfo }, ref) => { | ||
const imageSource = programInfo.image; | ||
|
||
const scaleAnimation = useFocusAnimation(isFocused); | ||
|
||
const accessibilityProps = useSpatialNavigatorFocusableAccessibilityProps(); | ||
|
||
return ( | ||
<LongProgramContainer | ||
style={scaleAnimation} // Apply the animated scale transform | ||
ref={ref} | ||
isFocused={isFocused} | ||
{...accessibilityProps} | ||
> | ||
<LongProgramImage source={imageSource} /> | ||
</LongProgramContainer> | ||
); | ||
}, | ||
); | ||
|
||
LongProgram.displayName = 'LongProgram'; | ||
|
||
const LongProgramContainer = styled(Animated.View)<{ isFocused: boolean }>( | ||
({ isFocused, theme }) => ({ | ||
height: theme.sizes.program.long.height, | ||
width: theme.sizes.program.long.width, | ||
overflow: 'hidden', | ||
borderRadius: 20, | ||
borderColor: isFocused ? theme.colors.primary.light : 'transparent', | ||
borderWidth: 3, | ||
}), | ||
); | ||
|
||
const LongProgramImage = styled(Image)({ | ||
height: '100%', | ||
width: '100%', | ||
}); |
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,85 @@ | ||
import { | ||
DefaultFocus, | ||
SpatialNavigationNode, | ||
SpatialNavigationScrollView, | ||
} from 'react-tv-space-navigation'; | ||
import { Page } from '../components/Page'; | ||
import '../components/configureRemoteControl'; | ||
import { programInfos } from '../modules/program/infra/programInfos'; | ||
import styled from '@emotion/native'; | ||
import { scaledPixels } from '../design-system/helpers/scaledPixels'; | ||
import { LongProgramNode, ProgramNode } from '../modules/program/view/ProgramNode'; | ||
import { theme } from '../design-system/theme/theme'; | ||
|
||
const HEADER_SIZE = scaledPixels(400); | ||
|
||
export const GridWithLongNodesPage = () => { | ||
return ( | ||
<Page> | ||
<CenteringView> | ||
<GridContainer> | ||
<SpatialNavigationScrollView offsetFromStart={HEADER_SIZE + 20}> | ||
<SpatialNavigationNode alignInGrid> | ||
<DefaultFocus> | ||
<> | ||
<FirstRow /> | ||
<SecondRow /> | ||
</> | ||
</DefaultFocus> | ||
</SpatialNavigationNode> | ||
</SpatialNavigationScrollView> | ||
</GridContainer> | ||
</CenteringView> | ||
</Page> | ||
); | ||
}; | ||
|
||
const FirstRow = () => { | ||
return ( | ||
<SpatialNavigationNode orientation="horizontal"> | ||
<ListContainer> | ||
<LongProgramNode programInfo={programInfos[0]} indexRange={[0, 1]} /> | ||
<ProgramNode programInfo={programInfos[1]} indexRange={[2, 2]} /> | ||
<ProgramNode programInfo={programInfos[2]} indexRange={[3, 3]} /> | ||
<LongProgramNode programInfo={programInfos[3]} indexRange={[4, 5]} /> | ||
<ProgramNode programInfo={programInfos[4]} indexRange={[6, 6]} /> | ||
</ListContainer> | ||
</SpatialNavigationNode> | ||
); | ||
}; | ||
|
||
const SecondRow = () => { | ||
const programs = programInfos.slice(6, 13); | ||
return ( | ||
<SpatialNavigationNode orientation="horizontal"> | ||
<ListContainer> | ||
{/* <LongProgramNode programInfo={programInfos[0]} indexRange={[0, 1]} /> */} | ||
{programs.map((program) => { | ||
return <ProgramNode programInfo={program} key={program.id} />; | ||
})} | ||
</ListContainer> | ||
</SpatialNavigationNode> | ||
); | ||
}; | ||
|
||
const ListContainer = styled.View(({ theme }) => ({ | ||
flexDirection: 'row', | ||
flexWrap: 'wrap', | ||
gap: theme.spacings.$4, | ||
padding: theme.spacings.$4, | ||
})); | ||
|
||
const GridContainer = styled.View({ | ||
backgroundColor: theme.colors.background.mainHover, | ||
margin: 'auto', | ||
height: '95%', | ||
width: '88%', | ||
borderRadius: scaledPixels(20), | ||
padding: scaledPixels(30), | ||
}); | ||
|
||
const CenteringView = styled.View({ | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}); |
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