Merge pull request #449 from lbryio/improve-suggested-subs
add button to view subscriptions from the suggested subscriptions view
This commit is contained in:
commit
7e76e47d77
3 changed files with 46 additions and 8 deletions
|
@ -43,7 +43,7 @@ class SuggestedSubscriptionItem extends React.PureComponent {
|
||||||
return (
|
return (
|
||||||
<View style={subscriptionsStyle.suggestedContainer}>
|
<View style={subscriptionsStyle.suggestedContainer}>
|
||||||
<FileItem
|
<FileItem
|
||||||
style={subscriptionsStyle.fileItem}
|
style={subscriptionsStyle.compactMainFileItem}
|
||||||
mediaStyle={subscriptionsStyle.fileItemMedia}
|
mediaStyle={subscriptionsStyle.fileItemMedia}
|
||||||
uri={this.uriForClaim(claims[0])}
|
uri={this.uriForClaim(claims[0])}
|
||||||
navigation={navigation} />
|
navigation={navigation} />
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
import { buildURI, parseURI } from 'lbry-redux';
|
import { buildURI, parseURI } from 'lbry-redux';
|
||||||
import { uriFromFileInfo } from 'utils/helper';
|
import { uriFromFileInfo } from 'utils/helper';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import Button from 'component/button';
|
||||||
import Colors from 'styles/colors';
|
import Colors from 'styles/colors';
|
||||||
import Constants from 'constants';
|
import Constants from 'constants';
|
||||||
import discoverStyle from 'styles/discover';
|
import discoverStyle from 'styles/discover';
|
||||||
|
@ -24,6 +25,10 @@ import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||||
import UriBar from 'component/uriBar';
|
import UriBar from 'component/uriBar';
|
||||||
|
|
||||||
class SubscriptionsPage extends React.PureComponent {
|
class SubscriptionsPage extends React.PureComponent {
|
||||||
|
state = {
|
||||||
|
showingSuggestedSubs: false
|
||||||
|
};
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const {
|
const {
|
||||||
doFetchMySubscriptions,
|
doFetchMySubscriptions,
|
||||||
|
@ -62,14 +67,19 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
unreadSubscriptions,
|
unreadSubscriptions,
|
||||||
navigation,
|
navigation,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
||||||
const hasSubscriptions = numberOfSubscriptions > 0;
|
const hasSubscriptions = numberOfSubscriptions > 0;
|
||||||
|
|
||||||
|
if (!hasSubscriptions && !this.state.showingSuggestedSubs) {
|
||||||
|
this.setState({ showingSuggestedSubs: true });
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={subscriptionsStyle.container}>
|
<View style={subscriptionsStyle.container}>
|
||||||
<UriBar navigation={navigation} />
|
<UriBar navigation={navigation} />
|
||||||
|
|
||||||
{hasSubscriptions && !loading &&
|
{(!this.state.showingSuggestedSubs && hasSubscriptions && !loading) &&
|
||||||
<View style={subscriptionsStyle.viewModeRow}>
|
<View style={subscriptionsStyle.viewModeRow}>
|
||||||
<Link
|
<Link
|
||||||
text={'All Subscriptions'}
|
text={'All Subscriptions'}
|
||||||
|
@ -85,9 +95,8 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
</View>}
|
</View>}
|
||||||
|
|
||||||
{(hasSubscriptions && !loading) &&
|
{(!this.state.showingSuggestedSubs && hasSubscriptions && !loading) &&
|
||||||
<View style={subscriptionsStyle.subContainer}>
|
<View style={subscriptionsStyle.subContainer}>
|
||||||
<UriBar navigation={navigation} />
|
|
||||||
{(viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL) &&
|
{(viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL) &&
|
||||||
<FlatList
|
<FlatList
|
||||||
style={subscriptionsStyle.scrollContainer}
|
style={subscriptionsStyle.scrollContainer}
|
||||||
|
@ -142,11 +151,25 @@ class SubscriptionsPage extends React.PureComponent {
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
|
|
||||||
{(!hasSubscriptions && !loading) &&
|
{this.state.showingSuggestedSubs &&
|
||||||
<View style={subscriptionsStyle.subContainer}>
|
<View style={subscriptionsStyle.suggestedSubsContainer}>
|
||||||
|
{!hasSubscriptions &&
|
||||||
<Text style={subscriptionsStyle.infoText}>
|
<Text style={subscriptionsStyle.infoText}>
|
||||||
You are not subscribed to any channels at the moment. Here are some channels that we think you might enjoy.
|
You are not subscribed to any channels at the moment. Here are some channels that we think you might enjoy.
|
||||||
|
</Text>}
|
||||||
|
|
||||||
|
{hasSubscriptions &&
|
||||||
|
<View>
|
||||||
|
<Text style={subscriptionsStyle.infoText}>
|
||||||
|
You are currently subscribed to {numberOfSubscriptions} channel{(numberOfSubscriptions > 1) ? 's' : ''}.
|
||||||
</Text>
|
</Text>
|
||||||
|
<Button
|
||||||
|
style={subscriptionsStyle.button}
|
||||||
|
text={"View my subscriptions"}
|
||||||
|
onPress={() => this.setState({ showingSuggestedSubs: false })} />
|
||||||
|
</View>
|
||||||
|
}
|
||||||
|
|
||||||
{loadingSuggested && <ActivityIndicator size="large" colors={Colors.LbryGreen} style={subscriptionsStyle.loading} />}
|
{loadingSuggested && <ActivityIndicator size="large" colors={Colors.LbryGreen} style={subscriptionsStyle.loading} />}
|
||||||
{!loadingSuggested && <SuggestedSubscriptions navigation={navigation} />}
|
{!loadingSuggested && <SuggestedSubscriptions navigation={navigation} />}
|
||||||
</View>}
|
</View>}
|
||||||
|
|
|
@ -13,8 +13,19 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
},
|
},
|
||||||
subContainer: {
|
subContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
},
|
||||||
|
suggestedSubsContainer: {
|
||||||
|
flex: 1,
|
||||||
marginTop: 60
|
marginTop: 60
|
||||||
},
|
},
|
||||||
|
button: {
|
||||||
|
alignSelf: 'flex-start',
|
||||||
|
backgroundColor: Colors.LbryGreen,
|
||||||
|
paddingLeft: 16,
|
||||||
|
paddingRight: 16,
|
||||||
|
marginLeft: 16,
|
||||||
|
marginBottom: 16
|
||||||
|
},
|
||||||
busyContainer: {
|
busyContainer: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
@ -52,6 +63,10 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
marginRight: 24,
|
marginRight: 24,
|
||||||
marginBottom: 24
|
marginBottom: 24
|
||||||
},
|
},
|
||||||
|
compactMainFileItem: {
|
||||||
|
marginLeft: 24,
|
||||||
|
marginRight: 24
|
||||||
|
},
|
||||||
compactItems: {
|
compactItems: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginTop: 6,
|
marginTop: 6,
|
||||||
|
@ -105,7 +120,7 @@ const subscriptionsStyle = StyleSheet.create({
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
marginLeft: 24,
|
marginLeft: 24,
|
||||||
marginRight: 24,
|
marginRight: 24,
|
||||||
marginTop: 24
|
marginTop: 84
|
||||||
},
|
},
|
||||||
viewModeLink: {
|
viewModeLink: {
|
||||||
marginRight: 24,
|
marginRight: 24,
|
||||||
|
|
Loading…
Reference in a new issue