Skip to content

Commit

Permalink
Merge pull request #33 from TriPSs/feature/shows-recommendations
Browse files Browse the repository at this point in the history
Feature/shows recommendations
  • Loading branch information
TriPSs authored Jan 10, 2019
2 parents f1522d9 + 3eab36a commit f90a6b9
Show file tree
Hide file tree
Showing 10 changed files with 781 additions and 161 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ android {
minSdkVersion 16
targetSdkVersion 26
versionCode 15
versionName "v0.11.1"
versionName "v0.12.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand Down
170 changes: 170 additions & 0 deletions app/components/Episode/Episode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import React from 'react'
import PropTypes from 'prop-types'
import { StyleSheet, View, Image } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'

import posterHolderImage from 'images/posterholder.png'

import Typography from 'components/Typography'
import Overlay from 'components/Overlay'
import BaseButton from 'components/BaseButton'

export const styles = StyleSheet.create({

default: {
display: 'flex',
margin : 8,
},

big: {
display: 'flex',
margin : 4,
},

posterWithTitle: {
display : 'flex',
flexDirection: 'row',
alignItems : 'center',
},

iconContainer: {
position: 'absolute',
top : 0,
width : '100%',
height : '100%',

justifyContent: 'center',
alignItems : 'center',
},

title: {
marginLeft: 8,
},

titleBig: {
marginLeft: 4,
marginBottom: 4,
},

summary: {
marginTop: 8,
},

})

export default class Episode extends React.PureComponent {

static propTypes = {
playItem : PropTypes.func.isRequired,
title : PropTypes.string.isRequired,
images : PropTypes.object.isRequired,
torrents : PropTypes.object.isRequired,
number : PropTypes.number.isRequired,
summary : PropTypes.string,
variant : PropTypes.oneOf([
'default',
'big',
]),
hasTorrents: PropTypes.bool,
}

static defaultProps = {
summary : null,
hasTorrents: false,
variant : 'default',
}

state = {
showPlaceholder: false,
}

handleImageError = () => {
this.setState({
showPlaceholder: true,
})
}

handlePlayItem = () => {
const { playItem, hasTorrents, torrents, ...episode } = this.props

if (hasTorrents) {
playItem(torrents, episode)
}
}

getAirsDate = () => {
const { aired } = this.props

const airs = new Date()
airs.setTime(aired)

return `${airs.getDate()}-${(airs.getMonth() + 1)}-${airs.getFullYear()}`
}

render() {
const { hasTorrents, title, summary, number, images, hasAired, variant } = this.props
const { showPlaceholder } = this.state

return (
<View style={styles[variant]}>

<View style={styles.posterWithTitle}>
<BaseButton onPress={this.handlePlayItem}>
<View>
<Image
onError={this.handleImageError}
defaultSource={posterHolderImage}
source={images.poster.thumb && !showPlaceholder
? { uri: images.poster.thumb }
: posterHolderImage
}
style={{
width : variant === 'big' ? 250 : 150,
height: variant === 'big' ? 150 : 100,
}} />

<View style={styles.iconContainer}>
<Overlay />

{hasAired && (
<Icon
iconStyle={{ margin: 0 }}
backgroundColor={'transparent'}
borderRadius={0}
name={hasTorrents ? 'play-circle-outline' : 'cancel'}
color={hasTorrents ? '#FFF' : 'red'}
size={60} />
)}

{!hasAired && (
<Typography variant={'caption'}>
{this.getAirsDate()}
</Typography>
)}
</View>
</View>
</BaseButton>

{variant === 'default' && (
<Typography style={styles.title}>
{`${number}. ${title}`}
</Typography>
)}
</View>

{variant === 'big' && (
<Typography style={styles.titleBig}>
{`${number}. ${title}`}
</Typography>
)}

{variant === 'default' && (
<Typography style={styles.summary} variant={'caption'}>
{summary}
</Typography>
)}

</View>
)
}
}
1 change: 1 addition & 0 deletions app/components/Episode/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Episode'
9 changes: 5 additions & 4 deletions app/modules/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"Season {{number}}": "Season {{number}}",
"Buffering": "Buffering...",
"Connecting": "Connecting...",
"progress: {{progress}}": "progress: {{progress}}",
"speed: {{downloadSpeed}}": "speed: {{downloadSpeed}}",
"seeds: {{seeds}}": "seeds: {{seeds}}",
"progress": "progress",
"speed": "speed",
"seeds": "seeds",
"complete": "complete",
"New version available {{version}}": "New version available {{version}}",
"Downloading {{version}}": "Downloading {{version}}",
Expand All @@ -19,5 +19,6 @@
"Terms of Service": "Terms of Service",
"Mark Watched": "Mark Watched",
"Mark Unwatched": "Mark Unwatched",
"Trailer": "Trailer"
"Trailer": "Trailer",
"Controls": "Controls"
}
9 changes: 5 additions & 4 deletions app/modules/i18n/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"Season {{number}}": "Seizoen {{number}}",
"Buffering": "Bufferen...",
"Connecting": "Verbinding maken...",
"progress: {{progress}}": "vooruitgang: {{progress}}",
"speed: {{downloadSpeed}}": "snelheid: {{downloadSpeed}}",
"seeds: {{seeds}}": "seeds: {{seeds}}",
"progress": "vooruitgang",
"speed": "snelheid",
"seed": "seeds",
"complete": "klaar",
"New version available {{version}}": "Nieuwe versie beschikbaar {{version}}",
"Downloading {{version}}": "Downloaden {{version}}",
Expand All @@ -19,5 +19,6 @@
"Terms of Service": "Gebruiksvoorwaarden",
"Mark Watched": "Markeer bekeken",
"Mark Unwatched": "Markeer onbekeken",
"Trailer": "Trailer"
"Trailer": "Trailer",
"Controls": "Controls"
}
7 changes: 4 additions & 3 deletions app/screens/Item/ItemScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class Item extends React.PureComponent {

state = {
selectFromTorrents: null,
episodeToPlay : {},
episodeToPlay : null,
}

componentDidMount() {
Expand Down Expand Up @@ -116,7 +116,7 @@ export default class Item extends React.PureComponent {
}

playItem = (magnet) => {
const { navigation: { navigate, state: { params: item } } } = this.props
const { navigation: { navigate }, item } = this.props
const { episodeToPlay } = this.state

this.setState({
Expand All @@ -127,7 +127,8 @@ export default class Item extends React.PureComponent {
magnet,
item: {
...item,
...episodeToPlay,
...(episodeToPlay || {}),
showTitle: (episodeToPlay ? item.title : null),
},
})
}
Expand Down
61 changes: 61 additions & 0 deletions app/screens/Player/PlayPauseIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react'
import { Dimensions } from 'react-native'
import { View } from 'react-native'

import IconButton from 'components/IconButton'

const { height: windowHeight, width: windowWidth } = Dimensions.get('window')

const ICON_SIZE = 76

export default class PlayPauseIcon extends React.Component {

getPositionStyle = () => {
const { isPortrait } = this.props

if (isPortrait) {
return {
left: (windowWidth - ICON_SIZE) / 2,
top : (windowHeight - ICON_SIZE) / 2,
}
}

return {
left: (windowHeight - ICON_SIZE + 55) / 2,
top : (windowWidth - ICON_SIZE) / 2,
}
}

render() {
const { paused, handlePauseVideo, handlePlayVideo } = this.props

return (
<View
style={{
position: 'absolute',
width : ICON_SIZE,
height : ICON_SIZE,
zIndex : 2000,
...this.getPositionStyle(),
}}
pointerEvents={'box-none'}>

{!paused && (
<IconButton
onPress={handlePauseVideo}
name={'pause'}
color={'#FFF'}
size={60} />
)}

{paused && (
<IconButton
onPress={handlePlayVideo}
name={'play'}
color={'#FFF'}
size={60} />
)}
</View>
)
}
}
Loading

0 comments on commit f90a6b9

Please sign in to comment.