Merge pull request #265 from lbryio/thumbnails
tweak thumbnail aspect ratio and sizing on discover and search pages
This commit is contained in:
commit
0c29785a7e
6 changed files with 25 additions and 7 deletions
|
@ -37,6 +37,7 @@ class FileItem extends React.PureComponent {
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
rewardedContentClaimIds,
|
rewardedContentClaimIds,
|
||||||
style,
|
style,
|
||||||
|
mediaStyle,
|
||||||
navigation
|
navigation
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
@ -60,7 +61,8 @@ class FileItem extends React.PureComponent {
|
||||||
thumbnail={thumbnail}
|
thumbnail={thumbnail}
|
||||||
blurRadius={obscureNsfw ? 15 : 0}
|
blurRadius={obscureNsfw ? 15 : 0}
|
||||||
resizeMode="cover"
|
resizeMode="cover"
|
||||||
isResolvingUri={isResolvingUri} />
|
isResolvingUri={isResolvingUri}
|
||||||
|
style={mediaStyle} />
|
||||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
||||||
<Text style={discoverStyle.fileItemName}>{title}</Text>
|
<Text style={discoverStyle.fileItemName}>{title}</Text>
|
||||||
{channelName &&
|
{channelName &&
|
||||||
|
|
|
@ -36,6 +36,7 @@ class SearchResultItem extends React.PureComponent {
|
||||||
<View style={searchStyle.thumbnailContainer}>
|
<View style={searchStyle.thumbnailContainer}>
|
||||||
<FileItemMedia style={searchStyle.thumbnail}
|
<FileItemMedia style={searchStyle.thumbnail}
|
||||||
blurRadius={obscureNsfw ? 15 : 0}
|
blurRadius={obscureNsfw ? 15 : 0}
|
||||||
|
resizeMode="cover"
|
||||||
title={title}
|
title={title}
|
||||||
thumbnail={metadata ? metadata.thumbnail : null} />
|
thumbnail={metadata ? metadata.thumbnail : null} />
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -63,6 +63,7 @@ class DiscoverPage extends React.PureComponent {
|
||||||
renderItem={ ({item, index, section}) => (
|
renderItem={ ({item, index, section}) => (
|
||||||
<FileItem
|
<FileItem
|
||||||
style={discoverStyle.fileItem}
|
style={discoverStyle.fileItem}
|
||||||
|
mediaStyle={discoverStyle.fileItemMedia}
|
||||||
key={item}
|
key={item}
|
||||||
uri={normalizeURI(item)}
|
uri={normalizeURI(item)}
|
||||||
navigation={navigation} />
|
navigation={navigation} />
|
||||||
|
|
|
@ -39,6 +39,7 @@ class TrendingPage extends React.PureComponent {
|
||||||
renderItem={ ({item}) => (
|
renderItem={ ({item}) => (
|
||||||
<FileItem
|
<FileItem
|
||||||
style={discoverStyle.fileItem}
|
style={discoverStyle.fileItem}
|
||||||
|
mediaStyle={discoverStyle.fileItemMedia}
|
||||||
key={item}
|
key={item}
|
||||||
uri={normalizeURI(item)}
|
uri={normalizeURI(item)}
|
||||||
navigation={navigation} />
|
navigation={navigation} />
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { Dimensions, StyleSheet } from 'react-native';
|
||||||
import Colors from './colors';
|
import Colors from './colors';
|
||||||
|
|
||||||
|
const screenDimension = Dimensions.get('window');
|
||||||
|
const screenWidth = screenDimension.width;
|
||||||
|
const screenHeight = screenDimension.height;
|
||||||
|
// calculate thumbnail width and height based on device's aspect ratio
|
||||||
|
const horizontalMargin = 48; // left and right margins (24 + 24)
|
||||||
|
const verticalMargin = (screenWidth / screenHeight) * horizontalMargin;
|
||||||
|
const mediaWidth = screenWidth - horizontalMargin;
|
||||||
|
const mediaHeight = (screenWidth / (screenHeight - verticalMargin)) * mediaWidth;
|
||||||
|
|
||||||
const discoverStyle = StyleSheet.create({
|
const discoverStyle = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1
|
flex: 1
|
||||||
|
@ -40,6 +49,10 @@ const discoverStyle = StyleSheet.create({
|
||||||
marginRight: 24,
|
marginRight: 24,
|
||||||
marginBottom: 48
|
marginBottom: 48
|
||||||
},
|
},
|
||||||
|
fileItemMedia: {
|
||||||
|
width: mediaWidth,
|
||||||
|
height: mediaHeight
|
||||||
|
},
|
||||||
fileItemName: {
|
fileItemName: {
|
||||||
fontFamily: 'Metropolis-Bold',
|
fontFamily: 'Metropolis-Bold',
|
||||||
marginTop: 8,
|
marginTop: 8,
|
||||||
|
|
|
@ -25,13 +25,13 @@ const searchStyle = StyleSheet.create({
|
||||||
},
|
},
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: 80
|
height: 72
|
||||||
},
|
},
|
||||||
thumbnailContainer: {
|
thumbnailContainer: {
|
||||||
width: '25%'
|
width: '40%'
|
||||||
},
|
},
|
||||||
detailsContainer: {
|
detailsContainer: {
|
||||||
width: '70%'
|
width: '55%'
|
||||||
},
|
},
|
||||||
searchInput: {
|
searchInput: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -41,7 +41,7 @@ const searchStyle = StyleSheet.create({
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
fontFamily: 'Metropolis-SemiBold',
|
fontFamily: 'Metropolis-SemiBold',
|
||||||
fontSize: 16
|
fontSize: 14
|
||||||
},
|
},
|
||||||
uri: {
|
uri: {
|
||||||
fontFamily: 'Metropolis-SemiBold',
|
fontFamily: 'Metropolis-SemiBold',
|
||||||
|
@ -51,7 +51,7 @@ const searchStyle = StyleSheet.create({
|
||||||
publisher: {
|
publisher: {
|
||||||
fontFamily: 'Metropolis-SemiBold',
|
fontFamily: 'Metropolis-SemiBold',
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
marginTop: 4,
|
marginTop: 3,
|
||||||
color: '#c0c0c0'
|
color: '#c0c0c0'
|
||||||
},
|
},
|
||||||
noResultsText: {
|
noResultsText: {
|
||||||
|
|
Loading…
Reference in a new issue