-
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 #14 from TriPSs/feature/switch
feat(#13): Added quality selector before playing movies / episodes
- Loading branch information
Showing
10 changed files
with
172 additions
and
22 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
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,124 @@ | ||
import React from 'react' | ||
import { StyleSheet, View, Text } from 'react-native' | ||
import * as Animatable from 'react-native-animatable' | ||
import { material } from 'react-native-typography' | ||
|
||
import BaseButton from 'components/BaseButton' | ||
import IconButton from 'components/IconButton' | ||
|
||
import colors from 'modules/colors' | ||
|
||
const styles = StyleSheet.create({ | ||
|
||
root: { | ||
flex : 1, | ||
position: 'absolute', | ||
top : 0, | ||
left : 0, | ||
width : '100%', | ||
height : '100%', | ||
}, | ||
|
||
container: { | ||
opacity : 0.8, | ||
display : 'flex', | ||
justifyContent : 'center', | ||
alignItems : 'center', | ||
backgroundColor: colors.BACKGROUND, | ||
}, | ||
|
||
closeIcon: { | ||
position: 'absolute', | ||
top : 34, | ||
right : 14, | ||
}, | ||
|
||
quality: { | ||
...material.titleWhiteObject, | ||
margin: 8, | ||
}, | ||
|
||
}) | ||
|
||
export default class QualitySelector extends React.Component { | ||
|
||
static getDerivedStateFromProps(props) { | ||
if (props.torrents) { | ||
return { | ||
qualities: Object.keys(props.torrents).filter(quality => !!props.torrents[quality]), | ||
} | ||
} | ||
|
||
return {} | ||
} | ||
|
||
state = { | ||
hidden : false, | ||
qualities: null, | ||
} | ||
|
||
playQuality = (quality) => { | ||
const { playItem, torrents } = this.props | ||
|
||
playItem(torrents[quality]) | ||
} | ||
|
||
handleAnimationEnd = () => { | ||
const { torrents } = this.props | ||
|
||
this.setState({ | ||
hidden: !torrents, | ||
}) | ||
} | ||
|
||
handleAnimationBegin = () => { | ||
this.setState({ | ||
hidden: false, | ||
}) | ||
} | ||
|
||
render() { | ||
const { torrents, cancel } = this.props | ||
const { hidden, qualities } = this.state | ||
|
||
if (hidden && !torrents) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Animatable.View | ||
animation={torrents ? 'fadeIn' : 'fadeOut'} | ||
duration={200} | ||
style={[styles.root]} | ||
onAnimationBegin={this.handleAnimationBegin} | ||
onAnimationEnd={this.handleAnimationEnd} | ||
useNativeDriver> | ||
|
||
{qualities && ( | ||
<View style={[styles.root, styles.container]}> | ||
<View style={styles.closeIcon}> | ||
<IconButton | ||
onPress={cancel} | ||
name={'close'} | ||
color={'#FFF'} | ||
size={40} | ||
/> | ||
</View> | ||
|
||
{qualities.map((quality) => ( | ||
<BaseButton | ||
key={quality} | ||
onPress={() => this.playQuality(quality)}> | ||
<Text style={styles.quality}> | ||
{quality} | ||
</Text> | ||
</BaseButton> | ||
))} | ||
</View> | ||
)} | ||
|
||
</Animatable.View> | ||
) | ||
} | ||
|
||
} |
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 './QualitySelector' |
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