-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export page content props (#21)
* chore: extract page content props to allow more customisations * chore: updated custom view example * docs: updated readme file
- Loading branch information
Showing
9 changed files
with
246 additions
and
91 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
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,62 @@ | ||
import React, { useMemo, memo } from 'react'; | ||
import { Text, Dimensions } from 'react-native'; | ||
import Animated from 'react-native-reanimated'; | ||
import { PageContentProps } from '../../types'; | ||
import { styles } from './styles'; | ||
|
||
const { interpolate, Extrapolate } = Animated; | ||
|
||
const SCREEN_HEIGHT = Dimensions.get('window').height; | ||
|
||
const PageContentComponent = ({ | ||
animatedFocus, | ||
image, | ||
title, | ||
description, | ||
titleStyle: titleStyleOverride, | ||
descriptionStyle: descriptionStyleOverride, | ||
}: PageContentProps) => { | ||
//#region | ||
const animatedImageTopPosition = interpolate(animatedFocus, { | ||
inputRange: [0, 1], | ||
outputRange: [SCREEN_HEIGHT / 8, 0], | ||
extrapolate: Extrapolate.CLAMP, | ||
}); | ||
//#endregion | ||
|
||
//#region styles | ||
const titleStyle = useMemo(() => [styles.title, titleStyleOverride], [ | ||
titleStyleOverride, | ||
]); | ||
|
||
const descriptionStyle = useMemo( | ||
() => [styles.description, descriptionStyleOverride], | ||
[descriptionStyleOverride] | ||
); | ||
|
||
const imageContainerStyle: any = useMemo( | ||
() => [ | ||
styles.imageContainer, | ||
{ | ||
transform: [{ translateY: animatedImageTopPosition }], | ||
}, | ||
], | ||
[animatedImageTopPosition] | ||
); | ||
//#endregion | ||
return ( | ||
<> | ||
{image && ( | ||
<Animated.View style={imageContainerStyle}> | ||
{typeof image === 'function' ? image() : image} | ||
</Animated.View> | ||
)} | ||
<Text style={titleStyle}>{title}</Text> | ||
<Text style={descriptionStyle}>{description}</Text> | ||
</> | ||
); | ||
}; | ||
|
||
const PageContent = memo(PageContentComponent); | ||
|
||
export default PageContent; |
Empty file.
Oops, something went wrong.