Compare commits

..
95 changed files with 1606 additions and 3081 deletions

No files matched your search

+401 -336
View File
File diff suppressed because it is too large. Load diff
+7 -9
View File
@@ -12,30 +12,28 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#362d764c4c0de23032b6871b4d54207dc548028c",
"lbryinc": "lbryio/lbryinc#b9f354ae50bd57691765a7d042c5054167878bf4",
"lbry-redux": "lbryio/lbry-redux#67a654f60630710cae72419448a73a18d076d18a",
"lbryinc": "lbryio/lbryinc",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",
"moment": "^2.22.1",
"react": "16.8.6",
"react-native": "0.59.10",
"@react-native-community/async-storage": "^1.5.1",
"react-native-camera": "^2.11.1",
"react-native-camera": "^2.11.0",
"react-native-country-picker-modal": "^0.6.2",
"react-native-document-picker": "^3.2.4",
"react-native-document-picker": "^2.3.0",
"react-native-exception-handler": "2.9.0",
"react-native-fast-image": "^6.1.1",
"react-native-fast-image": "^5.0.3",
"react-native-fs": "^2.13.3",
"react-native-gesture-handler": "1.1.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-image-zoom-viewer": "^2.2.5",
"react-native-password-strength-meter": "^0.0.2",
"react-native-phone-input": "lbryio/react-native-phone-input",
"react-native-reanimated": "1.2.0",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^6.6.0",
"react-native-vector-icons": "^6.4.2",
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
"react-navigation": "^3.11.0",
"react-navigation-drawer": "^2.0.0",
"react-navigation-redux-helpers": "^3.0.2",
"react-redux": "^5.0.3",
"redux": "^4.0.4",
+31 -28
View File
@@ -17,8 +17,7 @@ import SubscriptionsPage from 'page/subscriptions';
import TransactionHistoryPage from 'page/transactionHistory';
import VerificationScreen from 'page/verification';
import WalletPage from 'page/wallet';
import { createStackNavigator, NavigationActions } from 'react-navigation';
import { createDrawerNavigator } from 'react-navigation-drawer';
import { createDrawerNavigator, createStackNavigator, NavigationActions } from 'react-navigation';
import {
createReduxContainer,
createReactNavigationReduxMiddleware,
@@ -40,7 +39,7 @@ import {
} from 'lbryinc';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { decode as atob } from 'base-64';
import { dispatchNavigateBack, dispatchNavigateToUri, transformUrl } from 'utils/helper';
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -128,84 +127,79 @@ const walletStack = createStackNavigator(
}
);
const drawerIconSize = 18;
const drawer = createDrawerNavigator(
{
DiscoverStack: {
screen: discoverStack,
navigationOptions: {
title: 'Explore',
drawerIcon: ({ tintColor }) => <Icon name="home" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="home" size={20} style={{ color: tintColor }} />,
},
},
Trending: {
TrendingStack: {
screen: TrendingPage,
navigationOptions: {
title: 'All Content',
drawerIcon: ({ tintColor }) => <Icon name="fire" size={drawerIconSize} style={{ color: tintColor }} />,
title: 'Trending',
drawerIcon: ({ tintColor }) => <Icon name="fire" size={20} style={{ color: tintColor }} />,
},
},
Subscriptions: {
MySubscriptionsStack: {
screen: SubscriptionsPage,
navigationOptions: {
title: 'Subscriptions',
drawerIcon: ({ tintColor }) => <Icon name="heart" solid size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="heart" solid size={20} style={{ color: tintColor }} />,
},
},
WalletStack: {
screen: walletStack,
navigationOptions: {
title: 'Wallet',
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="wallet" size={20} style={{ color: tintColor }} />,
},
},
Publish: {
screen: PublishPage,
navigationOptions: {
drawerIcon: ({ tintColor }) => <Icon name="upload" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="upload" size={20} style={{ color: tintColor }} />,
},
},
Publishes: {
screen: PublishesPage,
navigationOptions: {
drawerIcon: ({ tintColor }) => (
<Icon name="cloud-upload-alt" size={drawerIconSize} style={{ color: tintColor }} />
),
drawerIcon: ({ tintColor }) => <Icon name="cloud-upload-alt" size={20} style={{ color: tintColor }} />,
},
},
Rewards: {
screen: RewardsPage,
navigationOptions: {
drawerIcon: ({ tintColor }) => <Icon name="award" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="award" size={20} style={{ color: tintColor }} />,
},
},
Downloads: {
MyLBRYStack: {
screen: DownloadsPage,
navigationOptions: {
title: 'Library',
drawerIcon: ({ tintColor }) => <Icon name="download" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="download" size={20} style={{ color: tintColor }} />,
},
},
Settings: {
screen: SettingsPage,
navigationOptions: {
drawerLockMode: 'locked-closed',
drawerIcon: ({ tintColor }) => <Icon name="cog" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="cog" size={20} style={{ color: tintColor }} />,
},
},
About: {
screen: AboutPage,
navigationOptions: {
drawerLockMode: 'locked-closed',
drawerIcon: ({ tintColor }) => <Icon name="info" size={drawerIconSize} style={{ color: tintColor }} />,
drawerIcon: ({ tintColor }) => <Icon name="info" size={20} style={{ color: tintColor }} />,
},
},
},
{
drawerWidth: 300,
headerMode: 'none',
backBehavior: 'none',
unmountInactiveRoutes: true,
contentComponent: DrawerContent,
contentOptions: {
activeTintColor: Colors.LbryGreen,
@@ -271,11 +265,21 @@ class AppWithNavigationState extends React.Component {
'hardwareBackPress',
function() {
const { dispatch, nav, drawerStack } = this.props;
if (drawerStack.length > 1) {
dispatchNavigateBack(dispatch, nav, drawerStack);
return true;
// There should be a better way to check this
if (nav.routes.length > 0) {
if (nav.routes[0].routeName === 'Main') {
const mainRoute = nav.routes[0];
if (
mainRoute.index > 0 ||
mainRoute.routes[0].index > 0 /* Discover stack index */ ||
mainRoute.routes[4].index > 0 /* Wallet stack index */ ||
mainRoute.index >= 5 /* Settings and About screens */
) {
dispatchNavigateBack(dispatch, nav, drawerStack);
return true;
}
}
}
return false;
}.bind(this)
);
@@ -309,7 +313,6 @@ class AppWithNavigationState extends React.Component {
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false');
this.setState({ verifyPending: false });
NativeModules.Firebase.track('email_verified', { email: user.primary_email });
ToastAndroid.show('Your email address was successfully verified.', ToastAndroid.LONG);
// upon successful email verification, do wallet sync (if password has been set)
@@ -413,7 +416,7 @@ class AppWithNavigationState extends React.Component {
);
}
} else {
dispatchNavigateToUri(dispatch, nav, transformUrl(evt.url));
dispatchNavigateToUri(dispatch, nav, evt.url);
}
}
};
+7 -2
View File
@@ -34,11 +34,16 @@ export default class Button extends React.PureComponent {
}
let renderIcon = (
<Icon name={icon} size={16} color={iconColor || (theme === 'light' ? Colors.DarkGrey : Colors.White)} />
<Icon name={icon} size={18} color={iconColor ? iconColor : 'light' === theme ? Colors.DarkGrey : Colors.White} />
);
if (solid) {
renderIcon = (
<Icon name={icon} size={16} color={iconColor || (theme === 'light' ? Colors.DarkGrey : Colors.White)} solid />
<Icon
name={icon}
size={18}
color={iconColor ? iconColor : 'light' === theme ? Colors.DarkGrey : Colors.White}
solid
/>
);
}
+1 -8
View File
@@ -1,17 +1,10 @@
import { connect } from 'react-redux';
import {
doResolveUri,
makeSelectClaimForUri,
makeSelectThumbnailForUri,
makeSelectTitleForUri,
makeSelectIsUriResolving,
} from 'lbry-redux';
import { doResolveUri, makeSelectClaimForUri, makeSelectThumbnailForUri, makeSelectIsUriResolving } from 'lbry-redux';
import ChannelIconItem from './view';
const select = (state, props) => ({
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
});
+7 -37
View File
@@ -1,35 +1,9 @@
import React from 'react';
import { ActivityIndicator, Image, Text, TouchableOpacity, View } from 'react-native';
import Colors from 'styles/colors';
import autothumbStyle from 'styles/autothumb';
import channelIconStyle from 'styles/channelIcon';
export default class ChannelIconItem extends React.PureComponent {
static AUTO_THUMB_STYLES = [
autothumbStyle.autothumbPurple,
autothumbStyle.autothumbRed,
autothumbStyle.autothumbPink,
autothumbStyle.autothumbIndigo,
autothumbStyle.autothumbBlue,
autothumbStyle.autothumbLightBlue,
autothumbStyle.autothumbCyan,
autothumbStyle.autothumbTeal,
autothumbStyle.autothumbGreen,
autothumbStyle.autothumbYellow,
autothumbStyle.autothumbOrange,
];
state = {
autoStyle: null,
};
componentWillMount() {
this.setState({
autoStyle:
ChannelIconItem.AUTO_THUMB_STYLES[Math.floor(Math.random() * ChannelIconItem.AUTO_THUMB_STYLES.length)],
});
}
componentDidMount() {
const { claim, isPlaceholder, uri, resolveUri } = this.props;
if (!claim && !isPlaceholder) {
@@ -39,8 +13,6 @@ export default class ChannelIconItem extends React.PureComponent {
render() {
const { claim, isPlaceholder, isResolvingUri, onPress, thumbnail, title } = this.props;
const displayName = title || (claim ? claim.name : '');
const substrIndex = displayName.startsWith('@') ? 1 : 0;
return (
<TouchableOpacity style={channelIconStyle.container} onPress={onPress}>
@@ -53,7 +25,6 @@ export default class ChannelIconItem extends React.PureComponent {
style={[
channelIconStyle.thumbnailContainer,
isPlaceholder ? channelIconStyle.borderedThumbnailContainer : null,
isPlaceholder ? null : this.state.autoStyle,
]}
>
{isPlaceholder && (
@@ -61,18 +32,17 @@ export default class ChannelIconItem extends React.PureComponent {
<Text style={channelIconStyle.placeholderText}>ALL</Text>
</View>
)}
{!isPlaceholder && thumbnail && (
<Image style={channelIconStyle.thumbnail} resizeMode={'cover'} source={{ uri: thumbnail }} />
)}
{!isPlaceholder && !thumbnail && (
<Text style={channelIconStyle.autothumbCharacter}>
{displayName.substring(substrIndex, substrIndex + 1).toUpperCase()}
</Text>
{!isPlaceholder && (
<Image
style={channelIconStyle.thumbnail}
resizeMode={'cover'}
source={thumbnail ? { uri: thumbnail } : require('../../assets/default_avatar.jpg')}
/>
)}
</View>
{!isPlaceholder && (
<Text style={channelIconStyle.title} numberOfLines={1}>
{displayName}
{title || (claim ? claim.name : '')}
</Text>
)}
</TouchableOpacity>
+15 -34
View File
@@ -1,9 +1,9 @@
import React from 'react';
import { CLAIM_VALUES, isURIValid } from 'lbry-redux';
import { CLAIM_VALUES, isNameValid } from 'lbry-redux';
import { ActivityIndicator, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
import Button from 'component/button';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Link from 'component/link';
import channelSelectorStyle from 'styles/channelSelector';
@@ -26,19 +26,12 @@ export default class ChannelSelector extends React.PureComponent {
}
componentDidMount() {
const { channels, channelName, fetchChannelListMine, fetchingChannels } = this.props;
const { channels, fetchChannelListMine, fetchingChannels } = this.props;
if (!channels.length && !fetchingChannels) {
fetchChannelListMine();
}
}
componentDidUpdate() {
const { channelName } = this.props;
if (this.state.currentSelectedValue !== channelName) {
this.setState({ currentSelectedValue: channelName });
}
}
handleCreateCancel = () => {
this.setState({ showCreateChannel: false, newChannelName: '', newChannelBid: 0.1 });
};
@@ -61,13 +54,13 @@ export default class ChannelSelector extends React.PureComponent {
if (channel === CLAIM_VALUES.CHANNEL_NEW) {
this.setState({ addingChannel: true });
if (onChannelChange) {
onChannelChange(value);
onChannelChange(channel);
}
this.handleNewChannelBidChange(newChannelBid);
} else {
this.setState({ addingChannel: false });
if (onChannelChange) {
onChannelChange(value);
onChannelChange(channel);
}
}
};
@@ -75,22 +68,14 @@ export default class ChannelSelector extends React.PureComponent {
handleNewChannelNameChange = value => {
const { notify } = this.props;
let newChannelName = value,
newChannelNameError = '';
let newChannelName = value;
if (newChannelName.startsWith('@')) {
newChannelName = newChannelName.slice(1);
}
if (newChannelName.trim().length > 0 && !isURIValid(newChannelName)) {
newChannelNameError = 'Your channel name contains invalid characters.';
} else if (this.channelExists(newChannelName)) {
newChannelNameError = 'You have already created a channel with the same name.';
}
this.setState({
newChannelName,
newChannelNameError,
});
};
@@ -117,7 +102,7 @@ export default class ChannelSelector extends React.PureComponent {
const { balance, createChannel, onChannelChange, notify } = this.props;
const { newChannelBid, newChannelName } = this.state;
if (newChannelName.trim().length === 0 || !isURIValid(newChannelName.substr(1), false)) {
if (newChannelName.trim().length === 0 || !isNameValid(newChannelName.substr(1), false)) {
notify({ message: 'Your channel name contains invalid characters.' });
return;
}
@@ -178,9 +163,10 @@ export default class ChannelSelector extends React.PureComponent {
render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel;
const { enabled, fetchingChannels, channels = [] } = this.props;
const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(channels.map(ch => ch.name));
const { fetchingChannels, channels = [] } = this.props;
const pickerItems = [{ name: Constants.ITEM_ANONYMOUS }, { name: Constants.ITEM_CREATE_A_CHANNEL }].concat(
channels
);
const {
newChannelName,
newChannelNameError,
@@ -189,24 +175,22 @@ export default class ChannelSelector extends React.PureComponent {
creatingChannel,
createChannelError,
addingChannel,
showCreateChannel,
} = this.state;
return (
<View style={channelSelectorStyle.container}>
<Picker
enabled={enabled}
selectedValue={this.state.currentSelectedValue}
style={channelSelectorStyle.channelPicker}
itemStyle={channelSelectorStyle.channelPickerItem}
onValueChange={this.handlePickerValueChange}
>
{pickerItems.map(item => (
<Picker.Item label={item} value={item} key={item} />
<Picker.Item label={item.name} value={item.name} key={item.name} />
))}
</Picker>
{showCreateChannel && (
{this.state.showCreateChannel && (
<View style={channelSelectorStyle.createChannelContainer}>
<View style={channelSelectorStyle.channelInputContainer}>
<Text style={channelSelectorStyle.channelAt}>@</Text>
@@ -219,14 +203,11 @@ export default class ChannelSelector extends React.PureComponent {
underlineColorAndroid={Colors.NextLbryGreen}
/>
</View>
{newChannelNameError.length > 0 && (
<Text style={channelSelectorStyle.inlineError}>{newChannelNameError}</Text>
)}
<View style={channelSelectorStyle.bidRow}>
<Text style={channelSelectorStyle.label}>Deposit</Text>
<TextInput
style={channelSelectorStyle.bidAmountInput}
value={String(newChannelBid)}
value={String(this.state.newChannelBid)}
onChangeText={this.handleNewChannelBidChange}
placeholder={'0.00'}
keyboardType={'number-pad'}
@@ -245,7 +226,7 @@ export default class ChannelSelector extends React.PureComponent {
<Link style={channelSelectorStyle.cancelLink} text="Cancel" onPress={this.handleCreateCancel} />
<Button
style={channelSelectorStyle.createButton}
disabled={!(newChannelName.trim().length > 0 && newChannelBid > 0)}
disabled={!(this.state.newChannelName.trim().length > 0 && this.state.newChannelBid > 0)}
text="Create"
onPress={this.handleCreateChannelClick}
/>
+31 -12
View File
@@ -2,25 +2,44 @@ import { connect } from 'react-redux';
import {
MATURE_TAGS,
doClaimSearch,
selectClaimSearchByQuery,
selectClaimSearchByQueryLastPageReached,
selectFetchingClaimSearchByQuery,
doClaimSearchByTags,
makeSelectClaimSearchUrisForTags,
makeSelectFetchingClaimSearchForTags,
selectFetchingClaimSearch,
selectLastClaimSearchUris,
} from 'lbry-redux';
import { selectShowNsfw } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import ClaimList from './view';
const select = state => ({
showNsfwContent: selectShowNsfw(state),
claimSearchByQuery: selectClaimSearchByQuery(state),
lastPageReached: selectClaimSearchByQueryLastPageReached(state),
loadingByQuery: selectFetchingClaimSearchByQuery(state),
loading: selectFetchingClaimSearch(state),
});
const select = (state, props) => {
return {
loading: makeSelectFetchingClaimSearchForTags(props.tags)(state),
uris: makeSelectClaimSearchUrisForTags(props.tags)(state),
// for subscriptions
claimSearchLoading: selectFetchingClaimSearch(state),
claimSearchUris: selectLastClaimSearchUris(state),
};
};
const perform = dispatch => ({
claimSearch: options => dispatch(doClaimSearch(options)),
claimSearch: options => dispatch(doClaimSearch(Constants.DEFAULT_PAGE_SIZE, options)),
searchByTags: (tags, orderBy = Constants.DEFAULT_ORDER_BY, page = 1, additionalOptions = {}) =>
dispatch(
doClaimSearchByTags(
tags,
Constants.DEFAULT_PAGE_SIZE,
Object.assign(
{},
{
no_totals: true,
order_by: orderBy,
page,
not_tags: MATURE_TAGS,
},
additionalOptions
)
)
),
});
export default connect(
+111 -113
View File
@@ -1,7 +1,7 @@
import React from 'react';
import NavigationActions from 'react-navigation';
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
import { MATURE_TAGS, normalizeURI, createNormalizedClaimSearchKey } from 'lbry-redux';
import { MATURE_TAGS, normalizeURI } from 'lbry-redux';
import _ from 'lodash';
import FileItem from 'component/fileItem';
import FileListItem from 'component/fileListItem';
@@ -21,82 +21,94 @@ class ClaimList extends React.PureComponent {
state = {
currentPage: 1, // initial page load is page 1
subscriptionsView: false, // whether or not this claim list is for subscriptions
lastPageReached: false,
trendingForAllView: false,
};
componentDidMount() {
const { channelIds } = this.props;
const {
channelIds,
trendingForAll,
claimSearch,
orderBy = Constants.DEFAULT_ORDER_BY,
searchByTags,
tags,
time,
} = this.props;
if (channelIds || trendingForAll) {
const options = {
order_by: orderBy,
no_totals: true,
not_tags: MATURE_TAGS,
page: this.state.currentPage,
};
if (channelIds) {
this.setState({ subscriptionsView: true });
options.channel_ids = channelIds;
} else if (trendingForAll) {
this.setState({ trendingForAllView: true });
}
if (channelIds) {
this.setState({ subscriptionsView: true });
claimSearch(options);
} else if (tags && tags.length > 0) {
const additionalOptions = {};
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
additionalOptions.release_time = this.getReleaseTimeOption(time);
}
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
}
this.doClaimSearch();
}
componentDidUpdate(prevProps) {
componentWillReceiveProps(nextProps) {
const {
claimSearchByQuery: prevClaimSearchByQuery,
claimSearch,
orderBy: prevOrderBy,
searchByTags,
tags: prevTags,
channelIds: prevChannelIds,
trendingForAll: prevTrendingForAll,
time: prevTime,
} = prevProps;
const { claimSearchByQuery, orderBy, tags, channelIds, time } = this.props;
} = this.props;
const { orderBy, tags, channelIds, trendingForAll, time } = nextProps;
if (
!_.isEqual(orderBy, prevOrderBy) ||
!_.isEqual(tags, prevTags) ||
!_.isEqual(channelIds, prevChannelIds) ||
time !== prevTime
time !== prevTime ||
trendingForAll !== prevTrendingForAll
) {
// reset to page 1 because the order, tags or channelIds changed
this.setState({ currentPage: 1 }, () => {
if (this.scrollView) {
this.scrollView.scrollToOffset({ animated: true, offset: 0 });
}
if (prevChannelIds && channelIds) {
if (trendingForAll || (prevChannelIds && channelIds)) {
const options = {
order_by: orderBy,
no_totals: true,
not_tags: MATURE_TAGS,
page: this.state.currentPage,
};
if (channelIds) {
this.setState({ subscriptionsView: true });
options.channel_ids = channelIds;
}
if (trendingForAll) {
this.setState({ trendingForAllView: true });
}
} else if (tags && tags.length > 0) {
this.setState({ subscriptionsView: false });
}
this.doClaimSearch();
claimSearch(options);
} else if (tags && tags.length > 0) {
this.setState({ subscriptionsView: false, trendingForAllView: false });
const additionalOptions = {};
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
additionalOptions.release_time = this.getReleaseTimeOption(time);
}
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
}
});
}
}
buildClaimSearchOptions() {
const { orderBy, channelIds, showNsfwContent, tags, time } = this.props;
const { currentPage, subscriptionsView } = this.state;
const options = {
order_by: orderBy,
no_totals: true,
page: currentPage,
page_size: Constants.DEFAULT_PAGE_SIZE,
};
if (channelIds) {
options.channel_ids = channelIds;
} else if (tags && tags.length > 0) {
options.any_tags = tags;
}
if (!showNsfwContent) {
options.not_tags = MATURE_TAGS;
}
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
options.release_time = this.getReleaseTimeOption(time);
}
return options;
}
getReleaseTimeOption = time => {
return `>${Math.floor(
moment()
@@ -105,27 +117,36 @@ class ClaimList extends React.PureComponent {
)}`;
};
doClaimSearch() {
const { claimSearch } = this.props;
const options = this.buildClaimSearchOptions();
claimSearch(options);
}
handleVerticalEndReached = () => {
// fetch more content
const { claimSearchByQuery, lastPageReached } = this.props;
const options = this.buildClaimSearchOptions();
const claimSearchKey = createNormalizedClaimSearchKey(options);
const uris = claimSearchByQuery[claimSearchKey];
if (
lastPageReached[claimSearchKey] ||
((uris.length > 0 && uris.length < Constants.DEFAULT_PAGE_SIZE) || uris.length >= softLimit)
) {
const { channelIds, claimSearch, claimSearchUris, orderBy, searchByTags, tags, time, uris } = this.props;
const { subscriptionsView, trendingForAllView } = this.state;
if ((claimSearchUris && claimSearchUris.length >= softLimit) || (uris && uris.length >= softLimit)) {
// don't fetch more than the specified limit to be displayed
return;
}
this.setState({ currentPage: this.state.currentPage + 1 }, () => this.doClaimSearch());
this.setState({ currentPage: this.state.currentPage + 1 }, () => {
if (subscriptionsView || trendingForAllView) {
const options = {
order_by: orderBy,
no_totals: true,
not_tags: MATURE_TAGS,
page: this.state.currentPage,
};
if (subscriptionsView) {
options.channel_ids = channelIds;
}
claimSearch(options);
} else {
const additionalOptions = {};
if (orderBy && orderBy[0] === Constants.ORDER_BY_EFFECTIVE_AMOUNT && Constants.TIME_ALL !== time) {
additionalOptions.release_time = this.getReleaseTimeOption(time);
}
searchByTags(tags, orderBy, this.state.currentPage, additionalOptions);
}
});
};
appendMorePlaceholder = items => {
@@ -140,7 +161,7 @@ class ClaimList extends React.PureComponent {
if (tags.length === 1) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: 'tagPage', params: { tag: tags[0] } });
} else {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TRENDING, params: { filterForTags: true } });
navigation.navigate({ routeName: Constants.FULL_ROUTE_NAME_TRENDING });
}
};
@@ -153,60 +174,22 @@ class ClaimList extends React.PureComponent {
);
};
verticalListEmptyComponent = () => {
return (
<Text style={claimListStyle.noContentText}>No content to display at this time. Please check back later.</Text>
);
};
renderVerticalItem = ({ item }) => {
const { hideChannel, navigation } = this.props;
return (
<FileListItem
key={item}
uri={item}
hideChannel={hideChannel}
style={claimListStyle.verticalListItem}
navigation={navigation}
/>
);
};
renderHorizontalItem = ({ item }) => {
const { navigation } = this.props;
return item === Constants.MORE_PLACEHOLDER ? (
this.renderMorePlaceholder()
) : (
<FileItem
style={discoverStyle.fileItem}
mediaStyle={discoverStyle.fileItemMedia}
key={item}
uri={normalizeURI(item)}
navigation={navigation}
showDetails
compactView={false}
/>
);
};
render() {
const {
ListHeaderComponent,
loading,
claimSearchLoading,
claimSearchUris,
morePlaceholder,
navigation,
orientation = Constants.ORIENTATION_VERTICAL,
style,
claimSearchByQuery,
uris,
} = this.props;
const { subscriptionsView } = this.state;
const options = this.buildClaimSearchOptions();
const claimSearchKey = createNormalizedClaimSearchKey(options);
const uris = claimSearchByQuery[claimSearchKey];
const { subscriptionsView, trendingForAllView } = this.state;
if (Constants.ORIENTATION_VERTICAL === orientation) {
const data = subscriptionsView || trendingForAllView ? claimSearchUris : uris;
return (
<View style={style}>
<FlatList
@@ -214,21 +197,22 @@ class ClaimList extends React.PureComponent {
this.scrollView = ref;
}}
ListHeaderComponent={ListHeaderComponent}
ListEmptyComponent={loading ? null : this.verticalListEmptyComponent}
style={claimListStyle.verticalScrollContainer}
contentContainerStyle={claimListStyle.verticalScrollPadding}
initialNumToRender={10}
maxToRenderPerBatch={20}
removeClippedSubviews
renderItem={this.renderVerticalItem}
data={uris}
renderItem={({ item }) => (
<FileListItem key={item} uri={item} style={claimListStyle.verticalListItem} navigation={navigation} />
)}
data={data}
keyExtractor={(item, index) => item}
onEndReached={this.handleVerticalEndReached}
onEndReachedThreshold={0.2}
/>
{loading && (
{(((subscriptionsView || trendingForAllView) && claimSearchLoading) || loading) && (
<View style={claimListStyle.verticalLoading}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
</View>
)}
</View>
@@ -239,7 +223,7 @@ class ClaimList extends React.PureComponent {
if (loading) {
return (
<View style={discoverStyle.listLoading}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
</View>
);
}
@@ -251,7 +235,21 @@ class ClaimList extends React.PureComponent {
initialNumToRender={3}
maxToRenderPerBatch={3}
removeClippedSubviews
renderItem={this.renderHorizontalItem}
renderItem={({ item }) => {
return item === Constants.MORE_PLACEHOLDER ? (
this.renderMorePlaceholder()
) : (
<FileItem
style={discoverStyle.fileItem}
mediaStyle={discoverStyle.fileItemMedia}
key={item}
uri={normalizeURI(item)}
navigation={navigation}
showDetails
compactView={false}
/>
);
}}
horizontal
showsHorizontalScrollIndicator={false}
data={uris ? this.appendMorePlaceholder(uris.slice(0, horizontalLimit)) : []}
+21 -68
View File
@@ -1,81 +1,34 @@
import React from 'react';
import { DrawerItems, SafeAreaView } from 'react-navigation';
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Icon from 'react-native-vector-icons/FontAwesome5';
import { ScrollView } from 'react-native';
import Constants from 'constants';
import discoverStyle from 'styles/discover';
const groupedMenuItems = {
'Find content': [
{ icon: 'hashtag', label: 'Your tags', route: Constants.DRAWER_ROUTE_DISCOVER },
{ icon: 'heart', solid: true, label: 'Subscriptions', route: Constants.DRAWER_ROUTE_SUBSCRIPTIONS },
{ icon: 'globe-americas', label: 'All content', route: Constants.DRAWER_ROUTE_TRENDING },
],
'Your content': [
{ icon: 'download', label: 'Library', route: Constants.DRAWER_ROUTE_MY_LBRY },
{ icon: 'cloud-upload-alt', label: 'Publishes', route: Constants.DRAWER_ROUTE_PUBLISHES },
{ icon: 'upload', label: 'New publish', route: Constants.DRAWER_ROUTE_PUBLISH },
],
Wallet: [
{ icon: 'wallet', label: 'Wallet', route: Constants.DRAWER_ROUTE_WALLET },
{ icon: 'award', label: 'Rewards', route: Constants.DRAWER_ROUTE_REWARDS },
],
Settings: [
{ icon: 'cog', label: 'Settings', route: Constants.DRAWER_ROUTE_SETTINGS },
{ icon: 'info', label: 'About', route: Constants.DRAWER_ROUTE_ABOUT },
],
};
const groupNames = Object.keys(groupedMenuItems);
class DrawerContent extends React.PureComponent {
render() {
const { activeTintColor, navigation, onItemPress } = this.props;
const { state } = navigation;
const activeItemKey = state.routes[state.index] ? state.routes[state.index].key : null;
const props = this.props;
const { navigation, onItemPress } = props;
return (
<ScrollView contentContainerStyle={discoverStyle.menuScrollContent}>
<ScrollView>
<SafeAreaView style={discoverStyle.drawerContentContainer} forceInset={{ top: 'always', horizontal: 'never' }}>
{groupNames.map(groupName => {
const menuItems = groupedMenuItems[groupName];
<DrawerItems
{...props}
onItemPress={route => {
const { routeName } = route.route;
if (Constants.FULL_ROUTE_NAME_DISCOVER === routeName) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_DISCOVER });
return;
}
return (
<View key={groupName} style={discoverStyle.menuGroup}>
{groupNames[3] !== groupName && (
<Text key={`${groupName}-title`} style={discoverStyle.menuGroupName}>
{groupName}
</Text>
)}
{menuItems.map(item => {
const focused =
activeItemKey === item.route ||
(activeItemKey === Constants.FULL_ROUTE_NAME_DISCOVER &&
item.route === Constants.DRAWER_ROUTE_DISCOVER) ||
(activeItemKey === Constants.FULL_ROUTE_NAME_WALLET &&
item.route === Constants.DRAWER_ROUTE_WALLET);
return (
<TouchableOpacity
accessible
accessibilityLabel={item.label}
style={[discoverStyle.menuItemTouchArea, focused ? discoverStyle.menuItemTouchAreaFocused : null]}
key={item.label}
onPress={() => navigation.navigate({ routeName: item.route })}
delayPressIn={0}
>
<View style={discoverStyle.menuItemIcon}>
<Icon name={item.icon} size={16} solid={item.solid} color={focused ? activeTintColor : null} />
</View>
<Text style={[discoverStyle.menuItem, focused ? discoverStyle.menuItemFocused : null]}>
{item.label}
</Text>
</TouchableOpacity>
);
})}
</View>
);
})}
if (Constants.FULL_ROUTE_NAME_WALLET === routeName) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_WALLET });
return;
}
onItemPress(route);
}}
/>
</SafeAreaView>
</ScrollView>
);
+1 -3
View File
@@ -8,7 +8,6 @@ import {
makeSelectTitleForUri,
makeSelectIsUriResolving,
makeSelectClaimIsNsfw,
makeSelectShortUrlForUri,
} from 'lbry-redux';
import { selectRewardContentClaimIds } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
@@ -18,10 +17,9 @@ const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
obscureNsfw: !selectShowNsfw(state),
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
+10 -17
View File
@@ -30,12 +30,12 @@ class FileItem extends React.PureComponent {
}
navigateToFileUri = () => {
const { navigation, uri, shortUrl } = this.props;
const { navigation, uri } = this.props;
const normalizedUri = normalizeURI(uri);
if (NativeModules.Firebase) {
NativeModules.Firebase.track('explore_click', { uri: normalizedUri, short_url: shortUrl });
NativeModules.Firebase.track('explore_click', { uri: normalizedUri });
}
navigateToUri(navigation, shortUrl || uri);
navigateToUri(navigation, normalizedUri);
};
render() {
@@ -50,28 +50,19 @@ class FileItem extends React.PureComponent {
style,
mediaStyle,
navigation,
nsfw,
obscureNsfw,
showDetails,
compactView,
titleBeforeThumbnail,
} = this.props;
if (claim && claim.value_type === 'channel') {
// don't display channels in the lists on the Explore page
return null;
}
const uri = normalizeURI(this.props.uri);
const obscure = obscureNsfw && nsfw;
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
const signingChannel = claim ? claim.signing_channel : null;
const channelName = signingChannel ? signingChannel.name : null;
const channelClaimId = signingChannel ? signingChannel.claim_id : null;
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
const shortChannelUri = signingChannel ? signingChannel.short_url : null;
const height = claim ? claim.height : null;
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
return (
<View style={style}>
@@ -82,13 +73,14 @@ class FileItem extends React.PureComponent {
</Text>
)}
<FileItemMedia
duration={duration}
title={title}
thumbnail={thumbnail}
blurRadius={obscureNsfw ? 15 : 0}
resizeMode="cover"
isResolvingUri={isResolvingUri}
style={mediaStyle}
/>
{!compactView && fileInfo && fileInfo.completed && fileInfo.download_path && (
<Icon style={discoverStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
)}
@@ -110,16 +102,17 @@ class FileItem extends React.PureComponent {
style={discoverStyle.channelName}
text={channelName}
onPress={() => {
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
navigateToUri(navigation, normalizeURI(fullChannelUri));
}}
/>
)}
{!channelName && !isResolvingUri && <Text style={discoverStyle.anonChannelName}>Anonymous</Text>}
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo uri={uri} />
</View>
)}
</TouchableOpacity>
{obscure && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
{obscureNsfw && (
<NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />
)}
</View>
);
}
+32 -38
View File
@@ -2,26 +2,24 @@ import React from 'react';
import { ActivityIndicator, Image, Text, View } from 'react-native';
import Colors from 'styles/colors';
import FastImage from 'react-native-fast-image';
import VideoDuration from 'component/videoDuration';
import autothumbStyle from 'styles/autothumb';
import fileItemMediaStyle from 'styles/fileItemMedia';
class FileItemMedia extends React.PureComponent {
static AUTO_THUMB_STYLES = [
autothumbStyle.autothumbPurple,
autothumbStyle.autothumbRed,
autothumbStyle.autothumbPink,
autothumbStyle.autothumbIndigo,
autothumbStyle.autothumbBlue,
autothumbStyle.autothumbLightBlue,
autothumbStyle.autothumbCyan,
autothumbStyle.autothumbTeal,
autothumbStyle.autothumbGreen,
autothumbStyle.autothumbYellow,
autothumbStyle.autothumbOrange,
fileItemMediaStyle.autothumbPurple,
fileItemMediaStyle.autothumbRed,
fileItemMediaStyle.autothumbPink,
fileItemMediaStyle.autothumbIndigo,
fileItemMediaStyle.autothumbBlue,
fileItemMediaStyle.autothumbLightBlue,
fileItemMediaStyle.autothumbCyan,
fileItemMediaStyle.autothumbTeal,
fileItemMediaStyle.autothumbGreen,
fileItemMediaStyle.autothumbYellow,
fileItemMediaStyle.autothumbOrange,
];
state = {
state: {
imageLoadFailed: false,
};
@@ -50,7 +48,7 @@ class FileItemMedia extends React.PureComponent {
return false;
}
if (thumbnail.substring(0, 7) !== 'http://' && thumbnail.substring(0, 8) !== 'https://') {
if (thumbnail.substring(0, 7) != 'http://' && thumbnail.substring(0, 8) != 'https://') {
return false;
}
@@ -59,34 +57,37 @@ class FileItemMedia extends React.PureComponent {
render() {
let style = this.props.style;
const { duration, isResolvingUri, thumbnail, title, resizeMode } = this.props;
const { blurRadius, isResolvingUri, thumbnail, title, resizeMode } = this.props;
const atStyle = this.state.autoThumbStyle;
if (this.isThumbnailValid(thumbnail) && !this.state.imageLoadFailed) {
if (style == null) {
style = fileItemMediaStyle.thumbnail;
}
return (
<View style={style}>
<FastImage
if (blurRadius > 0) {
// No blur radius support in FastImage yet
return (
<Image
source={{ uri: thumbnail }}
onError={() => this.setState({ imageLoadFailed: true })}
resizeMode={this.getFastImageResizeMode(resizeMode)}
style={fileItemMediaStyle.image}
blurRadius={blurRadius}
resizeMode={resizeMode ? resizeMode : 'cover'}
style={style}
/>
{duration && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
textStyle={fileItemMediaStyle.durationText}
/>
)}
</View>
);
}
return (
<FastImage
source={{ uri: thumbnail }}
onError={() => this.setState({ imageLoadFailed: true })}
resizeMode={this.getFastImageResizeMode(resizeMode)}
style={style}
/>
);
}
return (
<View style={[style || fileItemMediaStyle.autothumb, atStyle]}>
<View style={[style ? style : fileItemMediaStyle.autothumb, atStyle]}>
{isResolvingUri && (
<View style={fileItemMediaStyle.resolving}>
<ActivityIndicator color={Colors.White} size={'large'} />
@@ -103,13 +104,6 @@ class FileItemMedia extends React.PureComponent {
.toUpperCase()}
</Text>
)}
{duration && (
<VideoDuration
duration={duration}
style={fileItemMediaStyle.duration}
textStyle={fileItemMediaStyle.durationText}
/>
)}
</View>
);
}
+31 -31
View File
@@ -53,39 +53,39 @@ class FileList extends React.PureComponent<Props, State> {
dateNew: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
if (fileInfo1.pending) {
return -1;
}
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 0;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 0;
if (height1 > height2) {
return -1;
} else if (height1 < height2) {
return 1;
}
return 0;
})
if (fileInfo1.pending) {
return -1;
}
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 0;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 0;
if (height1 > height2) {
return -1;
} else if (height1 < height2) {
return 1;
}
return 0;
})
: [...fileInfos].reverse(),
dateOld: fileInfos =>
this.props.sortByHeight
? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 999999;
if (height1 < height2) {
return -1;
} else if (height1 > height2) {
return 1;
}
return 0;
})
const height1 = this.props.claimsById[fileInfo1.claim_id]
? this.props.claimsById[fileInfo1.claim_id].height
: 999999;
const height2 = this.props.claimsById[fileInfo2.claim_id]
? this.props.claimsById[fileInfo2.claim_id].height
: 999999;
if (height1 < height2) {
return -1;
} else if (height1 > height2) {
return 1;
}
return 0;
})
: fileInfos,
title: fileInfos =>
fileInfos.slice().sort((fileInfo1, fileInfo2) => {
@@ -160,7 +160,7 @@ class FileList extends React.PureComponent<Props, State> {
// This is unfortunate
// https://github.com/lbryio/lbry/issues/1159
const name = claimName || claimNameDownloaded;
uriParams.claimName = name;
uriParams.contentName = name;
uriParams.claimId = claimId;
const uri = buildURI(uriParams);
@@ -179,7 +179,7 @@ class FileList extends React.PureComponent<Props, State> {
style={fileListStyle.fileItem}
uri={item}
navigation={navigation}
showDetails
showDetails={true}
compactView={false}
/>
)}
+1 -6
View File
@@ -5,12 +5,10 @@ import {
makeSelectMetadataForUri,
makeSelectFileInfoForUri,
makeSelectIsUriResolving,
makeSelectClaimIsNsfw,
makeSelectShortUrlForUri,
makeSelectTitleForUri,
makeSelectThumbnailForUri,
} from 'lbry-redux';
import { selectBlackListedOutpoints, selectFilteredOutpoints, selectRewardContentClaimIds } from 'lbryinc';
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
import { selectShowNsfw } from 'redux/selectors/settings';
import FileListItem from './view';
@@ -21,11 +19,8 @@ const select = (state, props) => ({
filteredOutpoints: selectFilteredOutpoints(state),
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
obscureNsfw: !selectShowNsfw(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state),
shortUrl: makeSelectShortUrlForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
});
+15 -81
View File
@@ -3,7 +3,6 @@ import { normalizeURI, parseURI } from 'lbry-redux';
import { ActivityIndicator, Platform, Text, TouchableOpacity, View } from 'react-native';
import { navigateToUri, formatBytes } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DateTime from 'component/dateTime';
import FileItemMedia from 'component/fileItemMedia';
import Icon from 'react-native-vector-icons/FontAwesome5';
@@ -13,10 +12,6 @@ import ProgressBar from 'component/progressBar';
import fileListStyle from 'styles/fileList';
class FileListItem extends React.PureComponent {
state = {
url: null,
};
getStorageForFileInfo = fileInfo => {
if (!fileInfo.completed) {
const written = formatBytes(fileInfo.written_bytes);
@@ -46,30 +41,9 @@ class FileListItem extends React.PureComponent {
}
}
componentDidUpdate() {
const { claim, resolveUri, uri } = this.props;
if (!claim && uri !== this.state.url) {
this.setState({ url: uri }, () => resolveUri(uri));
}
}
defaultOnPress = () => {
const { autoplay, claim, featuredResult, navigation, uri, shortUrl } = this.props;
if (featuredResult && !claim) {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { vanityUrl: uri.trim() } });
} else {
navigateToUri(navigation, shortUrl || uri, { autoplay });
}
};
onPressHandler = () => {
const { claim, onPress } = this.props;
if (onPress) {
onPress(claim);
} else {
this.defaultOnPress();
}
const { navigation, uri } = this.props;
navigateToUri(navigation, uri);
};
render() {
@@ -79,82 +53,50 @@ class FileListItem extends React.PureComponent {
fileInfo,
filteredOutpoints,
metadata,
nsfw,
featuredResult,
isResolvingUri,
isDownloaded,
style,
obscureNsfw,
onPress,
navigation,
rewardedContentClaimIds,
thumbnail,
hideChannel,
onLongPress,
selected,
title,
} = this.props;
const uri = normalizeURI(this.props.uri);
const obscure = obscureNsfw && nsfw;
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
const isResolving = !fileInfo && isResolvingUri;
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
let name,
channel,
height,
isRewardContent,
channelClaimId,
fullChannelUri,
shortChannelUri,
shouldHide,
signingChannel;
let name, channel, height, channelClaimId, fullChannelUri, shouldHide, signingChannel;
if (claim) {
name = claim.name;
signingChannel = claim.signing_channel;
channel = signingChannel ? signingChannel.name : null;
height = claim.height;
isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
channelClaimId = signingChannel ? signingChannel.claim_id : null;
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
shortChannelUri = signingChannel ? signingChannel.short_url : null;
if (blackListedOutpoints || filteredOutpoints) {
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
}
// TODO: hide channels on tag pages?
// shouldHide = 'channel' === claim.value_type;
}
if (shouldHide || (!isResolvingUri && !claim && !featuredResult)) {
if (shouldHide || (featuredResult && !isResolvingUri && !claim && !title && !name)) {
return null;
}
return (
<View style={style}>
<TouchableOpacity
style={style}
onPress={this.onPressHandler}
onLongPress={() => {
if (onLongPress) {
onLongPress(claim);
}
}}
>
<TouchableOpacity style={style} onPress={onPress || this.defaultOnPress}>
<FileItemMedia
style={fileListStyle.thumbnail}
duration={duration}
blurRadius={obscureNsfw ? 15 : 0}
resizeMode="cover"
title={title || name || normalizeURI(uri).substring(7)}
title={title || name}
thumbnail={thumbnail}
/>
{selected && (
<View style={fileListStyle.selectedOverlay}>
<Icon name={'check-circle'} solid color={Colors.NextLbryGreen} size={32} />
</View>
)}
{fileInfo && fileInfo.completed && fileInfo.download_path && (
<Icon style={fileListStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
)}
@@ -177,26 +119,16 @@ class FileListItem extends React.PureComponent {
)}
{(title || name) && (
<View style={fileListStyle.titleContainer}>
<Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>
{this.formatTitle(title) || this.formatTitle(name)}
</Text>
{isRewardContent && <Icon style={fileListStyle.rewardIcon} name="award" size={12} />}
</View>
<Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>
{this.formatTitle(title) || this.formatTitle(name)}
</Text>
)}
{featuredResult && !isResolving && !claim && (
<View style={fileListStyle.titleContainer}>
<Text style={fileListStyle.featuredTitle}>Nothing here. Publish something!</Text>
</View>
)}
{channel && !hideChannel && (
<Link
style={fileListStyle.publisher}
text={channel}
onPress={() => {
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
navigateToUri(navigation, normalizeURI(fullChannelUri));
}}
/>
)}
@@ -223,7 +155,9 @@ class FileListItem extends React.PureComponent {
)}
</View>
</TouchableOpacity>
{obscure && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
{obscureNsfw && (
<NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />
)}
</View>
);
}
+2 -3
View File
@@ -23,7 +23,7 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
style={floatingButtonStyle.pendingContainer}
onPress={() => navigation && navigation.navigate({ routeName: 'Rewards' })}
>
<Icon name="award" size={14} style={floatingButtonStyle.rewardIcon} />
<Icon name="award" size={18} style={floatingButtonStyle.rewardIcon} />
<Text style={floatingButtonStyle.text}>{unclaimedRewardAmount}</Text>
</TouchableOpacity>
)}
@@ -31,10 +31,9 @@ class FloatingWalletBalance extends React.PureComponent<Props> {
style={floatingButtonStyle.container}
onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}
>
<Icon name="coins" size={12} style={floatingButtonStyle.balanceIcon} />
{isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />}
{(!isNaN(balance) || balance === 0) && (
<Text style={floatingButtonStyle.text}>{formatCredits(parseFloat(balance), 0, true)}</Text>
<Text style={floatingButtonStyle.text}>{formatCredits(parseFloat(balance), 2) + ' LBC'}</Text>
)}
</TouchableOpacity>
</View>
+1 -8
View File
@@ -418,13 +418,6 @@ class MediaPlayer extends React.PureComponent {
: mediaPlayerStyle.containedTrackingControls,
];
const seekerCircleStyle = [this.state.seeking ? mediaPlayerStyle.bigSeekerCircle : mediaPlayerStyle.seekerCircle];
if (!this.state.seeking) {
seekerCircleStyle.push(
this.state.fullscreenMode ? mediaPlayerStyle.seekerCircleTopFs : mediaPlayerStyle.seekerCircleTop
);
}
return (
<View style={styles} onLayout={onLayout}>
<Video
@@ -489,7 +482,7 @@ class MediaPlayer extends React.PureComponent {
]}
{...this.seekResponder.panHandlers}
>
<View style={seekerCircleStyle} />
<View style={this.state.seeking ? mediaPlayerStyle.bigSeekerCircle : mediaPlayerStyle.seekerCircle} />
</View>
<TouchableOpacity
style={[
-14
View File
@@ -10,8 +10,6 @@ import TagSearch from 'component/tagSearch';
import modalTagSelectorStyle from 'styles/modalTagSelector';
import { __ } from 'utils/helper';
const minimumTags = 2;
export default class ModalTagSelector extends React.PureComponent {
handleAddTag = tag => {
if (!tag) {
@@ -25,9 +23,6 @@ export default class ModalTagSelector extends React.PureComponent {
}
this.props.doToggleTagFollow(tag);
if (window.persistor) {
window.persistor.flush();
}
NativeModules.Firebase.track('tag_follow', { tag });
};
@@ -36,16 +31,7 @@ export default class ModalTagSelector extends React.PureComponent {
return;
}
const { followedTags, doToast } = this.props;
if (followedTags.length <= minimumTags) {
doToast({ message: __(`You can follow a minimum of ${minimumTags} tags.`) });
return;
}
this.props.doToggleTagFollow(tag);
if (window.persistor) {
window.persistor.flush();
}
NativeModules.Firebase.track('tag_unfollow', { tag });
};
+1 -1
View File
@@ -5,7 +5,7 @@ import discoverStyle from '../../styles/discover';
class NsfwOverlay extends React.PureComponent {
render() {
return (
<TouchableOpacity style={discoverStyle.overlay} activeOpacity={1} onPress={this.props.onPress}>
<TouchableOpacity style={discoverStyle.overlay} activeOpacity={0.95} onPress={this.props.onPress}>
<Text style={discoverStyle.overlayText}>
This content is Not Safe For Work. To view adult content, please change your Settings.
</Text>
+10 -13
View File
@@ -1,6 +1,5 @@
import React from 'react';
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
import { normalizeURI } from 'lbry-redux';
import { navigateToUri } from 'utils/helper';
import Colors from 'styles/colors';
import FileListItem from 'component/fileListItem';
@@ -42,7 +41,7 @@ export default class RelatedContent extends React.PureComponent {
didSearch;
render() {
const { recommendedContent, isSearching, navigation, uri, fullUri } = this.props;
const { recommendedContent, isSearching, navigation } = this.props;
if (!isSearching && (!recommendedContent || recommendedContent.length === 0)) {
return null;
@@ -52,17 +51,15 @@ export default class RelatedContent extends React.PureComponent {
<View style={relatedContentStyle.container}>
<Text style={relatedContentStyle.title}>Related Content</Text>
{recommendedContent &&
recommendedContent
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
.map(recommendedUri => (
<FileListItem
style={fileListStyle.item}
key={recommendedUri}
uri={recommendedUri}
navigation={navigation}
autoplay
/>
))}
recommendedContent.map(recommendedUri => (
<FileListItem
style={fileListStyle.item}
key={recommendedUri}
uri={recommendedUri}
navigation={navigation}
onPress={() => navigateToUri(navigation, recommendedUri, { autoplay: true })}
/>
))}
{isSearching && (
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={relatedContentStyle.loading} />
)}
+1 -2
View File
@@ -65,8 +65,7 @@ class StorageStatsCard extends React.PureComponent {
}
render() {
const { fileInfos } = this.props;
if (fileInfos.length === 0 || this.state.totalBytes === 0) {
if (this.state.totalBytes == 0) {
return null;
}
@@ -5,27 +5,17 @@ import Button from 'component/button';
import Colors from 'styles/colors';
class SubscribeNotificationButton extends React.PureComponent {
handlePress = () => {
render() {
const {
uri,
name,
doChannelSubscriptionEnableNotifications,
doChannelSubscriptionDisableNotifications,
doToast,
enabledChannelNotifications,
isSubscribed,
style,
} = this.props;
const shouldNotify = enabledChannelNotifications.indexOf(name) > -1;
if (shouldNotify) {
doChannelSubscriptionDisableNotifications(name);
doToast({ message: 'You will not receive notifications for new content.' });
} else {
doChannelSubscriptionEnableNotifications(name);
doToast({ message: 'You will receive all notifications for new content.' });
}
};
render() {
const { enabledChannelNotifications, name, uri, isSubscribed, style } = this.props;
if (!isSubscribed) {
return null;
@@ -41,14 +31,23 @@ class SubscribeNotificationButton extends React.PureComponent {
}
const shouldNotify = enabledChannelNotifications.indexOf(name) > -1;
const { claimName } = parseURI(uri);
return (
<Button
style={styles}
theme={'light'}
icon={shouldNotify ? 'bell-slash' : 'bell'}
solid
onPress={this.handlePress}
solid={true}
onPress={() => {
if (shouldNotify) {
doChannelSubscriptionDisableNotifications(name);
doToast({ message: 'You will not receive notifications for new content.' });
} else {
doChannelSubscriptionEnableNotifications(name);
doToast({ message: 'You will receive all notifications for new content.' });
}
}}
/>
);
}
@@ -1,13 +1,11 @@
import React from 'react';
import { buildURI, normalizeURI } from 'lbry-redux';
import { ActivityIndicator, FlatList, Image, Text, View } from 'react-native';
import { navigateToUri } from 'utils/helper';
import Colors from 'styles/colors';
import discoverStyle from 'styles/discover';
import FileItem from 'component/fileItem';
import SubscribeButton from 'component/subscribeButton';
import subscriptionsStyle from 'styles/subscriptions';
import Link from 'component/link';
import Tag from 'component/tag';
class SuggestedSubscriptionItem extends React.PureComponent {
@@ -20,12 +18,9 @@ class SuggestedSubscriptionItem extends React.PureComponent {
render() {
const { claim, isResolvingUri, navigation, thumbnail, title, uri } = this.props;
let shortUrl, tags;
if (claim) {
shortUrl = claim.short_url;
if (claim.value) {
tags = claim.value.tags;
}
let tags;
if (claim && claim.value) {
tags = claim.value.tags;
}
if (isResolvingUri) {
@@ -52,22 +47,15 @@ class SuggestedSubscriptionItem extends React.PureComponent {
{title}
</Text>
)}
{claim && (
<Link
style={subscriptionsStyle.suggestedItemName}
numberOfLines={1}
text={claim.name}
onPress={() => navigateToUri(navigation, normalizeURI(shortUrl || uri))}
/>
)}
<Text style={subscriptionsStyle.suggestedItemName} numberOfLines={1}>
{claim && claim.name}
</Text>
{tags && (
<View style={subscriptionsStyle.suggestedItemTagList}>
{tags &&
tags
.slice(0, 3)
.map(tag => (
<Tag style={subscriptionsStyle.tag} key={tag} name={tag} navigation={navigation} truncate />
))}
.map(tag => <Tag style={subscriptionsStyle.tag} key={tag} name={tag} navigation={navigation} />)}
</View>
)}
</View>
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { doClaimSearch, selectFetchingClaimSearch, selectClaimSearchByQuery, selectFollowedTags } from 'lbry-redux';
import { doClaimSearch, selectFetchingClaimSearch, selectLastClaimSearchUris, selectFollowedTags } from 'lbry-redux';
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'lbryinc';
import SuggestedSubscriptions from './view';
@@ -7,11 +7,11 @@ const select = state => ({
followedTags: selectFollowedTags(state),
suggested: selectSuggestedChannels(state),
loading: selectIsFetchingSuggested(state) || selectFetchingClaimSearch(state),
claimSearchByQuery: selectClaimSearchByQuery(state),
claimSearchUris: selectLastClaimSearchUris(state),
});
const perform = dispatch => ({
claimSearch: options => dispatch(doClaimSearch(options)),
claimSearch: options => dispatch(doClaimSearch(10, options)),
});
export default connect(
+7 -15
View File
@@ -1,6 +1,6 @@
import React from 'react';
import { ActivityIndicator, FlatList, SectionList, Text, View } from 'react-native';
import { createNormalizedClaimSearchKey, normalizeURI } from 'lbry-redux';
import { normalizeURI } from 'lbry-redux';
import { __, navigateToUri } from 'utils/helper';
import SubscribeButton from 'component/subscribeButton';
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
@@ -11,36 +11,28 @@ import Link from 'component/link';
import _ from 'lodash';
class SuggestedSubscriptions extends React.PureComponent {
state = {
options: {},
};
componentDidMount() {
const { claimSearch, followedTags } = this.props;
const options = {
any_tags: _.shuffle(followedTags.map(tag => tag.name)).slice(0, 3),
any_tags: _.shuffle(followedTags.map(tag => tag.name)).slice(0, 2),
page: 1,
no_totals: true,
claim_type: 'channel',
};
this.setState({ options });
claimSearch(options);
}
buildSections = () => {
const { suggested, claimSearchByQuery } = this.props;
const claimSearchKey = createNormalizedClaimSearchKey(this.state.options);
const claimSearchUris = claimSearchByQuery[claimSearchKey];
const { suggested, claimSearchUris } = this.props;
const suggestedUris = suggested ? suggested.map(suggested => suggested.uri) : [];
return [
{
title: __('Tags you follow'),
data: claimSearchUris ? claimSearchUris.filter(uri => !suggestedUris.includes(uri)) : [],
title: __('You might like'),
data: suggestedUris,
},
{
title: __('You might also like'),
data: _.shuffle(suggestedUris),
title: __('Tags you follow'),
data: claimSearchUris ? claimSearchUris.filter(uri => !suggestedUris.includes(uri)) : [],
},
];
};
+3 -4
View File
@@ -1,6 +1,5 @@
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import { MATURE_TAGS } from 'lbry-redux';
import { formatTagName } from 'utils/helper';
import tagStyle from 'styles/tag';
import Colors from 'styles/colors';
@@ -30,7 +29,7 @@ export default class Tag extends React.PureComponent {
};
render() {
const { name, onPress, style, type, truncate } = this.props;
const { name, onPress, style, type } = this.props;
let styles = [];
if (style) {
@@ -42,7 +41,7 @@ export default class Tag extends React.PureComponent {
}
styles.push({
backgroundColor: MATURE_TAGS.includes(name) ? Colors.TagGrape : Colors.TagGreen,
backgroundColor: Colors.TagGreen,
borderRadius: 8,
marginBottom: 4,
});
@@ -50,7 +49,7 @@ export default class Tag extends React.PureComponent {
return (
<TouchableOpacity style={styles} onPress={onPress || this.onPressDefault}>
<View style={tagStyle.content}>
<Text style={tagStyle.text}>{truncate ? formatTagName(name) : name}</Text>
<Text style={tagStyle.text}>{formatTagName(name)}</Text>
{type && <Icon style={tagStyle.icon} name={type === 'add' ? 'plus' : 'times'} size={8} />}
</View>
</TouchableOpacity>
+1 -18
View File
@@ -1,6 +1,5 @@
import React from 'react';
import { KeyboardAvoidingView, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { MATURE_TAGS } from 'lbry-redux';
import Tag from 'component/tag';
import tagStyle from 'styles/tag';
import Colors from 'styles/colors';
@@ -67,7 +66,7 @@ export default class TagSearch extends React.PureComponent {
};
render() {
const { name, style, type, selectedTags = [], showNsfwTags } = this.props;
const { name, style, type, selectedTags = [] } = this.props;
return (
<View>
@@ -86,22 +85,6 @@ export default class TagSearch extends React.PureComponent {
))}
</View>
</KeyboardAvoidingView>
{showNsfwTags && (
<View style={tagStyle.nsfwTagsContainer}>
<Text style={tagStyle.nsfwTagsTitle}>Mature tags</Text>
<View style={tagStyle.tagResultsList}>
{MATURE_TAGS.map(tag => (
<Tag
key={tag}
name={tag}
style={tagStyle.tag}
type="add"
onAddPress={name => this.onAddTagPress(name)}
/>
))}
</View>
</View>
)}
</View>
);
}
@@ -19,12 +19,11 @@ class TransactionListItem extends React.PureComponent {
return (
<View style={transactionListStyle.listItem}>
<View style={[transactionListStyle.row, transactionListStyle.topRow]}>
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<View style={transactionListStyle.col}>
<Text style={transactionListStyle.text}>{this.capitalize(type)}</Text>
{name && claimId && (
<Link
style={transactionListStyle.link}
numberOfLines={1}
onPress={() => navigateToUri(navigation, buildURI({ claimName: name, claimId }))}
text={name}
/>
@@ -38,7 +37,7 @@ class TransactionListItem extends React.PureComponent {
</View>
</View>
<View style={transactionListStyle.row}>
<View style={[transactionListStyle.col, transactionListStyle.leftCol]}>
<View style={transactionListStyle.col}>
<Link
style={transactionListStyle.smallLink}
text={txid.substring(0, 8)}
+2 -2
View File
@@ -1,6 +1,6 @@
// @flow
import React from 'react';
// import BusyIndicator from 'component/common/busy-indicator';
//import BusyIndicator from 'component/common/busy-indicator';
import { Text, View } from 'react-native';
import Button from '../button';
import Link from '../link';
@@ -33,7 +33,7 @@ class TransactionListRecent extends React.PureComponent<Props> {
{!fetchingTransactions && (
<TransactionList
navigation={navigation}
transactions={transactions.slice(0, 5)}
transactions={transactions}
emptyMessage={"Looks like you don't have any recent transactions."}
/>
)}
+56 -123
View File
@@ -1,12 +1,12 @@
// @flow
import React from 'react';
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
import { FlatList, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { navigateToUri, transformUrl } from 'utils/helper';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import { FlatList, Keyboard, TextInput, View } from 'react-native';
import { navigateToUri } from 'utils/helper';
import Constants from 'constants';
import UriBarItem from './internal/uri-bar-item';
import Icon from 'react-native-vector-icons/FontAwesome5';
import NavigationButton from 'component/navigationButton';
import discoverStyle from 'styles/discover';
import uriBarStyle from 'styles/uriBar';
class UriBar extends React.PureComponent {
@@ -16,16 +16,6 @@ class UriBar extends React.PureComponent {
keyboardDidHideListener = null;
state = {
changeTextTimeout: null,
currentValue: null,
inputText: null,
focused: false,
// TODO: Add a setting to enable / disable direct search?
directSearch: true,
};
componentDidMount() {
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
this.setSelection();
@@ -46,8 +36,20 @@ class UriBar extends React.PureComponent {
}
}
constructor(props) {
super(props);
this.state = {
changeTextTimeout: null,
currentValue: null,
inputText: null,
focused: false,
// TODO: Add a setting to enable / disable direct search?
directSearch: true,
};
}
handleChangeText = text => {
const newValue = text || '';
const newValue = text ? text : '';
clearTimeout(this.state.changeTextTimeout);
const { updateSearchQuery, onSearchSubmitted, navigation } = this.props;
@@ -109,19 +111,12 @@ class UriBar extends React.PureComponent {
handleSubmitEditing = () => {
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
if (this.state.inputText) {
let inputText = this.state.inputText,
inputTextIsUrl = false;
if (inputText.startsWith('lbry://')) {
const transformedUrl = transformUrl(inputText);
let inputText = this.state.inputText;
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
// if it's a URI (lbry://...), open the file page
if (transformedUrl && isURIValid(transformedUrl)) {
inputTextIsUrl = true;
navigateToUri(navigation, transformedUrl);
}
}
// couldn't parse the inputText as a URL for some reason, so do a search instead
if (!inputTextIsUrl) {
const uri = normalizeURI(inputText);
navigateToUri(navigation, uri);
} else {
updateSearchQuery(inputText);
// Not a URI, default to a search request
if (onSearchSubmitted) {
@@ -141,19 +136,7 @@ class UriBar extends React.PureComponent {
}
render() {
const {
allowEdit,
belowOverlay,
navigation,
onExitSelectionMode,
onEditActionPressed,
onDeleteActionPressed,
query,
selectedItemCount,
selectionMode,
suggestions,
value,
} = this.props;
const { navigation, suggestions, query, value, belowOverlay } = this.props;
if (this.state.currentValue === null) {
this.setState({ currentValue: value });
}
@@ -161,93 +144,43 @@ class UriBar extends React.PureComponent {
let style = [uriBarStyle.overlay, belowOverlay ? null : uriBarStyle.overlayElevated];
// TODO: Add optional setting to enable URI / search bar suggestions
/* if (this.state.focused) { style.push(uriBarStyle.inFocus); } */
/*if (this.state.focused) { style.push(uriBarStyle.inFocus); }*/
// TODO: selectionModeActions should be dynamically created / specified
return (
<View style={style}>
<View style={[uriBarStyle.uriContainer, belowOverlay ? null : uriBarStyle.containerElevated]}>
{selectionMode && (
<View style={uriBarStyle.selectionModeBar}>
<View style={uriBarStyle.selectionModeLeftBar}>
<TouchableOpacity
style={uriBarStyle.backTouchArea}
onPress={() => {
if (onExitSelectionMode) {
onExitSelectionMode();
}
}}
>
<Icon name="arrow-left" size={20} />
</TouchableOpacity>
{selectedItemCount > 0 && <Text style={uriBarStyle.itemCount}>{selectedItemCount}</Text>}
</View>
<View style={uriBarStyle.selectionModeActions}>
{allowEdit && selectedItemCount === 1 && (
<TouchableOpacity
style={[uriBarStyle.actionTouchArea, uriBarStyle.leftAction]}
onPress={() => {
if (onEditActionPressed) {
onEditActionPressed();
}
}}
>
<Icon name="edit" size={20} style={uriBarStyle.actionIcon} />
</TouchableOpacity>
)}
<TouchableOpacity
style={uriBarStyle.actionTouchArea}
onPress={() => {
if (onDeleteActionPressed) {
onDeleteActionPressed();
}
}}
>
<Icon name="trash-alt" solid={false} size={20} style={uriBarStyle.actionIcon} />
</TouchableOpacity>
</View>
</View>
)}
{!selectionMode && (
<NavigationButton
name="bars"
size={24}
style={uriBarStyle.drawerMenuButton}
iconStyle={uriBarStyle.drawerHamburger}
onPress={() => navigation.openDrawer()}
/>
)}
{!selectionMode && (
<TextInput
ref={ref => {
this.textInput = ref;
}}
autoCorrect={false}
style={uriBarStyle.uriText}
onLayout={() => {
this.setSelection();
}}
selectTextOnFocus
placeholder={'Search movies, music, and more'}
underlineColorAndroid={'transparent'}
numberOfLines={1}
clearButtonMode={'while-editing'}
value={this.state.currentValue}
returnKeyType={'go'}
inlineImageLeft={'baseline_search_black_24'}
inlineImagePadding={16}
onFocus={() => this.setState({ focused: true })}
onBlur={() => {
this.setState({ focused: false });
this.setSelection();
}}
onChangeText={this.handleChangeText}
onSubmitEditing={this.handleSubmitEditing}
/>
)}
<NavigationButton
name="bars"
size={24}
style={uriBarStyle.drawerMenuButton}
iconStyle={discoverStyle.drawerHamburger}
onPress={() => navigation.openDrawer()}
/>
<TextInput
ref={ref => {
this.textInput = ref;
}}
style={uriBarStyle.uriText}
onLayout={() => {
this.setSelection();
}}
selectTextOnFocus={true}
placeholder={'Search movies, music, and more'}
underlineColorAndroid={'transparent'}
numberOfLines={1}
clearButtonMode={'while-editing'}
value={this.state.currentValue}
returnKeyType={'go'}
inlineImageLeft={'baseline_search_black_24'}
inlineImagePadding={16}
onFocus={() => this.setState({ focused: true })}
onBlur={() => {
this.setState({ focused: false });
this.setSelection();
}}
onChangeText={this.handleChangeText}
onSubmitEditing={this.handleSubmitEditing}
/>
{this.state.focused && !this.state.directSearch && (
<View style={uriBarStyle.suggestions}>
<FlatList
-4
View File
@@ -1,4 +0,0 @@
import { connect } from 'react-redux';
import VideoDuration from './view';
export default connect()(VideoDuration);
-36
View File
@@ -1,36 +0,0 @@
import React from 'react';
import { Text, View } from 'react-native';
import fileListStyle from 'styles/fileList';
import _ from 'lodash';
export default class VideoDuration extends React.PureComponent {
getDurationString = duration => {
let seconds = duration;
const hours = Math.floor(seconds / 3600);
seconds = duration - hours * 3600;
const minutes = Math.floor(seconds / 60);
seconds = seconds % 60;
let durationString = '';
if (hours > 0) {
durationString += hours + ':';
}
durationString += _.padStart(minutes, hours > 0 ? 2 : 0, '0') + ':';
durationString += _.padStart(seconds, 2, '0');
return durationString;
};
render() {
const { duration, style, textStyle } = this.props;
if (!duration || isNaN(parseFloat(duration))) {
return null;
}
return (
<View style={style}>
<Text style={textStyle}>{this.getDurationString(duration)}</Text>
</View>
);
}
}
+3 -3
View File
@@ -53,9 +53,6 @@ const Constants = {
ACTION_REACT_NAVIGATION_NAVIGATE: 'Navigation/NAVIGATE',
ACTION_REACT_NAVIGATION_REPLACE: 'Navigation/REPLACE',
ACTION_SORT_BY_ITEM_CHANGED: 'SORT_BY_ITEM_CHANGED',
ACTION_TIME_ITEM_CHANGED: 'TIME_ITEM_CHANGED',
ORIENTATION_HORIZONTAL: 'horizontal',
ORIENTATION_VERTICAL: 'vertical',
@@ -79,7 +76,10 @@ const Constants = {
DRAWER_ROUTE_TAG: 'Tag',
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
FULL_ROUTE_NAME_TRENDING: 'TrendingStack',
FULL_ROUTE_NAME_MY_SUBSCRIPTIONS: 'MySubscriptionsStack',
FULL_ROUTE_NAME_WALLET: 'WalletStack',
FULL_ROUTE_NAME_MY_LBRY: 'MyLBRYStack',
ROUTE_FILE: 'File',
+19 -13
View File
@@ -136,29 +136,35 @@ const store = createStore(
);
window.store = store;
const persistor = persistStore(store, persistOptions, err => {
/* const persistor = persistStore(store, persistOptions, err => {
if (err) {
console.log('Unable to load saved SETTINGS');
}
});
window.persistor = persistor;
window.persistor = persistor; */
/*
const persistFilter = {
'auth': ['authToken'],
'claims': ['byId', 'claimsByUri'],
'content': ['positions'],
'subscriptions': ['enabledChannelNotifications', 'subscriptions'],
'settings': ['clientSettings'],
'tags': ['followedTags'],
'wallet': ['receiveAddress']
auth: ['authToken'],
claims: ['byId', 'claimsByUri'],
content: ['positions'],
subscriptions: ['enabledChannelNotifications', 'subscriptions'],
settings: ['clientSettings'],
tags: ['followedTags'],
wallet: ['receiveAddress'],
};
store.subscribe(() => {
const state = (({ auth, claims, content, subscriptions, settings, tags, wallet }) =>
({ auth, claims, content, subscriptions, settings, tags, wallet }))(store.getState());
const state = (({ auth, claims, content, subscriptions, settings, tags, wallet }) => ({
auth,
claims,
content,
subscriptions,
settings,
tags,
wallet,
}))(store.getState());
NativeModules.StatePersistor.update(state, persistFilter);
}); */
});
// TODO: Find i18n module that is compatible with react-native
global.__ = str => str;
+20 -22
View File
@@ -2,7 +2,7 @@ import React from 'react';
import { Lbry } from 'lbry-redux';
import { NativeModules, Text, View, ScrollView } from 'react-native';
import { navigateBack } from 'utils/helper';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Link from 'component/link';
import PageHeader from 'component/pageHeader';
import aboutStyle from 'styles/about';
@@ -18,7 +18,7 @@ class AboutPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -44,21 +44,19 @@ class AboutPage extends React.PureComponent {
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('About').then(result => {
if (NativeModules.VersionInfo) {
NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({ appVersion: version });
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
if (NativeModules.VersionInfo) {
NativeModules.VersionInfo.getAppVersion().then(version => {
this.setState({ appVersion: version });
});
Lbry.status().then(info => {
this.setState({
lbryId: info.installation_id,
});
}
Lbry.version().then(info => {
this.setState({
versionInfo: info,
});
});
Lbry.status().then(info => {
this.setState({
lbryId: info.installation_id,
});
});
@@ -107,7 +105,7 @@ class AboutPage extends React.PureComponent {
<Text style={aboutStyle.text}>Connected email</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
<Text selectable={true} style={aboutStyle.valueText}>
{userEmail}
</Text>
</View>
@@ -127,7 +125,7 @@ class AboutPage extends React.PureComponent {
<Text style={aboutStyle.text}>App version</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
<Text selectable={true} style={aboutStyle.valueText}>
{this.state.appVersion}
</Text>
</View>
@@ -135,10 +133,10 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>LBRY SDK</Text>
<Text style={aboutStyle.text}>Daemon (lbrynet)</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
<Text selectable={true} style={aboutStyle.valueText}>
{ver ? ver.lbrynet_version : loading}
</Text>
</View>
@@ -149,7 +147,7 @@ class AboutPage extends React.PureComponent {
<Text style={aboutStyle.text}>Platform</Text>
</View>
<View style={aboutStyle.col}>
<Text selectable style={aboutStyle.valueText}>
<Text selectable={true} style={aboutStyle.valueText}>
{ver ? ver.platform : loading}
</Text>
</View>
@@ -158,7 +156,7 @@ class AboutPage extends React.PureComponent {
<View style={aboutStyle.row}>
<View style={aboutStyle.col}>
<Text style={aboutStyle.text}>Installation ID</Text>
<Text selectable style={aboutStyle.lineValueText}>
<Text selectable={true} style={aboutStyle.lineValueText}>
{this.state.lbryId ? this.state.lbryId : loading}
</Text>
</View>
+10 -7
View File
@@ -1,23 +1,26 @@
import { connect } from 'react-redux';
import { doFetchClaimsByChannel, makeSelectClaimForUri } from 'lbry-redux';
import {
doFetchClaimsByChannel,
makeSelectClaimForUri,
makeSelectClaimsInChannelForCurrentPageState,
makeSelectFetchingChannelClaims,
makeSelectTotalPagesForChannel,
} from 'lbry-redux';
import { doPopDrawerStack } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectDrawerStack } from 'redux/selectors/drawer';
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import ChannelPage from './view';
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
claimsInChannel: makeSelectClaimsInChannelForCurrentPageState(props.uri)(state),
drawerStack: selectDrawerStack(state),
sortByItem: selectSortByItem(state),
timeItem: selectTimeItem(state),
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
totalPages: makeSelectTotalPagesForChannel(props.uri, 10)(state), // Update to use a default PAGE_SIZE constant
});
const perform = dispatch => ({
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
});
export default connect(
+98 -135
View File
@@ -1,111 +1,111 @@
// @flow
import React from 'react';
import {
ActivityIndicator,
Dimensions,
Image,
NativeModules,
ScrollView,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { ActivityIndicator, Dimensions, Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import { TabView, SceneMap } from 'react-native-tab-view';
import { normalizeURI } from 'lbry-redux';
import { navigateBack, getOrderBy } from 'utils/helper';
import ChannelIconItem from 'component/channelIconItem';
import ClaimList from 'component/claimList';
import { navigateBack } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Button from 'component/button';
import Icon from 'react-native-vector-icons/FontAwesome5';
import Link from 'component/link';
import ModalPicker from 'component/modalPicker';
import FileList from 'component/fileList';
import PageHeader from 'component/pageHeader';
import SubscribeButton from 'component/subscribeButton';
import SubscribeNotificationButton from 'component/subscribeNotificationButton';
import UriBar from 'component/uriBar';
import channelIconStyle from 'styles/channelIcon';
import channelPageStyle from 'styles/channelPage';
import discoverStyle from 'styles/discover';
class ChannelPage extends React.PureComponent {
state = {
autoStyle: null,
showSortPicker: false,
showTimePicker: false,
orderBy: Constants.DEFAULT_ORDER_BY,
page: 1,
showPageButtons: false,
activeTab: Constants.CONTENT_TAB,
};
componentWillMount() {
this.setState({
autoStyle:
ChannelIconItem.AUTO_THUMB_STYLES[Math.floor(Math.random() * ChannelIconItem.AUTO_THUMB_STYLES.length)],
});
}
componentDidMount() {
NativeModules.Firebase.setCurrentScreen('Channel');
const { uri, page, claimsInChannel, fetchClaims, fetchClaimCount } = this.props;
if (!claimsInChannel || !claimsInChannel.length) {
fetchClaims(uri, page || this.state.page);
}
}
handleSortByItemSelected = item => {
const { setSortByItem } = this.props;
setSortByItem(item);
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
handlePreviousPage = () => {
const { uri, fetchClaims } = this.props;
if (this.state.page > 1) {
this.setState({ page: this.state.page - 1, showPageButtons: false }, () => {
fetchClaims(uri, this.state.page);
});
}
};
handleTimeItemSelected = item => {
const { setTimeItem } = this.props;
setTimeItem(item);
this.setState({ showTimePicker: false });
};
listHeader = () => {
const { sortByItem, timeItem } = this.props;
return (
<View style={channelPageStyle.listHeader}>
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
</View>
</View>
</View>
);
handleNextPage = () => {
const { uri, fetchClaims, totalPages } = this.props;
if (this.state.page < totalPages) {
this.setState({ page: this.state.page + 1, showPageButtons: false }, () => {
fetchClaims(uri, this.state.page);
});
}
};
renderContent = () => {
const { claim, navigation, timeItem } = this.props;
const { fetching, claimsInChannel, totalPages, navigation } = this.props;
let channelId;
if (claim) {
channelId = claim.claim_id;
let contentList;
if (fetching) {
contentList = (
<View style={channelPageStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
<Text style={channelPageStyle.infoText}>Fetching content...</Text>
</View>
);
} else {
contentList =
claimsInChannel && claimsInChannel.length ? (
<FileList
sortByHeight
hideFilter
fileInfos={claimsInChannel}
navigation={navigation}
style={channelPageStyle.fileList}
contentContainerStyle={channelPageStyle.fileListContent}
onEndReached={() => this.setState({ showPageButtons: true })}
/>
) : (
<View style={channelPageStyle.busyContainer}>
<Text style={channelPageStyle.infoText}>No content found.</Text>
</View>
);
}
let pageButtons;
if (totalPages > 1 && this.state.showPageButtons) {
pageButtons = (
<View style={channelPageStyle.pageButtons}>
<View>
{this.state.page > 1 && (
<Button
style={channelPageStyle.button}
text={'Previous'}
disabled={!!fetching}
onPress={this.handlePreviousPage}
/>
)}
</View>
{this.state.page < totalPages && (
<Button
style={[channelPageStyle.button, channelPageStyle.nextButton]}
text={'Next'}
disabled={!!fetching}
onPress={this.handleNextPage}
/>
)}
</View>
);
}
return (
<View style={channelPageStyle.contentTab}>
{channelId && (
<ClaimList
ListHeaderComponent={this.listHeader}
hideChannel
orderBy={this.state.orderBy}
time={timeItem.name}
navigation={navigation}
orientation={Constants.ORIENTATION_VERTICAL}
channelIds={[channelId]}
style={channelPageStyle.claimList}
/>
)}
{contentList}
{pageButtons}
</View>
);
};
@@ -160,30 +160,18 @@ class ChannelPage extends React.PureComponent {
};
render() {
const { claim, navigation, uri, drawerStack, popDrawerStack, sortByItem, timeItem } = this.props;
const { fetching, claimsInChannel, claim, navigation, totalPages, uri, drawerStack, popDrawerStack } = this.props;
const { name, permanent_url: permanentUrl } = claim;
const { autoStyle, showSortPicker, showTimePicker } = this.state;
let thumbnailUrl,
coverUrl,
title,
fullUri,
displayName = null,
substrIndex = 0;
if (claim) {
if (claim.value) {
title = claim.value.title;
if (claim.value.cover) {
coverUrl = claim.value.cover.url;
}
if (claim.value.thumbnail) {
thumbnailUrl = claim.value.thumbnail.url;
}
let thumbnailUrl, coverUrl, title;
if (claim && claim.value) {
title = claim.value.title;
if (claim.value.cover) {
coverUrl = claim.value.cover.url;
}
if (claim.value.thumbnail) {
thumbnailUrl = claim.value.thumbnail.url;
}
displayName = title || claim.name;
substrIndex = displayName.startsWith('@') ? 1 : 0;
fullUri = normalizeURI(`${claim.name}#${claim.claim_id}`);
}
return (
@@ -206,25 +194,19 @@ class ChannelPage extends React.PureComponent {
<Text style={channelPageStyle.channelName}>{title && title.trim().length > 0 ? title : name}</Text>
</View>
<View style={[channelPageStyle.avatarImageContainer, autoStyle]}>
{thumbnailUrl && (
<Image style={channelPageStyle.avatarImage} resizeMode={'cover'} source={{ uri: thumbnailUrl }} />
)}
{(!thumbnailUrl || thumbnailUrl.trim().length === 0) && (
<Text style={channelIconStyle.autothumbCharacter}>
{displayName.substring(substrIndex, substrIndex + 1).toUpperCase()}
</Text>
)}
</View>
<View style={channelPageStyle.subscribeButtonContainer}>
<SubscribeButton style={channelPageStyle.subscribeButton} uri={fullUri} name={name} />
<SubscribeNotificationButton
style={[channelPageStyle.subscribeButton, channelPageStyle.bellButton]}
uri={fullUri}
name={name}
<View style={channelPageStyle.avatarImageContainer}>
<Image
style={channelPageStyle.avatarImage}
resizeMode={'cover'}
source={
thumbnailUrl && thumbnailUrl.trim().length > 0
? { uri: thumbnailUrl }
: require('../../assets/default_avatar.jpg')
}
/>
</View>
<SubscribeButton style={channelPageStyle.subscribeButton} uri={uri} name={name} />
</View>
<View style={channelPageStyle.tabBar}>
@@ -247,25 +229,6 @@ class ChannelPage extends React.PureComponent {
{Constants.CONTENT_TAB === this.state.activeTab && this.renderContent()}
{Constants.ABOUT_TAB === this.state.activeTab && this.renderAbout()}
</View>
{showSortPicker && (
<ModalPicker
title={__('Sort content by')}
onOverlayPress={() => this.setState({ showSortPicker: false })}
onItemSelected={this.handleSortByItemSelected}
selectedItem={sortByItem}
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
/>
)}
{showTimePicker && (
<ModalPicker
title={__('Content from')}
onOverlayPress={() => this.setState({ showTimePicker: false })}
onItemSelected={this.handleTimeItemSelected}
selectedItem={timeItem}
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
</View>
);
}
+12 -7
View File
@@ -1,5 +1,12 @@
import { connect } from 'react-redux';
import { doClaimSearch, doFileList, selectBalance, selectFileInfosDownloaded, selectFollowedTags } from 'lbry-redux';
import {
doClaimSearch,
doFileList,
selectBalance,
selectFileInfosDownloaded,
selectLastClaimSearchUris,
selectFollowedTags,
} from 'lbry-redux';
import {
doFetchFeaturedUris,
doFetchRewardedContent,
@@ -11,8 +18,9 @@ import {
selectSubscriptionClaims,
selectUnreadSubscriptions,
} from 'lbryinc';
import { doSetClientSetting, doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { makeSelectClientSetting, selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import DiscoverPage from './view';
@@ -26,9 +34,8 @@ const select = state => ({
followedTags: selectFollowedTags(state),
ratingReminderDisabled: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED)(state),
ratingReminderLastShown: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN)(state),
sortByItem: selectSortByItem(state),
timeItem: selectTimeItem(state),
unreadSubscriptions: selectUnreadSubscriptions(state),
uris: selectLastClaimSearchUris(state),
});
const perform = dispatch => ({
@@ -39,8 +46,6 @@ const perform = dispatch => ({
fileList: () => dispatch(doFileList()),
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
});
export default connect(
+68 -130
View File
@@ -11,7 +11,7 @@ import {
View,
} from 'react-native';
import { DEFAULT_FOLLOWED_TAGS, Lbry, normalizeURI, parseURI } from 'lbry-redux';
import { __, formatTagTitle, getOrderBy } from 'utils/helper';
import { __, formatTagTitle } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
import moment from 'moment';
import CategoryList from 'component/categoryList';
@@ -30,16 +30,13 @@ import _ from 'lodash';
class DiscoverPage extends React.PureComponent {
state = {
tagCollection: [],
remainingTags: [],
showModalTagSelector: false,
showSortPicker: false,
showTimePicker: false,
orderBy: Constants.DEFAULT_ORDER_BY,
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[0],
};
componentDidMount() {
NativeModules.Firebase.setCurrentScreen('Your tags');
// Track the total time taken if this is the first launch
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
@@ -63,28 +60,33 @@ class DiscoverPage extends React.PureComponent {
}
});
const { sortByItem, fetchRewardedContent, fetchSubscriptions, fileList, followedTags } = this.props;
const { fetchRewardedContent, fetchSubscriptions, fileList, followedTags } = this.props;
this.buildTagCollection(followedTags);
fetchRewardedContent();
fetchSubscriptions();
fileList();
this.handleSortByItemSelected(sortByItem);
this.showRatingReminder();
}
handleSortByItemSelected = item => {
const { setSortByItem } = this.props;
setSortByItem(item);
const orderBy = getOrderBy(item);
this.setState({ orderBy, showSortPicker: false });
};
let orderBy = [];
switch (item.name) {
case Constants.SORT_BY_HOT:
orderBy = Constants.DEFAULT_ORDER_BY;
break;
handleTimeItemSelected = item => {
const { setTimeItem } = this.props;
setTimeItem(item);
this.setState({ showTimePicker: false });
case Constants.SORT_BY_NEW:
orderBy = ['release_time'];
break;
case Constants.SORT_BY_TOP:
orderBy = ['effective_amount'];
break;
}
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
};
subscriptionForUri = (uri, channelName) => {
@@ -215,136 +217,81 @@ class DiscoverPage extends React.PureComponent {
// each of the followed tags
const tagCollection = _.shuffle(tags)
.slice(0, 5)
.slice(0, 6)
.map(tag => [tag]);
const usedTags = tagCollection.map(tagList => tagList[0]);
const remainingTags = tags.filter(tag => !usedTags.includes(tag));
// everything
tagCollection.unshift(tags);
this.setState({ remainingTags, tagCollection });
this.setState({ tagCollection });
};
handleTagPress = name => {
const { navigation, sortByItem } = this.props;
if (name.toLowerCase() !== 'all tags you follow') {
navigation.navigate({
routeName: Constants.DRAWER_ROUTE_TAG,
key: `tagPage`,
params: {
tag: name,
},
});
const { navigation } = this.props;
if (name.toLowerCase() !== 'trending') {
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: `tagPage`, params: { tag: name } });
} else {
// navigate to the trending page
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TRENDING, params: { filterForTags: true } });
navigation.navigate({ routeName: Constants.FULL_ROUTE_NAME_TRENDING });
}
};
sectionListHeader = () => {
const { sortByItem, timeItem } = this.props;
return (
<View style={discoverStyle.listHeader}>
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>Your tags</Text>
</View>
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
</View>
<Link
style={discoverStyle.customizeLink}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
</View>
</View>
);
};
sectionListFooter = () => {
const { remainingTags } = this.state;
if (remainingTags.length === 0) {
return null;
}
return (
<View style={discoverStyle.footer}>
<Text style={discoverStyle.footerTitle}>More tags you follow</Text>
<View style={discoverStyle.footerTags}>
{remainingTags.map(tag => (
<Text
key={tag}
style={[discoverStyle.categoryName, discoverStyle.footerTag]}
onPress={() => this.handleTagPress(tag)}
>
{formatTagTitle(tag)}
</Text>
))}
</View>
</View>
);
};
renderSectionListItem = ({ item, index, section }) => (
<ClaimList
key={item.sort().join(',')}
orderBy={this.state.orderBy}
time={this.props.timeItem.name}
tags={item}
morePlaceholder
navigation={this.props.navigation}
orientation={Constants.ORIENTATION_HORIZONTAL}
/>
);
renderSectionHeader = ({ section: { title } }) => (
<View style={discoverStyle.categoryTitleRow}>
<Text style={discoverStyle.categoryName} onPress={() => this.handleTagPress(title)}>
{formatTagTitle(title)}
</Text>
<TouchableOpacity onPress={() => this.handleTagPress(title)}>
<Icon name={'angle-double-down'} size={16} />
</TouchableOpacity>
</View>
);
render() {
const { navigation, sortByItem, timeItem } = this.props;
const { orderBy, showModalTagSelector, showSortPicker, showTimePicker } = this.state;
const { navigation } = this.props;
const { currentSortByItem, orderBy, showModalTagSelector, showSortPicker } = this.state;
return (
<View style={discoverStyle.container}>
<UriBar navigation={navigation} belowOverlay={showModalTagSelector} />
<SectionList
ListHeaderComponent={this.sectionListHeader}
ListFooterComponent={this.sectionListFooter}
ListHeaderComponent={
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>Explore</Text>
<View style={discoverStyle.rightTitleRow}>
<Link
style={discoverStyle.customizeLink}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
<TouchableOpacity
style={discoverStyle.tagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
</View>
</View>
}
style={discoverStyle.scrollContainer}
contentContainerStyle={discoverStyle.scrollPadding}
initialNumToRender={4}
maxToRenderPerBatch={4}
removeClippedSubviews
renderItem={this.renderSectionListItem}
renderSectionHeader={this.renderSectionHeader}
renderItem={({ item, index, section }) => (
<ClaimList
key={item.sort().join(',')}
orderBy={orderBy}
time={Constants.TIME_WEEK}
tags={item}
morePlaceholder
navigation={navigation}
orientation={Constants.ORIENTATION_HORIZONTAL}
/>
)}
renderSectionHeader={({ section: { title } }) => (
<View style={discoverStyle.categoryTitleRow}>
<Text style={discoverStyle.categoryName} onPress={() => this.handleTagPress(title)}>
{formatTagTitle(title)}
</Text>
<TouchableOpacity onPress={() => this.handleTagPress(title)}>
<Icon name={'angle-double-down'} size={16} />
</TouchableOpacity>
</View>
)}
sections={this.buildSections()}
keyExtractor={(item, index) => item}
/>
{!showModalTagSelector && !showSortPicker && !showTimePicker && (
<FloatingWalletBalance navigation={navigation} />
)}
{!showModalTagSelector && !showSortPicker && <FloatingWalletBalance navigation={navigation} />}
{showModalTagSelector && (
<ModalTagSelector
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
@@ -356,19 +303,10 @@ class DiscoverPage extends React.PureComponent {
title={__('Sort content by')}
onOverlayPress={() => this.setState({ showSortPicker: false })}
onItemSelected={this.handleSortByItemSelected}
selectedItem={sortByItem}
selectedItem={currentSortByItem}
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
/>
)}
{showTimePicker && (
<ModalPicker
title={__('Content from')}
onOverlayPress={() => this.setState({ showTimePicker: false })}
onItemSelected={this.handleTimeItemSelected}
selectedItem={timeItem}
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
</View>
);
}
+2 -11
View File
@@ -1,32 +1,23 @@
import { connect } from 'react-redux';
import {
doFileList,
doFetchClaimListMine,
selectFileInfosDownloaded,
selectDownloadedUris,
selectMyClaimsWithoutChannels,
selectIsFetchingClaimListMine,
selectIsFetchingFileList,
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doDeleteFile } from 'redux/actions/file';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import DownloadsPage from './view';
const select = state => ({
claims: selectMyClaimsWithoutChannels(state),
currentRoute: selectCurrentRoute(state),
fileInfos: selectFileInfosDownloaded(state),
downloadedUris: selectDownloadedUris(state),
fetching: selectIsFetchingFileList(state) || selectIsFetchingClaimListMine(state),
fetching: selectIsFetchingFileList(state),
});
const perform = dispatch => ({
deleteFile: (fileInfo, deleteFromDevice, abandonClaim) => {
dispatch(doDeleteFile(fileInfo, deleteFromDevice, abandonClaim));
},
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
fileList: () => dispatch(doFileList()),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_MY_LBRY)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+30 -138
View File
@@ -1,17 +1,7 @@
import React from 'react';
import { Lbry, buildURI, normalizeURI } from 'lbry-redux';
import {
ActivityIndicator,
Alert,
Button,
FlatList,
NativeModules,
Text,
TextInput,
View,
ScrollView,
} from 'react-native';
import { __, navigateToUri, uriFromFileInfo } from 'utils/helper';
import { Lbry, buildURI } from 'lbry-redux';
import { ActivityIndicator, Button, FlatList, Text, TextInput, View, ScrollView } from 'react-native';
import { navigateToUri, uriFromFileInfo } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PageHeader from 'component/pageHeader';
@@ -27,17 +17,11 @@ class DownloadsPage extends React.PureComponent {
title: 'Downloads',
};
state = {
selectionMode: false,
selectedUris: [],
selectedClaimsMap: {},
};
didFocusListener;
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -47,12 +31,9 @@ class DownloadsPage extends React.PureComponent {
}
onComponentFocused = () => {
const { fetchMyClaims, fileList, pushDrawerStack, setPlayerVisible } = this.props;
const { fileList, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Library');
fetchMyClaims();
fileList();
};
@@ -63,138 +44,49 @@ class DownloadsPage extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { currentRoute } = nextProps;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_MY_LBRY === currentRoute && currentRoute !== prevRoute) {
if (Constants.FULL_ROUTE_NAME_MY_LBRY === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
}
getFilteredUris = () => {
const { claims, downloadedUris } = this.props;
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
return downloadedUris.filter(uri => !claimUris.includes(uri));
};
getFilteredFileInfos = () => {
const { claims, fileInfos } = this.props;
const claimUris = claims.map(claim => normalizeURI(`${claim.name}#${claim.claim_id}`));
return fileInfos.filter(
fileInfo => !claimUris.includes(normalizeURI(`${fileInfo.claim_name}#${fileInfo.claim_id}`))
);
};
addOrRemoveItem = (uri, claim) => {
const { selectedClaimsMap } = this.state;
let selectedUris = [...this.state.selectedUris];
if (selectedUris.includes(uri)) {
delete selectedClaimsMap[uri];
selectedUris.splice(selectedUris.indexOf(uri), 1);
} else {
selectedClaimsMap[uri] = claim;
selectedUris.push(uri);
}
this.setState({ selectionMode: selectedUris.length > 0, selectedUris, selectedClaimsMap });
};
handleSelectItem = (uri, claim) => {
this.addOrRemoveItem(uri, claim);
};
handleItemLongPress = (uri, claim) => {
this.addOrRemoveItem(uri, claim);
};
onExitSelectionMode = () => {
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} });
};
onDeleteActionPressed = () => {
const { deleteFile, fileList } = this.props;
const { selectedClaimsMap } = this.state;
// show confirm alert
Alert.alert(
__('Delete files'),
__('Are you sure you want to delete the selected content?'),
[
{ text: __('No') },
{
text: __('Yes'),
onPress: () => {
const uris = Object.keys(selectedClaimsMap);
uris.forEach(uri => {
const { txid, nout } = selectedClaimsMap[uri];
deleteFile(`${txid}:${nout}`, true);
});
this.onExitSelectionMode();
fileList();
},
},
],
{
cancelable: true,
}
);
};
render() {
const { fetching, claims, downloadedUris, fileInfos, navigation } = this.props;
const { selectionMode, selectedUris } = this.state;
const filteredUris = this.getFilteredUris();
const hasDownloads = filteredUris && filteredUris.length > 0;
const { fetching, fileInfos, navigation } = this.props;
const hasDownloads = fileInfos && Object.values(fileInfos).length > 0;
return (
<View style={downloadsStyle.container}>
<UriBar
navigation={navigation}
selectionMode={selectionMode}
selectedItemCount={selectedUris.length}
onExitSelectionMode={this.onExitSelectionMode}
onDeleteActionPressed={this.onDeleteActionPressed}
/>
<View style={downloadsStyle.subContainer}>
{hasDownloads && <StorageStatsCard fileInfos={this.getFilteredFileInfos()} />}
{fetching && (
<View style={downloadsStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={downloadsStyle.loading} />
</View>
)}
{!fetching && !hasDownloads && (
<View style={downloadsStyle.busyContainer}>
<Text style={downloadsStyle.noDownloadsText}>You do not have any downloaded content on this device.</Text>
</View>
)}
{!fetching && hasDownloads && (
<UriBar navigation={navigation} />
{!fetching && !hasDownloads && (
<View style={downloadsStyle.busyContainer}>
<Text style={downloadsStyle.noDownloadsText}>
You have not watched or downloaded any content from LBRY yet.
</Text>
</View>
)}
{fetching && !hasDownloads && (
<View style={downloadsStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={downloadsStyle.loading} />
</View>
)}
{hasDownloads && (
<View style={downloadsStyle.subContainer}>
<StorageStatsCard fileInfos={fileInfos} />
<FlatList
extraData={this.state}
style={downloadsStyle.scrollContainer}
contentContainerStyle={downloadsStyle.scrollPadding}
renderItem={({ item }) => (
<FileListItem
autoplay
key={item}
uri={item}
style={fileListStyle.item}
selected={selectedUris.includes(item)}
onPress={claim => {
if (selectionMode) {
this.handleSelectItem(item, claim);
} else {
// TODO: when shortUrl is available for my claims, navigate to that URL instead
navigateToUri(navigation, item, { autoplay: true });
}
}}
onLongPress={claim => this.handleItemLongPress(item, claim)}
uri={uriFromFileInfo(item)}
navigation={navigation}
onPress={() => navigateToUri(navigation, uriFromFileInfo(item), { autoplay: true })}
/>
)}
data={downloadedUris}
keyExtractor={(item, index) => item}
data={fileInfos}
keyExtractor={(item, index) => item.outpoint}
/>
)}
</View>
</View>
)}
<FloatingWalletBalance navigation={navigation} />
</View>
);
+4 -8
View File
@@ -1,7 +1,6 @@
import { connect } from 'react-redux';
import {
doFetchFileInfo,
doFetchClaimListMine,
doFileGet,
doPurchaseUri,
doDeletePurchasedUri,
@@ -19,7 +18,6 @@ import {
makeSelectThumbnailForUri,
makeSelectTitleForUri,
selectBalance,
selectMyClaimUrisWithoutChannels,
selectPurchasedUris,
selectFailedPurchaseUris,
selectPurchaseUriErrorMessage,
@@ -52,15 +50,14 @@ const select = (state, props) => {
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
metadata: makeSelectMetadataForUri(selectProps.uri)(state),
// obscureNsfw: !selectShowNsfw(state),
// tab: makeSelectCurrentParam('tab')(state),
//obscureNsfw: !selectShowNsfw(state),
//tab: makeSelectCurrentParam('tab')(state),
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
position: makeSelectContentPositionForUri(selectProps.uri)(state),
purchasedUris: selectPurchasedUris(state),
failedPurchaseUris: selectFailedPurchaseUris(state),
myClaimUris: selectMyClaimUrisWithoutChannels(state),
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
@@ -74,15 +71,14 @@ const perform = dispatch => ({
},
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)),
notify: data => dispatch(doToast(data)),
popDrawerStack: () => dispatch(doPopDrawerStack()),
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)),
resolveUri: uri => dispatch(doResolveUri(uri)),
sendTip: (amount, claimId, isSupport, successCallback, errorCallback) =>
dispatch(doSendTip(amount, claimId, isSupport, successCallback, errorCallback)),
sendTip: (amount, claimId, uri, successCallback, errorCallback) =>
dispatch(doSendTip(amount, claimId, uri, successCallback, errorCallback)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)),
startDownload: (uri, outpoint, fileInfo) => dispatch(doStartDownload(uri, outpoint, fileInfo)),
+20 -72
View File
@@ -70,7 +70,6 @@ class FilePage extends React.PureComponent {
mediaLoaded: false,
pageSuspended: false,
relatedContentY: 0,
sendTipStarted: false,
showDescription: false,
showImageViewer: false,
showWebView: false,
@@ -89,12 +88,11 @@ class FilePage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
onComponentFocused = () => {
StatusBar.setHidden(false);
NativeModules.Firebase.setCurrentScreen('File');
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
@@ -232,11 +230,6 @@ class FilePage extends React.PureComponent {
}
};
onEditPressed = () => {
const { claim, navigation } = this.props;
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
};
onDeletePressed = () => {
const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props;
@@ -249,11 +242,11 @@ class FilePage extends React.PureComponent {
text: 'Yes',
onPress: () => {
const { uri } = navigation.state.params;
deleteFile(`${claim.txid}:${claim.nout}`, true);
deletePurchasedUri(uri);
NativeModules.UtilityModule.deleteDownload(uri);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.deleteDownload(uri);
}
this.setState({
downloadPressed: false,
fileViewLogged: false,
@@ -504,25 +497,9 @@ class FilePage extends React.PureComponent {
return;
}
const suffix = 'credit' + (parseInt(tipAmount, 10) === 1 ? '' : 's');
Alert.alert(
'Send tip',
`Are you sure you want to tip ${tipAmount} ${suffix}?`,
[
{ text: 'No' },
{
text: 'Yes',
onPress: () => {
this.setState({ sendTipStarted: true }, () =>
sendTip(tipAmount, claim.claim_id, false, () => {
this.setState({ tipAmount: null, showTipView: false, sendTipStarted: false });
})
);
},
},
],
{ cancelable: true }
);
sendTip(tipAmount, claim.claim_id, uri, () => {
this.setState({ tipAmount: 0, showTipView: false });
});
};
renderTags = tags => {
@@ -576,7 +553,6 @@ class FilePage extends React.PureComponent {
rewardedContentClaimIds,
isResolvingUri,
blackListedOutpoints,
myClaimUris,
navigation,
position,
purchaseUri,
@@ -649,25 +625,20 @@ class FilePage extends React.PureComponent {
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const { height, signing_channel: signingChannel, value } = claim;
const channelName = signingChannel && signingChannel.name;
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const canSendTip = this.state.tipAmount > 0;
const fullUri = `${claim.name}#${claim.claim_id}`;
const canEdit = myClaimUris.includes(normalizeURI(fullUri));
const showActions =
(canEdit || (fileInfo && fileInfo.download_path)) &&
fileInfo &&
fileInfo.download_path &&
!this.state.fullscreenMode &&
!this.state.showImageViewer &&
!this.state.showWebView;
const showFileActions =
canEdit ||
(fileInfo &&
fileInfo.download_path &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)));
fileInfo &&
fileInfo.download_path &&
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const canSendTip = this.state.tipAmount > 0;
const fullChannelUri =
channelClaimId && channelClaimId.trim().length > 0
? normalizeURI(`${channelName}#${channelClaimId}`)
: normalizeURI(channelName);
const shortChannelUri = signingChannel ? signingChannel.short_url : null;
channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
const playerStyle = [
filePageStyle.player,
@@ -683,7 +654,6 @@ class FilePage extends React.PureComponent {
const canLoadMedia =
this.state.streamingMode ||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2
const duration = claim && claim.value && claim.value.video ? claim.value.video.duration : null;
const isViewable = mediaType === 'image' || mediaType === 'text';
const isWebViewable = mediaType === 'text';
const canOpen = isViewable && completed;
@@ -751,12 +721,7 @@ class FilePage extends React.PureComponent {
>
<View style={filePageStyle.mediaContainer}>
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
<FileItemMedia
duration={duration}
style={filePageStyle.thumbnail}
title={title}
thumbnail={thumbnail}
/>
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={thumbnail} />
)}
{(!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded && (
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={filePageStyle.loading} />
@@ -833,16 +798,6 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.actions}>
{showFileActions && (
<View style={filePageStyle.fileActions}>
{canEdit && (
<Button
style={[filePageStyle.actionButton, filePageStyle.editButton]}
theme={'light'}
icon={'edit'}
text={'Edit'}
onPress={this.onEditPressed}
/>
)}
{completed && (
<Button
style={filePageStyle.actionButton}
@@ -885,7 +840,6 @@ class FilePage extends React.PureComponent {
<Text style={filePageStyle.title} selectable>
{title}
</Text>
{isRewardContent && <Icon name="award" style={filePageStyle.rewardIcon} size={16} />}
<View style={filePageStyle.descriptionToggle}>
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
</View>
@@ -901,7 +855,7 @@ class FilePage extends React.PureComponent {
numberOfLines={1}
ellipsizeMode={'tail'}
onPress={() => {
navigateToUri(navigation, normalizeURI(shortChannelUri || fullChannelUri));
navigateToUri(navigation, normalizeURI(fullChannelUri));
}}
/>
)}
@@ -957,19 +911,15 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.row}>
<View style={filePageStyle.amountRow}>
<TextInput
editable={!this.state.sendTipStarted}
ref={ref => (this.tipAmountInput = ref)}
onChangeText={value => this.setState({ tipAmount: value })}
underlineColorAndroid={Colors.NextLbryGreen}
keyboardType={'numeric'}
placeholder={'0'}
value={this.state.tipAmount}
selectTextOnFocus
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
/>
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
</View>
{this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
<Link
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
text={'Cancel'}
@@ -978,7 +928,7 @@ class FilePage extends React.PureComponent {
<Button
text={'Send a tip'}
style={[filePageStyle.button, filePageStyle.sendButton]}
disabled={!canSendTip || this.state.sendTipStarted}
disabled={!canSendTip}
onPress={this.handleSendTip}
/>
</View>
@@ -1002,12 +952,10 @@ class FilePage extends React.PureComponent {
</View>
)}
{costInfo && parseFloat(costInfo.cost) > balance && !fileInfo && (
<FileRewardsDriver navigation={navigation} />
)}
{costInfo && parseFloat(costInfo.cost) > balance && <FileRewardsDriver navigation={navigation} />}
<View onLayout={this.setRelatedContentPosition} />
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
<RelatedContent navigation={navigation} uri={uri} />
</ScrollView>
</View>
)}
+1 -1
View File
@@ -46,7 +46,7 @@ const perform = dispatch => ({
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
notify: data => dispatch(doToast(data)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
});
+16 -31
View File
@@ -4,7 +4,7 @@ import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View
import { NavigationActions, StackActions } from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import WalletPage from './internal/wallet-page';
import WelcomePage from './internal/welcome-page';
import EmailCollectPage from './internal/email-collect-page';
@@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
isEmailVerified: false,
skipAccountConfirmed: false,
showBottomContainer: false,
walletPassword: '',
walletPassword: null,
syncApplyStarted: false,
};
@@ -51,7 +51,6 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ isFirstRun: firstRun });
if (firstRun) {
NativeModules.Firebase.setCurrentScreen('First Run');
this.setState({ currentPage: FirstRunScreen.pages[0] });
} else {
// Not the first run. Navigate to the splash screen right away
@@ -74,7 +73,6 @@ class FirstRunScreen extends React.PureComponent {
notify({ message: String(emailNewErrorMessage), isError: true });
} else {
// Request successful. Navigate to email verify page.
NativeModules.Firebase.track('email_added', { email: this.state.email });
this.showPage(Constants.FIRST_RUN_PAGE_EMAIL_VERIFY);
}
}
@@ -86,25 +84,12 @@ class FirstRunScreen extends React.PureComponent {
this.setState({ showBottomContainer: true });
} else {
// password successfully verified
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet
Lbry.account_unlock({ password: this.state.walletPassword ? this.state.walletPassword : '' })
.then(() => this.closeFinalPage())
.catch(err =>
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })
);
},
err => {
notify({
message:
'The account restore operation could not be completed successfully. Please restart the app and try again.',
});
}
);
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.walletPassword);
}
setDefaultAccount();
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
this.closeFinalPage();
}
}
@@ -243,7 +228,7 @@ class FirstRunScreen extends React.PureComponent {
onEmailChanged = email => {
this.setState({ email });
if (Constants.FIRST_RUN_PAGE_EMAIL_COLLECT === this.state.currentPage) {
if (Constants.FIRST_RUN_PAGE_EMAIL_COLLECT == this.state.currentPage) {
this.setState({ showSkip: !email || email.trim().length === 0 });
} else {
this.setState({ showSkip: false });
@@ -251,14 +236,14 @@ class FirstRunScreen extends React.PureComponent {
};
onEmailViewLayout = phase => {
if (phase === 'collect') {
if ('collect' === phase) {
if (!this.state.emailCollectTracked) {
// we only want to track this once
this.setState({ emailCollectTracked: true }, () =>
NativeModules.Firebase.track('first_run_email_collect', null)
);
}
} else if (phase === 'verify') {
} else if ('verify' === phase) {
NativeModules.Firebase.track('first_run_email_verify', null);
}
@@ -266,7 +251,7 @@ class FirstRunScreen extends React.PureComponent {
};
onWalletPasswordChanged = password => {
this.setState({ walletPassword: password !== null ? password : '' });
this.setState({ walletPassword: password });
};
onWalletViewLayout = () => {
@@ -417,10 +402,10 @@ class FirstRunScreen extends React.PureComponent {
{Constants.FIRST_RUN_PAGE_SKIP_ACCOUNT !== this.state.currentPage &&
Constants.FIRST_RUN_PAGE_EMAIL_VERIFY !== this.state.currentPage && (
<Text style={firstRunStyle.buttonText}>
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? 'Use LBRY' : 'Continue'} »
</Text>
)}
<Text style={firstRunStyle.buttonText}>
{Constants.FIRST_RUN_PAGE_WALLET === this.state.currentPage ? 'Use LBRY' : 'Continue'} »
</Text>
)}
</TouchableOpacity>
)}
</View>
+2 -4
View File
@@ -3,13 +3,12 @@ import {
doPublish,
doResolveUri,
doToast,
doUpdatePublishForm,
doUploadThumbnail,
selectBalance,
selectPublishFormValues,
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import PublishPage from './view';
const select = state => ({
@@ -19,9 +18,8 @@ const select = state => ({
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
uploadThumbnail: (filePath, fsAdapter) => dispatch(doUploadThumbnail(filePath, null, fsAdapter)),
publish: (success, fail) => dispatch(doPublish(success, fail)),
publish: params => dispatch(doPublish(params)),
resolveUri: uri => dispatch(doResolveUri(uri)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+156 -393
View File
@@ -15,17 +15,8 @@ import {
View,
} from 'react-native';
import { FlatGrid } from 'react-native-super-grid';
import {
isNameValid,
buildURI,
normalizeURI,
parseURI,
regexInvalidURI,
CLAIM_VALUES,
LICENSES,
MATURE_TAGS,
THUMBNAIL_STATUSES,
} from 'lbry-redux';
import { isNameValid, buildURI, regexInvalidURI, CLAIM_VALUES, LICENSES, THUMBNAIL_STATUSES } from 'lbry-redux';
import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';
import { RNCamera } from 'react-native-camera';
import { generateCombination } from 'gfycat-style-urls';
import RNFS from 'react-native-fs';
@@ -43,7 +34,6 @@ import Tag from 'component/tag';
import TagSearch from 'component/tagSearch';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { __, navigateToUri } from 'utils/helper';
const languages = {
en: 'English',
@@ -77,17 +67,13 @@ class PublishPage extends React.PureComponent {
camera = null;
state = {
canPublish: false,
canUseCamera: false,
editMode: false,
titleFocused: false,
descriptionFocused: false,
loadingVideos: false,
// gallery videos
videos: null,
allThumbnailsChecked: false,
checkedThumbnails: [],
galleryThumbnailsChecked: false,
// camera
cameraType: RNCamera.Constants.Type.back,
@@ -110,22 +96,17 @@ class PublishPage extends React.PureComponent {
priceSet: false,
// input data
hasEditedContentAddress: false,
bid: 0.1,
description: null,
title: null,
language: 'en',
license: LICENSES.NONE,
licenseUrl: '',
otherLicenseDescription: '',
mature: false,
name: null,
price: 0,
currency: 'LBC',
uri: null,
tags: [],
selectedChannel: null,
uploadedThumbnailUri: null,
vanityUrlSet: false,
// other
publishStarted: false,
@@ -135,124 +116,30 @@ class PublishPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
DeviceEventEmitter.addListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.addListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
DeviceEventEmitter.addListener('onGalleryThumbnailsChecked', this.handleGalleryThumbnailsChecked);
}
componentWillUnmount() {
if (this.didFocusListener) {
this.didFocusListener.remove();
}
DeviceEventEmitter.removeListener('onGalleryThumbnailChecked', this.handleGalleryThumbnailChecked);
DeviceEventEmitter.removeListener('onAllGalleryThumbnailsChecked', this.handleAllGalleryThumbnailsChecked);
DeviceEventEmitter.removeListener('onGalleryThumbnailsChecked', this.handleGalleryThumbnailsChecked);
}
handleGalleryThumbnailChecked = evt => {
const checkedThumbnails = [...this.state.checkedThumbnails];
const { id } = evt;
// using checked because we only want thumbnails that can be displayed
if (!checkedThumbnails.includes(id)) {
checkedThumbnails.push(id);
}
this.setState({ checkedThumbnails });
};
handleAllGalleryThumbnailsChecked = () => {
this.setState({ allThumbnailsChecked: true });
handleGalleryThumbnailsChecked = () => {
this.setState({ galleryThumbnailsChecked: true });
};
onComponentFocused = () => {
const { balance, pushDrawerStack, setPlayerVisible, navigation } = this.props;
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
this.setState(
{
canPublish: balance >= 0.1,
loadingVideos: true,
},
() => {
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos, loadingVideos: false }));
}
);
// Check if this is an edit action
if (navigation.state.params) {
const { editMode, claimToEdit, vanityUrl } = navigation.state.params;
if (editMode) {
this.prepareEdit(claimToEdit);
} else if (vanityUrl) {
const { claimName } = parseURI(vanityUrl);
this.setState({
name: claimName,
hasEditedContentAddress: true,
vanityUrlSet: true,
});
}
}
});
};
prepareEdit = claim => {
let channelName;
const { amount, name, signing_channel: signingChannel, value } = claim;
const { description, fee, languages, license, license_url: licenseUrl, tags, thumbnail, title } = value;
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;
}
this.setState(
{
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,
},
() => {
this.handleNameChange(name);
if (channelName) {
this.handleChannelChange(channelName);
}
}
);
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos }));
};
getNewUri(name, channel) {
@@ -264,7 +151,7 @@ class PublishPage extends React.PureComponent {
// We are only going to store the full uri, but we need to resolve the uri with and without the channel name
let uri;
try {
uri = buildURI({ claimName: name, channelName });
uri = buildURI({ contentName: name, channelName });
} catch (e) {
// something wrong with channel or name
}
@@ -272,7 +159,7 @@ class PublishPage extends React.PureComponent {
if (uri) {
if (channelName) {
// resolve without the channel name so we know the winning bid for it
const uriLessChannel = buildURI({ claimName: name });
const uriLessChannel = buildURI({ contentName: name });
resolveUri(uriLessChannel);
}
resolveUri(uri);
@@ -287,18 +174,15 @@ class PublishPage extends React.PureComponent {
};
handlePublishPressed = () => {
const { notify, publish, updatePublishForm } = this.props;
const { notify, publish } = this.props;
const {
editMode,
bid,
channelName,
currentMedia,
currency,
description,
language,
license,
licenseUrl,
otherLicenseDescription,
mature,
name,
price,
priceSet,
@@ -318,50 +202,33 @@ class PublishPage extends React.PureComponent {
return;
}
if (!currentMedia && !editMode) {
// sanity check. normally shouldn't happen
notify({ message: 'No file selected. Please select a video or take a photo before publishing.' });
return;
const publishTags = tags.slice();
if (mature) {
publishTags.push('nsfw');
}
const publishParams = {
filePath: currentMedia ? currentMedia.filePath : null,
filePath: currentMedia.filePath,
bid: bid || 0.1,
tags: publishTags,
title: title || '',
thumbnail,
thumbnail: thumbnail,
description: description || '',
language,
nsfw: mature,
license,
licenseType: license,
licenseUrl,
otherLicenseDescription,
licenseUrl: '',
otherLicenseDescription: '',
name: name || undefined,
contentIsFree: !priceSet,
fee: { currency, amount: price },
fee: { currency: 'LBC', price },
uri: uri || undefined,
channel: CLAIM_VALUES.CHANNEL_ANONYMOUS === channelName ? null : channelName,
channel_name: CLAIM_VALUES.CHANNEL_ANONYMOUS === channelName ? undefined : channelName,
isStillEditing: false,
tags: tags.map(tag => {
return { name: tag };
}),
claim: null,
};
updatePublishForm(publishParams);
this.setState({ publishStarted: true }, () => publish(this.handlePublishSuccess, this.handlePublishFailure));
};
handlePublishSuccess = data => {
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 => {
const { notify } = this.props;
notify({ message: __('Your content could not be published at this time. Please try again.') });
this.setState({ publishStarted: false });
this.setState({ publishStarted: true }, () => publish(publishParams));
};
componentDidMount() {
@@ -370,7 +237,7 @@ class PublishPage extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { currentRoute, publishFormValues } = nextProps;
const { currentRoute: prevRoute, notify } = this.props;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_PUBLISH === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
@@ -378,21 +245,29 @@ class PublishPage extends React.PureComponent {
if (publishFormValues) {
if (publishFormValues.thumbnail && !this.state.uploadedThumbnailUri) {
this.setState({
currentThumbnailUri: publishFormValues.thumbnail,
uploadedThumbnailUri: publishFormValues.thumbnail,
});
this.setState({ uploadedThumbnailUri: publishFormValues.thumbnail });
}
if (this.state.publishStarted) {
if (publishFormValues.publishSuccess) {
this.setState({ publishStarted: false, currentPhase: Constants.PHASE_PUBLISH });
} else if (publishFormValues.publishError) {
// TODO: Display error if any
}
if (!publishFormValues.publishing && this.state.publishStarted) {
this.setState({ publishStarted: false });
}
}
}
}
setCurrentMedia(media) {
const name = generateCombination(2, ' ', true);
this.setState(
{
currentMedia: media,
title: null, // no title autogeneration (user will fill this in)
name: this.state.hasEditedContentAddress ? this.state.name : this.formatNameForTitle(name),
title: media.name,
name: this.formatNameForTitle(media.name),
currentPhase: Constants.PHASE_DETAILS,
},
() => this.handleNameChange(this.state.name)
@@ -400,52 +275,35 @@ class PublishPage extends React.PureComponent {
}
formatNameForTitle = title => {
return title.replace(new RegExp(regexInvalidURI.source, regexInvalidURI.flags + 'g'), '-').toLowerCase();
return title.replace(regexInvalidURI, '-').toLowerCase();
};
showSelector() {
const { updatePublishForm } = this.props;
this.setState({
publishStarted: false,
this.setState(
{
publishStarted: false,
editMode: false,
currentMedia: null,
currentThumbnailUri: null,
currentPhase: Constants.PHASE_SELECTOR,
currentMedia: null,
currentThumbnailUri: null,
currentPhase: Constants.PHASE_SELECTOR,
updatingThumbnailUri: false,
uploadThumbnailStarted: false,
// publish
advancedMode: false,
anonymous: true,
channelName: CLAIM_VALUES.CHANNEL_ANONYMOUS,
priceSet: false,
// publish
advancedMode: false,
anonymous: true,
channelName: CLAIM_VALUES.CHANNEL_ANONYMOUS,
priceSet: false,
// input data
hasEditedContentAddress: false,
bid: 0.1,
description: null,
title: null,
language: 'en',
license: LICENSES.NONE,
licenseUrl: '',
otherLicenseDescription: '',
name: null,
price: 0,
uri: null,
tags: [],
selectedChannel: null,
uploadedThumbnailUri: null,
vanityUrlSet: false,
},
() => {
// reset thumbnail
updatePublishForm({ thumbnail: null });
}
);
// input data
bid: 0.1,
description: null,
title: null,
language: 'en',
license: LICENSES.NONE,
name: null,
price: 0,
uri: null,
tags: [],
uploadedThumbnailUri: null,
});
}
handleRecordVideoPressed = () => {
@@ -482,6 +340,7 @@ class PublishPage extends React.PureComponent {
const currentMedia = {
id: -1,
filePath: this.getFilePathFromUri(data.uri),
name: generateCombination(2, ' ', true),
type: 'video/mp4', // always MP4
duration: 0,
};
@@ -526,6 +385,19 @@ class PublishPage extends React.PureComponent {
});
};
handleUploadPressed = () => {
DocumentPicker.show(
{
filetype: [DocumentPickerUtil.allFiles()],
},
(error, res) => {
if (!error) {
// console.log(res);
}
}
);
};
getRandomFileId = () => {
// generate a random id for a photo or recorded video between 1 and 20 (for creating thumbnails)
const id = Math.floor(Math.random() * (20 - 2)) + 1;
@@ -544,13 +416,9 @@ class PublishPage extends React.PureComponent {
this.setState({ price });
};
handleNameChange = (name, userInput) => {
handleNameChange = name => {
const { notify } = this.props;
this.setState({ name });
if (userInput) {
this.setState({ hasEditedContentAddress: true });
}
if (!isNameValid(name, false)) {
notify({ message: 'Your content address contains invalid characters' });
return;
@@ -560,14 +428,14 @@ class PublishPage extends React.PureComponent {
this.setState({ uri });
};
handleChannelChange = channel => {
const { name } = this.state;
const uri = this.getNewUri(name, channel);
this.setState({ uri, channelName: channel, selectedChannel: channel });
handleChannelChanged = channel => {
this.setState({ channelName: channel });
const uri = this.getNewUri(name, this.state.channelName);
this.setState({ uri });
};
handleAddTag = tag => {
if (!tag || !this.state.canPublish || this.state.publishStarted) {
if (!tag) {
return;
}
@@ -584,7 +452,7 @@ class PublishPage extends React.PureComponent {
};
handleRemoveTag = tag => {
if (!tag || !this.state.canPublish || this.state.publishStarted) {
if (!tag) {
return;
}
@@ -640,69 +508,20 @@ class PublishPage extends React.PureComponent {
};
handleTitleChange = title => {
this.setState({ title });
if (!this.state.editMode && !this.state.hasEditedContentAddress) {
// only autogenerate url if the user has not yet edited the field
// also shouldn't change url in edit mode
this.setState(
{
name: this.formatNameForTitle(title),
},
() => {
this.handleNameChange(this.state.name);
}
);
}
};
handleCurrencyValueChange = currency => {
this.setState({ currency });
};
handleDescriptionChange = description => {
this.setState({ description });
};
handleLanguageValueChange = language => {
this.setState({ language });
};
handleLicenseValueChange = license => {
const otherLicenseDescription = [LICENSES.COPYRIGHT, LICENSES.OTHER].includes(license)
? this.state.otherLicenseDescription
: '';
this.setState({
otherLicenseDescription,
license,
licenseUrl: LICENSES.CC_LICENSES.reduce((value, item) => {
if (typeof value === 'object') {
value = '';
}
if (license === item.value) {
value = item.url;
}
return value;
}),
});
};
handleChangeLicenseDescription = otherLicenseDescription => {
this.setState({ otherLicenseDescription });
this.setState(
{
title,
name: this.formatNameForTitle(title),
},
() => {
this.handleNameChange(this.state.name);
}
);
};
render() {
const { balance, navigation, notify, publishFormValues } = this.props;
const {
allThumbnailsChecked,
canUseCamera,
currentPhase,
checkedThumbnails,
loadingVideos,
thumbnailPath,
videos,
} = this.state;
const { canUseCamera, currentPhase, galleryThumbnailsChecked, thumbnailPath, videos } = this.state;
let content;
if (Constants.PHASE_SELECTOR === currentPhase) {
@@ -711,24 +530,12 @@ class PublishPage extends React.PureComponent {
<View style={publishStyle.actionsView}>
{canUseCamera && <RNCamera style={publishStyle.cameraPreview} type={RNCamera.Constants.Type.back} />}
<View style={publishStyle.actionsSubView}>
<TouchableOpacity
style={[
publishStyle.record,
canUseCamera ? publishStyle.transparentBackground : publishStyle.actionBackground,
]}
onPress={this.handleRecordVideoPressed}
>
<TouchableOpacity style={publishStyle.record} onPress={this.handleRecordVideoPressed}>
<Icon name="video" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Record</Text>
</TouchableOpacity>
<View style={publishStyle.subActions}>
<TouchableOpacity
style={[
publishStyle.photo,
canUseCamera ? publishStyle.transparentBackground : publishStyle.actionBackground,
]}
onPress={this.handleTakePhotoPressed}
>
<TouchableOpacity style={publishStyle.photo} onPress={this.handleTakePhotoPressed}>
<Icon name="camera" size={48} color={Colors.White} />
<Text style={publishStyle.actionText}>Take a photo</Text>
</TouchableOpacity>
@@ -741,28 +548,24 @@ class PublishPage extends React.PureComponent {
</View>
</View>
</View>
{(loadingVideos || !allThumbnailsChecked) && (
{(!videos || !thumbnailPath || !galleryThumbnailsChecked) && (
<View style={publishStyle.loadingView}>
<ActivityIndicator size="small" color={Colors.NextLbryGreen} />
<Text style={publishStyle.loadingText}>Please wait while we load your videos...</Text>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
</View>
)}
{!loadingVideos && (!videos || videos.length === 0) && (
<View style={publishStyle.relativeCentered}>
{thumbnailPath && (!videos || videos.length === 0) && (
<View style={publishStyle.centered}>
<Text style={publishStyle.noVideos}>
We could not find any videos on your device. Take a photo or record a video to get started.
</Text>
</View>
)}
{videos && thumbnailPath && allThumbnailsChecked && (
{videos && thumbnailPath && galleryThumbnailsChecked && (
<FlatGrid
style={publishStyle.galleryGrid}
initialNumToRender={18}
maxToRenderPerBatch={24}
removeClippedSubviews
itemDimension={134}
spacing={2}
items={videos.filter(video => checkedThumbnails.includes(video.id))}
items={this.state.videos}
renderItem={({ item, index }) => {
return (
<TouchableOpacity key={index} onPress={() => this.setCurrentMedia(item)}>
@@ -778,12 +581,9 @@ class PublishPage extends React.PureComponent {
)}
</View>
);
} else if (
Constants.PHASE_DETAILS === this.state.currentPhase &&
(this.state.editMode || this.state.currentMedia)
) {
} else if (Constants.PHASE_DETAILS === this.state.currentPhase && this.state.currentMedia) {
const { currentMedia, currentThumbnailUri } = this.state;
if (!currentThumbnailUri && !this.state.editMode) {
if (!currentThumbnailUri) {
this.updateThumbnailUriForMedia(currentMedia);
}
content = (
@@ -797,11 +597,11 @@ class PublishPage extends React.PureComponent {
/>
</View>
)}
{!this.state.canPublish && <PublishRewardsDriver navigation={navigation} />}
{balance < 0.1 && <PublishRewardsDriver navigation={navigation} />}
{this.state.uploadThumbnailStarted && !this.state.uploadedThumbnailUri && (
<View style={publishStyle.thumbnailUploadContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
<Text style={publishStyle.thumbnailUploadText}>Uploading thumbnail...</Text>
</View>
)}
@@ -812,7 +612,6 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Title</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={this.state.titleFocused ? '' : 'Title'}
style={publishStyle.inputText}
value={this.state.title}
@@ -830,7 +629,6 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.textInputTitle}>Description</Text>
)}
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={this.state.descriptionFocused ? '' : 'Description'}
style={publishStyle.inputText}
value={this.state.description}
@@ -856,17 +654,13 @@ class PublishPage extends React.PureComponent {
/>
))}
</View>
<TagSearch handleAddTag={this.handleAddTag} selectedTags={this.state.tags} showNsfwTags />
<TagSearch handleAddTag={this.handleAddTag} selectedTags={this.state.tags} />
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Channel</Text>
<ChannelSelector
enabled={this.state.canPublish && !this.state.publishStarted}
channelName={this.state.channelName}
onChannelChange={this.handleChannelChange}
/>
<ChannelSelector onChannelChange={this.handleChannelChange} />
</View>
<View style={publishStyle.card}>
@@ -884,7 +678,6 @@ class PublishPage extends React.PureComponent {
{this.state.priceSet && (
<View style={[publishStyle.inputRow, publishStyle.priceInputRow]}>
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'}
keyboardType={'number-pad'}
style={publishStyle.priceInput}
@@ -893,60 +686,55 @@ class PublishPage extends React.PureComponent {
value={String(this.state.price)}
onChangeText={this.handlePriceChange}
/>
<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>
<Text style={publishStyle.currency}>LBC</Text>
</View>
)}
</View>
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Content address</Text>
<Text style={publishStyle.helpText}>
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>
{this.state.advancedMode && (
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Content Address</Text>
<Text style={publishStyle.helpText}>
The address where people can find your content (ex. lbry://myvideo)
</Text>
<TextInput
editable={!this.state.editMode && this.state.canPublish && !this.state.publishStarted}
placeholder={'lbry://'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
value={this.state.name}
onChangeText={value => this.handleNameChange(value, true)}
/>
<View style={publishStyle.inputRow}>
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'0.00'}
style={publishStyle.priceInput}
placeholder={'lbry://'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
keyboardType={'numeric'}
value={String(this.state.bid)}
onChangeText={this.handleBidChange}
value={this.state.name}
onChangeText={this.handleNameChange}
/>
<Text style={publishStyle.currency}>LBC</Text>
<View style={publishStyle.inputRow}>
<TextInput
placeholder={'0.00'}
style={publishStyle.priceInput}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
keyboardType={'numeric'}
value={String(this.state.bid)}
onChangeText={this.handleBidChange}
/>
<Text style={publishStyle.currency}>LBC</Text>
</View>
<Text style={publishStyle.helpText}>
This LBC remains yours and the deposit can be undone at any time.
</Text>
</View>
<Text style={publishStyle.helpText}>This LBC remains yours and the deposit can be undone at any time.</Text>
</View>
)}
{this.state.advancedMode && (
<View style={publishStyle.card}>
<Text style={publishStyle.cardTitle}>Additional Options</Text>
<View style={publishStyle.toggleField}>
<Switch value={this.state.mature} onValueChange={value => this.setState({ mature: value })} />
<Text style={publishStyle.toggleText}>Mature content</Text>
</View>
<View>
<Text style={publishStyle.cardText}>Language</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.language}
style={publishStyle.picker}
itemStyle={publishStyle.pickerItem}
@@ -961,7 +749,6 @@ class PublishPage extends React.PureComponent {
<View>
<Text style={publishStyle.cardText}>License</Text>
<Picker
enabled={this.state.canPublish && !this.state.publishStarted}
selectedValue={this.state.license}
style={publishStyle.picker}
itemStyle={publishStyle.pickerItem}
@@ -975,17 +762,6 @@ class PublishPage extends React.PureComponent {
<Picker.Item label={'Copyrighted...'} value={LICENSES.COPYRIGHT} key={LICENSES.COPYRIGHT} />
<Picker.Item label={'Other...'} value={LICENSES.OTHER} key={LICENSES.OTHER} />
</Picker>
{[LICENSES.COPYRIGHT, LICENSES.OTHER].includes(this.state.license) && (
<TextInput
editable={this.state.canPublish && !this.state.publishStarted}
placeholder={'License description'}
style={publishStyle.inputText}
underlineColorAndroid={Colors.NextLbryGreen}
numberOfLines={1}
value={this.state.otherLicenseDescription}
onChangeText={this.handleChangeLicenseDescription}
/>
)}
</View>
</View>
)}
@@ -998,13 +774,6 @@ class PublishPage extends React.PureComponent {
/>
</View>
<View style={publishStyle.warning}>
<Text style={publishStyle.warningText}>
Please ensure that you have filled everything correctly as you cannot edit published content in this
release. This feature will be available in a future release.
</Text>
</View>
<View style={publishStyle.actionButtons}>
{(this.state.publishStarted || publishFormValues.publishing) && (
<View style={publishStyle.progress}>
@@ -1013,15 +782,19 @@ class PublishPage extends React.PureComponent {
)}
{!publishFormValues.publishing && !this.state.publishStarted && (
<Link style={publishStyle.cancelLink} text="Cancel" onPress={() => this.showSelector()} />
<Link
style={publishStyle.cancelLink}
text="Cancel"
onPress={() => this.setState({ currentPhase: Constants.PHASE_SELECTOR })}
/>
)}
{!publishFormValues.publishing && !this.state.publishStarted && (
<View style={publishStyle.rightActionButtons}>
<Button
style={publishStyle.publishButton}
disabled={!this.state.canPublish || !this.state.uploadedThumbnailUri}
text={this.state.editMode ? 'Save changes' : 'Publish'}
disabled={balance < 0.1 || !this.state.uploadedThumbnailUri}
text="Publish"
onPress={this.handlePublishPressed}
/>
</View>
@@ -1036,11 +809,7 @@ class PublishPage extends React.PureComponent {
<Text style={publishStyle.successTitle}>Success!</Text>
<Text style={publishStyle.successText}>Congratulations! Your content was successfully uploaded.</Text>
<View style={publishStyle.successRow}>
<Link
style={publishStyle.successUrl}
text={this.state.uri}
onPress={() => navigateToUri(navigation, this.state.uri)}
/>
<Link style={publishStyle.successUrl} text={this.state.uri} href={this.state.uri} />
<TouchableOpacity
onPress={() => {
Clipboard.setString(this.state.uri);
@@ -1072,7 +841,6 @@ class PublishPage extends React.PureComponent {
{this.state.canUseCamera && this.state.showCameraOverlay && (
<View style={publishStyle.cameraOverlay}>
<RNCamera
captureAudio={this.state.videoRecordingMode}
style={publishStyle.fullCamera}
ref={ref => {
this.camera = ref;
@@ -1091,11 +859,6 @@ class PublishPage extends React.PureComponent {
buttonPositive: 'OK',
buttonNegative: 'Cancel',
}}
notAuthorizedView={
<View style={publishStyle.fullCentered}>
<Text style={publishStyle.cameraInfo}>Camera not authorized</Text>
</View>
}
/>
<View
style={[
@@ -1104,7 +867,7 @@ class PublishPage extends React.PureComponent {
]}
>
<View style={publishStyle.controlsRow}>
<TouchableOpacity onPress={this.handleCloseCameraPressed} style={publishStyle.backButtonControl}>
<TouchableOpacity onPress={this.handleCloseCameraPressed}>
<Icon name="arrow-left" size={28} color={Colors.White} />
</TouchableOpacity>
+1 -9
View File
@@ -1,11 +1,5 @@
import { connect } from 'react-redux';
import {
doAbandonClaim,
doCheckPendingPublishes,
doFetchClaimListMine,
selectMyClaimUrisWithoutChannels,
selectIsFetchingClaimListMine,
} from 'lbry-redux';
import { doCheckPendingPublishes, selectMyClaimUrisWithoutChannels, selectIsFetchingClaimListMine } from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import PublishesPage from './view';
@@ -16,8 +10,6 @@ const select = state => ({
});
const perform = dispatch => ({
abandonClaim: (txid, nout) => dispatch(doAbandonClaim(txid, nout)),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
checkPendingPublishes: () => dispatch(doCheckPendingPublishes()),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISHES)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+9 -109
View File
@@ -1,5 +1,5 @@
import React from 'react';
import { ActivityIndicator, Alert, FlatList, NativeModules, Text, TouchableOpacity, View } from 'react-native';
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
import Button from 'component/button';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -7,20 +7,14 @@ import FileListItem from 'component/fileListItem';
import FloatingWalletBalance from 'component/floatingWalletBalance';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { __, navigateToUri } from 'utils/helper';
import { __ } from 'utils/helper';
class PublishesPage extends React.PureComponent {
state = {
selectionMode: false,
selectedUris: [],
selectedClaimsMap: {},
};
didFocusListener;
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -29,101 +23,23 @@ class PublishesPage extends React.PureComponent {
}
}
componentDidMount() {
this.onComponentFocused();
}
onComponentFocused = () => {
const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props;
const { checkPendingPublishes, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Publishes').then(result => {
fetchMyClaims();
checkPendingPublishes();
});
};
addOrRemoveItem = (uri, claim) => {
const { selectedClaimsMap } = this.state;
let selectedUris = [...this.state.selectedUris];
if (selectedUris.includes(uri)) {
delete selectedClaimsMap[uri];
selectedUris.splice(selectedUris.indexOf(uri), 1);
} else {
selectedClaimsMap[uri] = claim;
selectedUris.push(uri);
}
this.setState({ selectionMode: selectedUris.length > 0, selectedUris, selectedClaimsMap });
};
handleSelectItem = (uri, claim) => {
this.addOrRemoveItem(uri, claim);
};
handleItemLongPress = (uri, claim) => {
this.addOrRemoveItem(uri, claim);
};
onExitSelectionMode = () => {
this.setState({ selectionMode: false, selectedUris: [], selectedClaimsMap: {} });
};
onEditActionPressed = () => {
const { navigation } = this.props;
const { selectedClaimsMap, selectedUris } = this.state;
// only 1 item can be edited (and edit button should be visible only if there is a single selection)
const claim = selectedClaimsMap[selectedUris[0]];
this.onExitSelectionMode();
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
};
onDeleteActionPressed = () => {
const { abandonClaim } = this.props;
const { selectedClaimsMap } = this.state;
// show confirm alert
Alert.alert(
__('Unpublish'),
__('Are you sure you want to unpublish the selected content?'),
[
{ text: __('No') },
{
text: __('Yes'),
onPress: () => {
const uris = Object.keys(selectedClaimsMap);
uris.forEach(uri => {
const { txid, nout } = selectedClaimsMap[uri];
abandonClaim(txid, nout);
});
this.onExitSelectionMode();
},
},
],
{ cancelable: true }
);
checkPendingPublishes();
};
render() {
const { fetching, navigation, uris } = this.props;
const { selectionMode, selectedUris } = this.state;
return (
<View style={publishStyle.container}>
<UriBar
allowEdit
navigation={navigation}
selectionMode={selectionMode}
selectedItemCount={selectedUris.length}
onDeleteActionPressed={this.onDeleteActionPressed}
onEditActionPressed={this.onEditActionPressed}
onExitSelectionMode={this.onExitSelectionMode}
/>
<UriBar navigation={navigation} />
{fetching && (
<View style={publishStyle.centered}>
<ActivityIndicator size={'large'} color={Colors.NextLbryGreen} />
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
</View>
)}
@@ -144,27 +60,11 @@ class PublishesPage extends React.PureComponent {
<FlatList
style={publishStyle.publishesList}
contentContainerStyle={publishStyle.publishesScrollPadding}
extraData={this.state}
initialNumToRender={8}
maxToRenderPerBatch={24}
removeClippedSubviews
renderItem={({ item }) => (
<FileListItem
key={item}
uri={item}
style={publishStyle.listItem}
selected={selectedUris.includes(item)}
onPress={claim => {
if (selectionMode) {
this.handleSelectItem(item, claim);
} else {
// TODO: when shortUrl is available for my claims, navigate to that URL instead
navigateToUri(navigation, item);
}
}}
onLongPress={claim => this.handleItemLongPress(item, claim)}
navigation={navigation}
/>
<FileListItem hideChannel key={item} uri={item} style={publishStyle.listItem} navigation={navigation} />
)}
data={uris}
keyExtractor={(item, index) => item}
+1 -3
View File
@@ -28,7 +28,7 @@ class RewardsPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -42,8 +42,6 @@ class RewardsPage extends React.PureComponent {
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Rewards');
fetchRewards();
this.setState({
+3 -5
View File
@@ -10,21 +10,19 @@ import {
} from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import SearchPage from './view';
const numSearchResults = 50;
const select = state => ({
currentRoute: selectCurrentRoute(state),
isSearching: selectIsSearching(state),
query: selectSearchValue(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, numSearchResults)(state))(state),
uris: makeSelectSearchUris(makeSelectQueryWithOptions(null, 25)(state))(state),
urisByQuery: selectSearchUrisByQuery(state),
});
const perform = dispatch => ({
search: query => dispatch(doSearch(query, numSearchResults)),
search: query => dispatch(doSearch(query, 25)),
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SEARCH)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
+48 -49
View File
@@ -1,6 +1,6 @@
import React from 'react';
import { Lbry, parseURI, normalizeURI, isURIValid } from 'lbry-redux';
import { ActivityIndicator, Button, FlatList, NativeModules, Text, TextInput, View } from 'react-native';
import { ActivityIndicator, Button, Text, TextInput, View, ScrollView } from 'react-native';
import { navigateToUri } from 'utils/helper';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -24,7 +24,7 @@ class SearchPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -37,16 +37,15 @@ class SearchPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible, query, search } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Search').then(result => {
const searchQuery = query || this.getSearchQuery();
if (searchQuery && searchQuery.trim().length > 0) {
this.setState({
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
});
search(searchQuery);
}
});
const searchQuery = query || this.getSearchQuery();
if (searchQuery && searchQuery.trim().length > 0) {
this.setState({
currentQuery: searchQuery,
currentUri: isURIValid(searchQuery) ? normalizeURI(searchQuery) : null,
});
search(searchQuery);
}
};
componentDidMount() {
@@ -84,55 +83,55 @@ class SearchPage extends React.PureComponent {
search(keywords);
};
listEmptyComponent = () => {
const { query } = this.props;
return (
<View style={searchStyle.noResults}>
<Text style={searchStyle.noResultsText}>
There are no results to display for <Text style={searchStyle.boldText}>{query}</Text>. Please try a different
search term.
</Text>
</View>
);
};
listHeaderComponent = () => {
const { navigation } = this.props;
const { currentUri } = this.state;
return (
<FileListItem uri={currentUri} featuredResult style={searchStyle.featuredResultItem} navigation={navigation} />
);
};
render() {
const { isSearching, navigation, query, uris, urisByQuery } = this.props;
return (
<View style={searchStyle.container}>
<UriBar value={query} navigation={navigation} onSearchSubmitted={this.handleSearchSubmitted} />
{isSearching && (
<View style={searchStyle.busyContainer}>
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={searchStyle.loading} />
</View>
)}
<FlatList
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
data={uris}
keyExtractor={(item, index) => item}
initialNumToRender={10}
maxToRenderPerBatch={20}
removeClippedSubviews
ListEmptyComponent={!isSearching ? this.listEmptyComponent() : null}
ListHeaderComponent={this.state.currentUri ? this.listHeaderComponent() : null}
renderItem={({ item }) => (
<FileListItem key={item} uri={item} style={searchStyle.resultItem} navigation={navigation} />
)}
/>
{!isSearching && (
<ScrollView
style={searchStyle.scrollContainer}
contentContainerStyle={searchStyle.scrollPadding}
keyboardShouldPersistTaps={'handled'}
>
{this.state.currentUri && (
<FileListItem
key={this.state.currentUri}
uri={this.state.currentUri}
featuredResult
style={searchStyle.featuredResultItem}
navigation={navigation}
onPress={() => navigateToUri(navigation, this.state.currentUri)}
/>
)}
{uris && uris.length
? uris.map(uri => (
<FileListItem
key={uri}
uri={uri}
style={searchStyle.resultItem}
navigation={navigation}
onPress={() => navigateToUri(navigation, uri)}
/>
))
: null}
{(!uris || uris.length === 0) && (
<View style={searchStyle.noResults}>
<Text style={searchStyle.noResultsText}>
There are no results to display for <Text style={searchStyle.boldText}>{query}</Text>. Please try a
different search term.
</Text>
</View>
)}
</ScrollView>
)}
<FloatingWalletBalance navigation={navigation} />
</View>
);
+2 -3
View File
@@ -2,7 +2,7 @@ import React from 'react';
import { SETTINGS } from 'lbry-redux';
import { Text, View, ScrollView, Switch, NativeModules } from 'react-native';
import { navigateBack } from 'utils/helper';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import PageHeader from 'component/pageHeader';
import settingsStyle from 'styles/settings';
@@ -15,7 +15,7 @@ class SettingsPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -28,7 +28,6 @@ class SettingsPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Settings');
};
componentDidMount() {
+5 -7
View File
@@ -3,7 +3,7 @@ import { Lbry } from 'lbry-redux';
import { ActivityIndicator, Linking, NativeModules, Platform, Text, View } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
import { decode as atob } from 'base-64';
import { navigateToUri, transformUrl } from 'utils/helper';
import { navigateToUri } from 'utils/helper';
import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
@@ -81,7 +81,7 @@ class SplashScreen extends React.PureComponent {
});
}
} else {
navigateToUri(navigation, transformUrl(launchUrl));
navigateToUri(navigation, launchUrl);
}
}
};
@@ -130,7 +130,7 @@ class SplashScreen extends React.PureComponent {
if (user && user.id && user.has_verified_email) {
// user already authenticated
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword) {
if (walletPassword && walletPassword.trim().length > 0) {
getSync(walletPassword);
}
this.navigateToMain();
@@ -166,14 +166,14 @@ class SplashScreen extends React.PureComponent {
// For now, automatically unlock the wallet if a password is set so that downloads work
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
if (password) {
if (password && password.trim().length > 0) {
this.setState({
message: 'Unlocking account',
details: 'Decrypting wallet',
});
// unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password: password || '' })
Lbry.account_unlock({ password })
.then(() => {
this.setState({
message: testingNetwork,
@@ -239,8 +239,6 @@ class SplashScreen extends React.PureComponent {
NativeModules.Firebase.track('app_launch', null);
}
NativeModules.Firebase.setCurrentScreen('Splash');
this.props.fetchRewardedContent();
Linking.getInitialURL().then(url => {
if (url) {
+2 -4
View File
@@ -14,8 +14,8 @@ import {
selectShowSuggestedSubs,
} from 'lbryinc';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doSetClientSetting, doSetTimeItem } from 'redux/actions/settings';
import { makeSelectClientSetting, selectTimeItem } from 'redux/selectors/settings';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import SubscriptionsPage from './view';
@@ -32,7 +32,6 @@ const select = state => ({
viewMode: selectViewMode(state),
firstRunCompleted: selectFirstRunCompleted(state),
showSuggestedSubs: selectShowSuggestedSubs(state),
timeItem: selectTimeItem(state),
});
const perform = dispatch => ({
@@ -42,7 +41,6 @@ const perform = dispatch => ({
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_SUBSCRIPTIONS)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
});
export default connect(
+28 -43
View File
@@ -11,7 +11,7 @@ import {
View,
} from 'react-native';
import { buildURI, parseURI } from 'lbry-redux';
import { __, getOrderBy } from 'utils/helper';
import { __, uriFromFileInfo } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
import moment from 'moment';
import Button from 'component/button';
@@ -33,7 +33,6 @@ class SubscriptionsPage extends React.PureComponent {
state = {
showingSuggestedSubs: false,
showSortPicker: false,
showTimePicker: false,
orderBy: ['release_time'],
filteredChannels: [],
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting subscriptions by new
@@ -43,7 +42,7 @@ class SubscriptionsPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -64,8 +63,6 @@ class SubscriptionsPage extends React.PureComponent {
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Subscriptions');
doFetchMySubscriptions();
doFetchRecommendedSubscriptions();
};
@@ -77,19 +74,28 @@ class SubscriptionsPage extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { currentRoute } = nextProps;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
if (Constants.FULL_ROUTE_NAME_MY_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
}
handleSortByItemSelected = item => {
this.setState({ currentSortByItem: item, orderBy: getOrderBy(item), showSortPicker: false });
};
let orderBy = [];
switch (item.name) {
case Constants.SORT_BY_HOT:
orderBy = Constants.DEFAULT_ORDER_BY;
break;
handleTimeItemSelected = item => {
const { setTimeItem } = this.props;
setTimeItem(item);
this.setState({ showTimePicker: false });
case Constants.SORT_BY_NEW:
orderBy = ['release_time'];
break;
case Constants.SORT_BY_TOP:
orderBy = ['effective_amount'];
break;
}
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
};
handleChannelSelected = channelUri => {
@@ -112,17 +118,18 @@ class SubscriptionsPage extends React.PureComponent {
suggestedChannels,
subscribedChannels,
allSubscriptions,
doCompleteFirstRun,
doShowSuggestedSubs,
viewMode,
doSetViewMode,
loading,
loadingSuggested,
firstRunCompleted,
doCompleteFirstRun,
doShowSuggestedSubs,
showSuggestedSubs,
timeItem,
unreadSubscriptions,
navigation,
} = this.props;
const { currentSortByItem, filteredChannels, showSortPicker, showTimePicker } = this.state;
const { currentSortByItem, filteredChannels } = this.state;
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
const hasSubscriptions = numberOfSubscriptions > 0;
@@ -148,9 +155,7 @@ class SubscriptionsPage extends React.PureComponent {
<UriBar navigation={navigation} belowOverlay={this.state.showSortPicker} />
<View style={subscriptionsStyle.titleRow}>
<Text style={subscriptionsStyle.pageTitle}>Channels you follow</Text>
</View>
{!this.state.showingSuggestedSubs && hasSubscriptions && (
<View style={subscriptionsStyle.pickerRow}>
{!this.state.showingSuggestedSubs && hasSubscriptions && (
<TouchableOpacity
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
@@ -158,18 +163,8 @@ class SubscriptionsPage extends React.PureComponent {
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === currentSortByItem.name && (
<TouchableOpacity
style={subscriptionsStyle.tagSortBy}
onPress={() => this.setState({ showTimePicker: true })}
>
<Text style={subscriptionsStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
</View>
)}
)}
</View>
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
<View style={subscriptionsStyle.subContainer}>
<SubscribedChannelList
@@ -180,7 +175,6 @@ class SubscriptionsPage extends React.PureComponent {
style={subscriptionsStyle.claimList}
channelIds={channelIds}
orderBy={this.state.orderBy}
time={timeItem.name}
navigation={navigation}
orientation={Constants.ORIENTATION_VERTICAL}
/>
@@ -223,8 +217,8 @@ class SubscriptionsPage extends React.PureComponent {
</View>
)}
{!showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
{showSortPicker && (
{!this.state.showSortPicker && <FloatingWalletBalance navigation={navigation} />}
{this.state.showSortPicker && (
<ModalPicker
title={__('Sort content by')}
onOverlayPress={() => this.setState({ showSortPicker: false })}
@@ -233,15 +227,6 @@ class SubscriptionsPage extends React.PureComponent {
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
/>
)}
{showTimePicker && (
<ModalPicker
title={__('Content from')}
onOverlayPress={() => this.setState({ showTimePicker: false })}
onItemSelected={this.handleTimeItemSelected}
selectedItem={timeItem}
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
</View>
);
}
+2 -10
View File
@@ -1,24 +1,16 @@
import { connect } from 'react-redux';
import { selectFollowedTags, doToggleTagFollow } from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import Constants from 'constants';
import TagPage from './view';
const select = state => ({
currentRoute: selectCurrentRoute(state),
sortByItem: selectSortByItem(state),
timeItem: selectTimeItem(state),
followedTags: selectFollowedTags(state),
});
const perform = dispatch => ({
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TAG)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
toggleTagFollow: tag => dispatch(doToggleTagFollow(tag)),
});
export default connect(
+52 -85
View File
@@ -1,7 +1,7 @@
import React from 'react';
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
import { DEFAULT_FOLLOWED_TAGS, normalizeURI } from 'lbry-redux';
import { formatTagTitle, getOrderBy } from 'utils/helper';
import { formatTagTitle } from 'utils/helper';
import AsyncStorage from '@react-native-community/async-storage';
import moment from 'moment';
import ClaimList from 'component/claimList';
@@ -12,7 +12,6 @@ import fileListStyle from 'styles/fileList';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import FloatingWalletBalance from 'component/floatingWalletBalance';
import Link from 'component/link';
import ModalPicker from 'component/modalPicker';
import UriBar from 'component/uriBar';
@@ -22,13 +21,16 @@ class TagPage extends React.PureComponent {
showSortPicker: false,
showTimePicker: false,
orderBy: Constants.DEFAULT_ORDER_BY,
time: Constants.TIME_WEEK,
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[0],
currentTimeItem: Constants.CLAIM_SEARCH_TIME_ITEMS[1],
};
didFocusListener;
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -38,12 +40,10 @@ class TagPage extends React.PureComponent {
}
onComponentFocused = () => {
const { navigation, pushDrawerStack, setPlayerVisible, sortByItem } = this.props;
const { tag } = navigation.state.params;
this.setState({ tag, orderBy: getOrderBy(sortByItem) });
pushDrawerStack(Constants.DRAWER_ROUTE_TAG, navigation.state.params);
const { pushDrawerStack, setPlayerVisible, navigation } = this.props;
this.setState({ tag: navigation.state.params.tag });
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Tag');
};
componentDidMount() {
@@ -59,98 +59,65 @@ class TagPage extends React.PureComponent {
}
handleSortByItemSelected = item => {
const { setSortByItem } = this.props;
setSortByItem(item);
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
let orderBy = [];
switch (item.name) {
case Constants.SORT_BY_HOT:
orderBy = Constants.DEFAULT_ORDER_BY;
break;
case Constants.SORT_BY_NEW:
orderBy = ['release_time'];
break;
case Constants.SORT_BY_TOP:
orderBy = [Constants.ORDER_BY_EFFECTIVE_AMOUNT];
break;
}
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
};
handleTimeItemSelected = item => {
const { setTimeItem } = this.props;
setTimeItem(item);
this.setState({ showTimePicker: false });
};
isFollowingTag = tag => {
const { followedTags } = this.props;
return followedTags.map(tag => tag.name).includes(tag);
};
handleFollowTagToggle = () => {
const { toggleTagFollow } = this.props;
const { tag } = this.state;
const isFollowing = this.isFollowingTag(tag);
if (isFollowing) {
// unfollow
NativeModules.Firebase.track('tag_unfollow', { tag });
} else {
// follow
NativeModules.Firebase.track('tag_follow', { tag });
}
toggleTagFollow(tag);
if (window.persistor) {
window.persistor.flush();
}
};
listHeader = () => {
const { sortByItem, timeItem } = this.props;
const { tag } = this.state;
return (
<View style={discoverStyle.listHeader}>
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>{formatTagTitle(tag)}</Text>
</View>
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{Constants.SORT_BY_TOP === sortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
</View>
<Link
style={discoverStyle.customizeLink}
text={this.isFollowingTag(tag) ? 'Unfollow' : 'Follow'}
onPress={this.handleFollowTagToggle}
/>
</View>
</View>
);
this.setState({ currentTimeItem: item, time: item.name, showTimePicker: false });
};
render() {
const { navigation, sortByItem, timeItem } = this.props;
const { tag, showSortPicker, showTimePicker } = this.state;
const { navigation } = this.props;
const { tag, currentSortByItem, currentTimeItem, showSortPicker, showTimePicker } = this.state;
return (
<View style={discoverStyle.container}>
<UriBar navigation={navigation} belowOverlay={showSortPicker || showTimePicker} />
{this.state.tag && (
<ClaimList
ListHeaderComponent={this.listHeader}
style={discoverStyle.tagPageClaimList}
orderBy={this.state.orderBy}
time={timeItem.name}
tags={[tag]}
navigation={navigation}
orientation={Constants.ORIENTATION_VERTICAL}
/>
)}
<ClaimList
ListHeaderComponent={
<View style={discoverStyle.tagTitleRow}>
<Text style={discoverStyle.tagPageTitle}>{formatTagTitle(tag)}</Text>
{Constants.SORT_BY_TOP === currentSortByItem.name && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{currentTimeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
<TouchableOpacity style={discoverStyle.tagSortBy} onPress={() => this.setState({ showSortPicker: true })}>
<Text style={discoverStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
</View>
}
style={discoverStyle.tagPageClaimList}
orderBy={this.state.orderBy}
time={this.state.time}
tags={[tag]}
navigation={navigation}
orientation={Constants.ORIENTATION_VERTICAL}
/>
{!showSortPicker && !showTimePicker && <FloatingWalletBalance navigation={navigation} />}
{showSortPicker && (
<ModalPicker
title={__('Sort content by')}
onOverlayPress={() => this.setState({ showSortPicker: false })}
onItemSelected={this.handleSortByItemSelected}
selectedItem={sortByItem}
selectedItem={this.state.currentSortByItem}
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
/>
)}
@@ -159,7 +126,7 @@ class TagPage extends React.PureComponent {
title={__('Content from')}
onOverlayPress={() => this.setState({ showTimePicker: false })}
onItemSelected={this.handleTimeItemSelected}
selectedItem={timeItem}
selectedItem={this.state.currentTimeItem}
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
+8 -14
View File
@@ -1,7 +1,6 @@
import React from 'react';
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 { View, ScrollView, Text } from 'react-native';
import Constants from 'constants';
import TransactionList from 'component/transactionList';
import UriBar from 'component/uriBar';
import walletStyle from 'styles/wallet';
@@ -11,7 +10,7 @@ class TransactionHistoryPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -24,9 +23,7 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchTransactions, pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Transaction History').then(result => {
fetchTransactions();
});
fetchTransactions();
};
componentDidMount() {
@@ -45,16 +42,13 @@ class TransactionHistoryPage extends React.PureComponent {
const { fetchingTransactions, transactions, navigation } = this.props;
return (
<View style={walletStyle.container}>
<View>
<UriBar navigation={navigation} />
{fetchingTransactions && (
<View style={walletStyle.loadingContainer}>
<ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />
<Text style={walletStyle.loadingText}>Loading transactions...</Text>
</View>
)}
<ScrollView style={walletStyle.transactionHistoryScroll}>
<View style={walletStyle.historyList}>
{fetchingTransactions && !transactions.length && (
<Text style={walletStyle.infoText}>Loading transactions...</Text>
)}
{!fetchingTransactions && transactions.length === 0 && (
<Text style={walletStyle.infoText}>No transactions to list.</Text>
)}
+2 -7
View File
@@ -1,23 +1,18 @@
import { connect } from 'react-redux';
import { selectFollowedTags } from 'lbry-redux';
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import { doSetSortByItem, doSetTimeItem } from 'redux/actions/settings';
import { selectCurrentRoute } from 'redux/selectors/drawer';
import { selectSortByItem, selectTimeItem } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import TrendingPage from './view';
const select = state => ({
currentRoute: selectCurrentRoute(state),
sortByItem: selectSortByItem(state),
timeItem: selectTimeItem(state),
followedTags: selectFollowedTags(state),
});
const perform = dispatch => ({
pushDrawerStack: (routeName, params) => dispatch(doPushDrawerStack(routeName, params)),
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TRENDING)),
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
setSortByItem: item => dispatch(doSetSortByItem(item)),
setTimeItem: item => dispatch(doSetTimeItem(item)),
});
export default connect(
+34 -114
View File
@@ -1,7 +1,6 @@
import React from 'react';
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
import { normalizeURI } from 'lbry-redux';
import { getOrderBy } from 'utils/helper';
import { DEFAULT_FOLLOWED_TAGS, normalizeURI } from 'lbry-redux';
import AsyncStorage from '@react-native-community/async-storage';
import moment from 'moment';
import ClaimList from 'component/claimList';
@@ -24,10 +23,7 @@ const TRENDING_FOR_ITEMS = [
class TrendingPage extends React.PureComponent {
state = {
showModalTagSelector: false,
showSortByPicker: false,
showTimePicker: false,
showTrendingForPicker: false,
orderBy: Constants.DEFAULT_ORDER_BY,
currentTrendingForItem: TRENDING_FOR_ITEMS[0],
};
@@ -35,7 +31,7 @@ class TrendingPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -45,15 +41,9 @@ class TrendingPage extends React.PureComponent {
}
onComponentFocused = () => {
const { pushDrawerStack, setPlayerVisible, navigation, sortByItem } = this.props;
const { filterForTags } = navigation.state.params ? navigation.state.params : { filterForTags: false };
this.setState({
currentTrendingForItem: TRENDING_FOR_ITEMS[filterForTags ? 1 : 0],
orderBy: getOrderBy(sortByItem),
});
pushDrawerStack(Constants.DRAWER_ROUTE_TRENDING, navigation.state.params);
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('All content');
};
componentDidMount() {
@@ -63,7 +53,7 @@ class TrendingPage extends React.PureComponent {
componentWillReceiveProps(nextProps) {
const { currentRoute } = nextProps;
const { currentRoute: prevRoute } = this.props;
if (Constants.DRAWER_ROUTE_TRENDING === currentRoute && currentRoute !== prevRoute) {
if (Constants.FULL_ROUTE_NAME_TRENDING === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused();
}
}
@@ -72,96 +62,44 @@ class TrendingPage extends React.PureComponent {
this.setState({ currentTrendingForItem: item, showTrendingForPicker: false });
};
handleSortByItemSelected = item => {
const { setSortByItem } = this.props;
setSortByItem(item);
this.setState({ orderBy: getOrderBy(item), showSortPicker: false });
};
handleTimeItemSelected = item => {
const { setTimeItem } = this.props;
setTimeItem(item);
this.setState({ showTimePicker: false });
};
listHeader = () => {
const { sortByItem, timeItem } = this.props;
const { currentTrendingForItem } = this.state;
const sortByTop = Constants.SORT_BY_TOP === sortByItem.name;
return (
<View style={discoverStyle.listHeader}>
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>All content</Text>
</View>
<View style={discoverStyle.pickerRow}>
<View style={discoverStyle.leftPickerRow}>
<TouchableOpacity
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showSortPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{sortByItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
<Text style={discoverStyle.pickerLabel}>for</Text>
<TouchableOpacity
style={discoverStyle.allTagSortBy}
onPress={() => this.setState({ showTrendingForPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{currentTrendingForItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
{sortByTop && <Text style={discoverStyle.pickerLabel}>from</Text>}
{sortByTop && (
<TouchableOpacity style={discoverStyle.tagTime} onPress={() => this.setState({ showTimePicker: true })}>
<Text style={discoverStyle.tagSortText}>{timeItem.label}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
)}
</View>
{TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name && (
<Link
style={discoverStyle.customizeLink}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
)}
</View>
</View>
);
};
render() {
const { followedTags, navigation, sortByItem, timeItem } = this.props;
const {
currentTrendingForItem,
orderBy,
showModalTagSelector,
showSortPicker,
showTimePicker,
showTrendingForPicker,
} = this.state;
const filteredForTags = TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name;
const { followedTags, navigation } = this.props;
const { currentTrendingForItem, showModalTagSelector, showTrendingForPicker } = this.state;
return (
<View style={discoverStyle.container}>
<UriBar navigation={navigation} />
<ClaimList
ListHeaderComponent={this.listHeader}
ListHeaderComponent={
<View style={discoverStyle.titleRow}>
<Text style={discoverStyle.pageTitle}>Trending</Text>
<View style={discoverStyle.rightTitleRow}>
{TRENDING_FOR_ITEMS[1].name === currentTrendingForItem.name && (
<Link
style={discoverStyle.customizeLink}
text={'Customize'}
onPress={() => this.setState({ showModalTagSelector: true })}
/>
)}
<TouchableOpacity
style={discoverStyle.tagSortBy}
onPress={() => this.setState({ showTrendingForPicker: true })}
>
<Text style={discoverStyle.tagSortText}>{currentTrendingForItem.label.split(' ')[0]}</Text>
<Icon style={discoverStyle.tagSortIcon} name={'sort-down'} size={14} />
</TouchableOpacity>
</View>
</View>
}
style={discoverStyle.verticalClaimList}
orderBy={orderBy}
tags={filteredForTags ? followedTags.map(tag => tag.name) : null}
time={timeItem.name}
orderBy={Constants.DEFAULT_ORDER_BY}
trendingForAll={TRENDING_FOR_ITEMS[0].name === currentTrendingForItem.name}
tags={followedTags.map(tag => tag.name)}
time={null}
navigation={navigation}
orientation={Constants.ORIENTATION_VERTICAL}
/>
{!showModalTagSelector && !showTrendingForPicker && !showSortPicker && !showTimePicker && (
<FloatingWalletBalance navigation={navigation} />
)}
{!showModalTagSelector && <FloatingWalletBalance navigation={navigation} />}
{showModalTagSelector && (
<ModalTagSelector
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
@@ -170,31 +108,13 @@ class TrendingPage extends React.PureComponent {
)}
{showTrendingForPicker && (
<ModalPicker
title={'Filter for'}
title={'Trending for'}
onOverlayPress={() => this.setState({ showTrendingForPicker: false })}
onItemSelected={this.handleTrendingForItemSelected}
selectedItem={currentTrendingForItem}
items={TRENDING_FOR_ITEMS}
/>
)}
{showSortPicker && (
<ModalPicker
title={__('Sort content by')}
onOverlayPress={() => this.setState({ showSortPicker: false })}
onItemSelected={this.handleSortByItemSelected}
selectedItem={sortByItem}
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
/>
)}
{showTimePicker && (
<ModalPicker
title={__('Content from')}
onOverlayPress={() => this.setState({ showTimePicker: false })}
onItemSelected={this.handleTimeItemSelected}
selectedItem={timeItem}
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
/>
)}
</View>
);
}
+3 -3
View File
@@ -29,7 +29,7 @@ import {
} from 'lbryinc';
import { doSetClientSetting } from 'redux/actions/settings';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import Verification from './view';
const select = state => ({
@@ -54,13 +54,13 @@ const select = state => ({
const perform = dispatch => ({
addUserEmail: email => dispatch(doUserEmailNew(email)),
addUserPhone: (phone, countryCode) => dispatch(doUserPhoneNew(phone, countryCode)),
addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)),
getSync: password => dispatch(doGetSync(password)),
checkSync: () => dispatch(doCheckSync()),
verifyPhone: verificationCode => dispatch(doUserPhoneVerify(verificationCode)),
notify: data => dispatch(doToast(data)),
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
setDefaultAccount: (success, failure) => dispatch(doSetDefaultAccount(success, failure)),
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
@@ -1,11 +1,11 @@
import React from 'react';
import { Lbry } from 'lbry-redux';
import { ActivityIndicator, NativeModules, View, Text, TextInput } from 'react-native';
import { ActivityIndicator, View, Text, TextInput } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import Link from 'component/link';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
import rewardStyle from 'styles/reward';
@@ -44,12 +44,11 @@ class EmailVerifyPage extends React.PureComponent {
notify({ message: String(emailNewErrorMessage), isError: true });
this.setState({ verifyStarted: false });
} else {
NativeModules.Firebase.track('email_added', { email: this.state.email });
this.setState({ phase: Constants.PHASE_VERIFICATION });
if (setEmailVerificationPhase) {
setEmailVerificationPhase(true);
}
// notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
//notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
}
}
@@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
import Button from 'component/button';
import Link from 'component/link';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward';
@@ -62,29 +62,11 @@ class SyncVerifyPage extends React.PureComponent {
} else {
// password successfully verified
if (NativeModules.UtilityModule) {
NativeModules.UtilityModule.setSecureValue(
Constants.KEY_FIRST_RUN_PASSWORD,
this.state.password ? this.state.password : ''
);
NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password);
}
setDefaultAccount(
() => {
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
// unlock the wallet
Lbry.account_unlock({ password: this.state.password ? this.state.password : '' })
.then(() => navigation.goBack())
.catch(err =>
notify({ message: 'The wallet could not be unlocked at this time. Please restart the app.' })
);
},
err => {
notify({
message:
'The account restore operation could not be completed successfully. Please restart the app and try again.',
});
}
);
setDefaultAccount();
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
navigation.goBack();
}
}
}
+1 -5
View File
@@ -4,7 +4,7 @@ import { ActivityIndicator, Linking, NativeModules, Text, TouchableOpacity, View
import { NavigationActions, StackActions } from 'react-navigation';
import AsyncStorage from '@react-native-community/async-storage';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import EmailVerifyPage from './internal/email-verify-page';
import ManualVerifyPage from './internal/manual-verify-page';
import PhoneVerifyPage from './internal/phone-verify-page';
@@ -29,7 +29,6 @@ class VerificationScreen extends React.PureComponent {
componentDidMount() {
const { user } = this.props;
this.checkVerificationStatus(user);
NativeModules.Firebase.setCurrentScreen('Verification');
}
setEmailVerificationPhase = value => {
@@ -69,9 +68,6 @@ class VerificationScreen extends React.PureComponent {
if (this.state.isEmailVerified && this.state.isRewardApproved) {
// verification steps already completed
// simply navigate back to the rewards page
if (user.primary_email) {
NativeModules.Firebase.track('reward_eligibility_completed', { email: user.primary_email });
}
navigation.goBack();
}
}
+3 -4
View File
@@ -9,7 +9,7 @@ import WalletSyncDriver from 'component/walletSyncDriver';
import Button from 'component/button';
import Link from 'component/link';
import UriBar from 'component/uriBar';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
import walletStyle from 'styles/wallet';
class WalletPage extends React.PureComponent {
@@ -17,7 +17,7 @@ class WalletPage extends React.PureComponent {
componentWillMount() {
const { navigation } = this.props;
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
}
componentWillUnmount() {
@@ -42,12 +42,11 @@ class WalletPage extends React.PureComponent {
const { pushDrawerStack, setPlayerVisible } = this.props;
pushDrawerStack();
setPlayerVisible();
NativeModules.Firebase.setCurrentScreen('Wallet');
const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword) {
if (walletPassword && walletPassword.trim().length > 0) {
getSync(walletPassword);
}
});
+3 -3
View File
@@ -1,9 +1,9 @@
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
export const doPushDrawerStack = (routeName, params) => dispatch =>
export const doPushDrawerStack = routeName => dispatch =>
dispatch({
type: Constants.ACTION_PUSH_DRAWER_STACK,
data: { routeName, params },
data: routeName,
});
export const doPopDrawerStack = () => dispatch =>
+1
View File
@@ -88,6 +88,7 @@ export const doNativeSearch = (
dispatch(batchActions(...actions));
})
.catch(e => {
console.log(e);
dispatch({
type: ACTIONS.SEARCH_FAIL,
});
-23
View File
@@ -1,5 +1,4 @@
import { ACTIONS } from 'lbry-redux';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
export function doSetClientSetting(key, value) {
return dispatch => {
@@ -16,25 +15,3 @@ export function doSetClientSetting(key, value) {
}
};
}
export function doSetSortByItem(item) {
return dispatch => {
dispatch({
type: Constants.ACTION_SORT_BY_ITEM_CHANGED,
data: {
name: item.name,
},
});
};
}
export function doSetTimeItem(item) {
return dispatch => {
dispatch({
type: Constants.ACTION_TIME_ITEM_CHANGED,
data: {
name: item.name,
},
});
};
}
+5 -5
View File
@@ -1,8 +1,8 @@
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import Constants from 'constants';
const reducers = {};
const defaultState = {
stack: [{ route: Constants.DRAWER_ROUTE_DISCOVER, params: {} }], // Discover is always the first drawer route
stack: [Constants.DRAWER_ROUTE_DISCOVER], // Discover is always the first drawer route
playerVisible: false,
currentRoute: null,
};
@@ -13,11 +13,11 @@ reducers[Constants.ACTION_SET_PLAYER_VISIBLE] = (state, action) =>
});
reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
const { routeName, params } = action.data;
const routeName = action.data;
const newStack = state.stack.slice();
if (routeName !== newStack[newStack.length - 1].route) {
newStack.push({ route: routeName, params });
if (routeName !== newStack[newStack.length - 1]) {
newStack.push(routeName);
}
return {
-13
View File
@@ -1,11 +1,8 @@
import { ACTIONS } from 'lbry-redux';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
const reducers = {};
const defaultState = {
clientSettings: {},
sortByItemName: Constants.SORT_BY_HOT,
timeItemName: Constants.TIME_WEEK,
};
reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
@@ -19,16 +16,6 @@ reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => {
});
};
reducers[Constants.ACTION_SORT_BY_ITEM_CHANGED] = (state, action) =>
Object.assign({}, state, {
sortByItemName: action.data.name,
});
reducers[Constants.ACTION_TIME_ITEM_CHANGED] = (state, action) =>
Object.assign({}, state, {
timeItemName: action.data.name,
});
export default function reducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
-11
View File
@@ -1,6 +1,5 @@
import { SETTINGS } from 'lbry-redux';
import { createSelector } from 'reselect';
import { getSortByItemForName, getTimeItemForName } from 'utils/helper';
const selectState = state => state.settings || {};
@@ -14,16 +13,6 @@ export const selectClientSettings = createSelector(
state => state.clientSettings || {}
);
export const selectSortByItem = createSelector(
selectState,
state => getSortByItemForName(state.sortByItemName)
);
export const selectTimeItem = createSelector(
selectState,
state => getTimeItemForName(state.timeItemName)
);
export const makeSelectClientSetting = setting =>
createSelector(
selectClientSettings,
-39
View File
@@ -1,39 +0,0 @@
import { StyleSheet } from 'react-native';
const autothumbStyle = StyleSheet.create({
autothumbPurple: {
backgroundColor: '#9c27b0',
},
autothumbRed: {
backgroundColor: '#e53935',
},
autothumbPink: {
backgroundColor: '#e91e63',
},
autothumbIndigo: {
backgroundColor: '#3f51b5',
},
autothumbBlue: {
backgroundColor: '#2196f3',
},
autothumbLightBlue: {
backgroundColor: '#039be5',
},
autothumbCyan: {
backgroundColor: '#00acc1',
},
autothumbTeal: {
backgroundColor: '#009688',
},
autothumbGreen: {
backgroundColor: '#43a047',
},
autothumbYellow: {
backgroundColor: '#ffeb3b',
},
autothumbOrange: {
backgroundColor: '#ffa726',
},
});
export default autothumbStyle;
+1 -1
View File
@@ -33,7 +33,7 @@ const buttonStyle = StyleSheet.create({
fontSize: 14,
},
textWithIcon: {
marginLeft: 4,
marginLeft: 8,
},
});
-7
View File
@@ -18,8 +18,6 @@ const channelIconStyle = StyleSheet.create({
height: 80,
borderRadius: 160,
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
},
borderedThumbnailContainer: {
borderWidth: 1,
@@ -45,11 +43,6 @@ const channelIconStyle = StyleSheet.create({
marginTop: 4,
textAlign: 'center',
},
autothumbCharacter: {
fontFamily: 'Inter-UI-Regular',
fontSize: 48,
color: Colors.White,
},
});
export default channelIconStyle;
+6 -25
View File
@@ -31,11 +31,13 @@ const channelPageStyle = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'row',
},
infoText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 20,
textAlign: 'center',
marginLeft: 10,
},
pageButtons: {
width: '100%',
@@ -64,21 +66,15 @@ const channelPageStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular',
fontSize: 18,
},
subscribeButtonContainer: {
position: 'absolute',
flexDirection: 'row',
right: 8,
bottom: -90,
zIndex: 100,
},
subscribeButton: {
alignSelf: 'flex-start',
backgroundColor: Colors.White,
paddingLeft: 16,
paddingRight: 16,
},
bellButton: {
marginLeft: 8,
position: 'absolute',
right: 8,
bottom: -88,
zIndex: 100,
},
cover: {
width: '100%',
@@ -124,7 +120,6 @@ const channelPageStyle = StyleSheet.create({
marginBottom: 24,
},
aboutScrollContent: {
paddingTop: 52,
padding: 24,
},
aboutTitle: {
@@ -146,25 +141,11 @@ const channelPageStyle = StyleSheet.create({
left: 24,
bottom: -40,
zIndex: 100,
alignItems: 'center',
justifyContent: 'center',
},
avatarImage: {
width: '100%',
height: '100%',
},
listHeader: {
marginTop: 16,
marginBottom: 8,
marginLeft: 16,
marginRight: 16,
},
claimList: {
flex: 1,
},
claimListContent: {
paddingTop: 16,
},
});
export default channelPageStyle;
-6
View File
@@ -65,12 +65,6 @@ const channelSelectorStyle = StyleSheet.create({
createButton: {
backgroundColor: Colors.NextLbryGreen,
},
inlineError: {
fontFamily: 'Inter-UI-Regular',
fontSize: 12,
color: Colors.Red,
marginTop: 2,
},
});
export default channelSelectorStyle;
-7
View File
@@ -11,13 +11,6 @@ const claimListStyle = StyleSheet.create({
verticalScrollContainer: {
flex: 1,
},
noContentText: {
color: Colors.DescriptionGrey,
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
margin: 16,
textAlign: 'center',
},
verticalScrollPadding: {
paddingBottom: 16,
},
-1
View File
@@ -10,7 +10,6 @@ const Colors = {
BrighterLbryGreen: '#40b887',
NextLbryGreen: '#38d9a9',
TagGreen: '#e3f6f1',
TagGrape: '#da77f255',
LightGrey: '#cccccc',
LighterGrey: '#e5e5e5',
Orange: '#ffbb00',
+16 -93
View File
@@ -28,25 +28,16 @@ const discoverStyle = StyleSheet.create({
scrollContainer: {
flex: 1,
},
listHeader: {
marginBottom: 8,
marginLeft: 16,
marginRight: 16,
},
titleRow: {
flexDirection: 'row',
marginTop: 76,
marginBottom: 8,
alignItems: 'center',
justifyContent: 'space-between',
marginLeft: 16,
marginRight: 16,
},
pickerRow: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: 8,
},
leftPickerRow: {
rightTitleRow: {
flexDirection: 'row',
alignItems: 'center',
},
@@ -57,6 +48,7 @@ const discoverStyle = StyleSheet.create({
customizeLink: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
marginRight: 48,
},
trendingContainer: {
flex: 1,
@@ -84,25 +76,6 @@ const discoverStyle = StyleSheet.create({
marginTop: 6,
marginBottom: 6,
},
footer: {
marginTop: 12,
marginLeft: 16,
marginRight: 16,
marginBottom: 56,
},
footerTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 20,
marginBottom: 10,
},
footerTags: {
flexDirection: 'row',
flexWrap: 'wrap',
},
footerTag: {
marginRight: 24,
marginBottom: 12,
},
categoryName: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 18,
@@ -148,12 +121,6 @@ const discoverStyle = StyleSheet.create({
marginTop: 4,
color: Colors.LbryGreen,
},
anonChannelName: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 12,
marginTop: 4,
color: Colors.DescriptionGrey,
},
downloadedIcon: {
position: 'absolute',
right: 8,
@@ -175,6 +142,14 @@ const discoverStyle = StyleSheet.create({
textAlign: 'center',
color: '#0c604b',
},
drawerMenuButton: {
height: '100%',
justifyContent: 'center',
},
drawerHamburger: {
marginLeft: 16,
marginRight: 16,
},
rightHeaderIcon: {
marginRight: 16,
},
@@ -188,8 +163,8 @@ const discoverStyle = StyleSheet.create({
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
width: '100%',
height: '100%',
},
overlayText: {
color: Colors.White,
@@ -203,7 +178,7 @@ const discoverStyle = StyleSheet.create({
justifyContent: 'space-between',
},
rewardIcon: {
color: Colors.NextLbryGreen,
color: Colors.Red,
flex: 0.1,
textAlign: 'right',
marginTop: 6,
@@ -266,12 +241,7 @@ const discoverStyle = StyleSheet.create({
tagSortBy: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 24,
},
allTagSortBy: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 8,
marginRight: 4,
},
tagTime: {
flexDirection: 'row',
@@ -285,53 +255,6 @@ const discoverStyle = StyleSheet.create({
tagSortIcon: {
marginTop: -6,
},
pickerLabel: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
color: Colors.DescriptionGrey,
marginRight: 6,
},
menuScrollContent: {
paddingTop: 16,
},
menuGroup: {
marginTop: 8,
marginBottom: 8,
},
menuGroupName: {
fontFamily: 'Inter-UI-Regular',
fontSize: 12,
color: Colors.DescriptionGrey,
textTransform: 'uppercase',
marginBottom: 4,
marginLeft: 16,
marginRight: 16,
},
menuItemTouchArea: {
flex: 1,
flexDirection: 'row',
paddingTop: 12,
paddingBottom: 12,
paddingLeft: 16,
paddingRight: 16,
alignItems: 'center',
},
menuItemTouchAreaFocused: {
backgroundColor: Colors.VeryLightGrey,
},
menuItemFocused: {
color: Colors.LbryGreen,
},
menuItemIcon: {
alignItems: 'center',
justifyContent: 'center',
width: 24,
},
menuItem: {
marginLeft: 8,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
});
export default discoverStyle;
+33 -17
View File
@@ -15,6 +15,39 @@ const fileItemMediaStyle = StyleSheet.create({
color: Colors.White,
fontSize: 40,
},
autothumbPurple: {
backgroundColor: '#9c27b0',
},
autothumbRed: {
backgroundColor: '#e53935',
},
autothumbPink: {
backgroundColor: '#e91e63',
},
autothumbIndigo: {
backgroundColor: '#3f51b5',
},
autothumbBlue: {
backgroundColor: '#2196f3',
},
autothumbLightBlue: {
backgroundColor: '#039be5',
},
autothumbCyan: {
backgroundColor: '#00acc1',
},
autothumbTeal: {
backgroundColor: '#009688',
},
autothumbGreen: {
backgroundColor: '#43a047',
},
autothumbYellow: {
backgroundColor: '#ffeb3b',
},
autothumbOrange: {
backgroundColor: '#ffa726',
},
resolving: {
alignItems: 'center',
flex: 1,
@@ -26,29 +59,12 @@ const fileItemMediaStyle = StyleSheet.create({
fontSize: 16,
marginTop: 8,
},
image: {
width: '100%',
height: '100%',
},
thumbnail: {
flex: 1,
width: '100%',
height: 200,
shadowColor: 'transparent',
},
duration: {
backgroundColor: Colors.Black,
position: 'absolute',
right: 4,
bottom: 4,
paddingLeft: 2,
paddingRight: 2,
},
durationText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 12,
color: Colors.White,
},
});
export default fileItemMediaStyle;
-20
View File
@@ -38,16 +38,6 @@ const fileListStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
selectedOverlay: {
position: 'absolute',
left: 0,
top: 0,
width: thumbnailWidth,
height: thumbnailHeight,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#000000aa',
},
title: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: screenWidthPixels <= 720 ? 12 : 14,
@@ -105,16 +95,6 @@ const fileListStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
titleContainer: {
flexDirection: 'row',
marginRight: 16,
},
rewardIcon: {
color: Colors.NextLbryGreen,
textAlign: 'right',
marginLeft: 4,
marginTop: 4,
},
});
export default fileListStyle;
+2 -8
View File
@@ -194,10 +194,6 @@ const filePageStyle = StyleSheet.create({
},
fileActions: {
alignSelf: 'flex-end',
flexDirection: 'row',
},
editButton: {
marginRight: 8,
},
socialActions: {
alignSelf: 'flex-start',
@@ -293,7 +289,6 @@ const filePageStyle = StyleSheet.create({
},
tipAmountInput: {
alignSelf: 'flex-start',
textAlign: 'right',
width: 80,
fontSize: 16,
letterSpacing: 1,
@@ -358,9 +353,8 @@ const filePageStyle = StyleSheet.create({
fontSize: 14,
},
rewardIcon: {
color: Colors.NextLbryGreen,
marginTop: -8,
marginLeft: 8,
color: Colors.White,
marginRight: 8,
},
backButton: {
position: 'absolute',
+1 -1
View File
@@ -178,7 +178,7 @@ const firstRunStyle = StyleSheet.create({
marginBottom: 24,
},
passwordWarningText: {
color: Colors.NextLbryGreen,
color: Colors.BrightRed,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
+11 -17
View File
@@ -13,14 +13,13 @@ const floatingButtonStyle = StyleSheet.create({
container: {
zIndex: 100,
borderRadius: 24,
padding: 10,
paddingLeft: 16,
paddingRight: 16,
padding: 14,
paddingLeft: 20,
paddingRight: 20,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
backgroundColor: Colors.LbryGreen,
shadowColor: Colors.Black,
shadowColor: 'black',
shadowOpacity: 0.1,
shadowRadius: StyleSheet.hairlineWidth,
shadowOffset: {
@@ -30,10 +29,10 @@ const floatingButtonStyle = StyleSheet.create({
},
pendingContainer: {
borderRadius: 24,
padding: 10,
paddingLeft: 12,
paddingRight: 58,
marginRight: -52,
padding: 14,
paddingLeft: 20,
paddingRight: 70,
marginRight: -60,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: Colors.BrighterLbryGreen,
@@ -42,8 +41,8 @@ const floatingButtonStyle = StyleSheet.create({
},
text: {
color: Colors.White,
fontFamily: 'Inter-UI-SemiBold',
fontSize: 16,
fontFamily: 'Inter-UI-Bold',
fontSize: 18,
},
bottomRight: {
right: 10,
@@ -51,12 +50,7 @@ const floatingButtonStyle = StyleSheet.create({
},
rewardIcon: {
color: Colors.White,
marginRight: 3,
},
balanceIcon: {
color: Colors.White,
marginRight: 3,
marginTop: -1,
marginRight: 4,
},
});
+1 -6
View File
@@ -96,17 +96,12 @@ const mediaPlayerStyle = StyleSheet.create({
seekerCircle: {
borderRadius: 12,
position: 'relative',
top: 14,
left: 15,
height: 12,
width: 12,
backgroundColor: Colors.LbryGreen,
},
seekerCircleTop: {
top: 14,
},
seekerCircleTopFs: {
top: 15,
},
seekerHandle: {
backgroundColor: 'transparent',
position: 'absolute',
+5 -54
View File
@@ -16,7 +16,7 @@ const publishStyle = StyleSheet.create({
flex: 1,
},
galleryGridImage: {
width: '100%',
width: 134,
height: 90,
},
inputText: {
@@ -64,20 +64,15 @@ const publishStyle = StyleSheet.create({
overflow: 'hidden',
},
record: {
backgroundColor: 'transparent',
flex: 0.5,
justifyContent: 'center',
alignItems: 'center',
},
actionBackground: {
backgroundColor: Colors.Black,
},
transparentBackground: {
backgroundColor: 'transparent',
},
subActions: {
flex: 0.5,
borderLeftWidth: 2,
borderLeftColor: Colors.DarkGrey,
borderLeftColor: Colors.DarkerGrey,
},
actionText: {
color: Colors.White,
@@ -86,6 +81,7 @@ const publishStyle = StyleSheet.create({
marginTop: 8,
},
photo: {
backgroundColor: 'transparent',
height: 240,
justifyContent: 'center',
alignItems: 'center',
@@ -94,7 +90,7 @@ const publishStyle = StyleSheet.create({
backgroundColor: Colors.Black,
height: 120,
borderTopWidth: 2,
borderTopColor: Colors.DarkGrey,
borderTopColor: Colors.DarkerGrey,
justifyContent: 'center',
alignItems: 'center',
},
@@ -118,7 +114,6 @@ const publishStyle = StyleSheet.create({
width: 80,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
textAlign: 'right',
},
currency: {
fontFamily: 'Inter-UI-Regular',
@@ -148,13 +143,6 @@ const publishStyle = StyleSheet.create({
flex: 1,
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
},
loadingText: {
color: Colors.White,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
marginLeft: 8,
},
titleRow: {
flexDirection: 'row',
@@ -240,9 +228,6 @@ const publishStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'space-between',
},
backButtonControl: {
flex: 0.1,
},
mainControlsRow: {
flex: 0.8,
flexDirection: 'row',
@@ -251,7 +236,6 @@ const publishStyle = StyleSheet.create({
},
switchCameraToggle: {
marginRight: 48,
color: Colors.White,
},
cameraAction: {
width: 72,
@@ -282,12 +266,6 @@ const publishStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'flex-end',
},
warning: {
marginTop: 24,
marginLeft: 16,
marginRight: 16,
alignItems: 'center',
},
rewardDriverCard: {
alignItems: 'center',
backgroundColor: Colors.BrighterLbryGreen,
@@ -348,11 +326,6 @@ const publishStyle = StyleSheet.create({
fontSize: 14,
marginLeft: 8,
},
relativeCentered: {
alignItems: 'center',
justifyContent: 'center',
padding: 16,
},
centered: {
position: 'absolute',
left: 0,
@@ -362,18 +335,6 @@ const publishStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
currencyPicker: {
width: 100,
},
fullCentered: {
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
},
noPublishes: {
position: 'absolute',
left: 0,
@@ -413,16 +374,6 @@ const publishStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
cameraInfo: {
color: Colors.White,
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
},
warningText: {
fontFamily: 'Inter-UI-Regular',
fontSize: 14,
color: Colors.DescriptionGrey,
},
});
export default publishStyle;
-5
View File
@@ -12,11 +12,6 @@ const searchStyle = StyleSheet.create({
},
busyContainer: {
flex: 1,
position: 'absolute',
top: 60,
left: 0,
right: 0,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
},
+1 -9
View File
@@ -156,18 +156,10 @@ const subscriptionsStyle = StyleSheet.create({
alignItems: 'center',
justifyContent: 'space-between',
},
pickerRow: {
flexDirection: 'row',
alignItems: 'center',
marginLeft: 16,
marginRight: 16,
marginTop: 8,
marginBottom: 8,
},
tagSortBy: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 24,
marginRight: 4,
},
tagSortText: {
fontFamily: 'Inter-UI-Regular',
-8
View File
@@ -30,14 +30,6 @@ const tagStyle = StyleSheet.create({
flexDirection: 'row',
flexWrap: 'wrap',
},
nsfwTagsContainer: {
marginTop: 8,
},
nsfwTagsTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
marginBottom: 4,
},
});
export default tagStyle;
-3
View File
@@ -17,9 +17,6 @@ const transactionListStyle = StyleSheet.create({
topRow: {
marginBottom: 4,
},
leftCol: {
flex: 0.7,
},
col: {
alignSelf: 'stretch',
},
-37
View File
@@ -20,10 +20,6 @@ const uriBarStyle = StyleSheet.create({
containerElevated: {
elevation: 4,
},
drawerHamburger: {
marginLeft: 16,
marginRight: 16,
},
uriText: {
backgroundColor: Colors.VeryLightGrey,
borderRadius: 24,
@@ -77,39 +73,6 @@ const uriBarStyle = StyleSheet.create({
justifyContent: 'center',
flex: 3,
},
selectionModeBar: {
flex: 1,
height: 46,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
selectionModeLeftBar: {
flexDirection: 'row',
alignItems: 'center',
marginLeft: 16,
},
selectionModeActions: {
flexDirection: 'row',
alignItems: 'center',
marginRight: 16,
},
backTouchArea: {
height: '100%',
alignItems: 'center',
},
leftAction: {
marginRight: 16,
},
actionTouchArea: {
height: '100%',
alignItems: 'center',
},
itemCount: {
fontFamily: 'Inter-UI-Regular',
fontSize: 20,
marginLeft: 30,
},
});
export default uriBarStyle;
-17
View File
@@ -3,7 +3,6 @@ import Colors from './colors';
const walletStyle = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.PageBackground,
},
scrollContainer: {
@@ -289,22 +288,6 @@ const walletStyle = StyleSheet.create({
syncSwitch: {
marginLeft: 8,
},
loadingContainer: {
position: 'absolute',
flexDirection: 'row',
left: 0,
right: 0,
top: 60,
bottom: 0,
alignItems: 'center',
justifyContent: 'center',
},
loadingText: {
color: '#aaaaaa',
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
marginLeft: 8,
},
});
export default walletStyle;
+14 -62
View File
@@ -1,5 +1,5 @@
import { NavigationActions, StackActions } from 'react-navigation';
import { buildURI, isURIValid, normalizeURI } from 'lbry-redux';
import { buildURI, isURIValid } from 'lbry-redux';
import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
@@ -11,19 +11,19 @@ function getRouteForSpecialUri(uri) {
switch (page) {
case Constants.PAGE_REWARDS:
targetRoute = Constants.DRAWER_ROUTE_REWARDS;
targetRoute = 'Rewards';
break;
case Constants.PAGE_SETTINGS:
targetRoute = Constants.DRAWER_ROUTE_SETTINGS;
targetRoute = 'Settings';
break;
case Constants.PAGE_TRENDING:
targetRoute = Constants.DRAWER_ROUTE_TRENDING;
targetRoute = 'TrendingStack';
break;
case Constants.PAGE_WALLET:
targetRoute = Constants.FULL_ROUTE_NAME_WALLET;
targetRoute = 'WalletStack';
break;
default:
targetRoute = Constants.FULL_ROUTE_NAME_DISCOVER;
targetRoute = 'DiscoverStack';
break;
}
@@ -154,12 +154,11 @@ export function navigateBack(navigation, drawerStack, popDrawerStack) {
}
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route, params } = target;
navigation.goBack(navigation.state.key);
if (DrawerRoutes.indexOf(route) === -1 && isURIValid(route)) {
navigateToUri(navigation, route, null, true);
if (DrawerRoutes.indexOf(target) === -1 && isURIValid(target)) {
navigateToUri(navigation, target, null, true);
} else {
navigation.navigate({ routeName: route, params });
navigation.navigate({ routeName: target });
}
}
@@ -167,15 +166,13 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
dispatch(doPopDrawerStack());
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const { route } = target;
dispatch(NavigationActions.back());
if (DrawerRoutes.indexOf(route) === -1 && isURIValid(route)) {
dispatchNavigateToUri(dispatch, nav, route, true);
if (DrawerRoutes.indexOf(target) === -1 && isURIValid(target)) {
dispatchNavigateToUri(dispatch, nav, target, true);
} else {
const newTarget = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
const navigateAction = NavigationActions.navigate({
routeName: newTarget.route,
params: newTarget.params,
routeName: drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0],
});
dispatch(navigateAction);
}
@@ -184,7 +181,7 @@ export function dispatchNavigateBack(dispatch, nav, drawerStack) {
export function uriFromFileInfo(fileInfo) {
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo;
const uriParams = {};
uriParams.claimName = claimName || claimNameDownloaded;
uriParams.contentName = claimName || claimNameDownloaded;
uriParams.claimId = claimId;
return buildURI(uriParams);
}
@@ -207,51 +204,6 @@ export function formatTagName(name) {
return name.substring(0, 7) + '...';
}
export function getSortByItemForName(name) {
for (let i = 0; i < Constants.CLAIM_SEARCH_SORT_BY_ITEMS.length; i++) {
if (name === Constants.CLAIM_SEARCH_SORT_BY_ITEMS[i].name) {
return Constants.CLAIM_SEARCH_SORT_BY_ITEMS[i];
}
}
return null;
}
export function getTimeItemForName(name) {
for (let i = 0; i < Constants.CLAIM_SEARCH_TIME_ITEMS.length; i++) {
if (name === Constants.CLAIM_SEARCH_TIME_ITEMS[i].name) {
return Constants.CLAIM_SEARCH_TIME_ITEMS[i];
}
}
return null;
}
export function getOrderBy(item) {
let orderBy = [];
switch (item.name) {
case Constants.SORT_BY_HOT:
orderBy = Constants.DEFAULT_ORDER_BY;
break;
case Constants.SORT_BY_NEW:
orderBy = ['release_time'];
break;
case Constants.SORT_BY_TOP:
orderBy = [Constants.ORDER_BY_EFFECTIVE_AMOUNT];
break;
}
return orderBy;
}
// replace occurrences of ':' with '#' in a url (entered in the URI bar)
export function transformUrl(url) {
const start = 'lbry://'.length;
return normalizeURI(url.substring(start).replace(/:/g, '#'));
}
// i18n placeholder until we find a good react-native i18n module
export function __(str) {
return str;