Merge pull request #424 from lbryio/channel-page-tweaks
* optimise space usage by the page navigation buttons on the channel page * use full URIs for channel name links
This commit is contained in:
commit
9efcc36e15
6 changed files with 40 additions and 21 deletions
|
@ -63,6 +63,8 @@ class FileItem extends React.PureComponent {
|
||||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||||
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;
|
||||||
|
const channelClaimId = claim && claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||||
|
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
|
||||||
const height = claim ? claim.height : null;
|
const height = claim ? claim.height : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -85,8 +87,7 @@ class FileItem extends React.PureComponent {
|
||||||
<View style={discoverStyle.detailsRow}>
|
<View style={discoverStyle.detailsRow}>
|
||||||
{channelName &&
|
{channelName &&
|
||||||
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
||||||
const channelUri = normalizeURI(channelName);
|
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||||
navigateToUri(navigation, channelUri);
|
|
||||||
}} />}
|
}} />}
|
||||||
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo block={height} />
|
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo block={height} />
|
||||||
</View>}
|
</View>}
|
||||||
|
|
|
@ -145,7 +145,15 @@ class FileList extends React.PureComponent<Props, State> {
|
||||||
sortFunctions: {};
|
sortFunctions: {};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { fileInfos, hideFilter, checkPending, navigation, style } = this.props;
|
const {
|
||||||
|
contentContainerStyle,
|
||||||
|
fileInfos,
|
||||||
|
hideFilter,
|
||||||
|
checkPending,
|
||||||
|
navigation,
|
||||||
|
onEndReached,
|
||||||
|
style
|
||||||
|
} = this.props;
|
||||||
const { sortBy } = this.state;
|
const { sortBy } = this.state;
|
||||||
const items = [];
|
const items = [];
|
||||||
|
|
||||||
|
@ -170,7 +178,9 @@ class FileList extends React.PureComponent<Props, State> {
|
||||||
return (
|
return (
|
||||||
<FlatList
|
<FlatList
|
||||||
style={style}
|
style={style}
|
||||||
|
contentContainerStyle={contentContainerStyle}
|
||||||
data={items}
|
data={items}
|
||||||
|
onEndReached={onEndReached}
|
||||||
keyExtractor={(item, index) => item}
|
keyExtractor={(item, index) => item}
|
||||||
renderItem={({item}) => (
|
renderItem={({item}) => (
|
||||||
<FileItem style={discoverStyle.fileItem}
|
<FileItem style={discoverStyle.fileItem}
|
||||||
|
|
|
@ -63,11 +63,13 @@ class FileListItem extends React.PureComponent {
|
||||||
const isResolving = !fileInfo && isResolvingUri;
|
const isResolving = !fileInfo && isResolvingUri;
|
||||||
const title = fileInfo ? fileInfo.metadata.title : metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
|
const title = fileInfo ? fileInfo.metadata.title : metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
|
||||||
|
|
||||||
let name, channel, height;
|
let name, channel, height, channelClaimId, fullChannelUri;
|
||||||
if (claim) {
|
if (claim) {
|
||||||
name = claim.name;
|
name = claim.name;
|
||||||
channel = claim.channel_name;
|
channel = claim.channel_name;
|
||||||
height = claim.height;
|
height = claim.height;
|
||||||
|
channelClaimId = claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||||
|
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -90,8 +92,7 @@ class FileListItem extends React.PureComponent {
|
||||||
{(title || name) && <Text style={fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
|
{(title || name) && <Text style={fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
|
||||||
{channel &&
|
{channel &&
|
||||||
<Link style={fileListStyle.publisher} text={channel} onPress={() => {
|
<Link style={fileListStyle.publisher} text={channel} onPress={() => {
|
||||||
const channelUri = normalizeURI(channel);
|
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||||
navigateToUri(navigation, channelUri);
|
|
||||||
}} />}
|
}} />}
|
||||||
|
|
||||||
<View style={fileListStyle.info}>
|
<View style={fileListStyle.info}>
|
||||||
|
|
|
@ -11,7 +11,8 @@ import channelPageStyle from 'styles/channelPage';
|
||||||
|
|
||||||
class ChannelPage extends React.PureComponent {
|
class ChannelPage extends React.PureComponent {
|
||||||
state = {
|
state = {
|
||||||
page: 1
|
page: 1,
|
||||||
|
showPageButtons: false
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -26,7 +27,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
handlePreviousPage = () => {
|
handlePreviousPage = () => {
|
||||||
const { uri, fetchClaims } = this.props;
|
const { uri, fetchClaims } = this.props;
|
||||||
if (this.state.page > 1) {
|
if (this.state.page > 1) {
|
||||||
this.setState({ page: this.state.page - 1 }, () => {
|
this.setState({ page: this.state.page - 1, showPageButtons: false }, () => {
|
||||||
fetchClaims(uri, this.state.page);
|
fetchClaims(uri, this.state.page);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -35,7 +36,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
handleNextPage = () => {
|
handleNextPage = () => {
|
||||||
const { uri, fetchClaims, totalPages } = this.props;
|
const { uri, fetchClaims, totalPages } = this.props;
|
||||||
if (this.state.page < totalPages) {
|
if (this.state.page < totalPages) {
|
||||||
this.setState({ page: this.state.page + 1 }, () => {
|
this.setState({ page: this.state.page + 1, showPageButtons: false }, () => {
|
||||||
fetchClaims(uri, this.state.page);
|
fetchClaims(uri, this.state.page);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,9 @@ class ChannelPage extends React.PureComponent {
|
||||||
hideFilter
|
hideFilter
|
||||||
fileInfos={claimsInChannel}
|
fileInfos={claimsInChannel}
|
||||||
navigation={navigation}
|
navigation={navigation}
|
||||||
style={channelPageStyle.fileList} />
|
style={channelPageStyle.fileList}
|
||||||
|
contentContainerStyle={channelPageStyle.fileListContent}
|
||||||
|
onEndReached={() => this.setState({ showPageButtons: true })} />
|
||||||
) : (
|
) : (
|
||||||
<View style={channelPageStyle.busyContainer}>
|
<View style={channelPageStyle.busyContainer}>
|
||||||
<Text style={channelPageStyle.infoText}>No content found.</Text>
|
<Text style={channelPageStyle.infoText}>No content found.</Text>
|
||||||
|
@ -81,7 +84,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
<View style={channelPageStyle.container}>
|
<View style={channelPageStyle.container}>
|
||||||
<PageHeader title={name} onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
|
<PageHeader title={name} onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
|
||||||
{contentList}
|
{contentList}
|
||||||
{(totalPages > 1) &&
|
{(totalPages > 1) && this.state.showPageButtons &&
|
||||||
<View style={channelPageStyle.pageButtons}>
|
<View style={channelPageStyle.pageButtons}>
|
||||||
<View>
|
<View>
|
||||||
{(this.state.page > 1) && <Button
|
{(this.state.page > 1) && <Button
|
||||||
|
|
|
@ -428,9 +428,9 @@ class FilePage extends React.PureComponent {
|
||||||
const { height, channel_name: channelName, value } = claim;
|
const { height, channel_name: channelName, value } = claim;
|
||||||
const showActions = !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView;
|
const showActions = !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView;
|
||||||
const showFileActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
const showFileActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||||
const channelClaimId =
|
const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||||
value && value.publisherSignature && value.publisherSignature.certificateId;
|
|
||||||
const canSendTip = this.state.tipAmount > 0;
|
const canSendTip = this.state.tipAmount > 0;
|
||||||
|
const fullChannelUri = channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||||
|
|
||||||
const playerStyle = [filePageStyle.player,
|
const playerStyle = [filePageStyle.player,
|
||||||
this.state.isLandscape ? filePageStyle.containedPlayerLandscape :
|
this.state.isLandscape ? filePageStyle.containedPlayerLandscape :
|
||||||
|
@ -575,8 +575,7 @@ class FilePage extends React.PureComponent {
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
ellipsizeMode={"tail"}
|
ellipsizeMode={"tail"}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
const channelUri = normalizeURI(channelName);
|
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||||
navigateToUri(navigation, channelUri);
|
|
||||||
}} />
|
}} />
|
||||||
<DateTime
|
<DateTime
|
||||||
style={filePageStyle.publishDate}
|
style={filePageStyle.publishDate}
|
||||||
|
@ -588,11 +587,11 @@ class FilePage extends React.PureComponent {
|
||||||
<View style={filePageStyle.subscriptionRow}>
|
<View style={filePageStyle.subscriptionRow}>
|
||||||
<SubscribeButton
|
<SubscribeButton
|
||||||
style={filePageStyle.actionButton}
|
style={filePageStyle.actionButton}
|
||||||
uri={channelUri}
|
uri={fullChannelUri}
|
||||||
name={channelName} />
|
name={channelName} />
|
||||||
<SubscribeNotificationButton
|
<SubscribeNotificationButton
|
||||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||||
uri={channelUri}
|
uri={fullChannelUri}
|
||||||
name={channelName} />
|
name={channelName} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -10,9 +10,12 @@ const channelPageStyle = StyleSheet.create({
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
fileList: {
|
fileList: {
|
||||||
paddingTop: 30,
|
|
||||||
flex: 1,
|
flex: 1,
|
||||||
marginBottom: 16
|
paddingTop: 30,
|
||||||
|
marginBottom: 60,
|
||||||
|
},
|
||||||
|
fileListContent: {
|
||||||
|
paddingBottom: 16
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
color: Colors.LbryGreen,
|
color: Colors.LbryGreen,
|
||||||
|
@ -33,11 +36,13 @@ const channelPageStyle = StyleSheet.create({
|
||||||
marginLeft: 10
|
marginLeft: 10
|
||||||
},
|
},
|
||||||
pageButtons: {
|
pageButtons: {
|
||||||
|
width: '100%',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 76,
|
||||||
paddingLeft: 16,
|
paddingLeft: 16,
|
||||||
paddingRight: 16,
|
paddingRight: 16
|
||||||
marginBottom: 76
|
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
backgroundColor: Colors.LbryGreen,
|
backgroundColor: Colors.LbryGreen,
|
||||||
|
|
Loading…
Reference in a new issue