Compare commits

...
Author SHA1 Message Date
Akinwale Ariwodola 23cf8b15bc use react-navigation-stack module 2019-09-23 17:47:30 +01:00
Akinwale Ariwodola 76cc8eaea1 update react-navigation-drawer package 2019-09-23 16:43:54 +01:00
Akinwale Ariwodola f372b33f42 Publish UX (#44)
* persist publish form state
* better handling of pending form states
2019-09-20 10:29:37 +01:00
Akinwale Ariwodola a26fb3e06b fix channel selector issues on publish page (#43)
* fix channel selector issues on publish page
* remove future release warning
* fix channel creation error
2019-09-15 12:02:34 +01:00
Akinwale Ariwodola 8bd3bd21e8 Merge pull request #42 from lbryio/reward-range
support reward range amount
2019-09-15 11:45:41 +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 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 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 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 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 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
49 changed files with 2942 additions and 813 deletions

No files matched your search

+460 -463
View File
File diff suppressed because it is too large. Load diff
+8 -7
View File
@@ -12,8 +12,8 @@
"base-64": "^0.1.0", "base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0", "@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3", "gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#73f10d488d5fd5df7aa806b60c8df5c948ca3c9a", "lbry-redux": "lbryio/lbry-redux#123efacf4d45289ebda9dc291976d475de227a55",
"lbryinc": "lbryio/lbryinc#17868d948a160af27a375956226f8dd23fa2c37d", "lbryinc": "lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"lodash": ">=4.17.11", "lodash": ">=4.17.11",
"merge": ">=1.2.1", "merge": ">=1.2.1",
"moment": "^2.22.1", "moment": "^2.22.1",
@@ -22,21 +22,21 @@
"@react-native-community/async-storage": "^1.5.1", "@react-native-community/async-storage": "^1.5.1",
"react-native-camera": "^2.11.1", "react-native-camera": "^2.11.1",
"react-native-country-picker-modal": "^0.6.2", "react-native-country-picker-modal": "^0.6.2",
"react-native-document-picker": "^2.3.0",
"react-native-exception-handler": "2.9.0", "react-native-exception-handler": "2.9.0",
"react-native-fast-image": "^6.1.1", "react-native-fast-image": "^6.1.1",
"react-native-fs": "^2.13.3", "react-native-fs": "^2.13.3",
"react-native-gesture-handler": "^1.1.0", "react-native-gesture-handler": "1.3.0",
"react-native-image-zoom-viewer": "^2.2.5", "react-native-image-zoom-viewer": "^2.2.5",
"react-native-password-strength-meter": "^0.0.2", "react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input", "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-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0", "react-native-vector-icons": "^6.6.0",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android", "react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
"react-navigation": "^3.11.0", "react-navigation": "^3.11.0",
"react-navigation-drawer": "^2.0.0", "react-navigation-drawer": "^2.2.2",
"react-navigation-redux-helpers": "^3.0.2", "react-navigation-redux-helpers": "^3.0.2",
"react-navigation-stack": "^1.8.1",
"react-redux": "^5.0.3", "react-redux": "^5.0.3",
"redux": "^4.0.4", "redux": "^4.0.4",
"redux-persist": "^5.10.0", "redux-persist": "^5.10.0",
@@ -44,7 +44,8 @@
"redux-persist-transform-compress": "^4.2.0", "redux-persist-transform-compress": "^4.2.0",
"redux-persist-transform-filter": "0.0.18", "redux-persist-transform-filter": "0.0.18",
"redux-thunk": "^2.3.0", "redux-thunk": "^2.3.0",
"rn-fetch-blob": "0.10.15" "rn-fetch-blob": "0.10.15",
"seedrandom": "3.0.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.5.4", "@babel/core": "^7.5.4",
+12 -3
View File
@@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import AboutPage from 'page/about'; import AboutPage from 'page/about';
import ChannelCreatorPage from 'page/channelCreator';
import DiscoverPage from 'page/discover'; import DiscoverPage from 'page/discover';
import DownloadsPage from 'page/downloads'; import DownloadsPage from 'page/downloads';
import DrawerContent from 'component/drawerContent'; import DrawerContent from 'component/drawerContent';
@@ -17,8 +18,9 @@ import SubscriptionsPage from 'page/subscriptions';
import TransactionHistoryPage from 'page/transactionHistory'; import TransactionHistoryPage from 'page/transactionHistory';
import VerificationScreen from 'page/verification'; import VerificationScreen from 'page/verification';
import WalletPage from 'page/wallet'; import WalletPage from 'page/wallet';
import { createStackNavigator, NavigationActions } from 'react-navigation'; import { NavigationActions } from 'react-navigation';
import { createDrawerNavigator } from 'react-navigation-drawer'; import { createDrawerNavigator } from 'react-navigation-drawer';
import { createStackNavigator } from 'react-navigation-stack';
import { import {
createReduxContainer, createReduxContainer,
createReactNavigationReduxMiddleware, createReactNavigationReduxMiddleware,
@@ -40,7 +42,7 @@ import {
} from 'lbryinc'; } from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import { decode as atob } from 'base-64'; 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 AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -159,6 +161,12 @@ const drawer = createDrawerNavigator(
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={drawerIconSize} style={{ color: tintColor }} />, 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: { Publish: {
screen: PublishPage, screen: PublishPage,
navigationOptions: { navigationOptions: {
@@ -203,6 +211,7 @@ const drawer = createDrawerNavigator(
}, },
{ {
drawerWidth: 300, drawerWidth: 300,
drawerBackgroundColor: 'transparent',
headerMode: 'none', headerMode: 'none',
backBehavior: 'none', backBehavior: 'none',
unmountInactiveRoutes: true, unmountInactiveRoutes: true,
@@ -413,7 +422,7 @@ class AppWithNavigationState extends React.Component {
); );
} }
} else { } 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.autothumbBlue,
autothumbStyle.autothumbLightBlue, autothumbStyle.autothumbLightBlue,
autothumbStyle.autothumbCyan, autothumbStyle.autothumbCyan,
autothumbStyle.autothumbTeal,
autothumbStyle.autothumbGreen, autothumbStyle.autothumbGreen,
autothumbStyle.autothumbYellow, autothumbStyle.autothumbYellow,
autothumbStyle.autothumbOrange, autothumbStyle.autothumbOrange,
autothumbStyle.autothumbDeepPurple,
autothumbStyle.autothumbAmber,
autothumbStyle.autothumbLime,
autothumbStyle.autothumbLightGreen,
autothumbStyle.autothumbDeepOrange,
autothumbStyle.autothumbBrown,
]; ];
state = { state = {
+13 -2
View File
@@ -26,10 +26,20 @@ export default class ChannelSelector extends React.PureComponent {
} }
componentDidMount() { componentDidMount() {
const { channels, fetchChannelListMine, fetchingChannels } = this.props; const { channels, channelName, fetchChannelListMine, fetchingChannels } = this.props;
if (!channels.length && !fetchingChannels) { if (!channels.length && !fetchingChannels) {
fetchChannelListMine(); 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 = () => { handleCreateCancel = () => {
@@ -171,7 +181,7 @@ export default class ChannelSelector extends React.PureComponent {
render() { render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel; 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 pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(channels.map(ch => ch.name));
const { const {
@@ -188,6 +198,7 @@ export default class ChannelSelector extends React.PureComponent {
return ( return (
<View style={channelSelectorStyle.container}> <View style={channelSelectorStyle.container}>
<Picker <Picker
enabled={enabled}
selectedValue={this.state.currentSelectedValue} selectedValue={this.state.currentSelectedValue}
style={channelSelectorStyle.channelPicker} style={channelSelectorStyle.channelPicker}
itemStyle={channelSelectorStyle.channelPickerItem} 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 Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import ClaimList from './view'; import ClaimList from './view';
const select = (state, props) => { const select = state => ({
return { showNsfwContent: selectShowNsfw(state),
claimSearchByQuery: selectClaimSearchByQuery(state), claimSearchByQuery: selectClaimSearchByQuery(state),
lastPageReached: selectClaimSearchByQueryLastPageReached(state), lastPageReached: selectClaimSearchByQueryLastPageReached(state),
loadingByQuery: selectFetchingClaimSearchByQuery(state), loadingByQuery: selectFetchingClaimSearchByQuery(state),
loading: selectFetchingClaimSearch(state), loading: selectFetchingClaimSearch(state),
}; });
};
const perform = dispatch => ({ const perform = dispatch => ({
claimSearch: options => dispatch(doClaimSearch(options)), claimSearch: options => dispatch(doClaimSearch(options)),
+6 -3
View File
@@ -42,7 +42,6 @@ class ClaimList extends React.PureComponent {
tags: prevTags, tags: prevTags,
channelIds: prevChannelIds, channelIds: prevChannelIds,
time: prevTime, time: prevTime,
showNsfwContent,
} = prevProps; } = prevProps;
const { claimSearchByQuery, orderBy, tags, channelIds, time } = this.props; const { claimSearchByQuery, orderBy, tags, channelIds, time } = this.props;
@@ -72,7 +71,7 @@ class ClaimList extends React.PureComponent {
} }
buildClaimSearchOptions() { 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 { currentPage, subscriptionsView } = this.state;
const options = { const options = {
@@ -205,7 +204,11 @@ class ClaimList extends React.PureComponent {
const options = this.buildClaimSearchOptions(); const options = this.buildClaimSearchOptions();
const claimSearchKey = createNormalizedClaimSearchKey(options); 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) { if (Constants.ORIENTATION_VERTICAL === orientation) {
return ( return (
+55 -41
View File
@@ -12,6 +12,7 @@ const groupedMenuItems = {
{ icon: 'globe-americas', label: 'All content', route: Constants.DRAWER_ROUTE_TRENDING }, { icon: 'globe-americas', label: 'All content', route: Constants.DRAWER_ROUTE_TRENDING },
], ],
'Your content': [ 'Your content': [
{ icon: 'at', label: 'Channels', route: Constants.DRAWER_ROUTE_CHANNEL_CREATOR },
{ icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY }, { icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY },
{ icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES }, { icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES },
{ icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH }, { icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH },
@@ -36,48 +37,61 @@ class DrawerContent extends React.PureComponent {
const activeItemKey = state.routes[state.index] ? state.routes[state.index].key : null; const activeItemKey = state.routes[state.index] ? state.routes[state.index].key : null;
return ( return (
<ScrollView contentContainerStyle={discoverStyle.menuScrollContent}> <View style={discoverStyle.drawerContentArea}>
<SafeAreaView style={discoverStyle.drawerContentContainer} forceInset={{ top: 'always', horizontal: 'never' }}> <ScrollView contentContainerStyle={discoverStyle.menuScrollContent}>
{groupNames.map(groupName => { <SafeAreaView
const menuItems = groupedMenuItems[groupName]; style={discoverStyle.drawerContentContainer}
forceInset={{ top: 'always', horizontal: 'never' }}
>
{groupNames.map(groupName => {
const menuItems = groupedMenuItems[groupName];
return ( return (
<View key={groupName} style={discoverStyle.menuGroup}> <View key={groupName} style={discoverStyle.menuGroup}>
{groupNames[3] !== groupName && ( {groupNames[3] !== groupName && (
<Text key={`${groupName}-title`} style={discoverStyle.menuGroupName}> <Text key={`${groupName}-title`} style={discoverStyle.menuGroupName}>
{groupName} {groupName}
</Text> </Text>
)} )}
{menuItems.map(item => { {menuItems.map(item => {
const focused = const focused =
activeItemKey === item.route || activeItemKey === item.route ||
(activeItemKey === Constants.FULL_ROUTE_NAME_DISCOVER && (activeItemKey === Constants.FULL_ROUTE_NAME_DISCOVER &&
item.route === Constants.DRAWER_ROUTE_DISCOVER) || item.route === Constants.DRAWER_ROUTE_DISCOVER) ||
(activeItemKey === Constants.FULL_ROUTE_NAME_WALLET && (activeItemKey === Constants.FULL_ROUTE_NAME_WALLET &&
item.route === Constants.DRAWER_ROUTE_WALLET); item.route === Constants.DRAWER_ROUTE_WALLET);
return ( return (
<TouchableOpacity <TouchableOpacity
accessible accessible
accessibilityLabel={item.label} accessibilityLabel={item.label}
style={[discoverStyle.menuItemTouchArea, focused ? discoverStyle.menuItemTouchAreaFocused : null]} style={[
key={item.label} discoverStyle.menuItemTouchArea,
onPress={() => navigation.navigate({ routeName: item.route })} focused ? discoverStyle.menuItemTouchAreaFocused : null,
delayPressIn={0} ]}
> key={item.label}
<View style={discoverStyle.menuItemIcon}> onPress={() => navigation.navigate({ routeName: item.route })}
<Icon name={item.icon} size={16} solid={item.solid} color={focused ? activeTintColor : null} /> delayPressIn={0}
</View> >
<Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}> <View style={discoverStyle.menuItemIcon}>
{item.label} <Icon
</Text> name={item.icon}
</TouchableOpacity> size={16}
); solid={item.solid}
})} color={focused ? activeTintColor : null}
</View> />
); </View>
})} <Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}>
</SafeAreaView> {item.label}
</ScrollView> </Text>
</TouchableOpacity>
);
})}
</View>
);
})}
</SafeAreaView>
</ScrollView>
</View>
); );
} }
} }
+31 -31
View File
@@ -53,39 +53,39 @@ class FileList extends React.PureComponent<Props, State> {
dateNew: fileInfos => dateNew: fileInfos =>
this.props.sortByHeight this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => { ? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
if (fileInfo1.pending) { if (fileInfo1.pending) {
return -1; return -1;
} }
const height1 = this.props.claimsById[fileInfo1.claim_id] const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height ? this.props.claimsById[fileInfo1.claim_id].height
: 0; : 0;
const height2 = this.props.claimsById[fileInfo2.claim_id] const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height ? this.props.claimsById[fileInfo2.claim_id].height
: 0; : 0;
if (height1 > height2) { if (height1 > height2) {
return -1; return -1;
} else if (height1 < height2) { } else if (height1 < height2) {
return 1; return 1;
} }
return 0; return 0;
}) })
: [...fileInfos].reverse(), : [...fileInfos].reverse(),
dateOld: fileInfos => dateOld: fileInfos =>
this.props.sortByHeight this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => { ? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const height1 = this.props.claimsById[fileInfo1.claim_id] const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height ? this.props.claimsById[fileInfo1.claim_id].height
: 999999; : 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id] const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height ? this.props.claimsById[fileInfo2.claim_id].height
: 999999; : 999999;
if (height1 < height2) { if (height1 < height2) {
return -1; return -1;
} else if (height1 > height2) { } else if (height1 > height2) {
return 1; return 1;
} }
return 0; return 0;
}) })
: fileInfos, : fileInfos,
title: fileInfos => title: fileInfos =>
fileInfos.slice().sort((fileInfo1, fileInfo2) => { fileInfos.slice().sort((fileInfo1, fileInfo2) => {
@@ -160,7 +160,7 @@ class FileList extends React.PureComponent<Props, State> {
// This is unfortunate // This is unfortunate
// https://github.com/lbryio/lbry/issues/1159 // https://github.com/lbryio/lbry/issues/1159
const name = claimName || claimNameDownloaded; const name = claimName || claimNameDownloaded;
uriParams.contentName = name; uriParams.claimName = name;
uriParams.claimId = claimId; uriParams.claimId = claimId;
const uri = buildURI(uriParams); const uri = buildURI(uriParams);
@@ -179,7 +179,7 @@ class FileList extends React.PureComponent<Props, State> {
style={fileListStyle.fileItem} style={fileListStyle.fileItem}
uri={item} uri={item}
navigation={navigation} navigation={navigation}
showDetails={true} showDetails
compactView={false} 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 { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
import { navigateToUri, formatBytes } from 'utils/helper'; import { navigateToUri, formatBytes } from 'utils/helper';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime'; import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia'; import FileItemMedia from 'component/fileItemMedia';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -12,6 +13,10 @@ import ProgressBar from 'component/progressBar';
import fileListStyle from 'styles/fileList'; import fileListStyle from 'styles/fileList';
class FileListItem extends React.PureComponent { class FileListItem extends React.PureComponent {
state = {
url: null,
};
getStorageForFileInfo = fileInfo => { getStorageForFileInfo = fileInfo => {
if (!fileInfo.completed) { if (!fileInfo.completed) {
const written = formatBytes(fileInfo.written_bytes); 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 = () => { defaultOnPress = () => {
const { autoplay, navigation, uri, shortUrl } = this.props; const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
navigateToUri(navigation, shortUrl || uri, { autoplay });
if (featuredResult && !claim) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
} else {
navigateToUri(navigation, shortUrl || uri, { autoplay });
}
}; };
onPressHandler = () => { onPressHandler = () => {
@@ -111,7 +128,7 @@ class FileListItem extends React.PureComponent {
// shouldHide = 'channel' === claim.value_type; // shouldHide = 'channel' === claim.value_type;
} }
if (shouldHide || (!isResolvingUri && !claim) || (featuredResult && !isResolvingUri && !claim && !title && !name)) { if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
return null; return null;
} }
@@ -130,7 +147,7 @@ class FileListItem extends React.PureComponent {
style={fileListStyle.thumbnail} style={fileListStyle.thumbnail}
duration={duration} duration={duration}
resizeMode="cover" resizeMode="cover"
title={title || name} title={title || name || normalizeURI(uri).substring(7)}
thumbnail={thumbnail} thumbnail={thumbnail}
/> />
{selected && ( {selected && (
@@ -167,6 +184,13 @@ class FileListItem extends React.PureComponent {
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />} {isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
</View> </View>
)} )}
{featuredResult && !isResolving && !claim && (
<View style={fileListStyle.titleContainer}>
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
</View>
)}
{channel && !hideChannel && ( {channel && !hideChannel && (
<Link <Link
style={fileListStyle.publisher} style={fileListStyle.publisher}
+16 -1
View File
@@ -13,6 +13,7 @@ type Props = {
id: string, id: string,
reward_title: string, reward_title: string,
reward_amount: number, reward_amount: number,
reward_range?: string,
transaction_id: string, transaction_id: string,
created_at: string, created_at: string,
reward_description: 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() { render() {
const { canClaim, isPending, onClaimPress, reward } = this.props; const { canClaim, isPending, onClaimPress, reward } = this.props;
const claimed = !!reward.transaction_id; const claimed = !!reward.transaction_id;
@@ -101,7 +116,7 @@ class RewardCard extends React.PureComponent<Props> {
)} )}
</View> </View>
<View style={rewardStyle.rightCol}> <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> <Text style={rewardStyle.rewardCurrency}>LBC</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
+2 -1
View File
@@ -67,11 +67,12 @@ export default class TagSearch extends React.PureComponent {
}; };
render() { render() {
const { name, style, type, selectedTags = [], showNsfwTags } = this.props; const { editable, name, style, type, selectedTags = [], showNsfwTags } = this.props;
return ( return (
<View> <View>
<TextInput <TextInput
editable={editable}
style={tagStyle.searchInput} style={tagStyle.searchInput}
placeholder={'Search for more tags'} placeholder={'Search for more tags'}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
@@ -19,11 +19,12 @@ class TransactionListItem extends React.PureComponent {
return ( return (
<View style={transactionListStyle.listItem}> <View style={transactionListStyle.listItem}>
<View style={[transactionListStyle.row, transactionListStyle.topRow]}> <View style={[transactionListStyle.row, transactionListStyle.topRow]}>
<View style={transactionListStyle.col}> <View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<Text style={transactionListStyle.text}>{this.capitalize(type)}</Text> <Text style={transactionListStyle.text}>{this.capitalize(type)}</Text>
{name && claimId && ( {name && claimId && (
<Link <Link
style={transactionListStyle.link} style={transactionListStyle.link}
numberOfLines={1}
onPress={() => navigateToUri(navigation, buildURI({ claimName: name, claimId }))} onPress={() => navigateToUri(navigation, buildURI({ claimName: name, claimId }))}
text={name} text={name}
/> />
@@ -37,7 +38,7 @@ class TransactionListItem extends React.PureComponent {
</View> </View>
</View> </View>
<View style={transactionListStyle.row}> <View style={transactionListStyle.row}>
<View style={transactionListStyle.col}> <View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<Link <Link
style={transactionListStyle.smallLink} style={transactionListStyle.smallLink}
text={txid.substring(0, 8)} text={txid.substring(0, 8)}
+28 -6
View File
@@ -2,7 +2,7 @@
import React from 'react'; import React from 'react';
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux'; import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native'; 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 Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import UriBarItem from './internal/uri-bar-item'; import UriBarItem from './internal/uri-bar-item';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -109,12 +109,19 @@ class UriBar extends React.PureComponent {
handleSubmitEditing = () => { handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props; const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
if (this.state.inputText) { if (this.state.inputText) {
let inputText = this.state.inputText; let inputText = this.state.inputText,
if (inputText.startsWith('lbry://') && isURIValid(inputText)) { inputTextIsUrl = false;
if (inputText.startsWith('lbry://')) {
const transformedUrl = transformUrl(inputText);
// if it's a URI (lbry://...), open the file page // if it's a URI (lbry://...), open the file page
const uri = normalizeURI(inputText); if (transformedUrl && isURIValid(transformedUrl)) {
navigateToUri(navigation, uri); inputTextIsUrl = true;
} else { navigateToUri(navigation, transformedUrl);
}
}
// couldn't parse the inputText as a URL for some reason, so do a search instead
if (!inputTextIsUrl) {
updateSearchQuery(inputText); updateSearchQuery(inputText);
// Not a URI, default to a search request // Not a URI, default to a search request
if (onSearchSubmitted) { if (onSearchSubmitted) {
@@ -135,9 +142,11 @@ class UriBar extends React.PureComponent {
render() { render() {
const { const {
allowEdit,
belowOverlay, belowOverlay,
navigation, navigation,
onExitSelectionMode, onExitSelectionMode,
onEditActionPressed,
onDeleteActionPressed, onDeleteActionPressed,
query, query,
selectedItemCount, selectedItemCount,
@@ -175,6 +184,19 @@ class UriBar extends React.PureComponent {
</View> </View>
<View style={uriBarStyle.selectionModeActions}> <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 <TouchableOpacity
style={uriBarStyle.actionTouchArea} style={uriBarStyle.actionTouchArea}
onPress={() => { onPress={() => {
+15
View File
@@ -25,6 +25,9 @@ const Constants = {
PHASE_DETAILS: 'details', PHASE_DETAILS: 'details',
PHASE_PUBLISH: 'publish', PHASE_PUBLISH: 'publish',
PHASE_LIST: 'list',
PHASE_NEW: 'create',
CONTENT_TAB: 'content', CONTENT_TAB: 'content',
ABOUT_TAB: 'about', ABOUT_TAB: 'about',
@@ -56,6 +59,11 @@ const Constants = {
ACTION_SORT_BY_ITEM_CHANGED: 'SORT_BY_ITEM_CHANGED', ACTION_SORT_BY_ITEM_CHANGED: 'SORT_BY_ITEM_CHANGED',
ACTION_TIME_ITEM_CHANGED: 'TIME_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_HORIZONTAL: 'horizontal',
ORIENTATION_VERTICAL: 'vertical', ORIENTATION_VERTICAL: 'vertical',
@@ -69,6 +77,7 @@ const Constants = {
DRAWER_ROUTE_SUBSCRIPTIONS: 'Subscriptions', DRAWER_ROUTE_SUBSCRIPTIONS: 'Subscriptions',
DRAWER_ROUTE_MY_LBRY: 'Downloads', DRAWER_ROUTE_MY_LBRY: 'Downloads',
DRAWER_ROUTE_PUBLISH: 'Publish', DRAWER_ROUTE_PUBLISH: 'Publish',
DRAWER_ROUTE_PUBLISH_FORM: 'PublishForm',
DRAWER_ROUTE_PUBLISHES: 'Publishes', DRAWER_ROUTE_PUBLISHES: 'Publishes',
DRAWER_ROUTE_REWARDS: 'Rewards', DRAWER_ROUTE_REWARDS: 'Rewards',
DRAWER_ROUTE_WALLET: 'Wallet', DRAWER_ROUTE_WALLET: 'Wallet',
@@ -77,6 +86,8 @@ const Constants = {
DRAWER_ROUTE_SEARCH: 'Search', DRAWER_ROUTE_SEARCH: 'Search',
DRAWER_ROUTE_TRANSACTION_HISTORY: 'TransactionHistory', DRAWER_ROUTE_TRANSACTION_HISTORY: 'TransactionHistory',
DRAWER_ROUTE_TAG: 'Tag', DRAWER_ROUTE_TAG: 'Tag',
DRAWER_ROUTE_CHANNEL_CREATOR: 'ChannelCreator',
DRAWER_ROUTE_CHANNEL_CREATOR_FORM: 'ChannnelCreatorForm',
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack', FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
FULL_ROUTE_NAME_WALLET: 'WalletStack', FULL_ROUTE_NAME_WALLET: 'WalletStack',
@@ -146,4 +157,8 @@ export const DrawerRoutes = [
Constants.DRAWER_ROUTE_ABOUT, Constants.DRAWER_ROUTE_ABOUT,
Constants.DRAWER_ROUTE_SEARCH, Constants.DRAWER_ROUTE_SEARCH,
Constants.DRAWER_ROUTE_TRANSACTION_HISTORY, 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 createCompressor from 'redux-persist-transform-compress';
import createFilter from 'redux-persist-transform-filter'; import createFilter from 'redux-persist-transform-filter';
import moment from 'moment'; import moment from 'moment';
import formReducer from 'redux/reducers/form';
import drawerReducer from 'redux/reducers/drawer'; import drawerReducer from 'redux/reducers/drawer';
import settingsReducer from 'redux/reducers/settings'; import settingsReducer from 'redux/reducers/settings';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
@@ -109,6 +110,7 @@ const reducers = persistCombineReducers(persistOptions, {
file: fileReducer, file: fileReducer,
fileInfo: fileInfoReducer, fileInfo: fileInfoReducer,
filtered: filteredReducer, filtered: filteredReducer,
form: formReducer,
homepage: homepageReducer, homepage: homepageReducer,
nav: navigatorReducer, nav: navigatorReducer,
notifications: notificationsReducer, notifications: notificationsReducer,
+14 -13
View File
@@ -43,21 +43,22 @@ class AboutPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible } = this.props; const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack(); pushDrawerStack();
setPlayerVisible(); setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('About');
if (NativeModules.VersionInfo) { NativeModules.Firebase.setCurrentScreen('About').then(result => {
NativeModules.VersionInfo.getAppVersion().then(version => { if (NativeModules.VersionInfo) {
this.setState({ appVersion: version }); NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({ appVersion: version });
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
}); });
} Lbry.status().then(info => {
Lbry.version().then(info => { this.setState({
this.setState({ lbryId: info.installation_id,
versionInfo: info, });
});
});
Lbry.status().then(info => {
this.setState({
lbryId: info.installation_id,
}); });
}); });
+2 -2
View File
@@ -1,5 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doFetchClaimsByChannel, makeSelectClaimForUri } from 'lbry-redux'; import { makeSelectClaimForUri, selectMyChannelClaims } from 'lbry-redux';
import { doPopDrawerStack } from 'redux/actions/drawer'; import { doPopDrawerStack } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings'; import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer'; import { selectDrawerStack } from 'redux/selectors/drawer';
@@ -7,6 +7,7 @@ import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import ChannelPage from './view'; import ChannelPage from './view';
const select = (state, props) => ({ const select = (state, props) => ({
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
drawerStack: selectDrawerStack(state), drawerStack: selectDrawerStack(state),
sortByItem: selectSortByItem(state), sortByItem: selectSortByItem(state),
@@ -14,7 +15,6 @@ const select = (state, props) => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
popDrawerStack: () => dispatch(doPopDrawerStack()), popDrawerStack: () => dispatch(doPopDrawerStack()),
setSortByItem: item => dispatch(doSetSortByItem(item)), setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)), setTimeItem: item => dispatch(doSetTimeItem(item)),
+64 -7
View File
@@ -2,6 +2,7 @@
import React from 'react'; import React from 'react';
import { import {
ActivityIndicator, ActivityIndicator,
Alert,
Dimensions, Dimensions,
Image, Image,
NativeModules, 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() { 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 { name, permanent_url: permanentUrl } = claim;
const { autoStyle, showSortPicker, showTimePicker } = this.state; const { autoStyle, showSortPicker, showTimePicker } = this.state;
const ownedChannel = channels ? channels.map(channel => channel.permanent_url).includes(permanentUrl) : false;
let thumbnailUrl, let thumbnailUrl,
coverUrl, coverUrl,
@@ -218,12 +255,32 @@ class ChannelPage extends React.PureComponent {
</View> </View>
<View style={channelPageStyle.subscribeButtonContainer}> <View style={channelPageStyle.subscribeButtonContainer}>
<SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} /> {ownedChannel && (
<SubscribeNotificationButton <Button
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]} style={channelPageStyle.actionButton}
uri={fullUri} theme={'light'}
name={name} 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>
</View> </View>
+50
View File
@@ -0,0 +1,50 @@
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, selectHasChannelFormState } 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),
hasFormState: selectHasChannelFormState(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 { connect } from 'react-redux';
import { import {
doFetchFileInfo, doFetchFileInfo,
doFetchChannelListMine,
doFetchClaimListMine,
doFileGet, doFileGet,
doPurchaseUri, doPurchaseUri,
doDeletePurchasedUri, doDeletePurchasedUri,
@@ -18,11 +20,14 @@ import {
makeSelectThumbnailForUri, makeSelectThumbnailForUri,
makeSelectTitleForUri, makeSelectTitleForUri,
selectBalance, selectBalance,
selectMyChannelClaims,
selectMyClaimUrisWithoutChannels,
selectPurchasedUris, selectPurchasedUris,
selectFailedPurchaseUris, selectFailedPurchaseUris,
selectPurchaseUriErrorMessage, selectPurchaseUriErrorMessage,
} from 'lbry-redux'; } from 'lbry-redux';
import { import {
doClaimEligiblePurchaseRewards,
doFetchCostInfoForUri, doFetchCostInfoForUri,
makeSelectCostInfoForUri, makeSelectCostInfoForUri,
selectRewardContentClaimIds, selectRewardContentClaimIds,
@@ -44,20 +49,22 @@ const select = (state, props) => {
return { return {
balance: selectBalance(state), balance: selectBalance(state),
blackListedOutpoints: selectBlackListedOutpoints(state), blackListedOutpoints: selectBlackListedOutpoints(state),
channels: selectMyChannelClaims(state),
claim: makeSelectClaimForUri(selectProps.uri)(state), claim: makeSelectClaimForUri(selectProps.uri)(state),
drawerStack: selectDrawerStack(state), drawerStack: selectDrawerStack(state),
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state), isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
contentType: makeSelectContentTypeForUri(selectProps.uri)(state), contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state), costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
metadata: makeSelectMetadataForUri(selectProps.uri)(state), metadata: makeSelectMetadataForUri(selectProps.uri)(state),
//obscureNsfw: !selectShowNsfw(state), // obscureNsfw: !selectShowNsfw(state),
//tab: makeSelectCurrentParam('tab')(state), // tab: makeSelectCurrentParam('tab')(state),
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state), fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps), rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state), channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
position: makeSelectContentPositionForUri(selectProps.uri)(state), position: makeSelectContentPositionForUri(selectProps.uri)(state),
purchasedUris: selectPurchasedUris(state), purchasedUris: selectPurchasedUris(state),
failedPurchaseUris: selectFailedPurchaseUris(state), failedPurchaseUris: selectFailedPurchaseUris(state),
myClaimUris: selectMyClaimUrisWithoutChannels(state),
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state), purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state), streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state), thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
@@ -66,11 +73,14 @@ const select = (state, props) => {
}; };
const perform = dispatch => ({ const perform = dispatch => ({
claimEligibleRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => { deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim)); dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
}, },
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
fetchChannelListMine: () => dispatch(doFetchChannelListMine()),
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)), fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
popDrawerStack: () => dispatch(doPopDrawerStack()), popDrawerStack: () => dispatch(doPopDrawerStack()),
+49 -16
View File
@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Lbry, normalizeURI } from 'lbry-redux'; import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { import {
ActivityIndicator, ActivityIndicator,
@@ -100,7 +100,7 @@ class FilePage extends React.PureComponent {
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated); DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted); 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; const { uri, uriVars } = navigation.state.params;
this.setState({ uri, uriVars }); this.setState({ uri, uriVars });
@@ -108,6 +108,7 @@ class FilePage extends React.PureComponent {
this.fetchFileInfo(this.props); this.fetchFileInfo(this.props);
this.fetchCostInfo(this.props); this.fetchCostInfo(this.props);
fetchChannelListMine();
if (NativeModules.Firebase) { if (NativeModules.Firebase) {
NativeModules.Firebase.track('open_file_page', { uri: uri }); 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 = () => { onDeletePressed = () => {
const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props; const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props;
@@ -244,11 +250,11 @@ class FilePage extends React.PureComponent {
text: 'Yes', text: 'Yes',
onPress: () => { onPress: () => {
const { uri } = navigation.state.params; const { uri } = navigation.state.params;
deleteFile(`${claim.txid}:${claim.nout}`, true); deleteFile(`${claim.txid}:${claim.nout}`, true);
deletePurchasedUri(uri); deletePurchasedUri(uri);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.deleteDownload(uri); NativeModules.UtilityModule.deleteDownload(uri);
}
this.setState({ this.setState({
downloadPressed: false, downloadPressed: false,
fileViewLogged: false, fileViewLogged: false,
@@ -472,6 +478,7 @@ class FilePage extends React.PureComponent {
return; return;
} }
const { claimEligibleRewards } = this.props;
const { nout, claim_id: claimId, txid } = claim; const { nout, claim_id: claimId, txid } = claim;
const outpoint = `${txid}:${nout}`; const outpoint = `${txid}:${nout}`;
const params = { const params = {
@@ -483,7 +490,9 @@ class FilePage extends React.PureComponent {
params.time_to_start = timeToStart; params.time_to_start = timeToStart;
} }
Lbryio.call('file', 'view', params).catch(() => {}); Lbryio.call('file', 'view', params)
.then(() => claimEligibleRewards())
.catch(() => {});
this.setState({ fileViewLogged: true }); this.setState({ fileViewLogged: true });
}; };
@@ -562,6 +571,7 @@ class FilePage extends React.PureComponent {
const { const {
balance, balance,
claim, claim,
channels,
channelUri, channelUri,
costInfo, costInfo,
fileInfo, fileInfo,
@@ -571,6 +581,7 @@ class FilePage extends React.PureComponent {
rewardedContentClaimIds, rewardedContentClaimIds,
isResolvingUri, isResolvingUri,
blackListedOutpoints, blackListedOutpoints,
myClaimUris,
navigation, navigation,
position, position,
purchaseUri, purchaseUri,
@@ -579,6 +590,10 @@ class FilePage extends React.PureComponent {
} = this.props; } = this.props;
const { uri, autoplay } = navigation.state.params; 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; let innerContent = null;
if ((isResolvingUri && !claim) || !claim) { if ((isResolvingUri && !claim) || !claim) {
return ( return (
@@ -591,7 +606,14 @@ class FilePage extends React.PureComponent {
)} )}
{claim === null && !isResolvingUri && ( {claim === null && !isResolvingUri && (
<View style={filePageStyle.container}> <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> </View>
)} )}
<UriBar value={uri} navigation={navigation} /> <UriBar value={uri} navigation={navigation} />
@@ -600,7 +622,7 @@ class FilePage extends React.PureComponent {
} }
if (claim) { if (claim) {
if (claim && claim.name.length && claim.name[0] === '@') { if (isChannel) {
return <ChannelPage uri={uri} navigation={navigation} />; return <ChannelPage uri={uri} navigation={navigation} />;
} }
@@ -643,19 +665,20 @@ class FilePage extends React.PureComponent {
const isPlayable = mediaType === 'video' || mediaType === 'audio'; const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, signing_channel: signingChannel, value } = claim; const { height, signing_channel: signingChannel, value } = claim;
const channelName = signingChannel && signingChannel.name; 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 = const showActions =
fileInfo && (canEdit || (fileInfo && fileInfo.download_path)) &&
fileInfo.download_path &&
!this.state.fullscreenMode && !this.state.fullscreenMode &&
!this.state.showImageViewer && !this.state.showImageViewer &&
!this.state.showWebView; !this.state.showWebView;
const showFileActions = const showFileActions =
fileInfo && canEdit ||
fileInfo.download_path && (fileInfo &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)); fileInfo.download_path &&
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id; (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)));
const canSendTip = this.state.tipAmount > 0;
const fullUri = `${claim.name}#${claim.claim_id}`;
const fullChannelUri = const fullChannelUri =
channelClaimId && channelClaimId.trim().length > 0 channelClaimId && channelClaimId.trim().length > 0
? normalizeURI(`${channelName}#${channelClaimId}`) ? normalizeURI(`${channelName}#${channelClaimId}`)
@@ -826,6 +849,16 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.actions}> <View style={filePageStyle.actions}>
{showFileActions && ( {showFileActions && (
<View style={filePageStyle.fileActions}> <View style={filePageStyle.fileActions}>
{canEdit && (
<Button
style={[filePageStyle.actionButton, filePageStyle.editButton]}
theme={'light'}
icon={'edit'}
text={'Edit'}
onPress={this.onEditPressed}
/>
)}
{completed && ( {completed && (
<Button <Button
style={filePageStyle.actionButton} style={filePageStyle.actionButton}
+1 -1
View File
@@ -46,7 +46,7 @@ const perform = dispatch => ({
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
}); });
+22 -10
View File
@@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
isEmailVerified: false, isEmailVerified: false,
skipAccountConfirmed: false, skipAccountConfirmed: false,
showBottomContainer: false, showBottomContainer: false,
walletPassword: null, walletPassword: '',
syncApplyStarted: false, syncApplyStarted: false,
}; };
@@ -45,14 +45,13 @@ class FirstRunScreen extends React.PureComponent {
}); });
if (NativeModules.FirstRun) { if (NativeModules.FirstRun) {
NativeModules.Firebase.setCurrentScreen('First Run');
NativeModules.FirstRun.isFirstRun().then(firstRun => { NativeModules.FirstRun.isFirstRun().then(firstRun => {
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL); AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING); AsyncStorage.removeItem(Constants.KEY_EMAIL_VERIFY_PENDING);
this.setState({ isFirstRun: firstRun }); this.setState({ isFirstRun: firstRun });
if (firstRun) { if (firstRun) {
NativeModules.Firebase.setCurrentScreen('First Run');
this.setState({ currentPage: FirstRunScreen.pages[0] }); this.setState({ currentPage: FirstRunScreen.pages[0] });
} else { } else {
// Not the first run. Navigate to the splash screen right away // Not the first run. Navigate to the splash screen right away
@@ -87,12 +86,25 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true }); this.setState({ showBottomContainer: true });
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) { NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword); setDefaultAccount(
} () => {
setDefaultAccount(); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
this.closeFinalPage(); // 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 => { onWalletPasswordChanged = password => {
this.setState({ walletPassword: password }); this.setState({ walletPassword: password !== null ? password : '' });
}; };
onWalletViewLayout = () => { onWalletViewLayout = () => {
+11 -2
View File
@@ -8,22 +8,31 @@ import {
selectBalance, selectBalance,
selectPublishFormValues, selectPublishFormValues,
} from 'lbry-redux'; } 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, selectHasPublishFormState } from 'redux/selectors/form';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PublishPage from './view'; import PublishPage from './view';
const select = state => ({ const select = state => ({
balance: selectBalance(state), balance: selectBalance(state),
drawerStack: selectDrawerStack(state),
hasFormState: selectHasPublishFormState(state),
publishFormState: selectPublishFormState(state),
publishFormValues: selectPublishFormValues(state), publishFormValues: selectPublishFormValues(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
clearPublishFormState: () => dispatch(doClearPublishFormState()),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)), updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
uploadThumbnail: (filePath, fsAdapter) => dispatch(doUploadThumbnail(filePath, null, fsAdapter)), uploadThumbnail: (filePath, fsAdapter) => dispatch(doUploadThumbnail(filePath, null, fsAdapter)),
publish: (success, fail) => dispatch(doPublish(success, fail)), publish: (success, fail) => dispatch(doPublish(success, fail)),
resolveUri: uri => dispatch(doResolveUri(uri)), 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)), setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
}); });
+340 -118
View File
@@ -18,13 +18,14 @@ import { FlatGrid } from 'react-native-super-grid';
import { import {
isNameValid, isNameValid,
buildURI, buildURI,
normalizeURI,
parseURI,
regexInvalidURI, regexInvalidURI,
CLAIM_VALUES, CLAIM_VALUES,
LICENSES, LICENSES,
MATURE_TAGS, MATURE_TAGS,
THUMBNAIL_STATUSES, THUMBNAIL_STATUSES,
} from 'lbry-redux'; } from 'lbry-redux';
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';
import { RNCamera } from 'react-native-camera'; import { RNCamera } from 'react-native-camera';
import { generateCombination } from 'gfycat-style-urls'; import { generateCombination } from 'gfycat-style-urls';
import RNFS from 'react-native-fs'; import RNFS from 'react-native-fs';
@@ -42,7 +43,7 @@ import Tag from 'component/tag';
import TagSearch from 'component/tagSearch'; import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar'; import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish'; import publishStyle from 'styles/publish';
import __ from 'utils/helper'; import { __, navigateToUri } from 'utils/helper';
const languages = { const languages = {
en: 'English', en: 'English',
@@ -76,10 +77,14 @@ class PublishPage extends React.PureComponent {
camera = null; camera = null;
state = { state = {
canPublish: false,
canUseCamera: false, canUseCamera: false,
documentPickerOpen: false,
editMode: false,
titleFocused: false, titleFocused: false,
descriptionFocused: false, descriptionFocused: false,
loadingVideos: false, loadingVideos: false,
vanityUrl: null,
// gallery videos // gallery videos
videos: null, videos: null,
@@ -98,7 +103,7 @@ class PublishPage extends React.PureComponent {
currentMedia: null, currentMedia: null,
currentThumbnailUri: null, currentThumbnailUri: null,
updatingThumbnailUri: false, updatingThumbnailUri: false,
currentPhase: Constants.PHASE_SELECTOR, currentPhase: null,
// publish // publish
advancedMode: false, advancedMode: false,
@@ -107,6 +112,7 @@ class PublishPage extends React.PureComponent {
priceSet: false, priceSet: false,
// input data // input data
hasEditedContentAddress: false,
bid: 0.1, bid: 0.1,
description: null, description: null,
title: null, title: null,
@@ -114,13 +120,14 @@ class PublishPage extends React.PureComponent {
license: LICENSES.NONE, license: LICENSES.NONE,
licenseUrl: '', licenseUrl: '',
otherLicenseDescription: '', otherLicenseDescription: '',
mature: false,
name: null, name: null,
price: 0, price: 0,
currency: 'LBC',
uri: null, uri: null,
tags: [], tags: [],
selectedChannel: null, selectedChannel: null,
uploadedThumbnailUri: null, uploadedThumbnailUri: null,
vanityUrlSet: false,
// other // other
publishStarted: false, publishStarted: false,
@@ -133,6 +140,8 @@ class PublishPage extends React.PureComponent {
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused); // this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
DeviceEventEmitter.addListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked); DeviceEventEmitter.addListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.addListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked); DeviceEventEmitter.addListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.addListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.addListener('onDocumentPickerCanceled', this.onPickerCanceled);
} }
componentWillUnmount() { componentWillUnmount() {
@@ -141,6 +150,8 @@ class PublishPage extends React.PureComponent {
} }
DeviceEventEmitter.removeListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked); DeviceEventEmitter.removeListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.removeListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked); DeviceEventEmitter.removeListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.removeListener('onDocumentPickerFilePicked', this.onFilePicked);
DeviceEventEmitter.removeListener('onDocumentPickerCanceled', this.onPickerCanceled);
} }
handleGalleryThumbnailChecked = evt => { handleGalleryThumbnailChecked = evt => {
@@ -157,20 +168,120 @@ class PublishPage extends React.PureComponent {
this.setState({ allThumbnailsChecked: true }); this.setState({ allThumbnailsChecked: true });
}; };
loadPendingFormState = () => {
const { publishFormState } = this.props;
const advancedMode = publishFormState.license !== null;
this.setState({ ...publishFormState, advancedMode });
};
onComponentFocused = () => { onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible } = this.props; const { balance, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
pushDrawerStack(); NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
setPlayerVisible(); pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
NativeModules.Firebase.setCurrentScreen('Publish'); 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
let isEditMode = false,
vanityUrlSet = false;
if (navigation.state.params) {
const { displayForm, editMode, claimToEdit, vanityUrl } = navigation.state.params;
if (editMode) {
this.prepareEdit(claimToEdit);
isEditMode = true;
} else if (vanityUrl) {
const { claimName } = parseURI(vanityUrl);
vanityUrlSet = true;
this.setState({
name: claimName,
hasEditedContentAddress: true,
vanityUrlSet,
vanityUrl: claimName,
});
}
}
if (!isEditMode && hasFormState) {
this.loadPendingFormState();
if (vanityUrlSet) {
// replace name with the specified vanity URL if there was one in the pending state
this.setState({ name: this.state.vanityUrl });
}
this.setState({ currentPhase: Constants.PHASE_DETAILS });
} else {
this.setState({ currentPhase: Constants.PHASE_SELECTOR });
}
});
};
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( 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 +295,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 // We are only going to store the full uri, but we need to resolve the uri with and without the channel name
let uri; let uri;
try { try {
uri = buildURI({ contentName: name, channelName }); uri = buildURI({ claimName: name, channelName });
} catch (e) { } catch (e) {
// something wrong with channel or name // something wrong with channel or name
} }
@@ -192,7 +303,7 @@ class PublishPage extends React.PureComponent {
if (uri) { if (uri) {
if (channelName) { if (channelName) {
// resolve without the channel name so we know the winning bid for it // 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(uriLessChannel);
} }
resolveUri(uri); resolveUri(uri);
@@ -209,15 +320,16 @@ class PublishPage extends React.PureComponent {
handlePublishPressed = () => { handlePublishPressed = () => {
const { notify, publish, updatePublishForm } = this.props; const { notify, publish, updatePublishForm } = this.props;
const { const {
editMode,
bid, bid,
channelName, channelName,
currentMedia, currentMedia,
currency,
description, description,
language, language,
license, license,
licenseUrl, licenseUrl,
otherLicenseDescription, otherLicenseDescription,
mature,
name, name,
price, price,
priceSet, priceSet,
@@ -237,28 +349,32 @@ class PublishPage extends React.PureComponent {
return; 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 = { const publishParams = {
filePath: currentMedia.filePath, filePath: currentMedia ? currentMedia.filePath : null,
bid: bid || 0.1, bid: bid || 0.1,
title: title || '', title: title || '',
thumbnail, thumbnail,
description: description || '', description: description || '',
language, language,
license, license,
licenseType: license,
licenseUrl, licenseUrl,
otherLicenseDescription, otherLicenseDescription,
name: name || undefined, name: name || undefined,
contentIsFree: !priceSet, contentIsFree: !priceSet,
fee: { currency: 'LBC', amount: price }, fee: { currency, amount: price },
uri: uri || undefined, uri: uri || undefined,
channel: CLAIM_VALUES.CHANNEL_ANONYMOUS === channelName ? null : channelName, channel: CLAIM_VALUES.CHANNEL_ANONYMOUS === channelName ? null : channelName,
isStillEditing: false, isStillEditing: false,
claim: { tags: tags.map(tag => {
value: { return { name: tag };
tags, }),
release_time: Math.round(Date.now() / 1000), // set now as the release time
},
},
}; };
updatePublishForm(publishParams); updatePublishForm(publishParams);
@@ -266,7 +382,11 @@ class PublishPage extends React.PureComponent {
}; };
handlePublishSuccess = data => { 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 => { handlePublishFailure = error => {
@@ -280,8 +400,8 @@ class PublishPage extends React.PureComponent {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { currentRoute, publishFormValues } = nextProps; const { currentRoute: prevRoute, drawerStack: prevDrawerStack, notify, updatePublishFormState } = this.props;
const { currentRoute: prevRoute, notify } = this.props; const { currentRoute, drawerStack, publishFormValues } = nextProps;
if (Constants.DRAWER_ROUTE_PUBLISH === currentRoute && currentRoute !== prevRoute) { if (Constants.DRAWER_ROUTE_PUBLISH === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused(); this.onComponentFocused();
@@ -289,24 +409,38 @@ class PublishPage extends React.PureComponent {
if (publishFormValues) { if (publishFormValues) {
if (publishFormValues.thumbnail && !this.state.uploadedThumbnailUri) { if (publishFormValues.thumbnail && !this.state.uploadedThumbnailUri) {
this.setState({ const { thumbnail } = publishFormValues;
currentThumbnailUri: publishFormValues.thumbnail, updatePublishFormState({ currentThumbnailUri: thumbnail, uploadedThumbnailUri: thumbnail });
uploadedThumbnailUri: publishFormValues.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) { setCurrentMedia(media) {
const { pushDrawerStack, updatePublishFormState } = this.props;
const name = generateCombination(2, ' ', true); const name = generateCombination(2, ' ', true);
const newName = this.state.hasEditedContentAddress ? this.state.name : this.formatNameForTitle(name);
updatePublishFormState({ currentMedia: media, name: newName });
this.setState( this.setState(
{ {
currentMedia: media, currentMedia: media,
title: name, title: null, // no title autogeneration (user will fill this in)
name: this.formatNameForTitle(name), name: newName,
currentPhase: Constants.PHASE_DETAILS, currentPhase: Constants.PHASE_DETAILS,
}, },
() => this.handleNameChange(this.state.name) () => {
this.handleNameChange(this.state.name);
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM);
}
); );
} }
@@ -320,6 +454,9 @@ class PublishPage extends React.PureComponent {
this.setState( this.setState(
{ {
publishStarted: false, publishStarted: false,
documentPickerOpen: false,
editMode: false,
vanityUrl: null,
currentMedia: null, currentMedia: null,
currentThumbnailUri: null, currentThumbnailUri: null,
@@ -334,6 +471,7 @@ class PublishPage extends React.PureComponent {
priceSet: false, priceSet: false,
// input data // input data
hasEditedContentAddress: false,
bid: 0.1, bid: 0.1,
description: null, description: null,
title: null, title: null,
@@ -347,6 +485,8 @@ class PublishPage extends React.PureComponent {
tags: [], tags: [],
selectedChannel: null, selectedChannel: null,
uploadedThumbnailUri: null, uploadedThumbnailUri: null,
vanityUrlSet: false,
}, },
() => { () => {
// reset thumbnail // reset thumbnail
@@ -367,6 +507,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 = () => { handleCloseCameraPressed = () => {
this.setState({ showCameraOverlay: false, videoRecordingMode: false }); this.setState({ showCameraOverlay: false, videoRecordingMode: false });
}; };
@@ -376,6 +546,8 @@ class PublishPage extends React.PureComponent {
}; };
handleCameraActionPressed = () => { handleCameraActionPressed = () => {
const { pushDrawerStack } = this.props;
// check if it's video or photo mode // check if it's video or photo mode
if (this.state.videoRecordingMode) { if (this.state.videoRecordingMode) {
if (this.state.recordingVideo) { if (this.state.recordingVideo) {
@@ -393,14 +565,17 @@ class PublishPage extends React.PureComponent {
duration: 0, duration: 0,
}; };
this.setCurrentMedia(currentMedia); this.setCurrentMedia(currentMedia);
this.setState({ this.setState(
currentThumbnailUri: null, {
updatingThumbnailUri: false, currentThumbnailUri: null,
currentPhase: Constants.PHASE_DETAILS, updatingThumbnailUri: false,
showCameraOverlay: false, currentPhase: Constants.PHASE_DETAILS,
videoRecordingMode: false, showCameraOverlay: false,
recordingVideo: false, videoRecordingMode: false,
}); recordingVideo: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH_FORM)
);
}); });
} }
} else { } else {
@@ -414,13 +589,16 @@ class PublishPage extends React.PureComponent {
duration: 0, duration: 0,
}; };
this.setCurrentMedia(currentMedia); this.setCurrentMedia(currentMedia);
this.setState({ this.setState(
currentPhase: Constants.PHASE_DETAILS, {
currentThumbnailUri: null, currentPhase: Constants.PHASE_DETAILS,
updatingThumbnailUri: false, currentThumbnailUri: null,
showCameraOverlay: false, updatingThumbnailUri: false,
videoRecordingMode: false, showCameraOverlay: false,
}); videoRecordingMode: false,
},
() => pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)
);
}); });
} }
}; };
@@ -433,18 +611,7 @@ class PublishPage extends React.PureComponent {
}); });
}; };
handleUploadPressed = () => { handleUploadPressed = () => {};
DocumentPicker.show(
{
filetype: [DocumentPickerUtil.allFiles()],
},
(error, res) => {
if (!error) {
// console.log(res);
}
}
);
};
getRandomFileId = () => { getRandomFileId = () => {
// generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails) // generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails)
@@ -457,16 +624,25 @@ class PublishPage extends React.PureComponent {
}; };
handleBidChange = bid => { handleBidChange = bid => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ bid });
this.setState({ bid }); this.setState({ bid });
}; };
handlePriceChange = price => { handlePriceChange = price => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ price });
this.setState({ price }); this.setState({ price });
}; };
handleNameChange = name => { handleNameChange = (name, userInput) => {
const { notify } = this.props; const { notify, updatePublishFormState } = this.props;
updatePublishFormState({ name });
this.setState({ name }); this.setState({ name });
if (userInput) {
this.setState({ hasEditedContentAddress: true });
}
if (!isNameValid(name, false)) { if (!isNameValid(name, false)) {
notify({ message: 'Your content address contains invalid characters' }); notify({ message: 'Your content address contains invalid characters' });
return; return;
@@ -477,22 +653,25 @@ class PublishPage extends React.PureComponent {
}; };
handleChannelChange = channel => { handleChannelChange = channel => {
const { updatePublishFormState } = this.props;
const { name } = this.state; const { name } = this.state;
const uri = this.getNewUri(name, channel); const uri = this.getNewUri(name, channel);
updatePublishFormState({ uri, channelName: channel, selectedChannel: channel });
this.setState({ uri, channelName: channel, selectedChannel: channel }); this.setState({ uri, channelName: channel, selectedChannel: channel });
}; };
handleAddTag = tag => { handleAddTag = tag => {
if (!tag) { if (!tag || !this.state.canPublish || this.state.publishStarted) {
return; return;
} }
const { notify } = this.props; const { notify, updatePublishFormState } = this.props;
const { tags } = this.state; const { tags } = this.state;
const index = tags.indexOf(tag.toLowerCase()); const index = tags.indexOf(tag.toLowerCase());
if (index === -1) { if (index === -1) {
const newTags = tags.slice(); const newTags = tags.slice();
newTags.push(tag); newTags.push(tag);
updatePublishFormState({ tags: newTags });
this.setState({ tags: newTags }); this.setState({ tags: newTags });
} else { } else {
notify({ message: __(`You already added the "${tag}" tag.`) }); notify({ message: __(`You already added the "${tag}" tag.`) });
@@ -500,15 +679,17 @@ class PublishPage extends React.PureComponent {
}; };
handleRemoveTag = tag => { handleRemoveTag = tag => {
if (!tag) { if (!tag || !this.state.canPublish || this.state.publishStarted) {
return; return;
} }
const { updatePublishFormState } = this.props;
const newTags = this.state.tags.slice(); const newTags = this.state.tags.slice();
const index = newTags.indexOf(tag.toLowerCase()); const index = newTags.indexOf(tag.toLowerCase());
if (index > -1) { if (index > -1) {
newTags.splice(index, 1); newTags.splice(index, 1);
updatePublishFormState({ tags: newTags });
this.setState({ tags: newTags }); this.setState({ tags: newTags });
} }
}; };
@@ -556,46 +737,65 @@ class PublishPage extends React.PureComponent {
}; };
handleTitleChange = title => { handleTitleChange = title => {
this.setState( const { updatePublishFormState } = this.props;
{ updatePublishFormState({ title });
title, this.setState({ title });
name: this.formatNameForTitle(title),
}, if (!this.state.editMode && !this.state.hasEditedContentAddress) {
() => { // only autogenerate url if the user has not yet edited the field
this.handleNameChange(this.state.name); // 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 => { handleDescriptionChange = description => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ description });
this.setState({ description }); this.setState({ description });
}; };
handleLanguageValueChange = language => { handleLanguageValueChange = language => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ language });
this.setState({ language }); this.setState({ language });
}; };
handleLicenseValueChange = license => { handleLicenseValueChange = license => {
const { updatePublishFormState } = this.props;
const otherLicenseDescription = [LICENSES.COPYRIGHT, LICENSES.OTHER].includes(license) const otherLicenseDescription = [LICENSES.COPYRIGHT, LICENSES.OTHER].includes(license)
? this.state.otherLicenseDescription ? this.state.otherLicenseDescription
: ''; : '';
const licenseUrl = LICENSES.CC_LICENSES.reduce((value, item) => {
this.setState({ if (typeof value === 'object') {
otherLicenseDescription, value = '';
license, }
licenseUrl: LICENSES.CC_LICENSES.reduce((value, item) => { if (license === item.value) {
if (typeof value === 'object') { value = item.url;
value = ''; }
} return value;
if (license === item.value) {
value = item.url;
}
return value;
}),
}); });
updatePublishFormState({ otherLicenseDescription, license, licenseUrl });
this.setState({ otherLicenseDescription, license, licenseUrl });
}; };
handleChangeLicenseDescription = otherLicenseDescription => { handleChangeLicenseDescription = otherLicenseDescription => {
const { updatePublishFormState } = this.props;
updatePublishFormState({ otherLicenseDescription });
this.setState({ otherLicenseDescription }); this.setState({ otherLicenseDescription });
}; };
@@ -639,12 +839,10 @@ class PublishPage extends React.PureComponent {
<Icon name="camera" size={48} color={Colors.White} /> <Icon name="camera" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Take a photo</Text> <Text style={publishStyle.actionText}>Take a photo</Text>
</TouchableOpacity> </TouchableOpacity>
{false && ( <TouchableOpacity style={publishStyle.upload} onPress={this.handleUploadPressed}>
<TouchableOpacity style={publishStyle.upload} onPress={this.handleUploadPressed}> <Icon name="file-upload" size={48} color={Colors.White} />
<Icon name="file-upload" size={48} color={Colors.White} /> <Text style={publishStyle.actionText}>Upload a file</Text>
<Text style={publishStyle.actionText}>Upload a file</Text> </TouchableOpacity>
</TouchableOpacity>
)}
</View> </View>
</View> </View>
</View> </View>
@@ -685,9 +883,12 @@ class PublishPage extends React.PureComponent {
)} )}
</View> </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; const { currentMedia, currentThumbnailUri } = this.state;
if (!currentThumbnailUri) { if (!currentThumbnailUri && !this.state.editMode) {
this.updateThumbnailUriForMedia(currentMedia); this.updateThumbnailUriForMedia(currentMedia);
} }
content = ( content = (
@@ -699,16 +900,16 @@ class PublishPage extends React.PureComponent {
resizeMode={FastImage.resizeMode.contain} resizeMode={FastImage.resizeMode.contain}
source={{ uri: currentThumbnailUri }} source={{ uri: currentThumbnailUri }}
/> />
</View>
)}
{balance < 0.1 && <PublishRewardsDriver navigation={navigation} />}
{this.state.uploadThumbnailStarted && !this.state.uploadedThumbnailUri && ( {this.state.uploadThumbnailStarted && !this.state.uploadedThumbnailUri && (
<View style={publishStyle.thumbnailUploadContainer}> <View style={publishStyle.thumbnailUploadContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} /> <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text> <Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text>
</View>
)}
</View> </View>
)} )}
{!this.state.canPublish && <PublishRewardsDriver navigation={navigation} />}
<View style={publishStyle.card}> <View style={publishStyle.card}>
<View style={publishStyle.textInputLayout}> <View style={publishStyle.textInputLayout}>
@@ -716,6 +917,7 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Title</Text> <Text style={publishStyle.textInputTitle}>Title</Text>
)} )}
<TextInput <TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={this.state.titleFocused ? '' : 'Title'} placeholder={this.state.titleFocused ? '' : 'Title'}
style={publishStyle.inputText} style={publishStyle.inputText}
value={this.state.title} value={this.state.title}
@@ -733,6 +935,8 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Description</Text> <Text style={publishStyle.textInputTitle}>Description</Text>
)} )}
<TextInput <TextInput
editable={this.state.canPublish && !this.state.publishStarted}
multiline
placeholder={this.state.descriptionFocused ? '' : 'Description'} placeholder={this.state.descriptionFocused ? '' : 'Description'}
style={publishStyle.inputText} style={publishStyle.inputText}
value={this.state.description} value={this.state.description}
@@ -764,7 +968,11 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.card}> <View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Channel</Text> <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>
<View style={publishStyle.card}> <View style={publishStyle.card}>
@@ -782,6 +990,7 @@ class PublishPage extends React.PureComponent {
{this.state.priceSet && ( {this.state.priceSet && (
<View style={[publishStyle.inputRow, publishStyle.priceInputRow]}> <View style={[publishStyle.inputRow, publishStyle.priceInputRow]}>
<TextInput <TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'} placeholder={'0.00'}
keyboardType={'number-pad'} keyboardType={'number-pad'}
style={publishStyle.priceInput} style={publishStyle.priceInput}
@@ -790,27 +999,40 @@ class PublishPage extends React.PureComponent {
value={String(this.state.price)} value={String(this.state.price)}
onChangeText={this.handlePriceChange} 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> </View>
<View style={publishStyle.card}> <View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Content Address</Text> <Text style={publishStyle.cardTitle}>Content address</Text>
<Text style={publishStyle.helpText}> <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> </Text>
<TextInput <TextInput
editable={!this.state.editMode && this.state.canPublish && !this.state.publishStarted}
placeholder={'lbry://'} placeholder={'lbry://'}
style={publishStyle.inputText} style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1} numberOfLines={1}
value={this.state.name} value={this.state.name}
onChangeText={this.handleNameChange} onChangeText={value => this.handleNameChange(value, true)}
/> />
<View style={publishStyle.inputRow}> <View style={publishStyle.inputRow}>
<TextInput <TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'} placeholder={'0.00'}
style={publishStyle.priceInput} style={publishStyle.priceInput}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
@@ -830,6 +1052,7 @@ class PublishPage extends React.PureComponent {
<View> <View>
<Text style={publishStyle.cardText}>Language</Text> <Text style={publishStyle.cardText}>Language</Text>
<Picker <Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.language} selectedValue={this.state.language}
style={publishStyle.picker} style={publishStyle.picker}
itemStyle={publishStyle.pickerItem} itemStyle={publishStyle.pickerItem}
@@ -844,6 +1067,7 @@ class PublishPage extends React.PureComponent {
<View> <View>
<Text style={publishStyle.cardText}>License</Text> <Text style={publishStyle.cardText}>License</Text>
<Picker <Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.license} selectedValue={this.state.license}
style={publishStyle.picker} style={publishStyle.picker}
itemStyle={publishStyle.pickerItem} itemStyle={publishStyle.pickerItem}
@@ -859,6 +1083,7 @@ class PublishPage extends React.PureComponent {
</Picker> </Picker>
{[LICENSES.COPYRIGHT, LICENSES.OTHER].includes(this.state.license) && ( {[LICENSES.COPYRIGHT, LICENSES.OTHER].includes(this.state.license) && (
<TextInput <TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'License description'} placeholder={'License description'}
style={publishStyle.inputText} style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
@@ -879,17 +1104,10 @@ class PublishPage extends React.PureComponent {
/> />
</View> </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}> <View style={publishStyle.actionButtons}>
{(this.state.publishStarted || publishFormValues.publishing) && ( {(this.state.publishStarted || publishFormValues.publishing) && (
<View style={publishStyle.progress}> <View style={publishStyle.progress}>
<ActivityIndicator size={'small'} color={Colors.LbryGreen} /> <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
</View> </View>
)} )}
@@ -901,8 +1119,8 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.rightActionButtons}> <View style={publishStyle.rightActionButtons}>
<Button <Button
style={publishStyle.publishButton} style={publishStyle.publishButton}
disabled={balance < 0.1 || !this.state.uploadedThumbnailUri} disabled={!this.state.canPublish || !this.state.uploadedThumbnailUri}
text="Publish" text={this.state.editMode ? 'Save changes' : 'Publish'}
onPress={this.handlePublishPressed} onPress={this.handlePublishPressed}
/> />
</View> </View>
@@ -917,7 +1135,11 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.successTitle}>Success!</Text> <Text style={publishStyle.successTitle}>Success!</Text>
<Text style={publishStyle.successText}>Congratulations! Your content was successfully uploaded.</Text> <Text style={publishStyle.successText}>Congratulations! Your content was successfully uploaded.</Text>
<View style={publishStyle.successRow}> <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 <TouchableOpacity
onPress={() => { onPress={() => {
Clipboard.setString(this.state.uri); Clipboard.setString(this.state.uri);
+35 -6
View File
@@ -33,14 +33,23 @@ class PublishesPage extends React.PureComponent {
this.onComponentFocused(); this.onComponentFocused();
} }
componentWillReceiveProps(nextProps) {
const { currentRoute } = nextProps;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_PUBLISHES === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
}
onComponentFocused = () => { onComponentFocused = () => {
const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props; const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack(); pushDrawerStack();
setPlayerVisible(); setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Publishes'); NativeModules.Firebase.setCurrentScreen('Publishes').then(result => {
fetchMyClaims();
fetchMyClaims(); checkPendingPublishes();
checkPendingPublishes(); });
}; };
addOrRemoveItem = (uri, claim) => { addOrRemoveItem = (uri, claim) => {
@@ -70,6 +79,16 @@ class PublishesPage extends React.PureComponent {
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} }); 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 = () => { onDeleteActionPressed = () => {
const { abandonClaim } = this.props; const { abandonClaim } = this.props;
const { selectedClaimsMap } = this.state; const { selectedClaimsMap } = this.state;
@@ -103,11 +122,13 @@ class PublishesPage extends React.PureComponent {
return ( return (
<View style={publishStyle.container}> <View style={publishStyle.container}>
<UriBar <UriBar
allowEdit
navigation={navigation} navigation={navigation}
selectionMode={selectionMode} selectionMode={selectionMode}
selectedItemCount={selectedUris.length} selectedItemCount={selectedUris.length}
onExitSelectionMode={this.onExitSelectionMode}
onDeleteActionPressed={this.onDeleteActionPressed} onDeleteActionPressed={this.onDeleteActionPressed}
onEditActionPressed={this.onEditActionPressed}
onExitSelectionMode={this.onExitSelectionMode}
/> />
{fetching && ( {fetching && (
<View style={publishStyle.centered}> <View style={publishStyle.centered}>
@@ -136,9 +157,17 @@ class PublishesPage extends React.PureComponent {
initialNumToRender={8} initialNumToRender={8}
maxToRenderPerBatch={24} maxToRenderPerBatch={24}
removeClippedSubviews removeClippedSubviews
ListFooterComponent={
<View style={publishStyle.publishesFooter}>
<Button
style={publishStyle.publishesFooterButton}
text={__('Publish something new')}
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
/>
</View>
}
renderItem={({ item }) => ( renderItem={({ item }) => (
<FileListItem <FileListItem
hideChannel
key={item} key={item}
uri={item} uri={item}
style={publishStyle.listItem} style={publishStyle.listItem}
+11 -17
View File
@@ -37,16 +37,16 @@ class SearchPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible, query, search } = this.props; const { pushDrawerStack, setPlayerVisible, query, search } = this.props;
pushDrawerStack(); pushDrawerStack();
setPlayerVisible(); setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Search'); NativeModules.Firebase.setCurrentScreen('Search').then(result => {
const searchQuery = query || this.getSearchQuery();
const searchQuery = query || this.getSearchQuery(); if (searchQuery && searchQuery.trim().length > 0) {
if (searchQuery && searchQuery.trim().length > 0) { this.setState({
this.setState({ currentQuery: searchQuery,
currentQuery: searchQuery, currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null, });
}); search(searchQuery);
search(searchQuery); }
} });
}; };
componentDidMount() { componentDidMount() {
@@ -101,13 +101,7 @@ class SearchPage extends React.PureComponent {
const { currentUri } = this.state; const { currentUri } = this.state;
return ( return (
<FileListItem <FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
uri={currentUri}
featuredResult
style={searchStyle.featuredResultItem}
navigation={navigation}
onPress={() => navigateToUri(navigation, this.state.currentUri)}
/>
); );
}; };
+5 -5
View File
@@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native'; import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation'; import { NavigationActions, StackActions } from 'react-navigation';
import { decode as atob } from 'base-64'; import { decode as atob } from 'base-64';
import { navigateToUri } from 'utils/helper'; import { navigateToUri, transformUrl } from 'utils/helper';
import moment from 'moment'; import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage'; import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button'; import Button from 'component/button';
@@ -81,7 +81,7 @@ class SplashScreen extends React.PureComponent {
}); });
} }
} else { } 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) { if (user && user.id && user.has_verified_email) {
// user already authenticated // user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) { if (walletPassword) {
getSync(walletPassword); getSync(walletPassword);
} }
this.navigateToMain(); 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 // 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 => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
if (password && password.trim().length > 0) { if (password) {
this.setState({ this.setState({
message: 'Unlocking account', message: 'Unlocking account',
details: 'Decrypting wallet', details: 'Decrypting wallet',
}); });
// unlock the wallet and then finish the splash screen // unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password }) Lbry.account_unlock({ password: password || '' })
.then(() => { .then(() => {
this.setState({ this.setState({
message: testingNetwork, message: testingNetwork,
+12 -8
View File
@@ -1,5 +1,6 @@
import React from 'react'; 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 Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import TransactionList from 'component/transactionList'; import TransactionList from 'component/transactionList';
import UriBar from 'component/uriBar'; import UriBar from 'component/uriBar';
@@ -23,9 +24,9 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchTransactions, pushDrawerStack, setPlayerVisible } = this.props; const { fetchTransactions, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack(); pushDrawerStack();
setPlayerVisible(); setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Transaction History'); NativeModules.Firebase.setCurrentScreen('Transaction History').then(result => {
fetchTransactions();
fetchTransactions(); });
}; };
componentDidMount() { componentDidMount() {
@@ -44,13 +45,16 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchingTransactions, transactions, navigation } = this.props; const { fetchingTransactions, transactions, navigation } = this.props;
return ( return (
<View> <View style={walletStyle.container}>
<UriBar navigation={navigation} /> <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}> <ScrollView style={walletStyle.transactionHistoryScroll}>
<View style={walletStyle.historyList}> <View style={walletStyle.historyList}>
{fetchingTransactions && !transactions.length && (
<Text style={walletStyle.infoText}>Loading transactions...</Text>
)}
{!fetchingTransactions && transactions.length === 0 && ( {!fetchingTransactions && transactions.length === 0 && (
<Text style={walletStyle.infoText}>No transactions to list.</Text> <Text style={walletStyle.infoText}>No transactions to list.</Text>
)} )}
+6 -3
View File
@@ -45,9 +45,12 @@ class TrendingPage extends React.PureComponent {
} }
onComponentFocused = () => { onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible, navigation } = this.props; const { pushDrawerStack, setPlayerVisible, navigation, sortByItem } = this.props;
const { filterForTags } = navigation.state.params ? navigation.state.params : { filterForTags: false }; 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); pushDrawerStack(Constants.DRAWER_ROUTE_TRENDING, navigation.state.params);
setPlayerVisible(); setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('All content'); NativeModules.Firebase.setCurrentScreen('All content');
@@ -110,7 +113,7 @@ class TrendingPage extends React.PureComponent {
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} /> <Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity> </TouchableOpacity>
{sortByTop && <Text style={discoverStyle.pickerLabel}>in the</Text>} {sortByTop && <Text style={discoverStyle.pickerLabel}>from</Text>}
{sortByTop && ( {sortByTop && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}> <TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
+3 -3
View File
@@ -29,7 +29,7 @@ import {
} from 'lbryinc'; } from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings'; import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/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'; import Verification from './view';
const select = state => ({ const select = state => ({
@@ -54,13 +54,13 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)), 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)), getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()), checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)), verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)), notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()), setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)), setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)), syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
@@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
import Button from 'component/button'; import Button from 'component/button';
import Link from 'component/link'; import Link from 'component/link';
import Colors from 'styles/colors'; 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 firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward'; import rewardStyle from 'styles/reward';
@@ -62,11 +62,29 @@ class SyncVerifyPage extends React.PureComponent {
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) { 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(); setDefaultAccount(
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); () => {
navigation.goBack(); 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; const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) { if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) { if (walletPassword) {
getSync(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 { routeName, params } = action.data;
const newStack = state.stack.slice(); 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 }); 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;
}
+23
View File
@@ -0,0 +1,23 @@
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 || {}
);
export const selectHasPublishFormState = createSelector(
selectPublishFormState,
values => Object.keys(values).length > 0
);
export const selectHasChannelFormState = createSelector(
selectChannelFormState,
values => Object.keys(values).length > 0
);
+18
View File
@@ -4,6 +4,9 @@ const autothumbStyle = StyleSheet.create({
autothumbPurple: { autothumbPurple: {
backgroundColor: '#9c27b0', backgroundColor: '#9c27b0',
}, },
autothumbDeepPurple: {
backgroundColor: '#5e35b1',
},
autothumbRed: { autothumbRed: {
backgroundColor: '#e53935', backgroundColor: '#e53935',
}, },
@@ -34,6 +37,21 @@ const autothumbStyle = StyleSheet.create({
autothumbOrange: { autothumbOrange: {
backgroundColor: '#ffa726', backgroundColor: '#ffa726',
}, },
autothumbAmber: {
backgroundColor: '#ffb300',
},
autothumbLime: {
backgroundColor: '#c0ca33',
},
autothumbLightGreen: {
backgroundColor: '#7cb342',
},
autothumbDeepOrange: {
backgroundColor: '#f4511e',
},
autothumbBrown: {
backgroundColor: '#6d4c41',
},
}); });
export default autothumbStyle; export default autothumbStyle;
+259
View File
@@ -0,0 +1,259 @@
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,
},
scrollPadding: {
padding: 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, flex: 1,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
padding: 24,
}, },
infoText: { infoText: {
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
@@ -165,6 +166,9 @@ const channelPageStyle = StyleSheet.create({
claimListContent: { claimListContent: {
paddingTop: 16, paddingTop: 16,
}, },
actionButton: {
backgroundColor: Colors.White,
},
}); });
export default channelPageStyle; export default channelPageStyle;
+4
View File
@@ -22,6 +22,10 @@ const discoverStyle = StyleSheet.create({
flex: 1, flex: 1,
backgroundColor: Colors.PageBackground, backgroundColor: Colors.PageBackground,
}, },
drawerContentArea: {
flex: 1,
backgroundColor: Colors.White,
},
drawerContentContainer: { drawerContentContainer: {
flex: 1, flex: 1,
}, },
+6 -2
View File
@@ -41,8 +41,8 @@ const filePageStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
textAlign: 'center', textAlign: 'center',
fontSize: 20, fontSize: 20,
marginLeft: 16, marginLeft: 24,
marginRight: 16, marginRight: 24,
}, },
scrollContainer: { scrollContainer: {
flex: 1, flex: 1,
@@ -194,6 +194,10 @@ const filePageStyle = StyleSheet.create({
}, },
fileActions: { fileActions: {
alignSelf: 'flex-end', alignSelf: 'flex-end',
flexDirection: 'row',
},
editButton: {
marginRight: 8,
}, },
socialActions: { socialActions: {
alignSelf: 'flex-start', alignSelf: 'flex-start',
+33 -10
View File
@@ -86,7 +86,7 @@ const publishStyle = StyleSheet.create({
marginTop: 8, marginTop: 8,
}, },
photo: { photo: {
height: 240, height: 120,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
}, },
@@ -156,6 +156,10 @@ const publishStyle = StyleSheet.create({
fontSize: 16, fontSize: 16,
marginLeft: 8, marginLeft: 8,
}, },
listEmptyText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
},
titleRow: { titleRow: {
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
@@ -324,18 +328,24 @@ const publishStyle = StyleSheet.create({
marginLeft: 4, marginLeft: 4,
}, },
thumbnailUploadContainer: { thumbnailUploadContainer: {
marginTop: 16,
marginLeft: 16,
marginRight: 16,
paddingLeft: 2,
paddingRight: 2,
flexDirection: 'row',
alignItems: 'center', 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: { thumbnailUploadText: {
fontFamily: 'Inter-UI-Regular', color: Colors.White,
fontSize: 14, fontFamily: 'Inter-UI-SemiBold',
marginLeft: 8, fontSize: 12,
marginLeft: 4,
}, },
toggleField: { toggleField: {
flexDirection: 'row', flexDirection: 'row',
@@ -362,6 +372,9 @@ const publishStyle = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
}, },
currencyPicker: {
width: 100,
},
fullCentered: { fullCentered: {
position: 'absolute', position: 'absolute',
left: 0, left: 0,
@@ -420,6 +433,16 @@ const publishStyle = StyleSheet.create({
fontSize: 14, fontSize: 14,
color: Colors.DescriptionGrey, color: Colors.DescriptionGrey,
}, },
publishesFooter: {
marginTop: 16,
marginLeft: 16,
marginRight: 16,
},
publishesFooterButton: {
alignSelf: 'flex-start',
backgroundColor: Colors.LbryGreen,
marginTop: 16,
},
}); });
export default publishStyle; export default publishStyle;
+3
View File
@@ -17,6 +17,9 @@ const transactionListStyle = StyleSheet.create({
topRow: { topRow: {
marginBottom: 4, marginBottom: 4,
}, },
leftCol: {
flex: 0.7,
},
col: { col: {
alignSelf: 'stretch', alignSelf: 'stretch',
}, },
+3
View File
@@ -98,6 +98,9 @@ const uriBarStyle = StyleSheet.create({
height: '100%', height: '100%',
alignItems: 'center', alignItems: 'center',
}, },
leftAction: {
marginRight: 16,
},
actionTouchArea: { actionTouchArea: {
height: '100%', height: '100%',
alignItems: 'center', alignItems: 'center',
+17
View File
@@ -3,6 +3,7 @@ import Colors from './colors';
const walletStyle = StyleSheet.create({ const walletStyle = StyleSheet.create({
container: { container: {
flex: 1,
backgroundColor: Colors.PageBackground, backgroundColor: Colors.PageBackground,
}, },
scrollContainer: { scrollContainer: {
@@ -288,6 +289,22 @@ const walletStyle = StyleSheet.create({
syncSwitch: { syncSwitch: {
marginLeft: 8, 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; export default walletStyle;
+86 -8
View File
@@ -1,7 +1,7 @@
import { NavigationActions, StackActions } from 'react-navigation'; 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 { 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; const tagNameLength = 10;
@@ -156,10 +156,26 @@ export function navigateBack(navigation, drawerStack, popDrawerStack) {
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0]; const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route, params } = target; const { route, params } = target;
navigation.goBack(navigation.state.key); 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); navigateToUri(navigation, route, null, true);
} else { } 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 target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route } = target; const { route } = target;
dispatch(NavigationActions.back()); dispatch(NavigationActions.back());
if (DrawerRoutes.indexOf(route) === -1 && isURIValid(route)) { if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
dispatchNavigateToUri(dispatch, nav, route, true); dispatchNavigateToUri(dispatch, nav, route, true);
} else { } else {
const newTarget = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0]; 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({ const navigateAction = NavigationActions.navigate({
routeName: newTarget.route, routeName: targetRoute,
params: newTarget.params, params: targetParams,
}); });
dispatch(navigateAction); dispatch(navigateAction);
} }
} }
@@ -184,7 +217,7 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
export function uriFromFileInfo(fileInfo) { export function uriFromFileInfo(fileInfo) {
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo; const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo;
const uriParams = {}; const uriParams = {};
uriParams.contentName = claimName || claimNameDownloaded; uriParams.claimName = claimName || claimNameDownloaded;
uriParams.claimId = claimId; uriParams.claimId = claimId;
return buildURI(uriParams); return buildURI(uriParams);
} }
@@ -246,7 +279,52 @@ export function getOrderBy(item) {
return orderBy; 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 // i18n placeholder until we find a good react-native i18n module
export function __(str) { export function __(str) {
return 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.');
}
});
}