display activity indicator for discover and trending items while resolving
This commit is contained in:
parent
fbb0d7090b
commit
608a08d2e8
3 changed files with 33 additions and 20 deletions
|
@ -23,7 +23,7 @@ class FileItem extends React.PureComponent {
|
||||||
|
|
||||||
resolve(props) {
|
resolve(props) {
|
||||||
const { isResolvingUri, resolveUri, claim, uri } = props;
|
const { isResolvingUri, resolveUri, claim, uri } = props;
|
||||||
|
|
||||||
if (!isResolvingUri && claim === undefined && uri) {
|
if (!isResolvingUri && claim === undefined && uri) {
|
||||||
resolveUri(uri);
|
resolveUri(uri);
|
||||||
}
|
}
|
||||||
|
@ -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,12 +56,16 @@ 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 &&
|
||||||
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
||||||
const channelUri = normalizeURI(channelName);
|
const channelUri = normalizeURI(channelName);
|
||||||
navigation.navigate({ routeName: 'File', key: channelUri, params: { uri: channelUri }});
|
navigation.navigate({ routeName: 'File', key: channelUri, params: { uri: channelUri }});
|
||||||
}} />}
|
}} />}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, Image, View } from 'react-native';
|
import { ActivityIndicator, Image, Text, View } from 'react-native';
|
||||||
import fileItemMediaStyle from '../../styles/fileItemMedia';
|
import Colors from '../../styles/colors';
|
||||||
|
import fileItemMediaStyle from '../../styles/fileItemMedia';
|
||||||
|
|
||||||
class FileItemMedia extends React.PureComponent {
|
class FileItemMedia extends React.PureComponent {
|
||||||
static AUTO_THUMB_STYLES = [
|
static AUTO_THUMB_STYLES = [
|
||||||
|
@ -28,14 +29,14 @@ 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')) {
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
style = fileItemMediaStyle.thumbnail;
|
style = fileItemMediaStyle.thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Image source={{uri: thumbnail}}
|
<Image source={{uri: thumbnail}}
|
||||||
blurRadius={blurRadius}
|
blurRadius={blurRadius}
|
||||||
|
@ -43,14 +44,20 @@ class FileItemMedia extends React.PureComponent {
|
||||||
style={style} />
|
style={style} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { StyleSheet, Dimensions } from 'react-native';
|
import { StyleSheet, Dimensions } from 'react-native';
|
||||||
|
|
||||||
const screenDimension = Dimensions.get('window');
|
const screenDimension = Dimensions.get('window');
|
||||||
const width = screenDimension.width - 48; // screen width minus combined left and right margins
|
const width = screenDimension.width - 48; // screen width minus combined left and right margins
|
||||||
|
|
||||||
const fileItemMediaStyle = StyleSheet.create({
|
const fileItemMediaStyle = StyleSheet.create({
|
||||||
|
@ -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%',
|
||||||
|
|
Loading…
Reference in a new issue