channel creator updates after review

This commit is contained in:
Akinwale Ariwodola 2019-09-11 08:22:56 +01:00
parent e95786b904
commit c4218d9f8b
6 changed files with 56 additions and 13 deletions

5
package-lock.json generated
View file

@ -9119,6 +9119,11 @@
"object-assign": "^4.1.1" "object-assign": "^4.1.1"
} }
}, },
"seedrandom": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.3.tgz",
"integrity": "sha512-PJLhhxIMjlMJaiIRtqiVW061EZn3cS+waZkbFe7eCa2R3g88HbNdWmw4NTFG1w5unxd0GeNaUUxZJP7gPAzSDQ=="
},
"semver": { "semver": {
"version": "5.7.1", "version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",

View file

@ -43,7 +43,8 @@
"redux-persist-transform-compress": "^4.2.0", "redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.18", "redux-persist-transform-filter": "0.0.18",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"rn-fetch-blob": "0.10.15" "rn-fetch-blob": "0.10.15",
"seedrandom": "3.0.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.5.4", "@babel/core": "^7.5.4",

View file

@ -16,6 +16,12 @@ export default class ChannelIconItem extends React.PureComponent {
autothumbStyle.autothumbGreen, autothumbStyle.autothumbGreen,
autothumbStyle.autothumbYellow, autothumbStyle.autothumbYellow,
autothumbStyle.autothumbOrange, autothumbStyle.autothumbOrange,
autothumbStyle.autothumbDeepPurple,
autothumbStyle.autothumbAmber,
autothumbStyle.autothumbLime,
autothumbStyle.autothumbLightGreen,
autothumbStyle.autothumbDeepOrange,
autothumbStyle.autothumbBrown,
]; ];
state = { state = {

View file

@ -27,6 +27,7 @@ import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar'; import UriBar from 'component/uriBar';
import channelCreatorStyle from 'styles/channelCreator'; import channelCreatorStyle from 'styles/channelCreator';
import channelIconStyle from 'styles/channelIcon'; import channelIconStyle from 'styles/channelIcon';
import seedrandom from 'seedrandom';
export default class ChannelCreator extends React.PureComponent { export default class ChannelCreator extends React.PureComponent {
state = { state = {
@ -97,11 +98,13 @@ export default class ChannelCreator extends React.PureComponent {
} }
generateAutoStyles = size => { generateAutoStyles = size => {
const { channels = [] } = this.props;
const autoStyles = []; const autoStyles = [];
for (let i = 0; i < size; i++) { for (let i = 0; i < size && i < channels.length; i++) {
autoStyles.push( // seed generator using the claim_id
ChannelIconItem.AUTO_THUMB_STYLES[Math.floor(Math.random() * ChannelIconItem.AUTO_THUMB_STYLES.length)] const rng = seedrandom(channels[i].permanent_url); // is this efficient?
); const index = Math.floor(rng.quick() * ChannelIconItem.AUTO_THUMB_STYLES.length);
autoStyles.push(ChannelIconItem.AUTO_THUMB_STYLES[index]);
} }
return autoStyles; return autoStyles;
}; };
@ -170,13 +173,19 @@ export default class ChannelCreator extends React.PureComponent {
// should only be one or the other, so just default to cover // should only be one or the other, so just default to cover
const isCover = this.state.coverImagePickerOpen; const isCover = this.state.coverImagePickerOpen;
const fileUrl = `file://${evt.path}`; const fileUrl = `file://${evt.path}`;
// set the path to local url first, before uploading
if (isCover) {
this.setState({ coverImageUrl: fileUrl });
} else {
this.setState({ thumbnailUrl: fileUrl });
}
this.setState( this.setState(
{ {
uploadingImage: true, uploadingImage: true,
avatarImagePickerOpen: false, avatarImagePickerOpen: false,
coverImagePickerOpen: false, coverImagePickerOpen: false,
coverImageUrl: isCover ? fileUrl : '', // set the path to local url first, before uploading
thumbnailUrl: isCover ? '' : fileUrl, // same as above
}, },
() => { () => {
uploadImageAsset( uploadImageAsset(
@ -835,7 +844,7 @@ export default class ChannelCreator extends React.PureComponent {
<View style={channelCreatorStyle.channelInputLayout}> <View style={channelCreatorStyle.channelInputLayout}>
{(this.state.channelNameFocused || {(this.state.channelNameFocused ||
(this.state.newChannelName != null && this.state.newChannelName.trim().length > 0)) && ( (this.state.newChannelName != null && this.state.newChannelName.trim().length > 0)) && (
<Text style={channelCreatorStyle.textInputTitle}>Channel name</Text> <Text style={channelCreatorStyle.textInputTitle}>Channel</Text>
)} )}
<View> <View>
<Text style={channelCreatorStyle.channelAt}>@</Text> <Text style={channelCreatorStyle.channelAt}>@</Text>
@ -844,7 +853,7 @@ export default class ChannelCreator extends React.PureComponent {
style={channelCreatorStyle.channelNameInput} style={channelCreatorStyle.channelNameInput}
value={this.state.newChannelName} value={this.state.newChannelName}
onChangeText={value => this.handleNewChannelNameChange(value, true)} onChangeText={value => this.handleNewChannelNameChange(value, true)}
placeholder={this.state.channelNameFocused ? '' : 'Channel name'} placeholder={this.state.channelNameFocused ? '' : 'Channel'}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
onFocus={() => this.setState({ channelNameFocused: true })} onFocus={() => this.setState({ channelNameFocused: true })}
onBlur={() => this.setState({ channelNameFocused: false })} onBlur={() => this.setState({ channelNameFocused: false })}

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Lbry, normalizeURI } from 'lbry-redux'; import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { import {
ActivityIndicator, ActivityIndicator,
@ -587,9 +587,11 @@ class FilePage extends React.PureComponent {
} = this.props; } = this.props;
const { uri, autoplay } = navigation.state.params; const { uri, autoplay } = navigation.state.params;
console.log(channels);
const myChannelUris = channels ? channels.map(channel => channel.permanent_url) : []; const myChannelUris = channels ? channels.map(channel => channel.permanent_url) : [];
const ownedClaim = myClaimUris.includes(uri) || myChannelUris.includes(uri); const ownedClaim = myClaimUris.includes(uri) || myChannelUris.includes(uri);
const { claimName } = parseURI(uri);
const isChannel = claimName && claimName[0] === '@';
let innerContent = null; let innerContent = null;
if ((isResolvingUri && !claim) || !claim) { if ((isResolvingUri && !claim) || !claim) {
return ( return (
@ -604,7 +606,9 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.container}> <View style={filePageStyle.container}>
{ownedClaim && ( {ownedClaim && (
<Text style={filePageStyle.emptyClaimText}> <Text style={filePageStyle.emptyClaimText}>
It looks like you just claimed this address! Your content will appear in a few minutes. {isChannel
? 'It looks like you just created this channel. It will appear in a few minutes.'
: 'It looks you just published this content. It will appear in a few minutes.'}
</Text> </Text>
)} )}
{!ownedClaim && <Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>} {!ownedClaim && <Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>}
@ -616,7 +620,7 @@ class FilePage extends React.PureComponent {
} }
if (claim) { if (claim) {
if (claim && claim.name.length && claim.name[0] === '@') { if (isChannel) {
return <ChannelPage uri={uri} navigation={navigation} />; return <ChannelPage uri={uri} navigation={navigation} />;
} }

View file

@ -4,6 +4,9 @@ const autothumbStyle = StyleSheet.create({
autothumbPurple: { autothumbPurple: {
backgroundColor: '#9c27b0', backgroundColor: '#9c27b0',
}, },
autothumbDeepPurple: {
backgroundColor: '#5e35b1',
},
autothumbRed: { autothumbRed: {
backgroundColor: '#e53935', backgroundColor: '#e53935',
}, },
@ -34,6 +37,21 @@ const autothumbStyle = StyleSheet.create({
autothumbOrange: { autothumbOrange: {
backgroundColor: '#ffa726', backgroundColor: '#ffa726',
}, },
autothumbAmber: {
backgroundColor: '#ffb300',
},
autothumbLime: {
backgroundColor: '#c0ca33',
},
autothumbLightGreen: {
backgroundColor: '#7cb342',
},
autothumbDeepOrange: {
backgroundColor: '#f4511e',
},
autothumbBrown: {
backgroundColor: '#6d4c41',
},
}); });
export default autothumbStyle; export default autothumbStyle;