Merge pull request #186 from lbryio/discover-resolve

display activity indicator for discover and trending items while resolving
This commit is contained in:
Akinwale Ariwodola 2018-06-22 18:43:34 +01:00 committed by GitHub
commit 676617ef19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 20 deletions

View file

@ -47,15 +47,6 @@ class FileItem extends React.PureComponent {
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id); const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
const channelName = claim ? claim.channel_name : null; const channelName = claim ? claim.channel_name : null;
let description = '';
if (isResolvingUri && !claim) {
description = 'Loading...';
} else if (metadata && metadata.description) {
description = metadata.description;
} else if (claim === null) {
description = 'This address contains no content.';
}
return ( return (
<View style={style}> <View style={style}>
<TouchableOpacity style={discoverStyle.container} onPress={() => { <TouchableOpacity style={discoverStyle.container} onPress={() => {
@ -65,7 +56,11 @@ class FileItem extends React.PureComponent {
navigation.navigate({ routeName: 'File', key: uri, params: { uri } }); navigation.navigate({ routeName: 'File', key: uri, params: { uri } });
} }
}> }>
<FileItemMedia title={title} thumbnail={thumbnail} blurRadius={obscureNsfw ? 15 : 0} resizeMode="cover" /> <FileItemMedia title={title}
thumbnail={thumbnail}
blurRadius={obscureNsfw ? 15 : 0}
resizeMode="cover"
isResolvingUri={isResolvingUri} />
<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 &&

View file

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { Text, Image, View } from 'react-native'; import { ActivityIndicator, Image, Text, View } from 'react-native';
import Colors from '../../styles/colors';
import fileItemMediaStyle from '../../styles/fileItemMedia'; import fileItemMediaStyle from '../../styles/fileItemMedia';
class FileItemMedia extends React.PureComponent { class FileItemMedia extends React.PureComponent {
@ -28,7 +29,7 @@ class FileItemMedia extends React.PureComponent {
render() { render() {
let style = this.props.style; let style = this.props.style;
const { title, thumbnail, blurRadius, resizeMode } = this.props; const { blurRadius, isResolvingUri, thumbnail, title, resizeMode } = this.props;
const atStyle = this.state.autoThumbStyle; const atStyle = this.state.autoThumbStyle;
if (thumbnail && ((typeof thumbnail) === 'string')) { if (thumbnail && ((typeof thumbnail) === 'string')) {
@ -46,11 +47,17 @@ class FileItemMedia extends React.PureComponent {
return ( return (
<View style={[style ? style : fileItemMediaStyle.autothumb, atStyle]}> <View style={[style ? style : fileItemMediaStyle.autothumb, atStyle]}>
<Text style={fileItemMediaStyle.autothumbText}>{title && {isResolvingUri && (
<View style={fileItemMediaStyle.resolving}>
<ActivityIndicator color={Colors.White} size={"large"} />
<Text style={fileItemMediaStyle.text}>Resolving...</Text>
</View>
)}
{!isResolvingUri && <Text style={fileItemMediaStyle.autothumbText}>{title &&
title title
.replace(/\s+/g, '') .replace(/\s+/g, '')
.substring(0, Math.min(title.replace(' ', '').length, 5)) .substring(0, Math.min(title.replace(' ', '').length, 5))
.toUpperCase()}</Text> .toUpperCase()}</Text>}
</View> </View>
); );
} }

View file

@ -49,6 +49,17 @@ const fileItemMediaStyle = StyleSheet.create({
autothumbOrange: { autothumbOrange: {
backgroundColor: '#ffa726' backgroundColor: '#ffa726'
}, },
resolving: {
alignItems: 'center',
flex: 1,
justifyContent: 'center'
},
text: {
color: '#ffffff',
fontFamily: 'Metropolis-Regular',
fontSize: 16,
marginTop: 8
},
thumbnail: { thumbnail: {
flex: 1, flex: 1,
width: '100%', width: '100%',