Compare commits

..
40 Commits
Author SHA1 Message Date
Akinwale Ariwodola ffb31fce16 Merge remote-tracking branch 'origin/reward-range' into rc-next 2019-09-13 18:25:01 +01:00
Akinwale Ariwodola 0cc2973792 Merge remote-tracking branch 'origin/publish-channel-selector' into rc-next 2019-09-13 18:24:43 +01:00
Akinwale Ariwodola 077a98a7e1 merge with channel-creator branch 2019-09-13 18:24:37 +01:00
Akinwale Ariwodola 0c6d17a1a2 persist publish form state 2019-09-13 18:22:06 +01:00
Akinwale Ariwodola ab9a7f183c remove future release warning 2019-09-13 08:51:46 +01:00
Akinwale Ariwodola 1678731601 fix channel selector issues on publish page 2019-09-13 08:48:33 +01:00
Akinwale Ariwodola 0115025b86 support reward range amount 2019-09-13 08:27:41 +01:00
Akinwale Ariwodola 34fa24ffd0 Channel creation and editing (#36) 2019-09-13 08:16:06 +01:00
Akinwale Ariwodola 78f2b4f3be use err.message conditionally, and isChannel from parseURI. 2019-09-13 08:14:24 +01:00
Akinwale Ariwodola 9e8ba95fec Merge pull request #41 from lbryio/autoclaim-rewards
auto claim eligible rewards after viewing a file
2019-09-12 07:20:02 +01:00
Akinwale Ariwodola d63253cc30 auto claim eligible rewards after viewing a file 2019-09-11 12:44:44 +01:00
Akinwale Ariwodola 0fe32e1a36 cleanup 2019-09-11 12:36:41 +01:00
Akinwale Ariwodola f008d95aa6 maintain form state when user navigates away 2019-09-11 12:32:54 +01:00
Akinwale Ariwodola 6ce143b145 Merge pull request #40 from lbryio/publish-currency
add currency selector on publish page
2019-09-11 09:07:34 +01:00
Akinwale Ariwodola c4218d9f8b channel creator updates after review 2019-09-11 08:22:56 +01:00
Akinwale Ariwodola c7ce7ea284 add currency selector on publish page 2019-09-10 13:23:34 +01:00
Akinwale Ariwodola 076122def4 Merge pull request #39 from lbryio/file-uploads
allow users to upload any file
2019-09-10 12:57:25 +01:00
Akinwale Ariwodola 625559528d allow users to upload any file 2019-09-09 16:26:50 +01:00
Akinwale Ariwodola e95786b904 do not list channels in pending abandon state 2019-09-09 15:33:48 +01:00
Akinwale Ariwodola f02fdd9979 channel creator updates 2019-09-09 11:14:53 +01:00
Akinwale Ariwodola 563a9135ce fix merge conflicts 2019-09-09 09:31:23 +01:00
Akinwale Ariwodola c88961002f canonical url and transform updates (#38)
* canonical url and transform updates
* account unlock after sync apply
* fix featured search item
* unlock after sync apply
* pin lbryinc commit
* fix featured search result item stuck loading
2019-09-06 19:43:47 +01:00
Akinwale Ariwodola decf0623fb better featured search result item handling (#37) 2019-09-05 15:57:27 +01:00
Akinwale Ariwodola c7f2b78b92 fixes as per review 2019-09-05 15:53:25 +01:00
Akinwale Ariwodola 47cf15741c better featured search result item handling 2019-09-02 14:15:48 +01:00
Akinwale Ariwodola 39eb2b1a96 fix tags for edit 2019-09-02 13:31:36 +01:00
Akinwale Ariwodola 2f0014be08 channel creator updates. upload image assets. 2019-09-02 13:03:58 +01:00
Akinwale Ariwodola 27c0ac7585 support optional parameters 2019-08-30 20:03:31 +01:00
Akinwale Ariwodola 44856e1ba1 channel creator page 2019-08-30 18:31:12 +01:00
Akinwale Ariwodola e74a419ffd cleanup 2019-08-27 07:10:09 +01:00
Akinwale Ariwodola 0c06f478c8 Merge pull request #35 from lbryio/filter-selectors
fix filter selectors getting stuck
2019-08-26 22:17:18 +01:00
Akinwale Ariwodola 9391c1b78c fix filter selectors getting stuck 2019-08-26 22:13:58 +01:00
Akinwale Ariwodola e902420269 fix: pin react-native-gesture-handler package 2019-08-26 21:17:38 +01:00
Akinwale Ariwodola dc0d3ad9b6 fix: not_tags and npm packages 2019-08-26 21:01:37 +01:00
Akinwale Ariwodola 1c70fc878a fix: buildURI calls 2019-08-26 20:39:51 +01:00
Akinwale Ariwodola 47cdf2698f tweak transaction history page 2019-08-25 17:41:37 +01:00
Akinwale Ariwodola cf5045cce3 tweak transaction list item 2019-08-25 17:34:26 +01:00
Akinwale Ariwodola e6139d59d9 edit published content (#32)
* edit published content
* fix: error from clicking post-publish link
* fixes from ui/ux review
2019-08-25 17:08:43 +01:00
Akinwale Ariwodola a45e9c5513 Merge pull request #33 from lbryio/fix-send-tip
send tip fix and tweaks
2019-08-25 16:37:40 +01:00
Akinwale Ariwodola 68d99ac639 setCurrentScreen tweaks 2019-08-25 16:35:51 +01:00
48 changed files with 2696 additions and 702 deletions

No files matched your search

+320 -397
View File
File diff suppressed because it is too large. Load diff
+6 -6
View File
@@ -12,8 +12,8 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#73f10d488d5fd5df7aa806b60c8df5c948ca3c9a",
"lbryinc": "lbryio/lbryinc#17868d948a160af27a375956226f8dd23fa2c37d",
"lbry-redux": "lbryio/lbry-redux#3133ea60b0302c162f7b6f67cc858997f1d2ab52",
"lbryinc": "lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",
"moment": "^2.22.1",
@@ -22,15 +22,14 @@
"@react-native-community/async-storage": "^1.5.1",
"react-native-camera": "^2.11.1",
"react-native-country-picker-modal": "^0.6.2",
"react-native-document-picker": "^2.3.0",
"react-native-exception-handler": "2.9.0",
"react-native-fast-image": "^6.1.1",
"react-native-fs": "^2.13.3",
"react-native-gesture-handler": "^1.1.0",
"react-native-gesture-handler": "1.1.0",
"react-native-image-zoom-viewer": "^2.2.5",
"react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input",
"react-native-reanimated": "^1.2.0",
"react-native-reanimated": "1.2.0",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
@@ -44,7 +43,8 @@
"redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.18",
"redux-thunk": "^2.3.0",
"rn-fetch-blob": "0.10.15"
"rn-fetch-blob": "0.10.15",
"seedrandom": "3.0.3"
},
"devDependencies": {
"@babel/core": "^7.5.4",
+9 -2
View File
@@ -1,5 +1,6 @@
import React from 'react';
import AboutPage from 'page/about';
import ChannelCreatorPage from 'page/channelCreator';
import DiscoverPage from 'page/discover';
import DownloadsPage from 'page/downloads';
import DrawerContent from 'component/drawerContent';
@@ -40,7 +41,7 @@ import {
} from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -159,6 +160,12 @@ const drawer = createDrawerNavigator(
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={drawerIconSize} style={{ color: tintColor }} />,
},
},
ChannelCreator: {
screen: ChannelCreatorPage,
navigationOptions: {
drawerIcon: ({ tintColor }) => <Icon name="at" size={drawerIconSize} style={{ color: tintColor }} />,
},
},
Publish: {
screen: PublishPage,
navigationOptions: {
@@ -413,7 +420,7 @@ class AppWithNavigationState extends React.Component {
);
}
} else {
dispatchNavigateToUri(dispatch, nav, evt.url);
dispatchNavigateToUri(dispatch, nav, transformUrl(evt.url));
}
}
};
+6 -1
View File
@@ -13,10 +13,15 @@ export default class ChannelIconItem extends React.PureComponent {
autothumbStyle.autothumbBlue,
autothumbStyle.autothumbLightBlue,
autothumbStyle.autothumbCyan,
autothumbStyle.autothumbTeal,
autothumbStyle.autothumbGreen,
autothumbStyle.autothumbYellow,
autothumbStyle.autothumbOrange,
autothumbStyle.autothumbDeepPurple,
autothumbStyle.autothumbAmber,
autothumbStyle.autothumbLime,
autothumbStyle.autothumbLightGreen,
autothumbStyle.autothumbDeepOrange,
autothumbStyle.autothumbBrown,
];
state = {
+13 -2
View File
@@ -26,10 +26,20 @@ export default class ChannelSelector extends React.PureComponent {
}
componentDidMount() {
const { channels, fetchChannelListMine, fetchingChannels } = this.props;
const { channels, channelName, fetchChannelListMine, fetchingChannels } = this.props;
if (!channels.length && !fetchingChannels) {
fetchChannelListMine();
}
this.setState({ currentSelectedValue: channelName });
}
componentWillReceiveProps(nextProps) {
const { channels: prevChannels = [], channelName } = this.props;
const { channels = [] } = nextProps;
if (channels.length !== prevChannels.length && channelName !== this.state.currentSelectedValue) {
this.setState({ currentSelectedValue: channelName });
}
}
handleCreateCancel = () => {
@@ -171,7 +181,7 @@ export default class ChannelSelector extends React.PureComponent {
render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel;
const { fetchingChannels, channels = [] } = this.props;
const { enabled, fetchingChannels, channels = [] } = this.props;
const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(channels.map(ch => ch.name));
const {
@@ -188,6 +198,7 @@ export default class ChannelSelector extends React.PureComponent {
return (
<View style={channelSelectorStyle.container}>
<Picker
enabled={enabled}
selectedValue={this.state.currentSelectedValue}
style={channelSelectorStyle.channelPicker}
itemStyle={channelSelectorStyle.channelPickerItem}
+7 -8
View File
@@ -11,14 +11,13 @@ import { selectShowNsfw } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import ClaimList from './view';
const select = (state, props) => {
return {
claimSearchByQuery: selectClaimSearchByQuery(state),
lastPageReached: selectClaimSearchByQueryLastPageReached(state),
loadingByQuery: selectFetchingClaimSearchByQuery(state),
loading: selectFetchingClaimSearch(state),
};
};
const select = state => ({
showNsfwContent: selectShowNsfw(state),
claimSearchByQuery: selectClaimSearchByQuery(state),
lastPageReached: selectClaimSearchByQueryLastPageReached(state),
loadingByQuery: selectFetchingClaimSearchByQuery(state),
loading: selectFetchingClaimSearch(state),
});
const perform = dispatch => ({
claimSearch: options => dispatch(doClaimSearch(options)),
+6 -3
View File
@@ -42,7 +42,6 @@ class ClaimList extends React.PureComponent {
tags: prevTags,
channelIds: prevChannelIds,
time: prevTime,
showNsfwContent,
} = prevProps;
const { claimSearchByQuery, orderBy, tags, channelIds, time } = this.props;
@@ -72,7 +71,7 @@ class ClaimList extends React.PureComponent {
}
buildClaimSearchOptions() {
const { orderBy = Constants.DEFAULT_ORDER_BY, channelIds, showNsfwContent, tags, time } = this.props;
const { orderBy, channelIds, showNsfwContent, tags, time } = this.props;
const { currentPage, subscriptionsView } = this.state;
const options = {
@@ -205,7 +204,11 @@ class ClaimList extends React.PureComponent {
const options = this.buildClaimSearchOptions();
const claimSearchKey = createNormalizedClaimSearchKey(options);
const uris = claimSearchByQuery[claimSearchKey];
let uris = claimSearchByQuery[claimSearchKey];
if (uris) {
uris = uris.filter(uri => uri && uri.length > 0);
}
if (Constants.ORIENTATION_VERTICAL === orientation) {
return (
+1
View File
@@ -12,6 +12,7 @@ const groupedMenuItems = {
{ icon: 'globe-americas', label: 'All content', route: Constants.DRAWER_ROUTE_TRENDING },
],
'Your content': [
{ icon: 'at', label: 'Channels', route: Constants.DRAWER_ROUTE_CHANNEL_CREATOR },
{ icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY },
{ icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES },
{ icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH },
+31 -31
View File
@@ -53,39 +53,39 @@ class FileList extends React.PureComponent<Props, State> {
dateNew: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
if (fileInfo1.pending) {
return -1;
}
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 0;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 0;
if (height1 > height2) {
return -1;
} else if (height1 < height2) {
return 1;
}
return 0;
})
if (fileInfo1.pending) {
return -1;
}
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 0;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 0;
if (height1 > height2) {
return -1;
} else if (height1 < height2) {
return 1;
}
return 0;
})
: [...fileInfos].reverse(),
dateOld: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 999999;
if (height1 < height2) {
return -1;
} else if (height1 > height2) {
return 1;
}
return 0;
})
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 999999;
if (height1 < height2) {
return -1;
} else if (height1 > height2) {
return 1;
}
return 0;
})
: fileInfos,
title: fileInfos =>
fileInfos.slice().sort((fileInfo1, fileInfo2) => {
@@ -160,7 +160,7 @@ class FileList extends React.PureComponent<Props, State> {
// This is unfortunate
// https://github.com/lbryio/lbry/issues/1159
const name = claimName || claimNameDownloaded;
uriParams.contentName = name;
uriParams.claimName = name;
uriParams.claimId = claimId;
const uri = buildURI(uriParams);
@@ -179,7 +179,7 @@ class FileList extends React.PureComponent<Props, State> {
style={fileListStyle.fileItem}
uri={item}
navigation={navigation}
showDetails={true}
showDetails
compactView={false}
/>
)}
+28 -4
View File
@@ -3,6 +3,7 @@ import { normalizeURI, parseURI } from 'lbry-redux';
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
import { navigateToUri, formatBytes } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -12,6 +13,10 @@ import ProgressBar from 'component/progressBar';
import fileListStyle from 'styles/fileList';
class FileListItem extends React.PureComponent {
state = {
url: null,
};
getStorageForFileInfo = fileInfo => {
if (!fileInfo.completed) {
const written = formatBytes(fileInfo.written_bytes);
@@ -41,9 +46,21 @@ class FileListItem extends React.PureComponent {
}
}
componentDidUpdate() {
const { claim, resolveUri, uri } = this.props;
if (!claim && uri !== this.state.url) {
this.setState({ url: uri }, () => resolveUri(uri));
}
}
defaultOnPress = () => {
const { autoplay, navigation, uri, shortUrl } = this.props;
navigateToUri(navigation, shortUrl || uri, { autoplay });
const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
if (featuredResult && !claim) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
} else {
navigateToUri(navigation, shortUrl || uri, { autoplay });
}
};
onPressHandler = () => {
@@ -111,7 +128,7 @@ class FileListItem extends React.PureComponent {
// shouldHide = 'channel' === claim.value_type;
}
if (shouldHide || (!isResolvingUri && !claim) || (featuredResult && !isResolvingUri && !claim && !title && !name)) {
if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
return null;
}
@@ -130,7 +147,7 @@ class FileListItem extends React.PureComponent {
style={fileListStyle.thumbnail}
duration={duration}
resizeMode="cover"
title={title || name}
title={title || name || normalizeURI(uri).substring(7)}
thumbnail={thumbnail}
/>
{selected && (
@@ -167,6 +184,13 @@ class FileListItem extends React.PureComponent {
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
</View>
)}
{featuredResult && !isResolving && !claim && (
<View style={fileListStyle.titleContainer}>
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
</View>
)}
{channel && !hideChannel && (
<Link
style={fileListStyle.publisher}
+16 -1
View File
@@ -13,6 +13,7 @@ type Props = {
id: string,
reward_title: string,
reward_amount: number,
reward_range?: string,
transaction_id: string,
created_at: string,
reward_description: string,
@@ -55,6 +56,20 @@ class RewardCard extends React.PureComponent<Props> {
});
};
getDisplayAmount = () => {
const { reward } = this.props;
if (reward) {
if (reward.reward_range && reward.reward_range.includes('-')) {
return reward.reward_range.split('-')[0] + '+'; // ex: 5+
} else if (reward.reward_amount > 0) {
return reward.reward_amount;
}
}
// unknown amount which normally shouldn't happen
return '?';
};
render() {
const { canClaim, isPending, onClaimPress, reward } = this.props;
const claimed = !!reward.transaction_id;
@@ -101,7 +116,7 @@ class RewardCard extends React.PureComponent<Props> {
)}
</View>
<View style={rewardStyle.rightCol}>
<Text style={rewardStyle.rewardAmount}>{reward.reward_amount}</Text>
<Text style={rewardStyle.rewardAmount}>{this.getDisplayAmount()}</Text>
<Text style={rewardStyle.rewardCurrency}>LBC</Text>
</View>
</TouchableOpacity>
+2 -1
View File
@@ -67,11 +67,12 @@ export default class TagSearch extends React.PureComponent {
};
render() {
const { name, style, type, selectedTags = [], showNsfwTags } = this.props;
const { editable, name, style, type, selectedTags = [], showNsfwTags } = this.props;
return (
<View>
<TextInput
editable={editable}
style={tagStyle.searchInput}
placeholder={'Search for more tags'}
underlineColorAndroid={Colors.NextLbryGreen}
@@ -19,11 +19,12 @@ class TransactionListItem extends React.PureComponent {
return (
<View style={transactionListStyle.listItem}>
<View style={[transactionListStyle.row, transactionListStyle.topRow]}>
<View style={transactionListStyle.col}>
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<Text style={transactionListStyle.text}>{this.capitalize(type)}</Text>
{name && claimId && (
<Link
style={transactionListStyle.link}
numberOfLines={1}
onPress={() => navigateToUri(navigation, buildURI({ claimName: name, claimId }))}
text={name}
/>
@@ -37,7 +38,7 @@ class TransactionListItem extends React.PureComponent {
</View>
</View>
<View style={transactionListStyle.row}>
<View style={transactionListStyle.col}>
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<Link
style={transactionListStyle.smallLink}
text={txid.substring(0, 8)}
+28 -6
View File
@@ -2,7 +2,7 @@
import React from 'react';
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { navigateToUri } from 'utils/helper';
import { navigateToUri, transformUrl } from 'utils/helper';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import UriBarItem from './internal/uri-bar-item';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -109,12 +109,19 @@ class UriBar extends React.PureComponent {
handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
if (this.state.inputText) {
let inputText = this.state.inputText;
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
let inputText = this.state.inputText,
inputTextIsUrl = false;
if (inputText.startsWith('lbry://')) {
const transformedUrl = transformUrl(inputText);
// if it's a URI (lbry://...), open the file page
const uri = normalizeURI(inputText);
navigateToUri(navigation, uri);
} else {
if (transformedUrl && isURIValid(transformedUrl)) {
inputTextIsUrl = true;
navigateToUri(navigation, transformedUrl);
}
}
// couldn't parse the inputText as a URL for some reason, so do a search instead
if (!inputTextIsUrl) {
updateSearchQuery(inputText);
// Not a URI, default to a search request
if (onSearchSubmitted) {
@@ -135,9 +142,11 @@ class UriBar extends React.PureComponent {
render() {
const {
allowEdit,
belowOverlay,
navigation,
onExitSelectionMode,
onEditActionPressed,
onDeleteActionPressed,
query,
selectedItemCount,
@@ -175,6 +184,19 @@ class UriBar extends React.PureComponent {
</View>
<View style={uriBarStyle.selectionModeActions}>
{allowEdit && selectedItemCount === 1 && (
<TouchableOpacity
style={[uriBarStyle.actionTouchArea, uriBarStyle.leftAction]}
onPress={() => {
if (onEditActionPressed) {
onEditActionPressed();
}
}}
>
<Icon name="edit" size={20} style={uriBarStyle.actionIcon} />
</TouchableOpacity>
)}
<TouchableOpacity
style={uriBarStyle.actionTouchArea}
onPress={() => {
+15
View File
@@ -25,6 +25,9 @@ const Constants = {
PHASE_DETAILS: 'details',
PHASE_PUBLISH: 'publish',
PHASE_LIST: 'list',
PHASE_NEW: 'create',
CONTENT_TAB: 'content',
ABOUT_TAB: 'about',
@@ -56,6 +59,11 @@ const Constants = {
ACTION_SORT_BY_ITEM_CHANGED: 'SORT_BY_ITEM_CHANGED',
ACTION_TIME_ITEM_CHANGED: 'TIME_ITEM_CHANGED',
ACTION_UPDATE_PUBLISH_FORM_STATE: 'UPDATE_PUBLISH_FORM_STATE',
ACTION_UPDATE_CHANNEL_FORM_STATE: 'UPDATE_CHANNEL_FORM_STATE',
ACTION_CLEAR_PUBLISH_FORM_STATE: 'CLEAR_PUBLISH_FORM_STATE',
ACTION_CLEAR_CHANNEL_FORM_STATE: 'CLEAR_CHANNEL_FORM_STATE',
ORIENTATION_HORIZONTAL: 'horizontal',
ORIENTATION_VERTICAL: 'vertical',
@@ -69,6 +77,7 @@ const Constants = {
DRAWER_ROUTE_SUBSCRIPTIONS: 'Subscriptions',
DRAWER_ROUTE_MY_LBRY: 'Downloads',
DRAWER_ROUTE_PUBLISH: 'Publish',
DRAWER_ROUTE_PUBLISH_FORM: 'PublishForm',
DRAWER_ROUTE_PUBLISHES: 'Publishes',
DRAWER_ROUTE_REWARDS: 'Rewards',
DRAWER_ROUTE_WALLET: 'Wallet',
@@ -77,6 +86,8 @@ const Constants = {
DRAWER_ROUTE_SEARCH: 'Search',
DRAWER_ROUTE_TRANSACTION_HISTORY: 'TransactionHistory',
DRAWER_ROUTE_TAG: 'Tag',
DRAWER_ROUTE_CHANNEL_CREATOR: 'ChannelCreator',
DRAWER_ROUTE_CHANNEL_CREATOR_FORM: 'ChannnelCreatorForm',
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
FULL_ROUTE_NAME_WALLET: 'WalletStack',
@@ -146,4 +157,8 @@ export const DrawerRoutes = [
Constants.DRAWER_ROUTE_ABOUT,
Constants.DRAWER_ROUTE_SEARCH,
Constants.DRAWER_ROUTE_TRANSACTION_HISTORY,
Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
];
// sub-pages for main routes
export const InnerDrawerRoutes = [Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM, Constants.DRAWER_ROUTE_PUBLISH_FORM];
+2
View File
@@ -37,6 +37,7 @@ import FilesystemStorage from 'redux-persist-filesystem-storage';
import createCompressor from 'redux-persist-transform-compress';
import createFilter from 'redux-persist-transform-filter';
import moment from 'moment';
import formReducer from 'redux/reducers/form';
import drawerReducer from 'redux/reducers/drawer';
import settingsReducer from 'redux/reducers/settings';
import thunk from 'redux-thunk';
@@ -109,6 +110,7 @@ const reducers = persistCombineReducers(persistOptions, {
file: fileReducer,
fileInfo: fileInfoReducer,
filtered: filteredReducer,
form: formReducer,
homepage: homepageReducer,
nav: navigatorReducer,
notifications: notificationsReducer,
+14 -13
View File
@@ -43,21 +43,22 @@ class AboutPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('About');
if (NativeModules.VersionInfo) {
NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({ appVersion: version });
NativeModules.Firebase.setCurrentScreen('About').then(result => {
if (NativeModules.VersionInfo) {
NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({ appVersion: version });
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
});
Lbry.status().then(info => {
this.setState({
lbryId: info.installation_id,
Lbry.status().then(info => {
this.setState({
lbryId: info.installation_id,
});
});
});
+2 -2
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { doFetchClaimsByChannel, makeSelectClaimForUri } from 'lbry-redux';
import { makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
import { doPopDrawerStack } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer';
@@ -7,6 +7,7 @@ import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import ChannelPage from './view';
const select = (state, props) => ({
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(props.uri)(state),
drawerStack: selectDrawerStack(state),
sortByItem: selectSortByItem(state),
@@ -14,7 +15,6 @@ const select = (state, props) => ({
});
const perform = dispatch => ({
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
+64 -7
View File
@@ -2,6 +2,7 @@
import React from 'react';
import {
ActivityIndicator,
Alert,
Dimensions,
Image,
NativeModules,
@@ -159,10 +160,46 @@ class ChannelPage extends React.PureComponent {
);
};
onEditPressed = () => {
const { claim, navigation } = this.props;
if (claim) {
const { permanent_url: permanentUrl } = claim;
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
params: { editChannelUrl: permanentUrl },
});
}
};
onDeletePressed = () => {
const { abandonClaim, claim, navigation } = this.props;
if (claim) {
const { txid, nout } = claim;
// show confirm alert
Alert.alert(
__('Delete channel'),
__('Are you sure you want to delete this channel?'),
[
{ text: __('No') },
{
text: __('Yes'),
onPress: () => {
abandonClaim(txid, nout);
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR });
},
},
],
{ cancelable: true }
);
}
};
render() {
const { claim, navigation, uri, drawerStack, popDrawerStack, sortByItem, timeItem } = this.props;
const { channels, claim, navigation, uri, drawerStack, popDrawerStack, sortByItem, timeItem } = this.props;
const { name, permanent_url: permanentUrl } = claim;
const { autoStyle, showSortPicker, showTimePicker } = this.state;
const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false;
let thumbnailUrl,
coverUrl,
@@ -218,12 +255,32 @@ class ChannelPage extends React.PureComponent {
</View>
<View style={channelPageStyle.subscribeButtonContainer}>
<SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} />
<SubscribeNotificationButton
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]}
uri={fullUri}
name={name}
/>
{ownedChannel && (
<Button
style={channelPageStyle.actionButton}
theme={'light'}
icon={'edit'}
text={'Edit'}
onPress={this.onEditPressed}
/>
)}
{ownedChannel && (
<Button
style={channelPageStyle.deleteButton}
theme={'light'}
icon={'trash-alt'}
text={'Delete'}
onPress={this.onDeletePressed}
/>
)}
{!ownedChannel && <SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} />}
{!ownedChannel && (
<SubscribeNotificationButton
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]}
uri={fullUri}
name={name}
/>
)}
</View>
</View>
+49
View File
@@ -0,0 +1,49 @@
import { connect } from 'react-redux';
import {
selectAbandoningIds,
selectBalance,
selectMyChannelClaims,
selectFetchingMyChannels,
selectUpdatingChannel,
selectUpdateChannelError,
doAbandonClaim,
doFetchChannelListMine,
doCreateChannel,
doUpdateChannel,
doToast,
} from 'lbry-redux';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doUpdateChannelFormState, doClearChannelFormState } from 'redux/actions/form';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { selectChannelFormState } from 'redux/selectors/form';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import ChannelCreator from './view';
const select = state => ({
abandoningClaimIds: selectAbandoningIds(state),
channels: selectMyChannelClaims(state),
channelFormState: selectChannelFormState(state),
drawerStack: selectDrawerStack(state),
fetchingChannels: selectFetchingMyChannels(state),
balance: selectBalance(state),
updatingChannel: selectUpdatingChannel(state),
updateChannelError: selectUpdateChannelError(state),
});
const perform = dispatch => ({
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
notify: data => dispatch(doToast(data)),
clearChannelFormState: () => dispatch(doClearChannelFormState()),
createChannel: (name, amount, optionalParams) => dispatch(doCreateChannel(name, amount, optionalParams)),
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
updateChannel: params => dispatch(doUpdateChannel(params)),
updateChannelFormState: data => dispatch(doUpdateChannelFormState(data)),
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
});
export default connect(
select,
perform
)(ChannelCreator);
File diff suppressed because it is too large. Load diff
+12 -2
View File
@@ -1,6 +1,8 @@
import { connect } from 'react-redux';
import {
doFetchFileInfo,
doFetchChannelListMine,
doFetchClaimListMine,
doFileGet,
doPurchaseUri,
doDeletePurchasedUri,
@@ -18,11 +20,14 @@ import {
makeSelectThumbnailForUri,
makeSelectTitleForUri,
selectBalance,
selectMyChannelClaims,
selectMyClaimUrisWithoutChannels,
selectPurchasedUris,
selectFailedPurchaseUris,
selectPurchaseUriErrorMessage,
} from 'lbry-redux';
import {
doClaimEligiblePurchaseRewards,
doFetchCostInfoForUri,
makeSelectCostInfoForUri,
selectRewardContentClaimIds,
@@ -44,20 +49,22 @@ const select = (state, props) => {
return {
balance: selectBalance(state),
blackListedOutpoints: selectBlackListedOutpoints(state),
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(selectProps.uri)(state),
drawerStack: selectDrawerStack(state),
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
//obscureNsfw: !selectShowNsfw(state),
//tab: makeSelectCurrentParam('tab')(state),
// obscureNsfw: !selectShowNsfw(state),
// tab: makeSelectCurrentParam('tab')(state),
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
position: makeSelectContentPositionForUri(selectProps.uri)(state),
purchasedUris: selectPurchasedUris(state),
failedPurchaseUris: selectFailedPurchaseUris(state),
myClaimUris: selectMyClaimUrisWithoutChannels(state),
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
@@ -66,11 +73,14 @@ const select = (state, props) => {
};
const perform = dispatch => ({
claimEligibleRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
},
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
notify: data => dispatch(doToast(data)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
+49 -16
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { Lbry, normalizeURI } from 'lbry-redux';
import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
import { Lbryio } from 'lbryinc';
import {
ActivityIndicator,
@@ -100,7 +100,7 @@ class FilePage extends React.PureComponent {
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted);
const { fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
const { fetchChannelListMine, fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
const { uri, uriVars } = navigation.state.params;
this.setState({ uri, uriVars });
@@ -108,6 +108,7 @@ class FilePage extends React.PureComponent {
this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props);
fetchChannelListMine();
if (NativeModules.Firebase) {
NativeModules.Firebase.track('open_file_page', { uri: uri });
@@ -232,6 +233,11 @@ class FilePage extends React.PureComponent {
}
};
onEditPressed = () => {
const { claim, navigation } = this.props;
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
};
onDeletePressed = () => {
const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props;
@@ -244,11 +250,11 @@ class FilePage extends React.PureComponent {
text: 'Yes',
onPress: () => {
const { uri } = navigation.state.params;
deleteFile(`${claim.txid}:${claim.nout}`, true);
deletePurchasedUri(uri);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.deleteDownload(uri);
}
NativeModules.UtilityModule.deleteDownload(uri);
this.setState({
downloadPressed: false,
fileViewLogged: false,
@@ -472,6 +478,7 @@ class FilePage extends React.PureComponent {
return;
}
const { claimEligibleRewards } = this.props;
const { nout, claim_id: claimId, txid } = claim;
const outpoint = `${txid}:${nout}`;
const params = {
@@ -483,7 +490,9 @@ class FilePage extends React.PureComponent {
params.time_to_start = timeToStart;
}
Lbryio.call('file', 'view', params).catch(() => {});
Lbryio.call('file', 'view', params)
.then(() => claimEligibleRewards())
.catch(() => {});
this.setState({ fileViewLogged: true });
};
@@ -562,6 +571,7 @@ class FilePage extends React.PureComponent {
const {
balance,
claim,
channels,
channelUri,
costInfo,
fileInfo,
@@ -571,6 +581,7 @@ class FilePage extends React.PureComponent {
rewardedContentClaimIds,
isResolvingUri,
blackListedOutpoints,
myClaimUris,
navigation,
position,
purchaseUri,
@@ -579,6 +590,10 @@ class FilePage extends React.PureComponent {
} = this.props;
const { uri, autoplay } = navigation.state.params;
const myChannelUris = channels ? channels.map(channel => channel.permanent_url) : [];
const ownedClaim = myClaimUris.includes(uri) || myChannelUris.includes(uri);
const { isChannel } = parseURI(uri);
let innerContent = null;
if ((isResolvingUri && !claim) || !claim) {
return (
@@ -591,7 +606,14 @@ class FilePage extends React.PureComponent {
)}
{claim === null && !isResolvingUri && (
<View style={filePageStyle.container}>
<Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>
{ownedClaim && (
<Text style={filePageStyle.emptyClaimText}>
{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>
)}
{!ownedClaim && <Text style={filePageStyle.emptyClaimText}>There's nothing at this location.</Text>}
</View>
)}
<UriBar value={uri} navigation={navigation} />
@@ -600,7 +622,7 @@ class FilePage extends React.PureComponent {
}
if (claim) {
if (claim && claim.name.length && claim.name[0] === '@') {
if (isChannel) {
return <ChannelPage uri={uri} navigation={navigation} />;
}
@@ -643,19 +665,20 @@ class FilePage extends React.PureComponent {
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, signing_channel: signingChannel, value } = claim;
const channelName = signingChannel && signingChannel.name;
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const canSendTip = this.state.tipAmount > 0;
const fullUri = `${claim.name}#${claim.claim_id}`;
const canEdit = myClaimUris.includes(normalizeURI(fullUri));
const showActions =
fileInfo &&
fileInfo.download_path &&
(canEdit || (fileInfo && fileInfo.download_path)) &&
!this.state.fullscreenMode &&
!this.state.showImageViewer &&
!this.state.showWebView;
const showFileActions =
fileInfo &&
fileInfo.download_path &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const canSendTip = this.state.tipAmount > 0;
const fullUri = `${claim.name}#${claim.claim_id}`;
canEdit ||
(fileInfo &&
fileInfo.download_path &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)));
const fullChannelUri =
channelClaimId && channelClaimId.trim().length > 0
? normalizeURI(`${channelName}#${channelClaimId}`)
@@ -826,6 +849,16 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.actions}>
{showFileActions && (
<View style={filePageStyle.fileActions}>
{canEdit && (
<Button
style={[filePageStyle.actionButton, filePageStyle.editButton]}
theme={'light'}
icon={'edit'}
text={'Edit'}
onPress={this.onEditPressed}
/>
)}
{completed && (
<Button
style={filePageStyle.actionButton}
+1 -1
View File
@@ -46,7 +46,7 @@ const perform = dispatch => ({
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
});
+22 -10
View File
@@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
isEmailVerified: false,
skipAccountConfirmed: false,
showBottomContainer: false,
walletPassword: null,
walletPassword: '',
syncApplyStarted: false,
};
@@ -45,14 +45,13 @@ class FirstRunScreen extends React.PureComponent {
});
if (NativeModules.FirstRun) {
NativeModules.Firebase.setCurrentScreen('First Run');
NativeModules.FirstRun.isFirstRun().then(firstRun => {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
this.setState({ isFirstRun: firstRun });
if (firstRun) {
NativeModules.Firebase.setCurrentScreen('First Run');
this.setState({ currentPage: FirstRunScreen.pages[0] });
} else {
// Not the first run. Navigate to the splash screen right away
@@ -87,12 +86,25 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true });
} else {
// password successfully verified
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
}
setDefaultAccount();
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
this.closeFinalPage();
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet
Lbry.account_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' })
.then(() => this.closeFinalPage())
.catch(err =>
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })
);
},
err => {
notify({
message:
'The account restore operation could not be completed successfully. Please restart the app and try again.',
});
}
);
}
}
@@ -254,7 +266,7 @@ class FirstRunScreen extends React.PureComponent {
};
onWalletPasswordChanged = password => {
this.setState({ walletPassword: password });
this.setState({ walletPassword: password !== null ? password : '' });
};
onWalletViewLayout = () => {
+10 -2
View File
@@ -8,22 +8,30 @@ import {
selectBalance,
selectPublishFormValues,
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { doUpdatePublishFormState, doClearPublishFormState } from 'redux/actions/form';
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectPublishFormState } from 'redux/selectors/form';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PublishPage from './view';
const select = state => ({
balance: selectBalance(state),
drawerStack: selectDrawerStack(state),
publishFormState: selectPublishFormState(state),
publishFormValues: selectPublishFormValues(state),
});
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
clearPublishFormState: () => dispatch(doClearPublishFormState()),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
uploadThumbnail: (filePath, fsAdapter) => dispatch(doUploadThumbnail(filePath, null, fsAdapter)),
publish: (success, fail) => dispatch(doPublish(success, fail)),
resolveUri: uri => dispatch(doResolveUri(uri)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)),
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
});
+330 -116
View File
@@ -18,13 +18,14 @@ import { FlatGrid } from 'react-native-super-grid';
import {
isNameValid,
buildURI,
normalizeURI,
parseURI,
regexInvalidURI,
CLAIM_VALUES,
LICENSES,
MATURE_TAGS,
THUMBNAIL_STATUSES,
} from 'lbry-redux';
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';
import { RNCamera } from 'react-native-camera';
import { generateCombination } from 'gfycat-style-urls';
import RNFS from 'react-native-fs';
@@ -42,7 +43,7 @@ import Tag from 'component/tag';
import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import __ from 'utils/helper';
import { __, navigateToUri } from 'utils/helper';
const languages = {
en: 'English',
@@ -76,7 +77,10 @@ class PublishPage extends React.PureComponent {
camera = null;
state = {
canPublish: false,
canUseCamera: false,
documentPickerOpen: false,
editMode: false,
titleFocused: false,
descriptionFocused: false,
loadingVideos: false,
@@ -107,6 +111,7 @@ class PublishPage extends React.PureComponent {
priceSet: false,
// input data
hasEditedContentAddress: false,
bid: 0.1,
description: null,
title: null,
@@ -114,13 +119,14 @@ class PublishPage extends React.PureComponent {
license: LICENSES.NONE,
licenseUrl: '',
otherLicenseDescription: '',
mature: false,
name: null,
price: 0,
currency: 'LBC',
uri: null,
tags: [],
selectedChannel: null,
uploadedThumbnailUri: null,
vanityUrlSet: false,
// other
publishStarted: false,
@@ -133,6 +139,8 @@ class PublishPage extends React.PureComponent {
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
DeviceEventEmitter.addListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.addListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled);
}
componentWillUnmount() {
@@ -141,6 +149,8 @@ class PublishPage extends React.PureComponent {
}
DeviceEventEmitter.removeListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.removeListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.removeListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.removeListener('onDocumentPickerCanceled', this.onPickerCanceled);
}
handleGalleryThumbnailChecked = evt => {
@@ -157,20 +167,110 @@ class PublishPage extends React.PureComponent {
this.setState({ allThumbnailsChecked: true });
};
loadPendingFormState = () => {
const { publishFormState } = this.props;
const advancedMode = publishFormState.license;
this.setState({ ...publishFormState, advancedMode });
};
onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Publish');
const { balance, pushDrawerStack, setPlayerVisible, navigation } = this.props;
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
console.log(navigation.state.params);
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
setPlayerVisible();
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState(
{
canPublish: balance >= 0.1,
loadingVideos: true,
},
() => {
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos, loadingVideos: false }));
}
);
// Check if this is an edit action
if (navigation.state.params) {
const { displayForm, editMode, claimToEdit, vanityUrl } = navigation.state.params;
if (editMode) {
this.prepareEdit(claimToEdit);
} else if (vanityUrl) {
const { claimName } = parseURI(vanityUrl);
this.setState({
name: claimName,
hasEditedContentAddress: true,
vanityUrlSet: true,
});
} else if (displayForm) {
this.loadPendingFormState();
this.setState({ currentPhase: Constants.PHASE_DETAILS }, () =>
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
);
}
}
});
};
prepareEdit = claim => {
const { pushDrawerStack } = this.props;
const { amount, name, signing_channel: signingChannel, value } = claim;
const { description, fee, languages, license, license_url: licenseUrl, tags, thumbnail, title } = value;
let channelName;
if (signingChannel) {
channelName = signingChannel.name;
}
const thumbnailUrl = thumbnail ? thumbnail.url : null;
// Determine the license
let licenseType, otherLicenseDescription;
if (!LICENSES.CC_LICENSES.some(({ value }) => value === license)) {
if (!license || license === LICENSES.NONE || license === LICENSES.PUBLIC_DOMAIN) {
licenseType = license;
} else if (license && !licenseUrl && license !== LICENSES.NONE) {
licenseType = LICENSES.COPYRIGHT;
} else {
licenseType = LICENSES.OTHER;
}
otherLicenseDescription = license;
} else {
licenseType = license;
}
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState(
{
loadingVideos: true,
editMode: true,
currentPhase: Constants.PHASE_DETAILS,
hasEditedContentAddress: true,
bid: amount,
channelName,
description,
language: languages && languages.length > 0 ? languages[0] : 'en', // default to English
license: licenseType,
licenseUrl,
otherLicenseDescription,
name,
currency: fee && fee.currency ? fee.currency : 'LBC',
price: fee && fee.amount ? fee.amount : 0,
priceSet: fee && fee.amount > 0,
tags: tags && tags.length > 0 ? tags : [],
title,
currentThumbnailUri: thumbnailUrl,
uploadedThumbnailUri: thumbnailUrl,
vanityUrlSet: false,
},
() => {
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos, loadingVideos: false }));
this.handleNameChange(name);
if (channelName) {
this.handleChannelChange(channelName);
}
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
}
);
};
@@ -184,7 +284,7 @@ class PublishPage extends React.PureComponent {
// We are only going to store the full uri, but we need to resolve the uri with and without the channel name
let uri;
try {
uri = buildURI({ contentName: name, channelName });
uri = buildURI({ claimName: name, channelName });
} catch (e) {
// something wrong with channel or name
}
@@ -192,7 +292,7 @@ class PublishPage extends React.PureComponent {
if (uri) {
if (channelName) {
// resolve without the channel name so we know the winning bid for it
const uriLessChannel = buildURI({ contentName: name });
const uriLessChannel = buildURI({ claimName: name });
resolveUri(uriLessChannel);
}
resolveUri(uri);
@@ -209,15 +309,16 @@ class PublishPage extends React.PureComponent {
handlePublishPressed = () => {
const { notify, publish, updatePublishForm } = this.props;
const {
editMode,
bid,
channelName,
currentMedia,
currency,
description,
language,
license,
licenseUrl,
otherLicenseDescription,
mature,
name,
price,
priceSet,
@@ -237,28 +338,32 @@ class PublishPage extends React.PureComponent {
return;
}
if (!currentMedia && !editMode) {
// sanity check. normally shouldn't happen
notify({ message: 'No file selected. Please select a video or take a photo before publishing.' });
return;
}
const publishParams = {
filePath: currentMedia.filePath,
filePath: currentMedia ? currentMedia.filePath : null,
bid: bid || 0.1,
title: title || '',
thumbnail,
description: description || '',
language,
license,
licenseType: license,
licenseUrl,
otherLicenseDescription,
name: name || undefined,
contentIsFree: !priceSet,
fee: { currency: 'LBC', amount: price },
fee: { currency, amount: price },
uri: uri || undefined,
channel: CLAIM_VALUES.CHANNEL_ANONYMOUS === channelName ? null : channelName,
isStillEditing: false,
claim: {
value: {
tags,
release_time: Math.round(Date.now() / 1000), // set now as the release time
},
},
tags: tags.map(tag => {
return { name: tag };
}),
};
updatePublishForm(publishParams);
@@ -266,7 +371,11 @@ class PublishPage extends React.PureComponent {
};
handlePublishSuccess = data => {
this.setState({ publishStarted: false, currentPhase: Constants.PHASE_PUBLISH });
const { navigation, notify } = this.props;
notify({
message: `Your content was successfully published to ${this.state.uri}. It will be available in a few mintues.`,
});
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISHES, params: { publishSuccess: true } });
};
handlePublishFailure = error => {
@@ -280,8 +389,8 @@ class PublishPage extends React.PureComponent {
}
componentWillReceiveProps(nextProps) {
const { currentRoute, publishFormValues } = nextProps;
const { currentRoute: prevRoute, notify } = this.props;
const { currentRoute: prevRoute, drawerStack: prevDrawerStack, notify, updatePublishFormState } = this.props;
const { currentRoute, drawerStack, publishFormValues } = nextProps;
if (Constants.DRAWER_ROUTE_PUBLISH === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
@@ -289,24 +398,42 @@ class PublishPage extends React.PureComponent {
if (publishFormValues) {
if (publishFormValues.thumbnail && !this.state.uploadedThumbnailUri) {
this.setState({
currentThumbnailUri: publishFormValues.thumbnail,
uploadedThumbnailUri: publishFormValues.thumbnail,
});
const { thumbnail } = publishFormValues;
updatePublishFormState({ currentThumbnailUri: thumbnail, uploadedThumbnailUri: thumbnail });
this.setState({ currentThumbnailUri: thumbnail, uploadedThumbnailUri: thumbnail });
}
}
if (
this.state.currentPhase === Constants.PHASE_DETAILS &&
prevDrawerStack[prevDrawerStack.length - 1].route === Constants.DRAWER_ROUTE_PUBLISH_FORM &&
drawerStack[drawerStack.length - 1].route === Constants.DRAWER_ROUTE_PUBLISH
) {
// navigated back from the form
this.showSelector();
}
}
setCurrentMedia(media) {
const { pushDrawerStack, updatePublishFormState } = this.props;
const name = generateCombination(2, ' ', true);
const newName = this.state.hasEditedContentAddress ? this.state.name : this.formatNameForTitle(name);
updatePublishFormState({ currentMedia: media, name: newName });
this.setState(
{
currentMedia: media,
title: name,
name: this.formatNameForTitle(name),
title: null, // no title autogeneration (user will fill this in)
name: newName,
currentPhase: Constants.PHASE_DETAILS,
},
() => this.handleNameChange(this.state.name)
() => {
this.handleNameChange(this.state.name);
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
if (!this.state.editMode) {
// overwrite media with previous?
this.loadPendingFormState();
}
}
);
}
@@ -320,6 +447,8 @@ class PublishPage extends React.PureComponent {
this.setState(
{
publishStarted: false,
documentPickerOpen: false,
editMode: false,
currentMedia: null,
currentThumbnailUri: null,
@@ -334,6 +463,7 @@ class PublishPage extends React.PureComponent {
priceSet: false,
// input data
hasEditedContentAddress: false,
bid: 0.1,
description: null,
title: null,
@@ -347,6 +477,8 @@ class PublishPage extends React.PureComponent {
tags: [],
selectedChannel: null,
uploadedThumbnailUri: null,
vanityUrlSet: false,
},
() => {
// reset thumbnail
@@ -367,6 +499,36 @@ class PublishPage extends React.PureComponent {
}
};
handleUploadPressed = () => {
if (this.state.documentPickerOpen) {
return;
}
this.setState(
{
documentPickerOpen: true,
},
() => {
NativeModules.UtilityModule.openDocumentPicker('*/*');
}
);
};
onFilePicked = evt => {
this.setState({ documentPickerOpen: false }, () => {
const currentMedia = {
id: -1,
filePath: `file://${evt.path}`,
duration: 0,
};
this.setCurrentMedia(currentMedia);
});
};
onPickerCanceled = () => {
this.setState({ documentPickerOpen: false });
};
handleCloseCameraPressed = () => {
this.setState({ showCameraOverlay: false, videoRecordingMode: false });
};
@@ -376,6 +538,8 @@ class PublishPage extends React.PureComponent {
};
handleCameraActionPressed = () => {
const { pushDrawerStack } = this.props;
// check if it's video or photo mode
if (this.state.videoRecordingMode) {
if (this.state.recordingVideo) {
@@ -393,14 +557,17 @@ class PublishPage extends React.PureComponent {
duration: 0,
};
this.setCurrentMedia(currentMedia);
this.setState({
currentThumbnailUri: null,
updatingThumbnailUri: false,
currentPhase: Constants.PHASE_DETAILS,
showCameraOverlay: false,
videoRecordingMode: false,
recordingVideo: false,
});
this.setState(
{
currentThumbnailUri: null,
updatingThumbnailUri: false,
currentPhase: Constants.PHASE_DETAILS,
showCameraOverlay: false,
videoRecordingMode: false,
recordingVideo: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
);
});
}
} else {
@@ -414,13 +581,16 @@ class PublishPage extends React.PureComponent {
duration: 0,
};
this.setCurrentMedia(currentMedia);
this.setState({
currentPhase: Constants.PHASE_DETAILS,
currentThumbnailUri: null,
updatingThumbnailUri: false,
showCameraOverlay: false,
videoRecordingMode: false,
});
this.setState(
{
currentPhase: Constants.PHASE_DETAILS,
currentThumbnailUri: null,
updatingThumbnailUri: false,
showCameraOverlay: false,
videoRecordingMode: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)
);
});
}
};
@@ -433,18 +603,7 @@ class PublishPage extends React.PureComponent {
});
};
handleUploadPressed = () => {
DocumentPicker.show(
{
filetype: [DocumentPickerUtil.allFiles()],
},
(error, res) => {
if (!error) {
// console.log(res);
}
}
);
};
handleUploadPressed = () => {};
getRandomFileId = () => {
// generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails)
@@ -457,16 +616,25 @@ class PublishPage extends React.PureComponent {
};
handleBidChange = bid => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ bid });
this.setState({ bid });
};
handlePriceChange = price => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ price });
this.setState({ price });
};
handleNameChange = name => {
const { notify } = this.props;
handleNameChange = (name, userInput) => {
const { notify, updatePublishFormState } = this.props;
updatePublishFormState({ name });
this.setState({ name });
if (userInput) {
this.setState({ hasEditedContentAddress: true });
}
if (!isNameValid(name, false)) {
notify({ message: 'Your content address contains invalid characters' });
return;
@@ -477,22 +645,25 @@ class PublishPage extends React.PureComponent {
};
handleChannelChange = channel => {
const { updatePublishFormState } = this.props;
const { name } = this.state;
const uri = this.getNewUri(name, channel);
updatePublishFormState({ uri, channelName: channel, selectedChannel: channel });
this.setState({ uri, channelName: channel, selectedChannel: channel });
};
handleAddTag = tag => {
if (!tag) {
if (!tag || !this.state.canPublish || this.state.publishStarted) {
return;
}
const { notify } = this.props;
const { notify, updatePublishFormState } = this.props;
const { tags } = this.state;
const index = tags.indexOf(tag.toLowerCase());
if (index === -1) {
const newTags = tags.slice();
newTags.push(tag);
updatePublishFormState({ tags: newTags });
this.setState({ tags: newTags });
} else {
notify({ message: __(`You already added the "${tag}" tag.`) });
@@ -500,15 +671,17 @@ class PublishPage extends React.PureComponent {
};
handleRemoveTag = tag => {
if (!tag) {
if (!tag || !this.state.canPublish || this.state.publishStarted) {
return;
}
const { updatePublishFormState } = this.props;
const newTags = this.state.tags.slice();
const index = newTags.indexOf(tag.toLowerCase());
if (index > -1) {
newTags.splice(index, 1);
updatePublishFormState({ tags: newTags });
this.setState({ tags: newTags });
}
};
@@ -556,46 +729,65 @@ class PublishPage extends React.PureComponent {
};
handleTitleChange = title => {
this.setState(
{
title,
name: this.formatNameForTitle(title),
},
() => {
this.handleNameChange(this.state.name);
}
);
const { updatePublishFormState } = this.props;
updatePublishFormState({ title });
this.setState({ title });
if (!this.state.editMode && !this.state.hasEditedContentAddress) {
// only autogenerate url if the user has not yet edited the field
// also shouldn't change url in edit mode
this.setState(
{
name: this.formatNameForTitle(title),
},
() => {
this.handleNameChange(this.state.name);
}
);
}
};
handleCurrencyValueChange = currency => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ currency });
this.setState({ currency });
};
handleDescriptionChange = description => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ description });
this.setState({ description });
};
handleLanguageValueChange = language => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ language });
this.setState({ language });
};
handleLicenseValueChange = license => {
const { updatePublishFormState } = this.props;
const otherLicenseDescription = [LICENSES.COPYRIGHT, LICENSES.OTHER].includes(license)
? this.state.otherLicenseDescription
: '';
this.setState({
otherLicenseDescription,
license,
licenseUrl: LICENSES.CC_LICENSES.reduce((value, item) => {
if (typeof value === 'object') {
value = '';
}
if (license === item.value) {
value = item.url;
}
return value;
}),
const licenseUrl = LICENSES.CC_LICENSES.reduce((value, item) => {
if (typeof value === 'object') {
value = '';
}
if (license === item.value) {
value = item.url;
}
return value;
});
updatePublishFormState({ otherLicenseDescription, license, licenseUrl });
this.setState({ otherLicenseDescription, license, licenseUrl });
};
handleChangeLicenseDescription = otherLicenseDescription => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ otherLicenseDescription });
this.setState({ otherLicenseDescription });
};
@@ -639,12 +831,10 @@ class PublishPage extends React.PureComponent {
<Icon name="camera" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Take a photo</Text>
</TouchableOpacity>
{false && (
<TouchableOpacity style={publishStyle.upload} onPress={this.handleUploadPressed}>
<Icon name="file-upload" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Upload a file</Text>
</TouchableOpacity>
)}
<TouchableOpacity style={publishStyle.upload} onPress={this.handleUploadPressed}>
<Icon name="file-upload" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Upload a file</Text>
</TouchableOpacity>
</View>
</View>
</View>
@@ -685,9 +875,12 @@ class PublishPage extends React.PureComponent {
)}
</View>
);
} else if (Constants.PHASE_DETAILS === this.state.currentPhase && this.state.currentMedia) {
} else if (
Constants.PHASE_DETAILS === this.state.currentPhase &&
(this.state.editMode || this.state.currentMedia)
) {
const { currentMedia, currentThumbnailUri } = this.state;
if (!currentThumbnailUri) {
if (!currentThumbnailUri && !this.state.editMode) {
this.updateThumbnailUriForMedia(currentMedia);
}
content = (
@@ -699,16 +892,16 @@ class PublishPage extends React.PureComponent {
resizeMode={FastImage.resizeMode.contain}
source={{ uri: currentThumbnailUri }}
/>
</View>
)}
{balance < 0.1 && <PublishRewardsDriver navigation={navigation} />}
{this.state.uploadThumbnailStarted && !this.state.uploadedThumbnailUri && (
<View style={publishStyle.thumbnailUploadContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text>
{this.state.uploadThumbnailStarted && !this.state.uploadedThumbnailUri && (
<View style={publishStyle.thumbnailUploadContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text>
</View>
)}
</View>
)}
{!this.state.canPublish && <PublishRewardsDriver navigation={navigation} />}
<View style={publishStyle.card}>
<View style={publishStyle.textInputLayout}>
@@ -716,6 +909,7 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Title</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={this.state.titleFocused ? '' : 'Title'}
style={publishStyle.inputText}
value={this.state.title}
@@ -733,6 +927,8 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Description</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
multiline
placeholder={this.state.descriptionFocused ? '' : 'Description'}
style={publishStyle.inputText}
value={this.state.description}
@@ -764,7 +960,11 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Channel</Text>
<ChannelSelector onChannelChange={this.handleChannelChange} />
<ChannelSelector
enabled={this.state.canPublish && !this.state.publishStarted}
channelName={this.state.channelName}
onChannelChange={this.handleChannelChange}
/>
</View>
<View style={publishStyle.card}>
@@ -782,6 +982,7 @@ class PublishPage extends React.PureComponent {
{this.state.priceSet && (
<View style={[publishStyle.inputRow, publishStyle.priceInputRow]}>
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'}
keyboardType={'number-pad'}
style={publishStyle.priceInput}
@@ -790,27 +991,40 @@ class PublishPage extends React.PureComponent {
value={String(this.state.price)}
onChangeText={this.handlePriceChange}
/>
<Text style={publishStyle.currency}>LBC</Text>
<Picker
style={publishStyle.currencyPicker}
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.currency}
itemStyle={publishStyle.pickerItem}
onValueChange={this.handleCurrencyValueChange}
>
<Picker.Item label={'LBC'} value={'LBC'} />
<Picker.Item label={'USD'} value={'USD'} />
</Picker>
</View>
)}
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Content Address</Text>
<Text style={publishStyle.cardTitle}>Content address</Text>
<Text style={publishStyle.helpText}>
The address where people can find your content (ex. lbry://myvideo)
The address where people can find your content (ex. lbry://myvideo).
{this.state.editMode &&
' You cannot change this address while editing your content. If you wish to use a new address, please republish the content.'}
</Text>
<TextInput
editable={!this.state.editMode && this.state.canPublish && !this.state.publishStarted}
placeholder={'lbry://'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
value={this.state.name}
onChangeText={this.handleNameChange}
onChangeText={value => this.handleNameChange(value, true)}
/>
<View style={publishStyle.inputRow}>
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'}
style={publishStyle.priceInput}
underlineColorAndroid={Colors.NextLbryGreen}
@@ -830,6 +1044,7 @@ class PublishPage extends React.PureComponent {
<View>
<Text style={publishStyle.cardText}>Language</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.language}
style={publishStyle.picker}
itemStyle={publishStyle.pickerItem}
@@ -844,6 +1059,7 @@ class PublishPage extends React.PureComponent {
<View>
<Text style={publishStyle.cardText}>License</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.license}
style={publishStyle.picker}
itemStyle={publishStyle.pickerItem}
@@ -859,6 +1075,7 @@ class PublishPage extends React.PureComponent {
</Picker>
{[LICENSES.COPYRIGHT, LICENSES.OTHER].includes(this.state.license) && (
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'License description'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
@@ -879,13 +1096,6 @@ class PublishPage extends React.PureComponent {
/>
</View>
<View style={publishStyle.warning}>
<Text style={publishStyle.warningText}>
Please ensure that you have filled everything correctly as you cannot edit published content in this
release. This feature will be available in a future release.
</Text>
</View>
<View style={publishStyle.actionButtons}>
{(this.state.publishStarted || publishFormValues.publishing) && (
<View style={publishStyle.progress}>
@@ -901,8 +1111,8 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.rightActionButtons}>
<Button
style={publishStyle.publishButton}
disabled={balance < 0.1 || !this.state.uploadedThumbnailUri}
text="Publish"
disabled={!this.state.canPublish || !this.state.uploadedThumbnailUri}
text={this.state.editMode ? 'Save changes' : 'Publish'}
onPress={this.handlePublishPressed}
/>
</View>
@@ -917,7 +1127,11 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.successTitle}>Success!</Text>
<Text style={publishStyle.successText}>Congratulations! Your content was successfully uploaded.</Text>
<View style={publishStyle.successRow}>
<Link style={publishStyle.successUrl} text={this.state.uri} href={this.state.uri} />
<Link
style={publishStyle.successUrl}
text={this.state.uri}
onPress={() => navigateToUri(navigation, this.state.uri)}
/>
<TouchableOpacity
onPress={() => {
Clipboard.setString(this.state.uri);
+26 -6
View File
@@ -33,14 +33,23 @@ class PublishesPage extends React.PureComponent {
this.onComponentFocused();
}
componentWillReceiveProps(nextProps) {
const { currentRoute } = nextProps;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_PUBLISHES === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
}
onComponentFocused = () => {
const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Publishes');
fetchMyClaims();
checkPendingPublishes();
NativeModules.Firebase.setCurrentScreen('Publishes').then(result => {
fetchMyClaims();
checkPendingPublishes();
});
};
addOrRemoveItem = (uri, claim) => {
@@ -70,6 +79,16 @@ class PublishesPage extends React.PureComponent {
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} });
};
onEditActionPressed = () => {
const { navigation } = this.props;
const { selectedClaimsMap, selectedUris } = this.state;
// only 1 item can be edited (and edit button should be visible only if there is a single selection)
const claim = selectedClaimsMap[selectedUris[0]];
this.onExitSelectionMode();
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
};
onDeleteActionPressed = () => {
const { abandonClaim } = this.props;
const { selectedClaimsMap } = this.state;
@@ -103,11 +122,13 @@ class PublishesPage extends React.PureComponent {
return (
<View style={publishStyle.container}>
<UriBar
allowEdit
navigation={navigation}
selectionMode={selectionMode}
selectedItemCount={selectedUris.length}
onExitSelectionMode={this.onExitSelectionMode}
onDeleteActionPressed={this.onDeleteActionPressed}
onEditActionPressed={this.onEditActionPressed}
onExitSelectionMode={this.onExitSelectionMode}
/>
{fetching && (
<View style={publishStyle.centered}>
@@ -138,7 +159,6 @@ class PublishesPage extends React.PureComponent {
removeClippedSubviews
renderItem={({ item }) => (
<FileListItem
hideChannel
key={item}
uri={item}
style={publishStyle.listItem}
+11 -17
View File
@@ -37,16 +37,16 @@ class SearchPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible, query, search } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Search');
const searchQuery = query || this.getSearchQuery();
if (searchQuery && searchQuery.trim().length > 0) {
this.setState({
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
});
search(searchQuery);
}
NativeModules.Firebase.setCurrentScreen('Search').then(result => {
const searchQuery = query || this.getSearchQuery();
if (searchQuery && searchQuery.trim().length > 0) {
this.setState({
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
});
search(searchQuery);
}
});
};
componentDidMount() {
@@ -101,13 +101,7 @@ class SearchPage extends React.PureComponent {
const { currentUri } = this.state;
return (
<FileListItem
uri={currentUri}
featuredResult
style={searchStyle.featuredResultItem}
navigation={navigation}
onPress={() => navigateToUri(navigation, this.state.currentUri)}
/>
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
);
};
+5 -5
View File
@@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
import { decode as atob } from 'base-64';
import { navigateToUri } from 'utils/helper';
import { navigateToUri, transformUrl } from 'utils/helper';
import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
@@ -81,7 +81,7 @@ class SplashScreen extends React.PureComponent {
});
}
} else {
navigateToUri(navigation, launchUrl);
navigateToUri(navigation, transformUrl(launchUrl));
}
}
};
@@ -130,7 +130,7 @@ class SplashScreen extends React.PureComponent {
if (user && user.id && user.has_verified_email) {
// user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) {
if (walletPassword) {
getSync(walletPassword);
}
this.navigateToMain();
@@ -166,14 +166,14 @@ class SplashScreen extends React.PureComponent {
// For now, automatically unlock the wallet if a password is set so that downloads work
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
if (password && password.trim().length > 0) {
if (password) {
this.setState({
message: 'Unlocking account',
details: 'Decrypting wallet',
});
// unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password })
Lbry.account_unlock({ password: password || '' })
.then(() => {
this.setState({
message: testingNetwork,
+12 -8
View File
@@ -1,5 +1,6 @@
import React from 'react';
import { NativeModules, View, ScrollView, Text } from 'react-native';
import { ActivityIndicator, NativeModules, View, ScrollView, Text } from 'react-native';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import TransactionList from 'component/transactionList';
import UriBar from 'component/uriBar';
@@ -23,9 +24,9 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchTransactions, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Transaction History');
fetchTransactions();
NativeModules.Firebase.setCurrentScreen('Transaction History').then(result => {
fetchTransactions();
});
};
componentDidMount() {
@@ -44,13 +45,16 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchingTransactions, transactions, navigation } = this.props;
return (
<View>
<View style={walletStyle.container}>
<UriBar navigation={navigation} />
{fetchingTransactions && (
<View style={walletStyle.loadingContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={walletStyle.loadingText}>Loading transactions...</Text>
</View>
)}
<ScrollView style={walletStyle.transactionHistoryScroll}>
<View style={walletStyle.historyList}>
{fetchingTransactions && !transactions.length && (
<Text style={walletStyle.infoText}>Loading transactions...</Text>
)}
{!fetchingTransactions && transactions.length === 0 && (
<Text style={walletStyle.infoText}>No transactions to list.</Text>
)}
+6 -3
View File
@@ -45,9 +45,12 @@ class TrendingPage extends React.PureComponent {
}
onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible, navigation } = this.props;
const { pushDrawerStack, setPlayerVisible, navigation, sortByItem } = this.props;
const { filterForTags } = navigation.state.params ? navigation.state.params : { filterForTags: false };
this.setState({ currentTrendingForItem: TRENDING_FOR_ITEMS[filterForTags ? 1 : 0] });
this.setState({
currentTrendingForItem: TRENDING_FOR_ITEMS[filterForTags ? 1 : 0],
orderBy: getOrderBy(sortByItem),
});
pushDrawerStack(Constants.DRAWER_ROUTE_TRENDING, navigation.state.params);
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('All content');
@@ -110,7 +113,7 @@ class TrendingPage extends React.PureComponent {
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{sortByTop && <Text style={discoverStyle.pickerLabel}>in the</Text>}
{sortByTop && <Text style={discoverStyle.pickerLabel}>from</Text>}
{sortByTop && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
+3 -3
View File
@@ -29,7 +29,7 @@ import {
} from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import Constants from 'constants';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Verification from './view';
const select = state => ({
@@ -54,13 +54,13 @@ const select = state => ({
const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)),
addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)),
addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
@@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
import Button from 'component/button';
import Link from 'component/link';
import Colors from 'styles/colors';
import Constants from 'constants';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward';
@@ -62,11 +62,29 @@ class SyncVerifyPage extends React.PureComponent {
} else {
// password successfully verified
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password);
NativeModules.UtilityModule.setSecureValue(
Constants.KEY_FIRST_RUN_PASSWORD,
this.state.password ? this.state.password : ''
);
}
setDefaultAccount();
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
navigation.goBack();
setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet
Lbry.account_unlock({ password: this.state.password ? this.state.password : '' })
.then(() => navigation.goBack())
.catch(err =>
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })
);
},
err => {
notify({
message:
'The account restore operation could not be completed successfully. Please restart the app and try again.',
});
}
);
}
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ class WalletPage extends React.PureComponent {
const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) {
if (walletPassword) {
getSync(walletPassword);
}
});
+23
View File
@@ -0,0 +1,23 @@
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
export const doUpdatePublishFormState = publishFormValue => dispatch =>
dispatch({
type: Constants.ACTION_UPDATE_PUBLISH_FORM_STATE,
data: { ...publishFormValue },
});
export const doUpdateChannelFormState = channelFormValue => dispatch =>
dispatch({
type: Constants.ACTION_UPDATE_CHANNEL_FORM_STATE,
data: { ...channelFormValue },
});
export const doClearPublishFormState = () => dispatch =>
dispatch({
type: Constants.ACTION_CLEAR_PUBLISH_FORM_STATE,
});
export const doClearChannelFormState = () => dispatch =>
dispatch({
type: Constants.ACTION_CLEAR_CHANNEL_FORM_STATE,
});
+13 -1
View File
@@ -16,7 +16,19 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
const { routeName, params } = action.data;
const newStack = state.stack.slice();
if (routeName !== newStack[newStack.length - 1].route) {
const lastRoute = newStack[newStack.length - 1].route;
let canPushStack = routeName !== lastRoute;
if (
lastRoute === Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM &&
routeName === Constants.DRAWER_ROUTE_CHANNEL_CREATOR
) {
canPushStack = false;
}
if (lastRoute === Constants.DRAWER_ROUTE_PUBLISH_FORM && routeName === Constants.DRAWER_ROUTE_PUBLISH) {
canPushStack = false;
}
if (canPushStack) {
newStack.push({ route: routeName, params });
}
+49
View File
@@ -0,0 +1,49 @@
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
const reducers = {};
const defaultState = {
channelFormValues: {},
publishFormValues: {},
};
reducers[Constants.ACTION_UPDATE_PUBLISH_FORM_STATE] = (state, action) => {
const { data } = action;
const publishFormValues = Object.assign({}, state.publishFormValues);
const newPublishFormValues = Object.assign(publishFormValues, data);
return {
...state,
publishFormValues: newPublishFormValues,
};
};
reducers[Constants.ACTION_UPDATE_CHANNEL_FORM_STATE] = (state, action) => {
const { data } = action;
const channelFormValues = Object.assign({}, state.channelFormValues);
const newChannelFormValues = Object.assign(channelFormValues, data);
return {
...state,
channelFormValues: newChannelFormValues,
};
};
reducers[Constants.ACTION_CLEAR_PUBLISH_FORM_STATE] = state => {
return {
...state,
publishFormValues: {},
};
};
reducers[Constants.ACTION_CLEAR_CHANNEL_FORM_STATE] = state => {
return {
...state,
channelFormValues: {},
};
};
export default function reducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
return state;
}
+13
View File
@@ -0,0 +1,13 @@
import { createSelector } from 'reselect';
export const selectState = state => state.form || {};
export const selectPublishFormState = createSelector(
selectState,
state => state.publishFormValues || {}
);
export const selectChannelFormState = createSelector(
selectState,
state => state.channelFormValues || {}
);
+18
View File
@@ -4,6 +4,9 @@ const autothumbStyle = StyleSheet.create({
autothumbPurple: {
backgroundColor: '#9c27b0',
},
autothumbDeepPurple: {
backgroundColor: '#5e35b1',
},
autothumbRed: {
backgroundColor: '#e53935',
},
@@ -34,6 +37,21 @@ const autothumbStyle = StyleSheet.create({
autothumbOrange: {
backgroundColor: '#ffa726',
},
autothumbAmber: {
backgroundColor: '#ffb300',
},
autothumbLime: {
backgroundColor: '#c0ca33',
},
autothumbLightGreen: {
backgroundColor: '#7cb342',
},
autothumbDeepOrange: {
backgroundColor: '#f4511e',
},
autothumbBrown: {
backgroundColor: '#6d4c41',
},
});
export default autothumbStyle;
+261
View File
@@ -0,0 +1,261 @@
import { Dimensions, StyleSheet } from 'react-native';
import Colors from './colors';
const screenDimension = Dimensions.get('window');
const screenWidth = screenDimension.width;
const channelCreatorStyle = StyleSheet.create({
card: {
backgroundColor: Colors.White,
marginTop: 16,
marginLeft: 16,
marginRight: 16,
padding: 16,
},
container: {
flex: 1,
backgroundColor: Colors.PageBackground,
},
channelPicker: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
height: 52,
width: '100%',
},
bidRow: {
flexDirection: 'row',
alignItems: 'center',
},
label: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
channelNameInput: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
paddingLeft: 20,
},
bidAmountInput: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
marginLeft: 16,
textAlign: 'right',
width: 80,
},
helpText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 12,
},
channelTitleInput: {
marginBottom: 4,
},
createChannelContainer: {
marginTop: 60,
flex: 1,
},
channelAt: {
position: 'absolute',
left: 4,
top: 13,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
buttonContainer: {
marginTop: 24,
marginBottom: 16,
},
buttons: {
marginLeft: 16,
marginRight: 16,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
cancelLink: {
marginRight: 16,
},
createButton: {
backgroundColor: Colors.LbryGreen,
alignSelf: 'flex-end',
},
inlineError: {
fontFamily: 'Inter-UI-Regular',
fontSize: 12,
color: Colors.Red,
marginTop: 2,
},
imageSelectors: {
width: '100%',
height: 160,
},
coverImageTouchArea: {
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
},
coverImage: {
width: '100%',
height: '100%',
},
avatarImageContainer: {
position: 'absolute',
left: screenWidth / 2 - 80 / 2,
bottom: -16,
width: 80,
height: 80,
borderRadius: 160,
overflow: 'hidden',
},
avatarTouchArea: {
width: 80,
height: 80,
alignItems: 'center',
justifyContent: 'center',
},
avatarImage: {
width: '100%',
height: '100%',
},
listFooter: {
marginTop: 24,
},
createChannelButton: {
backgroundColor: Colors.LbryGreen,
alignSelf: 'flex-start',
},
scrollContainer: {
marginTop: 60,
marginLeft: 16,
marginRight: 16,
},
scrollPadding: {
paddingTop: 16,
},
channelListItem: {
flexDirection: 'row',
marginBottom: 16,
alignItems: 'center',
},
channelListTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 18,
marginBottom: 4,
},
channelListName: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
},
channelListAvatar: {
marginRight: 16,
width: 80,
height: 80,
borderRadius: 160,
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
},
selectedOverlay: {
position: 'absolute',
left: 0,
top: 0,
width: 80,
height: 80,
borderRadius: 160,
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#000000aa',
},
listHeader: {
alignItems: 'center',
marginTop: 16,
marginBottom: 16,
},
textInputLayout: {
marginBottom: 4,
},
textInputTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 12,
marginBottom: -10,
marginLeft: 4,
},
inputText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
toggleContainer: {
marginTop: 24,
alignItems: 'center',
justifyContent: 'flex-end',
},
modeLink: {
color: Colors.LbryGreen,
alignSelf: 'flex-end',
marginRight: 16,
},
cardTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 20,
marginBottom: 8,
},
tag: {
marginRight: 4,
marginBottom: 4,
},
tagList: {
flexDirection: 'row',
flexWrap: 'wrap',
},
editOverlay: {
alignItems: 'center',
justifyContent: 'center',
borderRadius: 24,
position: 'absolute',
padding: 8,
left: 4,
bottom: 4,
backgroundColor: '#00000077',
},
thumbnailEditOverlay: {
alignItems: 'center',
justifyContent: 'center',
borderRadius: 24,
position: 'absolute',
padding: 8,
left: 80 / 2 - 32 / 2,
bottom: 4,
backgroundColor: '#00000077',
},
editIcon: {
color: Colors.White,
fontFamily: 'Inter-UI-SemiBold',
fontSize: 12,
},
uploadProgress: {
alignItems: 'center',
borderRadius: 16,
flexDirection: 'row',
position: 'absolute',
top: 8,
right: 8,
backgroundColor: '#00000077',
paddingLeft: 8,
paddingRight: 8,
paddingTop: 4,
paddingBottom: 4,
justifyContent: 'center',
},
uploadText: {
color: Colors.White,
fontFamily: 'Inter-UI-SemiBold',
fontSize: 12,
marginLeft: 4,
},
});
export default channelCreatorStyle;
+4
View File
@@ -31,6 +31,7 @@ const channelPageStyle = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 24,
},
infoText: {
fontFamily: 'Inter-UI-Regular',
@@ -165,6 +166,9 @@ const channelPageStyle = StyleSheet.create({
claimListContent: {
paddingTop: 16,
},
actionButton: {
backgroundColor: Colors.White,
},
});
export default channelPageStyle;
+6 -2
View File
@@ -41,8 +41,8 @@ const filePageStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular',
textAlign: 'center',
fontSize: 20,
marginLeft: 16,
marginRight: 16,
marginLeft: 24,
marginRight: 24,
},
scrollContainer: {
flex: 1,
@@ -194,6 +194,10 @@ const filePageStyle = StyleSheet.create({
},
fileActions: {
alignSelf: 'flex-end',
flexDirection: 'row',
},
editButton: {
marginRight: 8,
},
socialActions: {
alignSelf: 'flex-start',
+23 -10
View File
@@ -86,7 +86,7 @@ const publishStyle = StyleSheet.create({
marginTop: 8,
},
photo: {
height: 240,
height: 120,
justifyContent: 'center',
alignItems: 'center',
},
@@ -156,6 +156,10 @@ const publishStyle = StyleSheet.create({
fontSize: 16,
marginLeft: 8,
},
listEmptyText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
},
titleRow: {
flexDirection: 'row',
justifyContent: 'space-between',
@@ -324,18 +328,24 @@ const publishStyle = StyleSheet.create({
marginLeft: 4,
},
thumbnailUploadContainer: {
marginTop: 16,
marginLeft: 16,
marginRight: 16,
paddingLeft: 2,
paddingRight: 2,
flexDirection: 'row',
alignItems: 'center',
borderRadius: 16,
flexDirection: 'row',
position: 'absolute',
top: 8,
right: 8,
backgroundColor: '#00000077',
paddingLeft: 8,
paddingRight: 8,
paddingTop: 4,
paddingBottom: 4,
justifyContent: 'center',
},
thumbnailUploadText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
marginLeft: 8,
color: Colors.White,
fontFamily: 'Inter-UI-SemiBold',
fontSize: 12,
marginLeft: 4,
},
toggleField: {
flexDirection: 'row',
@@ -362,6 +372,9 @@ const publishStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
currencyPicker: {
width: 100,
},
fullCentered: {
position: 'absolute',
left: 0,
+3
View File
@@ -17,6 +17,9 @@ const transactionListStyle = StyleSheet.create({
topRow: {
marginBottom: 4,
},
leftCol: {
flex: 0.7,
},
col: {
alignSelf: 'stretch',
},
+3
View File
@@ -98,6 +98,9 @@ const uriBarStyle = StyleSheet.create({
height: '100%',
alignItems: 'center',
},
leftAction: {
marginRight: 16,
},
actionTouchArea: {
height: '100%',
alignItems: 'center',
+17
View File
@@ -3,6 +3,7 @@ import Colors from './colors';
const walletStyle = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.PageBackground,
},
scrollContainer: {
@@ -288,6 +289,22 @@ const walletStyle = StyleSheet.create({
syncSwitch: {
marginLeft: 8,
},
loadingContainer: {
position: 'absolute',
flexDirection: 'row',
left: 0,
right: 0,
top: 60,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
},
loadingText: {
color: '#aaaaaa',
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
marginLeft: 8,
},
});
export default walletStyle;
+86 -8
View File
@@ -1,7 +1,7 @@
import { NavigationActions, StackActions } from 'react-navigation';
import { buildURI, isURIValid } from 'lbry-redux';
import { buildURI, isURIValid, normalizeURI } from 'lbry-redux';
import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants, { DrawerRoutes, InnerDrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
const tagNameLength = 10;
@@ -156,10 +156,26 @@ export function navigateBack(navigation, drawerStack, popDrawerStack) {
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route, params } = target;
navigation.goBack(navigation.state.key);
if (DrawerRoutes.indexOf(route) === -1 && isURIValid(route)) {
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route, null, true);
} else {
navigation.navigate({ routeName: route, params });
let targetRoute = route;
let targetParams = params;
if (InnerDrawerRoutes.includes(route)) {
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_CHANNEL_CREATOR;
} else if (Constants.DRAWER_ROUTE_PUBLISH_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_PUBLISH_FORM;
}
if (targetParams) {
targetParams.displayForm = true;
} else {
targetParams = { displayForm: true };
}
}
navigation.navigate({ routeName: targetRoute, targetParams });
}
}
@@ -169,14 +185,31 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route } = target;
dispatch(NavigationActions.back());
if (DrawerRoutes.indexOf(route) === -1 && isURIValid(route)) {
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
dispatchNavigateToUri(dispatch, nav, route, true);
} else {
const newTarget = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
let targetRoute = newTarget.route;
let targetParams = newTarget.params;
if (InnerDrawerRoutes.includes(targetRoute)) {
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_CHANNEL_CREATOR;
} else if (Constants.DRAWER_ROUTE_PUBLISH_FORM === route) {
targetRoute = Constants.DRAWER_ROUTE_PUBLISH_FORM;
}
if (targetParams) {
targetParams.displayForm = true;
} else {
targetParams = { displayForm: true };
}
}
const navigateAction = NavigationActions.navigate({
routeName: newTarget.route,
params: newTarget.params,
routeName: targetRoute,
params: targetParams,
});
dispatch(navigateAction);
}
}
@@ -184,7 +217,7 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
export function uriFromFileInfo(fileInfo) {
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo;
const uriParams = {};
uriParams.contentName = claimName || claimNameDownloaded;
uriParams.claimName = claimName || claimNameDownloaded;
uriParams.claimId = claimId;
return buildURI(uriParams);
}
@@ -246,7 +279,52 @@ export function getOrderBy(item) {
return orderBy;
}
// replace occurrences of ':' with '#' in a url (entered in the URI bar)
export function transformUrl(url) {
const start = 'lbry://'.length;
return normalizeURI(url.substring(start).replace(/:/g, '#'));
}
// i18n placeholder until we find a good react-native i18n module
export function __(str) {
return str;
}
export function uploadImageAsset(filePath, success, failure) {
const makeid = () => {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 24; i += 1) text += possible.charAt(Math.floor(Math.random() * 62));
return text;
};
const fileName = filePath.substring(filePath.lastIndexOf('/') + 1);
let fileExt = fileName.indexOf('.') > -1 ? fileName.substring(fileName.lastIndexOf('.') + 1).trim() : 0;
if (!fileExt) {
fileExt = 'jpg'; // default to jpg
}
const fileType = `image/${fileExt}`;
const data = new FormData();
const name = makeid();
data.append('name', name);
data.append('file', { uri: 'file://' + filePath, type: fileType, name: fileName });
return fetch('https://spee.ch/api/claim/publish', {
method: 'POST',
body: data,
})
.then(response => response.json())
.then(json => {
if (json.success) {
if (success) {
success({ url: `${json.data.url}.${fileExt}` });
}
}
})
.catch(err => {
if (failure) {
failure(err.message ? err.message : 'The image failed to upload.');
}
});
}