Skip to content

Commit

Permalink
Merge pull request #85 from pct-org/feature/improvements
Browse files Browse the repository at this point in the history
Feature/improvements
  • Loading branch information
TriPSs authored Oct 1, 2020
2 parents 7236a93 + 03b4aca commit 628c784
Show file tree
Hide file tree
Showing 78 changed files with 2,227 additions and 1,724 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
- name: Install dependencies
run: yarn

- name: Check linting
run: yarn lint

- name: Run unit tests
run: yarn test:coverage

- name: Upload codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
# - name: Check linting
# run: yarn lint
#
# - name: Run unit tests
# run: yarn test:coverage
#
# - name: Upload codecov
# uses: codecov/codecov-action@v1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
105 changes: 105 additions & 0 deletions app/components/BottomSheet/BottomSheet.js
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
1 change: 1 addition & 0 deletions app/components/BottomSheet/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './BottomSheet'
82 changes: 0 additions & 82 deletions app/components/Button/Button.tv.js

This file was deleted.

7 changes: 1 addition & 6 deletions app/components/Button/index.js
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'
7 changes: 4 additions & 3 deletions app/components/Container/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ export const Container = ({ children, elevation, style }) => (
)

Container.propTypes = {
children: PropTypes.node.isRequired,
elevation: PropTypes.number.isRequired,
children: PropTypes.node,
elevation: PropTypes.number,
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.array
PropTypes.array,
]),
}

Container.defaultProps = {
children: null,
elevation: 0,
style: null,
}
Expand Down
37 changes: 37 additions & 0 deletions app/components/Divider/Divider.js
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
1 change: 1 addition & 0 deletions app/components/Divider/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Divider'
25 changes: 20 additions & 5 deletions app/components/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@ export const styles = StyleSheet.create({
},

text: {
marginTop: -(dimensions.UNIT / 2)
}
marginTop: -(dimensions.UNIT / 2),
},
})

export const IconButton = ({ onPress, onLongPress, onFocus, onBlur, animatable, animatableStyle, buttonProps, children, ...rest }) => (
export const IconButton = ({
onPress,
onLongPress,
onFocus,
onBlur,
animatable,
animatableStyle,
buttonProps,
children,
...rest
}) => (
<BaseButton
onPress={onPress}
onLongPress={onLongPress}
onFocus={onFocus}
onBlur={onBlur}

{...buttonProps}>
<Animatable.View
{...animatable}
Expand All @@ -51,11 +60,14 @@ export const IconButton = ({ onPress, onLongPress, onFocus, onBlur, animatable,

IconButton.propTypes = {
onPress: PropTypes.func,
onPressIn: PropTypes.func,
onPressOut: PropTypes.func,
onLongPress: PropTypes.func,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
children: PropTypes.string,
buttonProps: PropTypes.object,
animatableStyle: PropTypes.object,
animatable: PropTypes.object,
size: PropTypes.number,
}
Expand All @@ -64,11 +76,14 @@ IconButton.defaultProps = {
buttonProps: {},
animatable: {},
onPress: null,
onPressIn: null,
onPressOut: null,
onLongPress: null,
children: null,
animatableStyle: {},
onFocus: null,
onBlur: null,
size: dimensions.ICON_SIZE_DEFAULT
size: dimensions.ICON_SIZE_DEFAULT,
}

export default IconButton
3 changes: 1 addition & 2 deletions app/components/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Modal = ({ children, visible, onRequestClose }) => {
<IconButton
buttonProps={{
component: TouchableNativeFeedback,
rippleColor: null
rippleColor: null,
}}
onPress={onRequestClose}
name={'close'}
Expand All @@ -85,5 +85,4 @@ Modal.defaultProps = {
visible: false,
}


export default Modal
4 changes: 2 additions & 2 deletions app/components/MyEpisode/MyEpisode.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export const MyEpisode = ({ item, style, empty, ...rest }) => {
useNativeDriver>

<QualitySelector
visible={showQualitySelector}
item={item}
onRequestClose={() => toggleSelecting(false)}
visible={showQualitySelector}
onClose={() => toggleSelecting(false)}
/>

</Animatable.View>
Expand Down
Loading

0 comments on commit 628c784

Please sign in to comment.