-
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 #22 from TriPSs/feature/shows-recommendations
Feature/shows recommendations
- Loading branch information
Showing
28 changed files
with
865 additions
and
388 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,47 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View, ScrollView } from 'react-native' | ||
import { View, FlatList } from 'react-native' | ||
import { withNavigation } from 'react-navigation' | ||
|
||
import Card from 'components/Card' | ||
|
||
export class CardList extends React.Component { | ||
|
||
handleItemOpen = (item) => { | ||
const { handleItemOpen, navigation } = this.props | ||
|
||
if (handleItemOpen) { | ||
handleItemOpen(item) | ||
|
||
} else { | ||
navigation.navigate('Item', item) | ||
} | ||
} | ||
|
||
renderCard = ({ item }) => ( | ||
<Card | ||
item={item} | ||
onPress={() => this.handleItemOpen(item)} | ||
/> | ||
) | ||
|
||
render() { | ||
const { items, handleItemOpen, ...props } = this.props | ||
|
||
return ( | ||
<FlatList | ||
columnWrapperStyle={{ margin: 4 }} | ||
data={items} | ||
numColumns={3} | ||
initialNumToRender={12} | ||
renderItem={this.renderCard} | ||
keyExtractor={(item, index) => `${item.id}-${index}`} | ||
onEndReachedThreshold={100} | ||
ListFooterComponent={() => <View style={{ marginBottom: 16 }} />} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
import Card from '../Card' | ||
import Typography from '../Typography' | ||
|
||
const styles = StyleSheet.create({ | ||
|
||
root: { | ||
height : 190, | ||
width : 120, | ||
marginLeft : 10, | ||
marginRight: 10, | ||
alignSelf : 'stretch', | ||
position : 'relative', | ||
display : 'flex', | ||
alignItems : 'center', | ||
}, | ||
|
||
title: { | ||
marginLeft: 8, | ||
marginTop : 8, | ||
}, | ||
|
||
image: { | ||
height : '100%', | ||
width : '100%', | ||
resizeMode: 'cover', | ||
}, | ||
|
||
}) | ||
|
||
export const CardList = ({ loading, title, items, onPress, style }) => ( | ||
<View style={style}> | ||
<Typography | ||
style={styles.title} | ||
variant={'title'}> | ||
{title} | ||
</Typography> | ||
|
||
<ScrollView horizontal showsHorizontalScrollIndicator={false}> | ||
{items.map(item => ( | ||
<Card | ||
key={item.id} | ||
item={item} | ||
onPress={() => onPress(item)} | ||
/> | ||
))} | ||
|
||
{(loading || items.length === 0) && ( | ||
<React.Fragment> | ||
<Card empty /> | ||
<Card empty /> | ||
<Card empty /> | ||
</React.Fragment> | ||
)} | ||
</ScrollView> | ||
|
||
</View> | ||
) | ||
|
||
CardList.propTypes = { | ||
title : PropTypes.string.isRequired, | ||
items : PropTypes.array.isRequired, | ||
onPress: PropTypes.func.isRequired, | ||
loading: PropTypes.bool.isRequired, | ||
style : PropTypes.object, | ||
} | ||
|
||
CardList.defaultProps = { | ||
style: null, | ||
} | ||
|
||
export default CardList | ||
export default withNavigation(CardList) |
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,82 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { StyleSheet, View, ScrollView } from 'react-native' | ||
|
||
import Card from '../Card' | ||
import Typography from '../Typography' | ||
|
||
const styles = StyleSheet.create({ | ||
|
||
root: { | ||
height : 190, | ||
width : 120, | ||
marginLeft : 10, | ||
marginRight: 10, | ||
alignSelf : 'stretch', | ||
position : 'relative', | ||
display : 'flex', | ||
alignItems : 'center', | ||
}, | ||
|
||
title: { | ||
marginLeft: 8, | ||
marginTop : 8, | ||
}, | ||
|
||
image: { | ||
height : '100%', | ||
width : '100%', | ||
resizeMode: 'cover', | ||
}, | ||
|
||
scrollView: { | ||
margin: 4, | ||
} | ||
}) | ||
|
||
export const CardSlider = ({ loading, title, items, onPress, style }) => ( | ||
<View style={style}> | ||
<Typography | ||
style={styles.title} | ||
variant={'title'}> | ||
{title} | ||
</Typography> | ||
|
||
<ScrollView | ||
horizontal | ||
style={styles.scrollView} | ||
showsHorizontalScrollIndicator={false}> | ||
{items.map(item => ( | ||
<Card | ||
small | ||
key={item.id} | ||
item={item} | ||
onPress={() => onPress(item)} | ||
/> | ||
))} | ||
|
||
{(loading || items.length === 0) && ( | ||
<React.Fragment> | ||
<Card empty /> | ||
<Card empty /> | ||
<Card empty /> | ||
</React.Fragment> | ||
)} | ||
</ScrollView> | ||
|
||
</View> | ||
) | ||
|
||
CardSlider.propTypes = { | ||
title : PropTypes.string.isRequired, | ||
items : PropTypes.array.isRequired, | ||
onPress: PropTypes.func.isRequired, | ||
loading: PropTypes.bool.isRequired, | ||
style : PropTypes.object, | ||
} | ||
|
||
CardSlider.defaultProps = { | ||
style: null, | ||
} | ||
|
||
export default CardSlider |
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 './CardSlider' |
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
Oops, something went wrong.