-
Notifications
You must be signed in to change notification settings - Fork 10
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 #85 from pct-org/feature/improvements
Feature/improvements
- Loading branch information
Showing
78 changed files
with
2,227 additions
and
1,724 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,105 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View } from 'react-native' | ||
import ReanimatedBottomSheet from 'reanimated-bottom-sheet' | ||
import Animated from 'react-native-reanimated' | ||
|
||
import useBackButton from 'modules/hooks/useBackButton' | ||
|
||
import Container from '../Container' | ||
import Portal from '../Portal' | ||
|
||
export const styles = StyleSheet.create({ | ||
|
||
overlayContainer: { | ||
position: 'absolute', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
}, | ||
|
||
overlay: { | ||
backgroundColor: 'black', | ||
}, | ||
|
||
}) | ||
|
||
export const BottomSheet = React.forwardRef(({ children, contentHeight, renderHeader, snapPoints }, ref) => { | ||
const [fall] = React.useState(new Animated.Value(1)) | ||
const [visible, toggleVisible] = React.useState(false) | ||
|
||
const biggestSnapPoint = contentHeight || snapPoints.reduce((biggest, current) => current > biggest ? current | ||
: biggest, 0) | ||
|
||
const handleBottomSheetOpen = React.useCallback(() => { | ||
toggleVisible(true) | ||
}, []) | ||
|
||
const handleBottomSheetClose = React.useCallback(() => { | ||
toggleVisible(false) | ||
}, []) | ||
|
||
useBackButton(() => { | ||
if (visible && ref.current) { | ||
ref.current.snapTo(snapPoints.length - 1) | ||
|
||
return true | ||
} | ||
|
||
return false | ||
}) | ||
|
||
return ( | ||
<Portal> | ||
<Animated.View | ||
pointerEvents={ | ||
visible | ||
? 'auto' | ||
: 'none' | ||
} | ||
style={{ | ||
...styles.overlayContainer, | ||
opacity: Animated.interpolate(fall, { | ||
inputRange: [0, 1], | ||
outputRange: [0.8, 0], | ||
}), | ||
}}> | ||
<View style={[styles.overlayContainer, styles.overlay]} /> | ||
</Animated.View> | ||
|
||
<ReanimatedBottomSheet | ||
ref={ref} | ||
snapPoints={snapPoints} | ||
borderRadius={10} | ||
initialSnap={snapPoints.length - 1} | ||
enabledContentTapInteraction={false} | ||
callbackNode={fall} | ||
onOpenStart={handleBottomSheetOpen} | ||
onCloseEnd={handleBottomSheetClose} | ||
renderHeader={renderHeader} | ||
renderContent={() => ( | ||
<Container | ||
elevation={1} | ||
style={{ | ||
height: biggestSnapPoint, | ||
}}> | ||
{children} | ||
</Container> | ||
)} | ||
/> | ||
</Portal> | ||
) | ||
}) | ||
|
||
BottomSheet.propTypes = { | ||
snapPoints: PropTypes.array, | ||
contentHeight: PropTypes.number, | ||
} | ||
|
||
BottomSheet.defaultProps = { | ||
snapPoints: [400, 0], | ||
contentHeight: null, | ||
} | ||
|
||
export default BottomSheet |
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 @@ | ||
export { default } from './BottomSheet' |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1 @@ | ||
import useCorrect from 'modules/useCorrect' | ||
|
||
import ButtonMobile from './Button' | ||
import ButtonTV from './Button.tv' | ||
|
||
export default useCorrect(ButtonMobile, null, ButtonTV) | ||
export { default } from './Button' |
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,37 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View } from 'react-native' | ||
|
||
import { styles as containerStyles } from 'components/Container/Container' | ||
|
||
export const styles = StyleSheet.create({ | ||
|
||
root: { | ||
height: 1, | ||
width: '100%', | ||
}, | ||
|
||
}) | ||
|
||
export const Divider = ({ style }) => ( | ||
<View | ||
style={[styles.root, style]} | ||
pointerEvents={'box-none'}> | ||
<View | ||
style={[ | ||
containerStyles.elevationRoot, | ||
containerStyles.elevation3, | ||
]} | ||
pointerEvents={'none'} /> | ||
</View> | ||
) | ||
|
||
Divider.propTypes = { | ||
style: PropTypes.object, | ||
} | ||
|
||
Divider.defaultProps = { | ||
style: {}, | ||
} | ||
|
||
export default Divider |
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 @@ | ||
export { default } from './Divider' |
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
Oops, something went wrong.