Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d3aabb00b | ||
|
|
836ff2ae13 | ||
|
|
9d7d2c821f | ||
|
|
a594c69e60 | ||
|
|
24176b3e91 | ||
|
|
60b4210c53 | ||
|
|
4fc0056e9e | ||
|
|
2aedcb8b4d | ||
|
|
507c8f0394 | ||
|
|
b194bd9276 | ||
|
|
da9276ea75 | ||
|
|
683c13f909 | ||
|
|
7a7530a970 | ||
|
|
bc7d546dd9 | ||
|
|
dcd8c97a9c | ||
|
|
0847868882 | ||
|
|
e121cfe5c6 | ||
|
|
ed2532dae1 |
No files matched your search
Generated
+1204
-23
File diff suppressed because it is too large.
Load diff
+8
-4
@@ -4,6 +4,7 @@
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"devtools": "react-devtools",
|
||||
"format": "prettier 'src/**/*.{js,json}' --write",
|
||||
"precommit": "lint-staged"
|
||||
},
|
||||
@@ -11,7 +12,7 @@
|
||||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"gfycat-style-urls": "^1.0.3",
|
||||
"lbry-redux": "lbryio/lbry-redux",
|
||||
"lbry-redux": "lbryio/lbry-redux#67a654f60630710cae72419448a73a18d076d18a",
|
||||
"lbryinc": "lbryio/lbryinc",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
@@ -36,15 +37,16 @@
|
||||
"react-navigation-redux-helpers": "^3.0.2",
|
||||
"react-redux": "^5.0.3",
|
||||
"redux": "^4.0.4",
|
||||
"redux-persist": "^4.10.2",
|
||||
"redux-persist": "^5.10.0",
|
||||
"redux-persist-filesystem-storage": "^1.3.2",
|
||||
"redux-persist-transform-compress": "^4.2.0",
|
||||
"redux-persist-transform-filter": "0.0.18",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"rn-fetch-blob": "^0.10.15"
|
||||
"rn-fetch-blob": "0.10.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.5.4",
|
||||
"babel-eslint": "10.0.2",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.5.4",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-stage-2": "^6.18.0",
|
||||
@@ -59,8 +61,10 @@
|
||||
"eslint-plugin-react": "^7.12.4",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"flow-babel-webpack-plugin": "^1.1.1",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.0.4",
|
||||
"metro-react-native-babel-preset": "^0.55.0",
|
||||
"prettier": "^1.11.1"
|
||||
"prettier": "^1.11.1",
|
||||
"react-devtools": "^3.6.3"
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import DrawerContent from 'component/drawerContent';
|
||||
import FilePage from 'page/file';
|
||||
import FirstRunScreen from 'page/firstRun';
|
||||
import PublishPage from 'page/publish';
|
||||
import PublishesPage from 'page/publishes';
|
||||
import RewardsPage from 'page/rewards';
|
||||
import TagPage from 'page/tag';
|
||||
import TrendingPage from 'page/trending';
|
||||
import SearchPage from 'page/search';
|
||||
import SettingsPage from 'page/settings';
|
||||
@@ -40,7 +42,7 @@ import { decode as atob } from 'base-64';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
import discoverStyle from 'styles/discover';
|
||||
@@ -72,6 +74,12 @@ const discoverStack = createStackNavigator(
|
||||
header: null,
|
||||
}),
|
||||
},
|
||||
Tag: {
|
||||
screen: TagPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null,
|
||||
}),
|
||||
},
|
||||
Search: {
|
||||
screen: SearchPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
@@ -87,9 +95,9 @@ const discoverStack = createStackNavigator(
|
||||
|
||||
discoverStack.navigationOptions = ({ navigation }) => {
|
||||
let drawerLockMode = 'unlocked';
|
||||
/*if (navigation.state.index > 0) {
|
||||
/* if (navigation.state.index > 0) {
|
||||
drawerLockMode = 'locked-closed';
|
||||
}*/
|
||||
} */
|
||||
|
||||
return {
|
||||
drawerLockMode,
|
||||
@@ -139,7 +147,7 @@ const drawer = createDrawerNavigator(
|
||||
screen: SubscriptionsPage,
|
||||
navigationOptions: {
|
||||
title: 'Subscriptions',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="heart" solid={true} size={20} style={{ color: tintColor }} />,
|
||||
drawerIcon: ({ tintColor }) => <Icon name="heart" solid size={20} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
WalletStack: {
|
||||
@@ -155,6 +163,12 @@ const drawer = createDrawerNavigator(
|
||||
drawerIcon: ({ tintColor }) => <Icon name="upload" size={20} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
Publishes: {
|
||||
screen: PublishesPage,
|
||||
navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="cloud-upload-alt" size={20} style={{ color: tintColor }} />,
|
||||
},
|
||||
},
|
||||
Rewards: {
|
||||
screen: RewardsPage,
|
||||
navigationOptions: {
|
||||
@@ -279,8 +293,8 @@ class AppWithNavigationState extends React.Component {
|
||||
checkEmailVerification = () => {
|
||||
const { dispatch } = this.props;
|
||||
AsyncStorage.getItem(Constants.KEY_EMAIL_VERIFY_PENDING).then(pending => {
|
||||
this.setState({ verifyPending: 'true' === pending });
|
||||
if ('true' === pending) {
|
||||
this.setState({ verifyPending: pending === Constants.TRUE_STRING });
|
||||
if (pending === Constants.TRUE_STRING) {
|
||||
dispatch(doUserCheckEmailVerified());
|
||||
}
|
||||
});
|
||||
@@ -322,7 +336,7 @@ class AppWithNavigationState extends React.Component {
|
||||
currentDisplayType = 'toast';
|
||||
}
|
||||
|
||||
if ('toast' === currentDisplayType) {
|
||||
if (currentDisplayType === 'toast') {
|
||||
ToastAndroid.show(message, ToastAndroid.LONG);
|
||||
}
|
||||
|
||||
@@ -331,7 +345,7 @@ class AppWithNavigationState extends React.Component {
|
||||
|
||||
if (user && !emailVerifyPending && !this.state.emailVerifyDone && (emailToVerify || emailVerifyErrorMessage)) {
|
||||
AsyncStorage.getItem(Constants.KEY_SHOULD_VERIFY_EMAIL).then(shouldVerify => {
|
||||
if ('true' === shouldVerify) {
|
||||
if (shouldVerify === 'true') {
|
||||
this.setState({ emailVerifyDone: true });
|
||||
const message = emailVerifyErrorMessage
|
||||
? String(emailVerifyErrorMessage)
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import CategoryList from './view';
|
||||
|
||||
export default connect(
|
||||
null,
|
||||
null
|
||||
)(CategoryList);
|
||||
export default connect()(CategoryList);
|
||||
@@ -0,0 +1,18 @@
|
||||
import { connect } from 'react-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),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(ChannelIconItem);
|
||||
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Image, Text, TouchableOpacity, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import channelIconStyle from 'styles/channelIcon';
|
||||
|
||||
export default class ChannelIconItem extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { claim, isPlaceholder, uri, resolveUri } = this.props;
|
||||
if (!claim && !isPlaceholder) {
|
||||
resolveUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { claim, isPlaceholder, isResolvingUri, onPress, thumbnail, title } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={channelIconStyle.container} onPress={onPress}>
|
||||
{isResolvingUri && (
|
||||
<View style={channelIconStyle.centered}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
<View
|
||||
style={[
|
||||
channelIconStyle.thumbnailContainer,
|
||||
isPlaceholder ? channelIconStyle.borderedThumbnailContainer : null,
|
||||
]}
|
||||
>
|
||||
{isPlaceholder && (
|
||||
<View style={channelIconStyle.centered}>
|
||||
<Text style={channelIconStyle.placeholderText}>ALL</Text>
|
||||
</View>
|
||||
)}
|
||||
{!isPlaceholder && (
|
||||
<Image
|
||||
style={channelIconStyle.thumbnail}
|
||||
resizeMode={'cover'}
|
||||
source={thumbnail ? { uri: thumbnail } : require('../../assets/default_avatar.jpg')}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{!isPlaceholder && (
|
||||
<Text style={channelIconStyle.title} numberOfLines={1}>
|
||||
{title || (claim ? claim.name : '')}
|
||||
</Text>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
MATURE_TAGS,
|
||||
doClaimSearch,
|
||||
doClaimSearchByTags,
|
||||
makeSelectClaimSearchUrisForTags,
|
||||
makeSelectFetchingClaimSearchForTags,
|
||||
selectFetchingClaimSearch,
|
||||
selectLastClaimSearchUris,
|
||||
} from 'lbry-redux';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import ClaimList from './view';
|
||||
|
||||
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(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(
|
||||
select,
|
||||
perform
|
||||
)(ClaimList);
|
||||
@@ -0,0 +1,265 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { MATURE_TAGS, normalizeURI } from 'lbry-redux';
|
||||
import _ from 'lodash';
|
||||
import FileItem from 'component/fileItem';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import claimListStyle from 'styles/claimList';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import moment from 'moment';
|
||||
|
||||
const horizontalLimit = 7;
|
||||
const softLimit = 500;
|
||||
|
||||
class ClaimList extends React.PureComponent {
|
||||
scrollView = null;
|
||||
|
||||
state = {
|
||||
currentPage: 1, // initial page load is page 1
|
||||
subscriptionsView: false, // whether or not this claim list is for subscriptions
|
||||
trendingForAllView: false,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
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 });
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {
|
||||
claimSearch,
|
||||
orderBy: prevOrderBy,
|
||||
searchByTags,
|
||||
tags: prevTags,
|
||||
channelIds: prevChannelIds,
|
||||
trendingForAll: prevTrendingForAll,
|
||||
time: prevTime,
|
||||
} = this.props;
|
||||
const { orderBy, tags, channelIds, trendingForAll, time } = nextProps;
|
||||
if (
|
||||
!_.isEqual(orderBy, prevOrderBy) ||
|
||||
!_.isEqual(tags, prevTags) ||
|
||||
!_.isEqual(channelIds, prevChannelIds) ||
|
||||
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 (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 });
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getReleaseTimeOption = time => {
|
||||
return `>${Math.floor(
|
||||
moment()
|
||||
.subtract(1, time)
|
||||
.unix()
|
||||
)}`;
|
||||
};
|
||||
|
||||
handleVerticalEndReached = () => {
|
||||
// fetch more content
|
||||
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 }, () => {
|
||||
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 => {
|
||||
items.push(Constants.MORE_PLACEHOLDER);
|
||||
return items;
|
||||
};
|
||||
|
||||
onMorePressed = () => {
|
||||
const { navigation, tags } = this.props;
|
||||
|
||||
// tags.length > 1 means this is the Trending list
|
||||
if (tags.length === 1) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: 'tagPage', params: { tag: tags[0] } });
|
||||
} else {
|
||||
navigation.navigate({ routeName: Constants.FULL_ROUTE_NAME_TRENDING });
|
||||
}
|
||||
};
|
||||
|
||||
renderMorePlaceholder = () => {
|
||||
return (
|
||||
<TouchableOpacity style={discoverStyle.fileItemMore} onPress={this.onMorePressed}>
|
||||
<Text style={discoverStyle.moreText}>more</Text>
|
||||
<Icon style={discoverStyle.moreIcon} name={'angle-double-down'} color={Colors.White} size={16} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
ListHeaderComponent,
|
||||
loading,
|
||||
claimSearchLoading,
|
||||
claimSearchUris,
|
||||
morePlaceholder,
|
||||
navigation,
|
||||
orientation = Constants.ORIENTATION_VERTICAL,
|
||||
style,
|
||||
uris,
|
||||
} = this.props;
|
||||
const { subscriptionsView, trendingForAllView } = this.state;
|
||||
|
||||
if (Constants.ORIENTATION_VERTICAL === orientation) {
|
||||
const data = subscriptionsView || trendingForAllView ? claimSearchUris : uris;
|
||||
return (
|
||||
<View style={style}>
|
||||
<FlatList
|
||||
ref={ref => {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
ListHeaderComponent={ListHeaderComponent}
|
||||
style={claimListStyle.verticalScrollContainer}
|
||||
contentContainerStyle={claimListStyle.verticalScrollPadding}
|
||||
initialNumToRender={10}
|
||||
maxToRenderPerBatch={20}
|
||||
removeClippedSubviews
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem key={item} uri={item} style={claimListStyle.verticalListItem} navigation={navigation} />
|
||||
)}
|
||||
data={data}
|
||||
keyExtractor={(item, index) => item}
|
||||
onEndReached={this.handleVerticalEndReached}
|
||||
onEndReachedThreshold={0.2}
|
||||
/>
|
||||
{(((subscriptionsView || trendingForAllView) && claimSearchLoading) || loading) && (
|
||||
<View style={claimListStyle.verticalLoading}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (Constants.ORIENTATION_HORIZONTAL === orientation) {
|
||||
if (loading) {
|
||||
return (
|
||||
<View style={discoverStyle.listLoading}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
style={style || claimListStyle.horizontalScrollContainer}
|
||||
contentContainerStyle={claimListStyle.horizontalScrollPadding}
|
||||
initialNumToRender={3}
|
||||
maxToRenderPerBatch={3}
|
||||
removeClippedSubviews
|
||||
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)) : []}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default ClaimList;
|
||||
@@ -57,7 +57,7 @@ class CustomRewardCard extends React.PureComponent<Props> {
|
||||
return (
|
||||
<View style={[rewardStyle.rewardCard, rewardStyle.row]}>
|
||||
<View style={rewardStyle.leftCol}>
|
||||
{rewardIsPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
{rewardIsPending && <ActivityIndicator size="small" color={Colors.NextLbryGreen} />}
|
||||
</View>
|
||||
<View style={rewardStyle.midCol}>
|
||||
<Text style={rewardStyle.rewardTitle}>Custom Code</Text>
|
||||
|
||||
@@ -13,10 +13,6 @@ import NsfwOverlay from 'component/nsfwOverlay';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
class FileItem extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.resolve(this.props);
|
||||
}
|
||||
@@ -64,8 +60,7 @@ class FileItem extends React.PureComponent {
|
||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const signingChannel = claim ? claim.signing_channel : null;
|
||||
const channelName = signingChannel ? signingChannel.name : null;
|
||||
const channelClaimId =
|
||||
claim && claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
const channelClaimId = signingChannel ? signingChannel.claim_id : null;
|
||||
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
|
||||
const height = claim ? claim.height : null;
|
||||
|
||||
@@ -87,13 +82,7 @@ class FileItem extends React.PureComponent {
|
||||
/>
|
||||
|
||||
{!compactView && fileInfo && fileInfo.completed && fileInfo.download_path && (
|
||||
<Icon
|
||||
style={discoverStyle.downloadedIcon}
|
||||
solid={true}
|
||||
color={Colors.NextLbryGreen}
|
||||
name={'folder'}
|
||||
size={16}
|
||||
/>
|
||||
<Icon style={discoverStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
|
||||
)}
|
||||
{!compactView && (!fileInfo || !fileInfo.completed || !fileInfo.download_path) && (
|
||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
||||
|
||||
@@ -8,12 +8,15 @@ import {
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
} from 'lbry-redux';
|
||||
import { selectBlackListedOutpoints, selectFilteredOutpoints } from 'lbryinc';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileListItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
||||
filteredOutpoints: selectFilteredOutpoints(state),
|
||||
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
|
||||
@@ -41,10 +41,17 @@ class FileListItem extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
defaultOnPress = () => {
|
||||
const { navigation, uri } = this.props;
|
||||
navigateToUri(navigation, uri);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
blackListedOutpoints,
|
||||
claim,
|
||||
fileInfo,
|
||||
filteredOutpoints,
|
||||
metadata,
|
||||
featuredResult,
|
||||
isResolvingUri,
|
||||
@@ -53,6 +60,7 @@ class FileListItem extends React.PureComponent {
|
||||
onPress,
|
||||
navigation,
|
||||
thumbnail,
|
||||
hideChannel,
|
||||
title,
|
||||
} = this.props;
|
||||
|
||||
@@ -60,23 +68,28 @@ class FileListItem extends React.PureComponent {
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const isResolving = !fileInfo && isResolvingUri;
|
||||
|
||||
let name, channel, height, channelClaimId, fullChannelUri;
|
||||
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;
|
||||
channelClaimId = claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
channelClaimId = signingChannel ? signingChannel.claim_id : null;
|
||||
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
|
||||
|
||||
if (blackListedOutpoints || filteredOutpoints) {
|
||||
const outpointsToHide = blackListedOutpoints.concat(filteredOutpoints);
|
||||
shouldHide = outpointsToHide.some(outpoint => outpoint.txid === claim.txid && outpoint.nout === claim.nout);
|
||||
}
|
||||
}
|
||||
|
||||
if (featuredResult && !isResolvingUri && !claim && !title && !name) {
|
||||
if (shouldHide || (featuredResult && !isResolvingUri && !claim && !title && !name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<TouchableOpacity style={style} onPress={onPress}>
|
||||
<TouchableOpacity style={style} onPress={onPress || this.defaultOnPress}>
|
||||
<FileItemMedia
|
||||
style={fileListStyle.thumbnail}
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
@@ -85,13 +98,7 @@ class FileListItem extends React.PureComponent {
|
||||
thumbnail={thumbnail}
|
||||
/>
|
||||
{fileInfo && fileInfo.completed && fileInfo.download_path && (
|
||||
<Icon
|
||||
style={fileListStyle.downloadedIcon}
|
||||
solid={true}
|
||||
color={Colors.NextLbryGreen}
|
||||
name={'folder'}
|
||||
size={16}
|
||||
/>
|
||||
<Icon style={fileListStyle.downloadedIcon} solid color={Colors.NextLbryGreen} name={'folder'} size={16} />
|
||||
)}
|
||||
<View style={fileListStyle.detailsContainer}>
|
||||
{featuredResult && (
|
||||
@@ -116,7 +123,7 @@ class FileListItem extends React.PureComponent {
|
||||
{this.formatTitle(title) || this.formatTitle(name)}
|
||||
</Text>
|
||||
)}
|
||||
{channel && (
|
||||
{channel && !hideChannel && (
|
||||
<Link
|
||||
style={fileListStyle.publisher}
|
||||
text={channel}
|
||||
|
||||
@@ -428,7 +428,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
bufferForPlaybackMs: 5000,
|
||||
bufferForPlaybackAfterRebufferMs: 5000,
|
||||
}}
|
||||
ref={(ref: Video) => {
|
||||
ref={ref => {
|
||||
this.video = ref;
|
||||
}}
|
||||
resizeMode={this.state.resizeMode}
|
||||
@@ -445,7 +445,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
minLoadRetryCount={999}
|
||||
/>
|
||||
|
||||
{this.state.firstPlay && thumbnail && thumbnail.trim().length > 0 && (
|
||||
{this.state.firstPlay && thumbnail && (
|
||||
<FastImage
|
||||
source={{ uri: thumbnail }}
|
||||
resizeMode={FastImage.resizeMode.cover}
|
||||
@@ -468,7 +468,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
|
||||
{this.state.buffering && (
|
||||
<View style={mediaPlayerStyle.loadingContainer}>
|
||||
<ActivityIndicator color={Colors.LbryGreen} size="large" />
|
||||
<ActivityIndicator color={Colors.NextLbryGreen} size="large" />
|
||||
</View>
|
||||
)}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ModalPicker from './view';
|
||||
|
||||
export default connect()(ModalPicker);
|
||||
@@ -0,0 +1,60 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
import modalPickerStyle from 'styles/modalPicker';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
||||
export default class ModalPicker extends React.PureComponent {
|
||||
state = {
|
||||
selectedItem: null,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { items, selectedItem } = this.props;
|
||||
if (!selectedItem && items && items.length > 0) {
|
||||
this.setState({ selectedItem: items[0] });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({ selectedItem });
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { selectedItem: prevSelectedItem } = this.props;
|
||||
const { selectedItem } = nextProps;
|
||||
if (selectedItem && selectedItem.name !== prevSelectedItem.name) {
|
||||
this.setState({ selectedItem });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { items, onItemSelected, title, onOverlayPress } = this.props;
|
||||
const { selectedItem } = this.state;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={modalPickerStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
|
||||
<View style={modalPickerStyle.container}>
|
||||
<Text style={modalPickerStyle.title}>{title}</Text>
|
||||
<View style={modalPickerStyle.divider} />
|
||||
<View style={modalPickerStyle.list}>
|
||||
{items.length &&
|
||||
items.map(item => (
|
||||
<TouchableOpacity
|
||||
key={item.name}
|
||||
style={modalPickerStyle.listItem}
|
||||
onPress={() => onItemSelected(item)}
|
||||
>
|
||||
{item.icon && <Icon style={modalPickerStyle.itemIcon} name={item.icon} size={16} />}
|
||||
<Text style={modalPickerStyle.itemLabel}>{item.label}</Text>
|
||||
{selectedItem && selectedItem.name === item.name && (
|
||||
<Icon style={modalPickerStyle.itemSelected} name={'check'} color={Colors.LbryGreen} size={16} />
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectUnfollowedTags,
|
||||
selectFollowedTags,
|
||||
doReplaceTags,
|
||||
doToggleTagFollow,
|
||||
doAddTag,
|
||||
doDeleteTag,
|
||||
doToast,
|
||||
} from 'lbry-redux';
|
||||
import ModalTagSelector from './view';
|
||||
|
||||
const select = state => ({
|
||||
unfollowedTags: selectUnfollowedTags(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
{
|
||||
doToggleTagFollow,
|
||||
doAddTag,
|
||||
doDeleteTag,
|
||||
doReplaceTags,
|
||||
doToast,
|
||||
}
|
||||
)(ModalTagSelector);
|
||||
@@ -0,0 +1,68 @@
|
||||
import React from 'react';
|
||||
import { NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS } from 'lbry-redux';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Tag from 'component/tag';
|
||||
import TagSearch from 'component/tagSearch';
|
||||
import modalTagSelectorStyle from 'styles/modalTagSelector';
|
||||
import { __ } from 'utils/helper';
|
||||
|
||||
export default class ModalTagSelector extends React.PureComponent {
|
||||
handleAddTag = tag => {
|
||||
if (!tag) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { followedTags, doToast } = this.props;
|
||||
if (followedTags.map(followedTag => followedTag.name).includes(tag.toLowerCase())) {
|
||||
doToast({ message: __(`You already added the "${tag}" tag.`) });
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.doToggleTagFollow(tag);
|
||||
NativeModules.Firebase.track('tag_follow', { tag });
|
||||
};
|
||||
|
||||
handleRemoveTag = tag => {
|
||||
if (!tag) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.doToggleTagFollow(tag);
|
||||
NativeModules.Firebase.track('tag_unfollow', { tag });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { followedTags, onOverlayPress, onDonePress } = this.props;
|
||||
const tags = followedTags ? followedTags.map(tag => tag.name) : DEFAULT_FOLLOWED_TAGS;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={modalTagSelectorStyle.overlay} activeOpacity={1} onPress={onOverlayPress}>
|
||||
<View style={modalTagSelectorStyle.container}>
|
||||
<View style={modalTagSelectorStyle.titleRow}>
|
||||
<Text style={modalTagSelectorStyle.title}>Customize your tags</Text>
|
||||
</View>
|
||||
<View style={modalTagSelectorStyle.tagList}>
|
||||
{tags &&
|
||||
tags.map(tag => (
|
||||
<Tag
|
||||
key={tag}
|
||||
name={tag}
|
||||
type={'remove'}
|
||||
style={modalTagSelectorStyle.tag}
|
||||
onRemovePress={this.handleRemoveTag}
|
||||
/>
|
||||
))}
|
||||
</View>
|
||||
<TagSearch handleAddTag={this.handleAddTag} selectedTags={tags} />
|
||||
<View style={modalTagSelectorStyle.buttons}>
|
||||
<Button style={modalTagSelectorStyle.doneButton} text={'Done'} onPress={onDonePress} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectClaimForUri,
|
||||
doSearch,
|
||||
makeSelectRecommendedContentForUri,
|
||||
makeSelectTitleForUri,
|
||||
selectIsSearching,
|
||||
} from 'lbry-redux';
|
||||
import { doNativeSearch } from 'redux/actions/performance';
|
||||
import RelatedContent from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -16,7 +16,7 @@ const select = (state, props) => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: query => dispatch(doSearch(query, 20, undefined, true)),
|
||||
search: query => dispatch(doNativeSearch(query, 20, undefined, true)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -6,7 +6,7 @@ import FileListItem from 'component/fileListItem';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import relatedContentStyle from 'styles/relatedContent';
|
||||
|
||||
export default class RelatedContent extends React.PureComponent<Props> {
|
||||
export default class RelatedContent extends React.PureComponent {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
this.getRecommendedContent();
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
componentDidUpdate(prevProps) {
|
||||
const { claim, uri } = this.props;
|
||||
|
||||
if (uri !== prevProps.uri) {
|
||||
@@ -38,7 +38,7 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
didSearch: ?boolean;
|
||||
didSearch;
|
||||
|
||||
render() {
|
||||
const { recommendedContent, isSearching, navigation } = this.props;
|
||||
@@ -60,7 +60,9 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
onPress={() => navigateToUri(navigation, recommendedUri, { autoplay: true })}
|
||||
/>
|
||||
))}
|
||||
{isSearching && <ActivityIndicator size="small" color={Colors.LbryGreen} style={relatedContentStyle.loading} />}
|
||||
{isSearching && (
|
||||
<ActivityIndicator size="small" color={Colors.NextLbryGreen} style={relatedContentStyle.loading} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
{isPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
{isPending && <ActivityIndicator size="small" color={Colors.NextLbryGreen} />}
|
||||
</View>
|
||||
<View style={rewardStyle.midCol}>
|
||||
<Text style={rewardStyle.rewardTitle}>{reward.reward_title}</Text>
|
||||
|
||||
@@ -19,7 +19,7 @@ class SubscribeButton extends React.PureComponent {
|
||||
|
||||
const iconColor = isSubscribed ? null : Colors.Red;
|
||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||
const subscriptionLabel = isSubscribed ? null : __('Subscribe');
|
||||
const subscriptionLabel = isSubscribed ? null : __('Follow');
|
||||
const { claimName } = parseURI(uri);
|
||||
|
||||
return (
|
||||
@@ -28,7 +28,7 @@ class SubscribeButton extends React.PureComponent {
|
||||
theme={'light'}
|
||||
icon={isSubscribed ? 'heart-broken' : 'heart'}
|
||||
iconColor={iconColor}
|
||||
solid={isSubscribed ? false : true}
|
||||
solid={!isSubscribed}
|
||||
text={hideText ? null : subscriptionLabel}
|
||||
onPress={() => {
|
||||
subscriptionHandler({
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import SubscribedChannelList from './view';
|
||||
|
||||
export default connect()(SubscribedChannelList);
|
||||
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { Text, FlatList, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import ChannelIconItem from 'component/channelIconItem';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
|
||||
export default class SubscribedChannelList extends React.PureComponent {
|
||||
render() {
|
||||
const { subscribedChannels, onChannelSelected } = this.props;
|
||||
|
||||
return (
|
||||
<View style={subscriptionsStyle.channelList}>
|
||||
<FlatList
|
||||
contentContainerStyle={subscriptionsStyle.channelListScrollContainer}
|
||||
initialNumToRender={5}
|
||||
maxToRenderPerBatch={5}
|
||||
removeClippedSubviews
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
renderItem={({ item }) => (
|
||||
<ChannelIconItem
|
||||
key={item}
|
||||
isPlaceholder={item.toLowerCase() === Constants.ALL_PLACEHOLDER}
|
||||
uri={normalizeURI(item)}
|
||||
onPress={() => onChannelSelected(item)}
|
||||
/>
|
||||
)}
|
||||
data={subscribedChannels}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectClaimsInChannelForPage,
|
||||
doFetchClaimsByChannel,
|
||||
doResolveUris,
|
||||
doResolveUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectIsUriResolving,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import SuggestedSubscriptionItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claims: makeSelectClaimsInChannelForPage(props.categoryLink)(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
|
||||
resolveUris: uris => dispatch(doResolveUris(uris, true)),
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -1,76 +1,68 @@
|
||||
import React from 'react';
|
||||
import { buildURI, normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
|
||||
import { ActivityIndicator, FlatList, Image, Text, View } from 'react-native';
|
||||
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 Tag from 'component/tag';
|
||||
|
||||
class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { fetching, categoryLink, fetchChannel, resolveUris, claims } = this.props;
|
||||
if (!fetching && categoryLink && (!claims || claims.length)) {
|
||||
fetchChannel(categoryLink);
|
||||
const { claim, uri, resolveUri } = this.props;
|
||||
if (!claim) {
|
||||
resolveUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
uriForClaim = claim => {
|
||||
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = claim;
|
||||
const uriParams = {};
|
||||
|
||||
// This is unfortunate
|
||||
// https://github.com/lbryio/lbry/issues/1159
|
||||
const name = claimName || claimNameDownloaded;
|
||||
uriParams.contentName = name;
|
||||
uriParams.claimId = claimId;
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
return uri;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { categoryLink, fetching, obscureNsfw, claims, navigation } = this.props;
|
||||
const { claim, isResolvingUri, navigation, thumbnail, title, uri } = this.props;
|
||||
let tags;
|
||||
if (claim && claim.value) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
|
||||
if (!claims || !claims.length) {
|
||||
if (isResolvingUri) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<View style={subscriptionsStyle.itemLoadingContainer}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (claims && claims.length > 0) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.suggestedContainer}>
|
||||
<FileItem
|
||||
style={subscriptionsStyle.compactMainFileItem}
|
||||
mediaStyle={subscriptionsStyle.fileItemMedia}
|
||||
uri={this.uriForClaim(claims[0])}
|
||||
navigation={navigation}
|
||||
return (
|
||||
<View style={subscriptionsStyle.suggestedItem}>
|
||||
<View style={subscriptionsStyle.suggestedItemThumbnailContainer}>
|
||||
<Image
|
||||
style={subscriptionsStyle.suggestedItemThumbnail}
|
||||
resizeMode={'cover'}
|
||||
source={thumbnail ? { uri: thumbnail } : require('../../assets/default_avatar.jpg')}
|
||||
/>
|
||||
{claims.length > 1 && (
|
||||
<FlatList
|
||||
style={subscriptionsStyle.compactItems}
|
||||
horizontal={true}
|
||||
renderItem={({ item }) => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.compactFileItem}
|
||||
mediaStyle={subscriptionsStyle.compactFileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
compactView={true}
|
||||
/>
|
||||
)}
|
||||
data={claims.slice(1, 4).map(claim => this.uriForClaim(claim))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View style={subscriptionsStyle.suggestedItemDetails}>
|
||||
{title && (
|
||||
<Text style={subscriptionsStyle.suggestedItemTitle} numberOfLines={1}>
|
||||
{title}
|
||||
</Text>
|
||||
)}
|
||||
<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} />)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
<SubscribeButton style={subscriptionsStyle.suggestedItemSubscribe} uri={normalizeURI(uri)} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doClaimSearch, selectFetchingClaimSearch, selectLastClaimSearchUris, selectFollowedTags } from 'lbry-redux';
|
||||
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'lbryinc';
|
||||
import SuggestedSubscriptions from './view';
|
||||
|
||||
const select = state => ({
|
||||
followedTags: selectFollowedTags(state),
|
||||
suggested: selectSuggestedChannels(state),
|
||||
loading: selectIsFetchingSuggested(state),
|
||||
loading: selectIsFetchingSuggested(state) || selectFetchingClaimSearch(state),
|
||||
claimSearchUris: selectLastClaimSearchUris(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
claimSearch: options => dispatch(doClaimSearch(10, options)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
null
|
||||
perform
|
||||
)(SuggestedSubscriptions);
|
||||
@@ -1,53 +1,67 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
|
||||
import { ActivityIndicator, FlatList, SectionList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import { __, navigateToUri } from 'utils/helper';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import Link from 'component/link';
|
||||
import _ from 'lodash';
|
||||
|
||||
class SuggestedSubscriptions extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { claimSearch, followedTags } = this.props;
|
||||
const options = {
|
||||
any_tags: _.shuffle(followedTags.map(tag => tag.name)).slice(0, 2),
|
||||
page: 1,
|
||||
no_totals: true,
|
||||
claim_type: 'channel',
|
||||
};
|
||||
claimSearch(options);
|
||||
}
|
||||
|
||||
buildSections = () => {
|
||||
const { suggested, claimSearchUris } = this.props;
|
||||
const suggestedUris = suggested ? suggested.map(suggested => suggested.uri) : [];
|
||||
return [
|
||||
{
|
||||
title: __('You might like'),
|
||||
data: suggestedUris,
|
||||
},
|
||||
{
|
||||
title: __('Tags you follow'),
|
||||
data: claimSearchUris ? claimSearchUris.filter(uri => !suggestedUris.includes(uri)) : [],
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
render() {
|
||||
const { suggested, loading, navigation } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<View style={subscriptionsStyle.centered}>
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return suggested ? (
|
||||
return (
|
||||
<SectionList
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.suggestedScrollPadding}
|
||||
renderItem={({ item, index, section }) => (
|
||||
<SuggestedSubscriptionItem key={item} categoryLink={normalizeURI(item)} navigation={navigation} />
|
||||
<SuggestedSubscriptionItem key={item} uri={normalizeURI(item)} navigation={navigation} />
|
||||
)}
|
||||
renderSectionHeader={({ section: { title } }) => {
|
||||
const titleParts = title.split(';');
|
||||
const channelName = titleParts[0];
|
||||
const channelUri = normalizeURI(titleParts[1]);
|
||||
return (
|
||||
<View style={subscriptionsStyle.titleRow}>
|
||||
<Link
|
||||
style={subscriptionsStyle.channelTitle}
|
||||
text={channelName}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(channelUri));
|
||||
}}
|
||||
/>
|
||||
<SubscribeButton style={subscriptionsStyle.subscribeButton} uri={channelUri} name={channelName} />
|
||||
</View>
|
||||
);
|
||||
}}
|
||||
sections={suggested.map(({ uri, label }) => ({ title: label + ';' + uri, data: [uri] }))}
|
||||
renderSectionHeader={({ section: { title } }) => (
|
||||
<Text style={subscriptionsStyle.suggestedSubTitle}>{title}</Text>
|
||||
)}
|
||||
sections={this.buildSections()}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
) : null;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity, View } from 'react-native';
|
||||
import { formatTagName } from 'utils/helper';
|
||||
import tagStyle from 'styles/tag';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
|
||||
export default class Tag extends React.PureComponent {
|
||||
onPressDefault = () => {
|
||||
const { name, navigation, type, onAddPress, onRemovePress } = this.props;
|
||||
if ('add' === type) {
|
||||
if (type === 'add') {
|
||||
if (onAddPress) {
|
||||
onAddPress(name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ('remove' === type) {
|
||||
if (type === 'remove') {
|
||||
if (onRemovePress) {
|
||||
onRemovePress(name);
|
||||
}
|
||||
@@ -22,6 +24,7 @@ export default class Tag extends React.PureComponent {
|
||||
|
||||
if (navigation) {
|
||||
// navigate to tag page
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_TAG, key: `tagPage`, params: { tag: name } });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -46,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}>{name}</Text>
|
||||
<Text style={tagStyle.text}>{formatTagName(name)}</Text>
|
||||
{type && <Icon style={tagStyle.icon} name={type === 'add' ? 'plus' : 'times'} size={8} />}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import { KeyboardAvoidingView, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import Tag from 'component/tag';
|
||||
import tagStyle from 'styles/tag';
|
||||
import Colors from 'styles/colors';
|
||||
@@ -47,9 +47,17 @@ export default class TagSearch extends React.PureComponent {
|
||||
const suggestedTagsSet = new Set(unfollowedTags.map(tag => tag.name));
|
||||
const suggestedTags = Array.from(suggestedTagsSet).filter(tagNotSelected);
|
||||
if (tag && tag.trim().length > 0) {
|
||||
results.push(tag.toLowerCase());
|
||||
const lcTag = tag.toLowerCase();
|
||||
if (!results.includes(lcTag)) {
|
||||
results.push(lcTag);
|
||||
}
|
||||
const doesTagMatch = name => name.toLowerCase().includes(tag.toLowerCase());
|
||||
results = results.concat(suggestedTags.filter(doesTagMatch).slice(0, 5));
|
||||
results = results.concat(
|
||||
suggestedTags
|
||||
.filter(doesTagMatch)
|
||||
.filter(suggested => lcTag !== suggested.toLowerCase())
|
||||
.slice(0, 5)
|
||||
);
|
||||
} else {
|
||||
results = results.concat(suggestedTags.slice(0, 5));
|
||||
}
|
||||
@@ -70,11 +78,13 @@ export default class TagSearch extends React.PureComponent {
|
||||
numberOfLines={1}
|
||||
onChangeText={this.handleTagChange}
|
||||
/>
|
||||
<View style={tagStyle.tagResultsList}>
|
||||
{this.state.tagResults.map(tag => (
|
||||
<Tag key={tag} name={tag} style={tagStyle.tag} type="add" onAddPress={name => this.onAddTagPress(name)} />
|
||||
))}
|
||||
</View>
|
||||
<KeyboardAvoidingView behavior={'position'}>
|
||||
<View style={tagStyle.tagResultsList}>
|
||||
{this.state.tagResults.map(tag => (
|
||||
<Tag key={tag} name={tag} style={tagStyle.tag} type="add" onAddPress={name => this.onAddTagPress(name)} />
|
||||
))}
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,19 +136,19 @@ class UriBar extends React.PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigation, suggestions, query, value } = this.props;
|
||||
const { navigation, suggestions, query, value, belowOverlay } = this.props;
|
||||
if (this.state.currentValue === null) {
|
||||
this.setState({ currentValue: value });
|
||||
}
|
||||
|
||||
let style = [uriBarStyle.overlay];
|
||||
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); }*/
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<View style={uriBarStyle.uriContainer}>
|
||||
<View style={[uriBarStyle.uriContainer, belowOverlay ? null : uriBarStyle.containerElevated]}>
|
||||
<NavigationButton
|
||||
name="bars"
|
||||
size={24}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
const SORT_BY_NEW = 'new';
|
||||
const SORT_BY_HOT = 'hot';
|
||||
const SORT_BY_TOP = 'top';
|
||||
|
||||
const TIME_DAY = 'day';
|
||||
const TIME_WEEK = 'week';
|
||||
const TIME_MONTH = 'month';
|
||||
const TIME_YEAR = 'year';
|
||||
const TIME_ALL = 'all';
|
||||
|
||||
const Constants = {
|
||||
FIRST_RUN_PAGE_WELCOME: 'welcome',
|
||||
FIRST_RUN_PAGE_EMAIL_COLLECT: 'email-collect',
|
||||
@@ -43,6 +53,9 @@ const Constants = {
|
||||
ACTION_REACT_NAVIGATION_NAVIGATE: 'Navigation/NAVIGATE',
|
||||
ACTION_REACT_NAVIGATION_REPLACE: 'Navigation/REPLACE',
|
||||
|
||||
ORIENTATION_HORIZONTAL: 'horizontal',
|
||||
ORIENTATION_VERTICAL: 'vertical',
|
||||
|
||||
PAGE_REWARDS: 'rewards',
|
||||
PAGE_SETTINGS: 'settings',
|
||||
PAGE_TRENDING: 'trending',
|
||||
@@ -53,12 +66,14 @@ const Constants = {
|
||||
DRAWER_ROUTE_SUBSCRIPTIONS: 'Subscriptions',
|
||||
DRAWER_ROUTE_MY_LBRY: 'Downloads',
|
||||
DRAWER_ROUTE_PUBLISH: 'Publish',
|
||||
DRAWER_ROUTE_PUBLISHES: 'Publishes',
|
||||
DRAWER_ROUTE_REWARDS: 'Rewards',
|
||||
DRAWER_ROUTE_WALLET: 'Wallet',
|
||||
DRAWER_ROUTE_SETTINGS: 'Settings',
|
||||
DRAWER_ROUTE_ABOUT: 'About',
|
||||
DRAWER_ROUTE_SEARCH: 'Search',
|
||||
DRAWER_ROUTE_TRANSACTION_HISTORY: 'TransactionHistory',
|
||||
DRAWER_ROUTE_TAG: 'Tag',
|
||||
|
||||
FULL_ROUTE_NAME_DISCOVER: 'DiscoverStack',
|
||||
FULL_ROUTE_NAME_TRENDING: 'TrendingStack',
|
||||
@@ -76,6 +91,42 @@ const Constants = {
|
||||
|
||||
PLAY_STORE_URL: 'https://play.google.com/store/apps/details?id=io.lbry.browser',
|
||||
RATING_REMINDER_INTERVAL: 604800, // 7 days (7 * 24 * 3600s)
|
||||
|
||||
SORT_BY_HOT,
|
||||
SORT_BY_NEW,
|
||||
SORT_BY_TOP,
|
||||
|
||||
TIME_DAY,
|
||||
TIME_WEEK,
|
||||
TIME_MONTH,
|
||||
TIME_YEAR,
|
||||
TIME_ALL,
|
||||
|
||||
CLAIM_SEARCH_SORT_BY_ITEMS: [
|
||||
{ icon: 'fire-alt', name: SORT_BY_HOT, label: 'Trending content' },
|
||||
{ icon: 'certificate', name: SORT_BY_NEW, label: 'New content' },
|
||||
{ icon: 'chart-line', name: SORT_BY_TOP, label: 'Top content' },
|
||||
],
|
||||
|
||||
CLAIM_SEARCH_TIME_ITEMS: [
|
||||
{ name: TIME_DAY, label: 'Past 24 hours' },
|
||||
{ name: TIME_WEEK, label: 'Past week' },
|
||||
{ name: TIME_MONTH, label: 'Past month' },
|
||||
{ name: TIME_YEAR, label: 'Past year' },
|
||||
{ name: TIME_ALL, label: 'All time' },
|
||||
],
|
||||
|
||||
DEFAULT_ORDER_BY: ['trending_global', 'trending_mixed'],
|
||||
|
||||
ORDER_BY_EFFECTIVE_AMOUNT: 'effective_amount',
|
||||
|
||||
DEFAULT_PAGE_SIZE: 10,
|
||||
|
||||
ALL_PLACEHOLDER: '_all',
|
||||
|
||||
MORE_PLACEHOLDER: '_more',
|
||||
|
||||
TRUE_STRING: 'true',
|
||||
};
|
||||
|
||||
export default Constants;
|
||||
@@ -85,8 +136,12 @@ export const DrawerRoutes = [
|
||||
Constants.DRAWER_ROUTE_TRENDING,
|
||||
Constants.DRAWER_ROUTE_SUBSCRIPTIONS,
|
||||
Constants.DRAWER_ROUTE_MY_LBRY,
|
||||
Constants.DRAWER_ROUTE_TAG,
|
||||
Constants.DRAWER_ROUTE_PUBLISH,
|
||||
Constants.DRAWER_ROUTE_REWARDS,
|
||||
Constants.DRAWER_ROUTE_WALLET,
|
||||
Constants.DRAWER_ROUTE_PUBLISH,
|
||||
Constants.DRAWER_ROUTE_PUBLISHES,
|
||||
Constants.DRAWER_ROUTE_SETTINGS,
|
||||
Constants.DRAWER_ROUTE_ABOUT,
|
||||
Constants.DRAWER_ROUTE_SEARCH,
|
||||
|
||||
+54
-27
@@ -18,20 +18,21 @@ import {
|
||||
authReducer,
|
||||
blacklistReducer,
|
||||
costInfoReducer,
|
||||
filteredReducer,
|
||||
homepageReducer,
|
||||
rewardsReducer,
|
||||
subscriptionsReducer,
|
||||
syncReducer,
|
||||
userReducer,
|
||||
} from 'lbryinc';
|
||||
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import AppWithNavigationState, {
|
||||
AppNavigator,
|
||||
navigatorReducer,
|
||||
reactNavigationMiddleware,
|
||||
} from 'component/AppNavigator';
|
||||
import { persistStore, autoRehydrate } from 'redux-persist';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import { REHYDRATE, PURGE, persistCombineReducers, persistStore } from 'redux-persist';
|
||||
import getStoredStateMigrateV4 from 'redux-persist/lib/integration/getStoredStateMigrateV4';
|
||||
import FilesystemStorage from 'redux-persist-filesystem-storage';
|
||||
import createCompressor from 'redux-persist-transform-compress';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
@@ -42,7 +43,6 @@ import thunk from 'redux-thunk';
|
||||
|
||||
const globalExceptionHandler = (error, isFatal) => {
|
||||
if (error && NativeModules.Firebase) {
|
||||
console.log(error);
|
||||
NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
|
||||
}
|
||||
};
|
||||
@@ -76,11 +76,30 @@ function enableBatching(reducer) {
|
||||
};
|
||||
}
|
||||
|
||||
/*const router = AppNavigator.router;
|
||||
const navAction = router.getActionForPathAndParams('FirstRun');
|
||||
const initialNavState = router.getStateForAction(navAction);*/
|
||||
const compressor = createCompressor();
|
||||
const authFilter = createFilter('auth', ['authToken']);
|
||||
const contentFilter = createFilter('content', ['positions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
const tagsFilter = createFilter('tags', ['followedTags']);
|
||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||
|
||||
const reducers = combineReducers({
|
||||
const v4PersistOptions = {
|
||||
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'tags', 'wallet'],
|
||||
// Order is important. Needs to be compressed last or other transforms can't
|
||||
// read the data
|
||||
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
||||
debounce: 10000,
|
||||
storage: FilesystemStorage,
|
||||
};
|
||||
|
||||
const persistOptions = Object.assign({}, v4PersistOptions, {
|
||||
key: 'primary',
|
||||
getStoredState: getStoredStateMigrateV4(v4PersistOptions),
|
||||
});
|
||||
|
||||
const reducers = persistCombineReducers(persistOptions, {
|
||||
auth: authReducer,
|
||||
blacklist: blacklistReducer,
|
||||
claims: claimsReducer,
|
||||
@@ -89,6 +108,7 @@ const reducers = combineReducers({
|
||||
drawer: drawerReducer,
|
||||
file: fileReducer,
|
||||
fileInfo: fileInfoReducer,
|
||||
filtered: filteredReducer,
|
||||
homepage: homepageReducer,
|
||||
nav: navigatorReducer,
|
||||
notifications: notificationsReducer,
|
||||
@@ -112,32 +132,39 @@ const composeEnhancers = compose;
|
||||
const store = createStore(
|
||||
enableBatching(reducers),
|
||||
{}, // initial state,
|
||||
composeEnhancers(autoRehydrate(), applyMiddleware(...middleware))
|
||||
composeEnhancers(applyMiddleware(...middleware))
|
||||
);
|
||||
window.store = store;
|
||||
|
||||
const compressor = createCompressor();
|
||||
const authFilter = createFilter('auth', ['authToken']);
|
||||
const contentFilter = createFilter('content', ['positions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||
|
||||
const persistOptions = {
|
||||
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'wallet'],
|
||||
// Order is important. Needs to be compressed last or other transforms can't
|
||||
// read the data
|
||||
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
||||
debounce: 10000,
|
||||
storage: FilesystemStorage,
|
||||
};
|
||||
|
||||
persistStore(store, persistOptions, err => {
|
||||
/* const persistor = persistStore(store, persistOptions, err => {
|
||||
if (err) {
|
||||
console.log('Unable to load saved SETTINGS');
|
||||
}
|
||||
});
|
||||
window.persistor = persistor; */
|
||||
|
||||
const persistFilter = {
|
||||
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());
|
||||
NativeModules.StatePersistor.update(state, persistFilter);
|
||||
});
|
||||
|
||||
// TODO: Find i18n module that is compatible with react-native
|
||||
global.__ = str => str;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ActivityIndicator, Dimensions, Image, ScrollView, Text, TouchableOpacit
|
||||
import { TabView, SceneMap } from 'react-native-tab-view';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import FileList from 'component/fileList';
|
||||
@@ -53,7 +53,7 @@ class ChannelPage extends React.PureComponent {
|
||||
if (fetching) {
|
||||
contentList = (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
<Text style={channelPageStyle.infoText}>Fetching content...</Text>
|
||||
</View>
|
||||
);
|
||||
@@ -123,21 +123,21 @@ class ChannelPage extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
const { cover, description, thumbnail, email, website_url, title } = claim.value;
|
||||
const { cover, description, thumbnail, email, website_url: websiteUrl, title } = claim.value;
|
||||
return (
|
||||
<View style={channelPageStyle.aboutTab}>
|
||||
{!website_url && !email && !description && (
|
||||
{!websiteUrl && !email && !description && (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>Nothing here yet. Please check back later.</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{(website_url || email || description) && (
|
||||
{(websiteUrl || email || description) && (
|
||||
<ScrollView style={channelPageStyle.aboutScroll} contentContainerStyle={channelPageStyle.aboutScrollContent}>
|
||||
{website_url && website_url.trim().length > 0 && (
|
||||
{websiteUrl && websiteUrl.trim().length > 0 && (
|
||||
<View style={channelPageStyle.aboutItem}>
|
||||
<Text style={channelPageStyle.aboutTitle}>Website</Text>
|
||||
<Link style={channelPageStyle.aboutText} text={website_url} href={website_url} />
|
||||
<Link style={channelPageStyle.aboutText} text={websiteUrl} href={websiteUrl} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doFileList, selectBalance, selectFileInfosDownloaded } from 'lbry-redux';
|
||||
import {
|
||||
doClaimSearch,
|
||||
doFileList,
|
||||
selectBalance,
|
||||
selectFileInfosDownloaded,
|
||||
selectLastClaimSearchUris,
|
||||
selectFollowedTags,
|
||||
} from 'lbry-redux';
|
||||
import {
|
||||
doFetchFeaturedUris,
|
||||
doFetchRewardedContent,
|
||||
@@ -11,9 +18,10 @@ import {
|
||||
selectSubscriptionClaims,
|
||||
selectUnreadSubscriptions,
|
||||
} from 'lbryinc';
|
||||
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import DiscoverPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
@@ -23,12 +31,15 @@ const select = state => ({
|
||||
featuredUris: selectFeaturedUris(state),
|
||||
fetchingFeaturedUris: selectFetchingFeaturedUris(state),
|
||||
fileInfos: selectFileInfosDownloaded(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
ratingReminderDisabled: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED)(state),
|
||||
ratingReminderLastShown: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN)(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
uris: selectLastClaimSearchUris(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
doClaimSearch,
|
||||
fetchFeaturedUris: () => dispatch(doFetchFeaturedUris()),
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||
|
||||
+152
-36
@@ -1,17 +1,41 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import { Alert, ActivityIndicator, Linking, NativeModules, SectionList, Text, View } from 'react-native';
|
||||
import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import {
|
||||
Alert,
|
||||
ActivityIndicator,
|
||||
Linking,
|
||||
NativeModules,
|
||||
SectionList,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS, Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { __, formatTagTitle } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import CategoryList from 'component/categoryList';
|
||||
import Constants from 'constants';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import ModalTagSelector from 'component/modalTagSelector';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import UriBar from 'component/uriBar';
|
||||
import _ from 'lodash';
|
||||
|
||||
class DiscoverPage extends React.PureComponent {
|
||||
state = {
|
||||
tagCollection: [],
|
||||
showModalTagSelector: false,
|
||||
showSortPicker: false,
|
||||
orderBy: Constants.DEFAULT_ORDER_BY,
|
||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[0],
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
// Track the total time taken if this is the first launch
|
||||
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
|
||||
@@ -19,7 +43,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
// We don't need this value anymore once we've retrieved it
|
||||
AsyncStorage.removeItem('firstLaunchTime');
|
||||
|
||||
// We know this is the first app launch because firstLaunchTime is set and it's a valid number
|
||||
// We know this is the first app launch because firstLaunchTime is set and it"s a valid number
|
||||
const start = parseInt(startTime, 10);
|
||||
const now = moment().unix();
|
||||
const delta = now - start;
|
||||
@@ -36,9 +60,9 @@ class DiscoverPage extends React.PureComponent {
|
||||
}
|
||||
});
|
||||
|
||||
const { fetchFeaturedUris, fetchRewardedContent, fetchSubscriptions, fileList } = this.props;
|
||||
const { fetchRewardedContent, fetchSubscriptions, fileList, followedTags } = this.props;
|
||||
|
||||
fetchFeaturedUris();
|
||||
this.buildTagCollection(followedTags);
|
||||
fetchRewardedContent();
|
||||
fetchSubscriptions();
|
||||
fileList();
|
||||
@@ -46,6 +70,25 @@ class DiscoverPage extends React.PureComponent {
|
||||
this.showRatingReminder();
|
||||
}
|
||||
|
||||
handleSortByItemSelected = 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 = ['effective_amount'];
|
||||
break;
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
};
|
||||
|
||||
subscriptionForUri = (uri, channelName) => {
|
||||
const { allSubscriptions } = this.props;
|
||||
const { claimId, claimName } = parseURI(uri);
|
||||
@@ -63,6 +106,14 @@ class DiscoverPage extends React.PureComponent {
|
||||
return null;
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { followedTags: prevFollowedTags } = this.props;
|
||||
const { followedTags } = nextProps;
|
||||
if (!_.isEqual(followedTags, prevFollowedTags)) {
|
||||
this.buildTagCollection(followedTags);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||
|
||||
@@ -112,7 +163,7 @@ class DiscoverPage extends React.PureComponent {
|
||||
const { ratingReminderDisabled, ratingReminderLastShown, setClientSetting } = this.props;
|
||||
|
||||
const now = moment().unix();
|
||||
if ('true' !== ratingReminderDisabled && ratingReminderLastShown) {
|
||||
if (ratingReminderDisabled !== 'true' && ratingReminderLastShown) {
|
||||
const lastShownParts = ratingReminderLastShown.split('|');
|
||||
if (lastShownParts.length === 2) {
|
||||
const lastShownTime = parseInt(lastShownParts[0], 10);
|
||||
@@ -154,43 +205,108 @@ class DiscoverPage extends React.PureComponent {
|
||||
setClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN, settingString);
|
||||
};
|
||||
|
||||
trimClaimIdFromCategory(category) {
|
||||
return category.split('#')[0];
|
||||
}
|
||||
buildSections = () => {
|
||||
return this.state.tagCollection.map(tags => ({
|
||||
title: tags.length === 1 ? tags[0] : 'All tags you follow',
|
||||
data: [tags],
|
||||
}));
|
||||
};
|
||||
|
||||
buildTagCollection = followedTags => {
|
||||
const tags = followedTags.map(tag => tag.name);
|
||||
|
||||
// each of the followed tags
|
||||
const tagCollection = _.shuffle(tags)
|
||||
.slice(0, 6)
|
||||
.map(tag => [tag]);
|
||||
// everything
|
||||
tagCollection.unshift(tags);
|
||||
|
||||
this.setState({ tagCollection });
|
||||
};
|
||||
|
||||
handleTagPress = 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.FULL_ROUTE_NAME_TRENDING });
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { featuredUris, fetchingFeaturedUris, navigation } = this.props;
|
||||
const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length,
|
||||
failedToLoad = !fetchingFeaturedUris && !hasContent;
|
||||
const { navigation } = this.props;
|
||||
const { currentSortByItem, orderBy, showModalTagSelector, showSortPicker } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
{!hasContent && fetchingFeaturedUris && (
|
||||
<View style={discoverStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<Text style={discoverStyle.title}>Fetching content...</Text>
|
||||
</View>
|
||||
<UriBar navigation={navigation} belowOverlay={showModalTagSelector} />
|
||||
<SectionList
|
||||
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={({ 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 && <FloatingWalletBalance navigation={navigation} />}
|
||||
{showModalTagSelector && (
|
||||
<ModalTagSelector
|
||||
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
|
||||
onDonePress={() => this.setState({ showModalTagSelector: false })}
|
||||
/>
|
||||
)}
|
||||
{!!hasContent && (
|
||||
<SectionList
|
||||
style={discoverStyle.scrollContainer}
|
||||
contentContainerStyle={discoverStyle.scrollPadding}
|
||||
initialNumToRender={4}
|
||||
maxToRenderPerBatch={4}
|
||||
removeClippedSubviews={true}
|
||||
renderItem={({ item, index, section }) => (
|
||||
<CategoryList key={item} category={item} categoryMap={featuredUris} navigation={navigation} />
|
||||
)}
|
||||
renderSectionHeader={({ section: { title } }) => <Text style={discoverStyle.categoryName}>{title}</Text>}
|
||||
sections={Object.keys(featuredUris).map(category => ({
|
||||
title: this.trimClaimIdFromCategory(category),
|
||||
data: [category],
|
||||
}))}
|
||||
keyExtractor={(item, index) => item}
|
||||
{showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={currentSortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ 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';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
@@ -65,7 +65,7 @@ class DownloadsPage extends React.PureComponent {
|
||||
)}
|
||||
{fetching && !hasDownloads && (
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={downloadsStyle.loading} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={downloadsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
{hasDownloads && (
|
||||
|
||||
+359
-348
@@ -25,7 +25,7 @@ import Button from 'component/button';
|
||||
import Tag from 'component/tag';
|
||||
import ChannelPage from 'page/channel';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import DateTime from 'component/dateTime';
|
||||
import FileDownloadButton from 'component/fileDownloadButton';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
@@ -379,23 +379,23 @@ class FilePage extends React.PureComponent {
|
||||
tokens.length === 0
|
||||
? ''
|
||||
: tokens.map((token, j) => {
|
||||
let hasSpace = j !== tokens.length - 1;
|
||||
let space = hasSpace ? ' ' : '';
|
||||
let hasSpace = j !== tokens.length - 1;
|
||||
let space = hasSpace ? ' ' : '';
|
||||
|
||||
if (token.match(/^(lbry|https?):\/\//g)) {
|
||||
return (
|
||||
<Link
|
||||
key={j}
|
||||
style={filePageStyle.link}
|
||||
href={token}
|
||||
text={token}
|
||||
effectOnTap={filePageStyle.linkTapped}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return token + space;
|
||||
}
|
||||
});
|
||||
if (token.match(/^(lbry|https?):\/\//g)) {
|
||||
return (
|
||||
<Link
|
||||
key={j}
|
||||
style={filePageStyle.link}
|
||||
href={token}
|
||||
text={token}
|
||||
effectOnTap={filePageStyle.linkTapped}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return token + space;
|
||||
}
|
||||
});
|
||||
|
||||
lineContent.push('\n');
|
||||
return <Text key={i}>{lineContent}</Text>;
|
||||
@@ -503,7 +503,10 @@ class FilePage extends React.PureComponent {
|
||||
};
|
||||
|
||||
renderTags = tags => {
|
||||
return tags.map((tag, i) => <Tag style={filePageStyle.tagItem} key={`${tag}-${i}`} name={tag} />);
|
||||
const { navigation } = this.props;
|
||||
return tags.map((tag, i) => (
|
||||
<Tag style={filePageStyle.tagItem} key={`${tag}-${i}`} name={tag} navigation={navigation} />
|
||||
));
|
||||
};
|
||||
|
||||
onFileDownloadButtonPlayed = () => {
|
||||
@@ -560,11 +563,11 @@ class FilePage extends React.PureComponent {
|
||||
|
||||
let innerContent = null;
|
||||
if ((isResolvingUri && !claim) || !claim) {
|
||||
innerContent = (
|
||||
return (
|
||||
<View style={filePageStyle.container}>
|
||||
{isResolvingUri && (
|
||||
<View style={filePageStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
<Text style={filePageStyle.infoText}>Loading decentralized data...</Text>
|
||||
</View>
|
||||
)}
|
||||
@@ -576,9 +579,13 @@ class FilePage extends React.PureComponent {
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
} else if (claim && claim.name.length && claim.name[0] === '@') {
|
||||
innerContent = <ChannelPage uri={uri} navigation={navigation} />;
|
||||
} else if (claim) {
|
||||
}
|
||||
|
||||
if (claim) {
|
||||
if (claim && claim.name.length && claim.name[0] === '@') {
|
||||
return <ChannelPage uri={uri} navigation={navigation} />;
|
||||
}
|
||||
|
||||
let isClaimBlackListed = false;
|
||||
|
||||
if (blackListedOutpoints) {
|
||||
@@ -592,7 +599,7 @@ class FilePage extends React.PureComponent {
|
||||
}
|
||||
|
||||
if (isClaimBlackListed) {
|
||||
innerContent = (
|
||||
return (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
<View style={filePageStyle.dmcaContainer}>
|
||||
<Text style={filePageStyle.dmcaText}>
|
||||
@@ -604,358 +611,362 @@ class FilePage extends React.PureComponent {
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
let tags = [];
|
||||
if (claim && claim.value && claim.value.tags) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
}
|
||||
|
||||
const completed = fileInfo && fileInfo.completed;
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const description = metadata.description ? metadata.description : null;
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
const { height, signing_channel: signingChannel, value } = claim;
|
||||
const channelName = signingChannel && signingChannel.name;
|
||||
const showActions =
|
||||
fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
!this.state.fullscreenMode &&
|
||||
!this.state.showImageViewer &&
|
||||
!this.state.showWebView;
|
||||
const showFileActions =
|
||||
fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullChannelUri =
|
||||
channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||
let tags = [];
|
||||
if (claim && claim.value && claim.value.tags) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
|
||||
const playerStyle = [
|
||||
filePageStyle.player,
|
||||
this.state.isLandscape
|
||||
? filePageStyle.containedPlayerLandscape
|
||||
: this.state.fullscreenMode
|
||||
const completed = fileInfo && fileInfo.completed;
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const description = metadata.description ? metadata.description : null;
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
const { height, signing_channel: signingChannel, value } = claim;
|
||||
const channelName = signingChannel && signingChannel.name;
|
||||
const showActions =
|
||||
fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
!this.state.fullscreenMode &&
|
||||
!this.state.showImageViewer &&
|
||||
!this.state.showWebView;
|
||||
const showFileActions =
|
||||
fileInfo &&
|
||||
fileInfo.download_path &&
|
||||
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullChannelUri =
|
||||
channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||
|
||||
const playerStyle = [
|
||||
filePageStyle.player,
|
||||
this.state.isLandscape
|
||||
? filePageStyle.containedPlayerLandscape
|
||||
: this.state.fullscreenMode
|
||||
? filePageStyle.fullscreenPlayer
|
||||
: filePageStyle.containedPlayer,
|
||||
];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
|
||||
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
|
||||
// at least 2MB (or the full download) before media can be loaded
|
||||
const canLoadMedia =
|
||||
this.state.streamingMode ||
|
||||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes == fileInfo.total_bytes)); // 2MB = 1024*1024*2
|
||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||
const isWebViewable = mediaType === 'text';
|
||||
const canOpen = isViewable && completed;
|
||||
const localFileUri = this.localUriForFileInfo(fileInfo);
|
||||
];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
|
||||
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
|
||||
// at least 2MB (or the full download) before media can be loaded
|
||||
const canLoadMedia =
|
||||
this.state.streamingMode ||
|
||||
(fileInfo && (fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes === fileInfo.total_bytes)); // 2MB = 1024*1024*2
|
||||
const isViewable = mediaType === 'image' || mediaType === 'text';
|
||||
const isWebViewable = mediaType === 'text';
|
||||
const canOpen = isViewable && completed;
|
||||
const localFileUri = this.localUriForFileInfo(fileInfo);
|
||||
|
||||
const openFile = () => {
|
||||
if (mediaType === 'image') {
|
||||
// use image viewer
|
||||
if (!this.state.showImageViewer) {
|
||||
this.setState({
|
||||
imageUrls: [
|
||||
{
|
||||
url: localFileUri,
|
||||
},
|
||||
],
|
||||
showImageViewer: true,
|
||||
});
|
||||
}
|
||||
const openFile = () => {
|
||||
if (mediaType === 'image') {
|
||||
// use image viewer
|
||||
if (!this.state.showImageViewer) {
|
||||
this.setState({
|
||||
imageUrls: [
|
||||
{
|
||||
url: localFileUri,
|
||||
},
|
||||
],
|
||||
showImageViewer: true,
|
||||
});
|
||||
}
|
||||
if (isWebViewable) {
|
||||
// show webview
|
||||
if (!this.state.showWebView) {
|
||||
this.setState({
|
||||
showWebView: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (isWebViewable) {
|
||||
// show webview
|
||||
if (!this.state.showWebView) {
|
||||
this.setState({
|
||||
showWebView: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (
|
||||
fileInfo &&
|
||||
!this.state.autoDownloadStarted &&
|
||||
this.state.uriVars &&
|
||||
'true' === this.state.uriVars.download
|
||||
) {
|
||||
this.setState({ autoDownloadStarted: true }, () => {
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (this.state.downloadPressed && canOpen) {
|
||||
// automatically open a web viewable or image file after the download button is pressed
|
||||
openFile();
|
||||
}
|
||||
if (fileInfo && !this.state.autoDownloadStarted && this.state.uriVars && this.state.uriVars.download === 'true') {
|
||||
this.setState({ autoDownloadStarted: true }, () => {
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
innerContent = (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{this.state.showWebView && isWebViewable && (
|
||||
<WebView source={{ uri: localFileUri }} style={filePageStyle.viewer} />
|
||||
)}
|
||||
if (this.state.downloadPressed && canOpen) {
|
||||
// automatically open a web viewable or image file after the download button is pressed
|
||||
openFile();
|
||||
}
|
||||
|
||||
{this.state.showImageViewer && (
|
||||
<ImageViewer
|
||||
style={StyleSheet.flatten(filePageStyle.viewer)}
|
||||
imageUrls={this.state.imageUrls}
|
||||
renderIndicator={() => null}
|
||||
/>
|
||||
)}
|
||||
return (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{this.state.showWebView && isWebViewable && (
|
||||
<WebView source={{ uri: localFileUri }} style={filePageStyle.viewer} />
|
||||
)}
|
||||
|
||||
{!this.state.showWebView && (
|
||||
<View
|
||||
style={
|
||||
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
|
||||
}
|
||||
onLayout={this.checkOrientation}
|
||||
{this.state.showImageViewer && (
|
||||
<ImageViewer
|
||||
style={StyleSheet.flatten(filePageStyle.viewer)}
|
||||
imageUrls={this.state.imageUrls}
|
||||
renderIndicator={() => null}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!this.state.showWebView && (
|
||||
<View
|
||||
style={
|
||||
this.state.fullscreenMode ? filePageStyle.innerPageContainerFsMode : filePageStyle.innerPageContainer
|
||||
}
|
||||
onLayout={this.checkOrientation}
|
||||
>
|
||||
<View style={filePageStyle.mediaContainer}>
|
||||
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
|
||||
<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} />
|
||||
)}
|
||||
{((isPlayable && !completed && !canLoadMedia) ||
|
||||
canOpen ||
|
||||
(!completed && !this.state.streamingMode)) &&
|
||||
!this.state.downloadPressed && (
|
||||
<FileDownloadButton
|
||||
uri={uri}
|
||||
style={filePageStyle.downloadButton}
|
||||
openFile={openFile}
|
||||
isPlayable={isPlayable}
|
||||
isViewable={isViewable}
|
||||
onPlay={this.onFileDownloadButtonPlayed}
|
||||
onView={() => this.setState({ downloadPressed: true })}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
|
||||
/>
|
||||
)}
|
||||
{!fileInfo && (
|
||||
<FilePrice
|
||||
uri={uri}
|
||||
style={filePageStyle.filePriceContainer}
|
||||
textStyle={filePageStyle.filePriceText}
|
||||
/>
|
||||
)}
|
||||
|
||||
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
|
||||
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<View
|
||||
style={playerBgStyle}
|
||||
ref={ref => {
|
||||
this.playerBackground = ref;
|
||||
}}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode && (
|
||||
<View style={fsPlayerBgStyle} />
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<MediaPlayer
|
||||
claim={claim}
|
||||
assignPlayer={ref => {
|
||||
this.player = ref;
|
||||
}}
|
||||
uri={uri}
|
||||
source={this.playerUriForFileInfo(fileInfo)}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onBackButtonPressed={this.onBackButtonPressed}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
onPlaybackFinished={this.onPlaybackFinished}
|
||||
thumbnail={thumbnail}
|
||||
position={position}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showActions && showFileActions && (
|
||||
<View style={filePageStyle.actions}>
|
||||
{showFileActions && (
|
||||
<View style={filePageStyle.fileActions}>
|
||||
{completed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
theme={'light'}
|
||||
icon={'trash'}
|
||||
text={'Delete'}
|
||||
onPress={this.onDeletePressed}
|
||||
/>
|
||||
)}
|
||||
{!completed &&
|
||||
fileInfo &&
|
||||
!fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
icon={'stop'}
|
||||
theme={'light'}
|
||||
text={'Stop Download'}
|
||||
onPress={this.onStopDownloadPressed}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<ScrollView
|
||||
style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
ref={ref => {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
>
|
||||
<View style={filePageStyle.mediaContainer}>
|
||||
{(canOpen || (!fileInfo || (isPlayable && !canLoadMedia)) || (!canOpen && fileInfo)) && (
|
||||
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={thumbnail} />
|
||||
)}
|
||||
{(!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded && (
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />
|
||||
)}
|
||||
{((isPlayable && !completed && !canLoadMedia) ||
|
||||
canOpen ||
|
||||
(!completed && !this.state.streamingMode)) &&
|
||||
!this.state.downloadPressed && (
|
||||
<FileDownloadButton
|
||||
uri={uri}
|
||||
style={filePageStyle.downloadButton}
|
||||
openFile={openFile}
|
||||
isPlayable={isPlayable}
|
||||
isViewable={isViewable}
|
||||
onPlay={this.onFileDownloadButtonPlayed}
|
||||
onView={() => this.setState({ downloadPressed: true })}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
|
||||
<TouchableWithoutFeedback
|
||||
style={filePageStyle.titleTouch}
|
||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
||||
>
|
||||
<View style={filePageStyle.titleRow}>
|
||||
<Text style={filePageStyle.title} selectable>
|
||||
{title}
|
||||
</Text>
|
||||
<View style={filePageStyle.descriptionToggle}>
|
||||
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
<View style={filePageStyle.channelRow}>
|
||||
<View style={filePageStyle.publishInfo}>
|
||||
{channelName && (
|
||||
<Link
|
||||
style={filePageStyle.channelName}
|
||||
selectable
|
||||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!fileInfo && (
|
||||
<FilePrice
|
||||
{!channelName && (
|
||||
<Text style={filePageStyle.anonChannelName} selectable ellipsizeMode={'tail'}>
|
||||
Anonymous
|
||||
</Text>
|
||||
)}
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
textStyle={filePageStyle.publishDateText}
|
||||
uri={uri}
|
||||
style={filePageStyle.filePriceContainer}
|
||||
textStyle={filePageStyle.filePriceText}
|
||||
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
|
||||
show={DateTime.SHOW_DATE}
|
||||
/>
|
||||
)}
|
||||
|
||||
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
|
||||
<Icon name={'arrow-left'} size={18} style={filePageStyle.backButtonIcon} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
{false && ((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
|
||||
theme={'light'}
|
||||
icon={'download'}
|
||||
onPress={this.onSaveFilePressed}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.tipButton]}
|
||||
theme={'light'}
|
||||
icon={'gift'}
|
||||
onPress={() => this.setState({ showTipView: true })}
|
||||
/>
|
||||
{channelName && (
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
hideText={false}
|
||||
/>
|
||||
)}
|
||||
{channelName && (
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<View
|
||||
style={playerBgStyle}
|
||||
ref={ref => {
|
||||
this.playerBackground = ref;
|
||||
}}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
|
||||
this.state.fullscreenMode && <View style={fsPlayerBgStyle} />}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && (
|
||||
<MediaPlayer
|
||||
claim={claim}
|
||||
assignPlayer={ref => {
|
||||
this.player = ref;
|
||||
}}
|
||||
uri={uri}
|
||||
source={this.playerUriForFileInfo(fileInfo)}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={evt => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onBackButtonPressed={this.onBackButtonPressed}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
onPlaybackFinished={this.onPlaybackFinished}
|
||||
thumbnail={thumbnail}
|
||||
position={position}
|
||||
/>
|
||||
|
||||
{this.state.showTipView && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView && (
|
||||
<View style={filePageStyle.tipCard}>
|
||||
<View style={filePageStyle.row}>
|
||||
<View style={filePageStyle.amountRow}>
|
||||
<TextInput
|
||||
ref={ref => (this.tipAmountInput = ref)}
|
||||
onChangeText={value => this.setState({ tipAmount: value })}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.tipAmount}
|
||||
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
|
||||
/>
|
||||
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
|
||||
</View>
|
||||
<Link
|
||||
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
|
||||
text={'Cancel'}
|
||||
onPress={() => this.setState({ showTipView: false })}
|
||||
/>
|
||||
<Button
|
||||
text={'Send a tip'}
|
||||
style={[filePageStyle.button, filePageStyle.sendButton]}
|
||||
disabled={!canSendTip}
|
||||
onPress={this.handleSendTip}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{showActions && showFileActions && (
|
||||
<View style={filePageStyle.actions}>
|
||||
{showFileActions && (
|
||||
<View style={filePageStyle.fileActions}>
|
||||
{completed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
theme={'light'}
|
||||
icon={'trash'}
|
||||
text={'Delete'}
|
||||
onPress={this.onDeletePressed}
|
||||
/>
|
||||
)}
|
||||
{!completed &&
|
||||
fileInfo &&
|
||||
!fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed && (
|
||||
<Button
|
||||
style={filePageStyle.actionButton}
|
||||
icon={'stop'}
|
||||
theme={'light'}
|
||||
text={'Stop Download'}
|
||||
onPress={this.onStopDownloadPressed}
|
||||
/>
|
||||
)}
|
||||
{this.state.showDescription && description && description.length > 0 && (
|
||||
<View style={filePageStyle.divider} />
|
||||
)}
|
||||
{this.state.showDescription && description && (
|
||||
<View>
|
||||
<Text style={filePageStyle.description} selectable>
|
||||
{this.linkify(description)}
|
||||
</Text>
|
||||
{tags && tags.length > 0 && (
|
||||
<View style={filePageStyle.tagContainer}>
|
||||
<Text style={filePageStyle.tagTitle}>Tags</Text>
|
||||
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<ScrollView
|
||||
style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
ref={ref => {
|
||||
this.scrollView = ref;
|
||||
}}
|
||||
>
|
||||
<TouchableWithoutFeedback
|
||||
style={filePageStyle.titleTouch}
|
||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}
|
||||
>
|
||||
<View style={filePageStyle.titleRow}>
|
||||
<Text style={filePageStyle.title} selectable={true}>
|
||||
{title}
|
||||
</Text>
|
||||
<View style={filePageStyle.descriptionToggle}>
|
||||
<Icon name={this.state.showDescription ? 'caret-up' : 'caret-down'} size={24} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
{channelName && (
|
||||
<View style={filePageStyle.channelRow}>
|
||||
<View style={filePageStyle.publishInfo}>
|
||||
<Link
|
||||
style={filePageStyle.channelName}
|
||||
selectable={true}
|
||||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={'tail'}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}}
|
||||
/>
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
textStyle={filePageStyle.publishDateText}
|
||||
uri={uri}
|
||||
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
|
||||
show={DateTime.SHOW_DATE}
|
||||
/>
|
||||
</View>
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
{false &&
|
||||
((isPlayable && !fileInfo) || (isPlayable && fileInfo && !fileInfo.download_path)) && (
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.saveFileButton]}
|
||||
theme={'light'}
|
||||
icon={'download'}
|
||||
onPress={this.onSaveFilePressed}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
style={[filePageStyle.actionButton, filePageStyle.tipButton]}
|
||||
theme={'light'}
|
||||
icon={'gift'}
|
||||
onPress={() => this.setState({ showTipView: true })}
|
||||
/>
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
hideText={false}
|
||||
/>
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={fullChannelUri}
|
||||
name={channelName}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{this.state.showTipView && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView && (
|
||||
<View style={filePageStyle.tipCard}>
|
||||
<View style={filePageStyle.row}>
|
||||
<View style={filePageStyle.amountRow}>
|
||||
<TextInput
|
||||
ref={ref => (this.tipAmountInput = ref)}
|
||||
onChangeText={value => this.setState({ tipAmount: value })}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.tipAmount}
|
||||
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
|
||||
/>
|
||||
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
|
||||
</View>
|
||||
<Link
|
||||
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
|
||||
text={'Cancel'}
|
||||
onPress={() => this.setState({ showTipView: false })}
|
||||
/>
|
||||
<Button
|
||||
text={'Send a tip'}
|
||||
style={[filePageStyle.button, filePageStyle.sendButton]}
|
||||
disabled={!canSendTip}
|
||||
onPress={this.handleSendTip}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{costInfo && parseFloat(costInfo.cost) > balance && <FileRewardsDriver navigation={navigation} />}
|
||||
|
||||
{this.state.showDescription && description && description.length > 0 && (
|
||||
<View style={filePageStyle.divider} />
|
||||
)}
|
||||
{this.state.showDescription && description && (
|
||||
<View>
|
||||
<Text style={filePageStyle.description} selectable={true}>
|
||||
{this.linkify(description)}
|
||||
</Text>
|
||||
{tags && tags.length > 0 && (
|
||||
<View style={filePageStyle.tagContainer}>
|
||||
<Text style={filePageStyle.tagTitle}>Tags</Text>
|
||||
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
|
||||
{costInfo && parseFloat(costInfo.cost) > balance && <FileRewardsDriver navigation={navigation} />}
|
||||
|
||||
<View onLayout={this.setRelatedContentPosition} />
|
||||
<RelatedContent navigation={navigation} uri={uri} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
<View onLayout={this.setRelatedContentPosition} />
|
||||
<RelatedContent navigation={navigation} uri={uri} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView && (
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return innerContent;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+39
-32
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Clipboard,
|
||||
DeviceEventEmitter,
|
||||
Image,
|
||||
NativeModules,
|
||||
Picker,
|
||||
@@ -22,7 +23,7 @@ import RNFS from 'react-native-fs';
|
||||
import Button from 'component/button';
|
||||
import ChannelSelector from 'component/channelSelector';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import FastImage from 'react-native-fast-image';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
@@ -72,6 +73,7 @@ class PublishPage extends React.PureComponent {
|
||||
|
||||
// gallery videos
|
||||
videos: null,
|
||||
galleryThumbnailsChecked: false,
|
||||
|
||||
// camera
|
||||
cameraType: RNCamera.Constants.Type.back,
|
||||
@@ -115,14 +117,31 @@ class PublishPage extends React.PureComponent {
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
DeviceEventEmitter.addListener('onGalleryThumbnailsChecked', this.handleGalleryThumbnailsChecked);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
DeviceEventEmitter.removeListener('onGalleryThumbnailsChecked', this.handleGalleryThumbnailsChecked);
|
||||
}
|
||||
|
||||
handleGalleryThumbnailsChecked = () => {
|
||||
this.setState({ galleryThumbnailsChecked: true });
|
||||
};
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
|
||||
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) {
|
||||
const { resolveUri } = this.props;
|
||||
// If they are midway through a channel creation, treat it as anonymous until it completes
|
||||
@@ -212,17 +231,6 @@ class PublishPage extends React.PureComponent {
|
||||
this.setState({ publishStarted: true }, () => publish(publishParams));
|
||||
};
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
|
||||
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
|
||||
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
|
||||
NativeModules.Gallery.getVideos().then(videos => this.setState({ videos }));
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
@@ -384,7 +392,7 @@ class PublishPage extends React.PureComponent {
|
||||
},
|
||||
(error, res) => {
|
||||
if (!error) {
|
||||
//console.log(res);
|
||||
// console.log(res);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -439,7 +447,7 @@ class PublishPage extends React.PureComponent {
|
||||
newTags.push(tag);
|
||||
this.setState({ tags: newTags });
|
||||
} else {
|
||||
notify({ message: `You already added the "${tag}" tag.` });
|
||||
notify({ message: __(`You already added the "${tag}" tag.`) });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -471,7 +479,7 @@ class PublishPage extends React.PureComponent {
|
||||
const mediaType = media.type.substring(0, 5);
|
||||
const tempId = this.getRandomFileId();
|
||||
|
||||
if ('video' === mediaType && media.id > -1) {
|
||||
if (mediaType === 'video' && media.id > -1) {
|
||||
const uri = `file://${thumbnailPath}/${media.id}.png`;
|
||||
this.setState({ currentThumbnailUri: uri, updatingThumbnailUri: false });
|
||||
|
||||
@@ -479,9 +487,9 @@ class PublishPage extends React.PureComponent {
|
||||
if (!this.state.uploadedThumbnailUri) {
|
||||
this.setState({ uploadThumbnailStarted: true }, () => uploadThumbnail(this.getFilePathFromUri(uri), RNFS));
|
||||
}
|
||||
} else if ('image' === mediaType || 'video' === mediaType) {
|
||||
} else if (mediaType === 'image' || mediaType === 'video') {
|
||||
const create =
|
||||
'image' === mediaType
|
||||
mediaType === 'image'
|
||||
? NativeModules.Gallery.createImageThumbnail
|
||||
: NativeModules.Gallery.createVideoThumbnail;
|
||||
create(tempId, media.filePath)
|
||||
@@ -513,16 +521,14 @@ class PublishPage extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const { balance, navigation, notify, publishFormValues } = this.props;
|
||||
const { thumbnailPath } = this.state;
|
||||
const { canUseCamera, currentPhase, galleryThumbnailsChecked, thumbnailPath, videos } = this.state;
|
||||
|
||||
let content;
|
||||
if (Constants.PHASE_SELECTOR === this.state.currentPhase) {
|
||||
if (Constants.PHASE_SELECTOR === currentPhase) {
|
||||
content = (
|
||||
<View style={publishStyle.gallerySelector}>
|
||||
<View style={publishStyle.actionsView}>
|
||||
{this.state.canUseCamera && (
|
||||
<RNCamera style={publishStyle.cameraPreview} type={RNCamera.Constants.Type.back} />
|
||||
)}
|
||||
{canUseCamera && <RNCamera style={publishStyle.cameraPreview} type={RNCamera.Constants.Type.back} />}
|
||||
<View style={publishStyle.actionsSubView}>
|
||||
<TouchableOpacity style={publishStyle.record} onPress={this.handleRecordVideoPressed}>
|
||||
<Icon name="video" size={48} color={Colors.White} />
|
||||
@@ -542,12 +548,19 @@ class PublishPage extends React.PureComponent {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{(!this.state.videos || !thumbnailPath) && (
|
||||
{(!videos || !thumbnailPath || !galleryThumbnailsChecked) && (
|
||||
<View style={publishStyle.loadingView}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
{this.state.videos && thumbnailPath && (
|
||||
{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 && galleryThumbnailsChecked && (
|
||||
<FlatGrid
|
||||
style={publishStyle.galleryGrid}
|
||||
itemDimension={134}
|
||||
@@ -867,13 +880,7 @@ class PublishPage extends React.PureComponent {
|
||||
<View style={publishStyle.cameraAction}>
|
||||
<Feather style={publishStyle.cameraActionIcon} name="circle" size={72} color={Colors.White} />
|
||||
{this.state.recordingVideo && (
|
||||
<Icon
|
||||
style={publishStyle.recordingIcon}
|
||||
name="circle"
|
||||
solid={true}
|
||||
size={44}
|
||||
color={Colors.Red}
|
||||
/>
|
||||
<Icon style={publishStyle.recordingIcon} name="circle" solid size={44} color={Colors.Red} />
|
||||
)}
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { connect } from 'react-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';
|
||||
|
||||
const select = state => ({
|
||||
uris: selectMyClaimUrisWithoutChannels(state),
|
||||
fetching: selectIsFetchingClaimListMine(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
checkPendingPublishes: () => dispatch(doCheckPendingPublishes()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISHES)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(PublishesPage);
|
||||
@@ -0,0 +1,80 @@
|
||||
import React from 'react';
|
||||
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
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import UriBar from 'component/uriBar';
|
||||
import publishStyle from 'styles/publish';
|
||||
import { __ } from 'utils/helper';
|
||||
|
||||
class PublishesPage extends React.PureComponent {
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { checkPendingPublishes, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
checkPendingPublishes();
|
||||
};
|
||||
|
||||
render() {
|
||||
const { fetching, navigation, uris } = this.props;
|
||||
|
||||
return (
|
||||
<View style={publishStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
{fetching && (
|
||||
<View style={publishStyle.centered}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{!fetching && (!uris || uris.length === 0) && (
|
||||
<View style={publishStyle.noPublishes}>
|
||||
<Text style={publishStyle.noPublishText}>
|
||||
{__('It looks like you have not published anything to LBRY yet.')}
|
||||
</Text>
|
||||
<Button
|
||||
style={publishStyle.publishNowButton}
|
||||
text={__('Publish something new')}
|
||||
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{uris && uris.length > 0 && (
|
||||
<FlatList
|
||||
style={publishStyle.publishesList}
|
||||
contentContainerStyle={publishStyle.publishesScrollPadding}
|
||||
initialNumToRender={8}
|
||||
maxToRenderPerBatch={24}
|
||||
removeClippedSubviews
|
||||
renderItem={({ item }) => (
|
||||
<FileListItem hideChannel key={item} uri={item} style={publishStyle.listItem} navigation={navigation} />
|
||||
)}
|
||||
data={uris}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default PublishesPage;
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { ActivityIndicator, NativeModules, ScrollView, Text, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import Link from 'component/link';
|
||||
import CustomRewardCard from 'component/customRewardCard';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
@@ -87,7 +87,7 @@ class RewardsPage extends React.PureComponent {
|
||||
// claim new_user and new_mobile rewards
|
||||
for (let i = 0; i < rewards.length; i++) {
|
||||
const { reward_type: type } = rewards[i];
|
||||
if ('new_user' === type || 'new_mobile' === type) {
|
||||
if (type === 'new_user' || type === 'new_mobile') {
|
||||
claimReward(rewards[i]);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class RewardsPage extends React.PureComponent {
|
||||
if (fetching) {
|
||||
return (
|
||||
<View style={rewardStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} />
|
||||
<Text style={rewardStyle.infoText}>Fetching rewards...</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
+11
-11
@@ -3,7 +3,7 @@ import { Lbry, parseURI, normalizeURI, isURIValid } from 'lbry-redux';
|
||||
import { ActivityIndicator, Button, Text, TextInput, View, ScrollView } from 'react-native';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
@@ -91,7 +91,7 @@ class SearchPage extends React.PureComponent {
|
||||
<UriBar value={query} navigation={navigation} onSearchSubmitted={this.handleSearchSubmitted} />
|
||||
{isSearching && (
|
||||
<View style={searchStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={searchStyle.loading} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={searchStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
@@ -105,7 +105,7 @@ class SearchPage extends React.PureComponent {
|
||||
<FileListItem
|
||||
key={this.state.currentUri}
|
||||
uri={this.state.currentUri}
|
||||
featuredResult={true}
|
||||
featuredResult
|
||||
style={searchStyle.featuredResultItem}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, this.state.currentUri)}
|
||||
@@ -113,14 +113,14 @@ class SearchPage extends React.PureComponent {
|
||||
)}
|
||||
{uris && uris.length
|
||||
? uris.map(uri => (
|
||||
<FileListItem
|
||||
key={uri}
|
||||
uri={uri}
|
||||
style={searchStyle.resultItem}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, uri)}
|
||||
/>
|
||||
))
|
||||
<FileListItem
|
||||
key={uri}
|
||||
uri={uri}
|
||||
style={searchStyle.resultItem}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, uri)}
|
||||
/>
|
||||
))
|
||||
: null}
|
||||
{(!uris || uris.length === 0) && (
|
||||
<View style={searchStyle.noResults}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { doBalanceSubscribe, doUpdateBlockHeight, doToast } from 'lbry-redux';
|
||||
import {
|
||||
doAuthenticate,
|
||||
doBlackListedOutpointsSubscribe,
|
||||
doFilteredOutpointsSubscribe,
|
||||
doCheckSubscriptionsInit,
|
||||
doFetchMySubscriptions,
|
||||
doFetchRewardedContent,
|
||||
@@ -25,6 +26,7 @@ const perform = dispatch => ({
|
||||
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
|
||||
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
|
||||
blacklistedOutpointsSubscribe: () => dispatch(doBlackListedOutpointsSubscribe()),
|
||||
filteredOutpointsSubscribe: () => dispatch(doFilteredOutpointsSubscribe()),
|
||||
checkSubscriptionsInit: () => dispatch(doCheckSubscriptionsInit()),
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: callback => dispatch(doFetchMySubscriptions(callback)),
|
||||
|
||||
+6
-11
@@ -10,7 +10,7 @@ import Button from 'component/button';
|
||||
import ProgressBar from 'component/progressBar';
|
||||
import PropTypes from 'prop-types';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import splashStyle from 'styles/splash';
|
||||
|
||||
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
|
||||
@@ -50,7 +50,7 @@ class SplashScreen extends React.PureComponent {
|
||||
}
|
||||
|
||||
navigateToMain = () => {
|
||||
const { navigation } = this.props;
|
||||
const { navigation, notify, verifyUserEmail, verifyUserEmailFailure } = this.props;
|
||||
const resetAction = StackActions.reset({
|
||||
index: 0,
|
||||
actions: [NavigationActions.navigate({ routeName: 'Main' })],
|
||||
@@ -114,9 +114,8 @@ class SplashScreen extends React.PureComponent {
|
||||
balanceSubscribe,
|
||||
blacklistedOutpointsSubscribe,
|
||||
checkSubscriptionsInit,
|
||||
filteredOutpointsSubscribe,
|
||||
getSync,
|
||||
navigation,
|
||||
notify,
|
||||
updateBlockHeight,
|
||||
user,
|
||||
} = this.props;
|
||||
@@ -125,11 +124,8 @@ class SplashScreen extends React.PureComponent {
|
||||
// Leave the splash screen
|
||||
balanceSubscribe();
|
||||
blacklistedOutpointsSubscribe();
|
||||
filteredOutpointsSubscribe();
|
||||
checkSubscriptionsInit();
|
||||
updateBlockHeight();
|
||||
setInterval(() => {
|
||||
updateBlockHeight();
|
||||
}, BLOCK_HEIGHT_INTERVAL);
|
||||
|
||||
if (user && user.id && user.has_verified_email) {
|
||||
// user already authenticated
|
||||
@@ -186,7 +182,6 @@ class SplashScreen extends React.PureComponent {
|
||||
this.finishSplashScreen();
|
||||
})
|
||||
.catch(() => this.handleAccountUnlockFailed());
|
||||
return;
|
||||
} else {
|
||||
this.setState({
|
||||
message: testingNetwork,
|
||||
@@ -222,7 +217,7 @@ class SplashScreen extends React.PureComponent {
|
||||
});
|
||||
} else if (walletStatus && walletStatus.blocks_behind > 0) {
|
||||
const behind = walletStatus.blocks_behind;
|
||||
const behindText = behind + ' block' + (behind == 1 ? '' : 's') + ' behind';
|
||||
const behindText = behind + ' block' + (behind === 1 ? '' : 's') + ' behind';
|
||||
this.setState({
|
||||
message: 'Blockchain Sync',
|
||||
details: behindText,
|
||||
@@ -254,7 +249,7 @@ class SplashScreen extends React.PureComponent {
|
||||
// Start measuring the first launch time from the splash screen
|
||||
// (time to first user interaction - after first run completed)
|
||||
AsyncStorage.getItem('hasLaunched').then(value => {
|
||||
if ('true' !== value) {
|
||||
if (value !== 'true') {
|
||||
AsyncStorage.setItem('hasLaunched', 'true');
|
||||
// only set firstLaunchTime since we've determined that this is the first app launch ever
|
||||
AsyncStorage.setItem('firstLaunchTime', String(moment().unix()));
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
doFetchRecommendedSubscriptions,
|
||||
selectSubscriptionClaims,
|
||||
selectSubscriptions,
|
||||
selectSubscriptionsBeingFetched,
|
||||
selectIsFetchingSubscriptions,
|
||||
selectIsFetchingSuggested,
|
||||
selectSuggestedChannels,
|
||||
selectUnreadSubscriptions,
|
||||
selectViewMode,
|
||||
selectFirstRunCompleted,
|
||||
@@ -16,13 +17,15 @@ import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import SubscriptionsPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
loading: selectIsFetchingSubscriptions(state) || Boolean(Object.keys(selectSubscriptionsBeingFetched(state)).length),
|
||||
loading: selectIsFetchingSubscriptions(state),
|
||||
loadingSuggested: selectIsFetchingSuggested(state),
|
||||
subscribedChannels: selectSubscriptions(state),
|
||||
suggestedChannels: selectSuggestedChannels(state),
|
||||
subscriptionsViewMode: makeSelectClientSetting(Constants.SETTING_SUBSCRIPTIONS_VIEW_MODE)(state),
|
||||
allSubscriptions: selectSubscriptionClaims(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
|
||||
+109
-98
@@ -1,24 +1,41 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import { ActivityIndicator, FlatList, NativeModules, SectionList, ScrollView, Text, View } from 'react-native';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
FlatList,
|
||||
NativeModules,
|
||||
SectionList,
|
||||
ScrollView,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { buildURI, parseURI } from 'lbry-redux';
|
||||
import { uriFromFileInfo } 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';
|
||||
import ClaimList from 'component/claimList';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import FileItem from 'component/fileItem';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import SubscribedChannelList from 'component/subscribedChannelList';
|
||||
import SuggestedSubscriptions from 'component/suggestedSubscriptions';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class SubscriptionsPage extends React.PureComponent {
|
||||
state = {
|
||||
showingSuggestedSubs: false,
|
||||
showSortPicker: false,
|
||||
orderBy: ['release_time'],
|
||||
filteredChannels: [],
|
||||
currentSortByItem: Constants.CLAIM_SEARCH_SORT_BY_ITEMS[1], // should always default to sorting subscriptions by new
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
@@ -48,7 +65,6 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
setPlayerVisible();
|
||||
doFetchMySubscriptions();
|
||||
doFetchRecommendedSubscriptions();
|
||||
doSetViewMode(subscriptionsViewMode ? subscriptionsViewMode : Constants.SUBSCRIPTIONS_VIEW_ALL);
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -63,19 +79,48 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
changeViewMode = viewMode => {
|
||||
const { setClientSetting, doSetViewMode } = this.props;
|
||||
setClientSetting(Constants.SETTING_SUBSCRIPTIONS_VIEW_MODE, viewMode);
|
||||
doSetViewMode(viewMode);
|
||||
handleSortByItemSelected = 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 = ['effective_amount'];
|
||||
break;
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
};
|
||||
|
||||
handleChannelSelected = channelUri => {
|
||||
const { subscribedChannels } = this.props;
|
||||
this.setState({
|
||||
filteredChannels:
|
||||
channelUri === Constants.ALL_PLACEHOLDER
|
||||
? []
|
||||
: subscribedChannels.filter(channel => channel.uri === channelUri),
|
||||
});
|
||||
};
|
||||
|
||||
prependSubscribedChannelsWithAll = subscribedChannels => {
|
||||
const channelUris = subscribedChannels.map(channel => channel.uri);
|
||||
return [Constants.ALL_PLACEHOLDER].concat(channelUris);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
suggestedChannels,
|
||||
subscribedChannels,
|
||||
allSubscriptions,
|
||||
loading,
|
||||
viewMode,
|
||||
doSetViewMode,
|
||||
loading,
|
||||
loadingSuggested,
|
||||
firstRunCompleted,
|
||||
doCompleteFirstRun,
|
||||
@@ -84,6 +129,7 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
unreadSubscriptions,
|
||||
navigation,
|
||||
} = this.props;
|
||||
const { currentSortByItem, filteredChannels } = this.state;
|
||||
|
||||
const numberOfSubscriptions = subscribedChannels ? subscribedChannels.length : 0;
|
||||
const hasSubscriptions = numberOfSubscriptions > 0;
|
||||
@@ -92,111 +138,65 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
this.setState({ showingSuggestedSubs: true });
|
||||
}
|
||||
|
||||
const channelIds =
|
||||
filteredChannels.length > 0
|
||||
? filteredChannels.map(channel => {
|
||||
const { claimId } = parseURI(channel.uri);
|
||||
return claimId;
|
||||
})
|
||||
: subscribedChannels &&
|
||||
subscribedChannels.map(channel => {
|
||||
const { claimId } = parseURI(channel.uri);
|
||||
return claimId;
|
||||
});
|
||||
|
||||
return (
|
||||
<View style={subscriptionsStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
|
||||
<View style={subscriptionsStyle.viewModeRow}>
|
||||
<Link
|
||||
text={'All Subscriptions'}
|
||||
style={[
|
||||
subscriptionsStyle.viewModeLink,
|
||||
viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL
|
||||
? subscriptionsStyle.activeMode
|
||||
: subscriptionsStyle.inactiveMode,
|
||||
]}
|
||||
onPress={() => this.changeViewMode(Constants.SUBSCRIPTIONS_VIEW_ALL)}
|
||||
/>
|
||||
<Link
|
||||
text={'Latest Only'}
|
||||
style={[
|
||||
subscriptionsStyle.viewModeLink,
|
||||
viewMode === Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST
|
||||
? subscriptionsStyle.activeMode
|
||||
: subscriptionsStyle.inactiveMode,
|
||||
]}
|
||||
onPress={() => this.changeViewMode(Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST)}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
<UriBar navigation={navigation} belowOverlay={this.state.showSortPicker} />
|
||||
<View style={subscriptionsStyle.titleRow}>
|
||||
<Text style={subscriptionsStyle.pageTitle}>Channels you follow</Text>
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && (
|
||||
<TouchableOpacity
|
||||
style={subscriptionsStyle.tagSortBy}
|
||||
onPress={() => this.setState({ showSortPicker: true })}
|
||||
>
|
||||
<Text style={subscriptionsStyle.tagSortText}>{currentSortByItem.label.split(' ')[0]}</Text>
|
||||
<Icon style={subscriptionsStyle.tagSortIcon} name={'sort-down'} size={14} />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
{!this.state.showingSuggestedSubs && hasSubscriptions && !loading && (
|
||||
<View style={subscriptionsStyle.subContainer}>
|
||||
{viewMode === Constants.SUBSCRIPTIONS_VIEW_ALL && (
|
||||
<FlatList
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.scrollPadding}
|
||||
renderItem={({ item }) => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.fileItem}
|
||||
mediaStyle={fileListStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={uriFromFileInfo(item)}
|
||||
navigation={navigation}
|
||||
compactView={false}
|
||||
showDetails={true}
|
||||
/>
|
||||
)}
|
||||
data={allSubscriptions.sort((a, b) => {
|
||||
return b.height - a.height;
|
||||
})}
|
||||
keyExtractor={(item, index) => uriFromFileInfo(item)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{viewMode === Constants.SUBSCRIPTIONS_VIEW_LATEST_FIRST && (
|
||||
<View style={subscriptionsStyle.subContainer}>
|
||||
{unreadSubscriptions.length ? (
|
||||
<ScrollView
|
||||
style={subscriptionsStyle.scrollContainer}
|
||||
contentContainerStyle={subscriptionsStyle.scrollPadding}
|
||||
>
|
||||
{unreadSubscriptions.map(({ channel, uris }) => {
|
||||
const { claimName } = parseURI(channel);
|
||||
return uris.map(uri => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.fileItem}
|
||||
mediaStyle={fileListStyle.fileItemMedia}
|
||||
key={uri}
|
||||
uri={uri}
|
||||
navigation={navigation}
|
||||
compactView={false}
|
||||
showDetails={true}
|
||||
/>
|
||||
));
|
||||
})}
|
||||
</ScrollView>
|
||||
) : (
|
||||
<View style={subscriptionsStyle.contentContainer}>
|
||||
<Text style={subscriptionsStyle.contentText}>
|
||||
All caught up! You might like the channels below.
|
||||
</Text>
|
||||
<SuggestedSubscriptions navigation={navigation} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
<SubscribedChannelList
|
||||
subscribedChannels={this.prependSubscribedChannelsWithAll(subscribedChannels)}
|
||||
onChannelSelected={this.handleChannelSelected}
|
||||
/>
|
||||
<ClaimList
|
||||
style={subscriptionsStyle.claimList}
|
||||
channelIds={channelIds}
|
||||
orderBy={this.state.orderBy}
|
||||
navigation={navigation}
|
||||
orientation={Constants.ORIENTATION_VERTICAL}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{hasSubscriptions && loading && (
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={subscriptionsStyle.loading} />
|
||||
<ActivityIndicator size="large" color={Colors.NextLbryGreen} style={subscriptionsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{this.state.showingSuggestedSubs && (
|
||||
<View style={subscriptionsStyle.suggestedSubsContainer}>
|
||||
{!hasSubscriptions && (
|
||||
<Text style={subscriptionsStyle.infoText}>
|
||||
You are not subscribed to any channels at the moment. Here are some channels that we think you might
|
||||
enjoy.
|
||||
</Text>
|
||||
<View style={subscriptionsStyle.infoArea}>
|
||||
<Text style={subscriptionsStyle.infoText}>You are not subscribed to any channels at the moment.</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{hasSubscriptions && (
|
||||
<View>
|
||||
<View style={subscriptionsStyle.infoArea}>
|
||||
<Text style={subscriptionsStyle.infoText}>
|
||||
You are currently subscribed to {numberOfSubscriptions} channel{numberOfSubscriptions > 1 ? 's' : ''}.
|
||||
</Text>
|
||||
@@ -209,13 +209,24 @@ class SubscriptionsPage extends React.PureComponent {
|
||||
)}
|
||||
|
||||
{loadingSuggested && (
|
||||
<ActivityIndicator size="large" colors={Colors.LbryGreen} style={subscriptionsStyle.loading} />
|
||||
<View style={subscriptionsStyle.centered}>
|
||||
<ActivityIndicator size="large" colors={Colors.NextLbryGreen} style={subscriptionsStyle.loading} />
|
||||
</View>
|
||||
)}
|
||||
{!loadingSuggested && <SuggestedSubscriptions navigation={navigation} />}
|
||||
</View>
|
||||
)}
|
||||
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
{!this.state.showSortPicker && <FloatingWalletBalance navigation={navigation} />}
|
||||
{this.state.showSortPicker && (
|
||||
<ModalPicker
|
||||
title={__('Sort content by')}
|
||||
onOverlayPress={() => this.setState({ showSortPicker: false })}
|
||||
onItemSelected={this.handleSortByItemSelected}
|
||||
selectedItem={this.state.currentSortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import TagPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TAG)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(TagPage);
|
||||
@@ -0,0 +1,138 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { DEFAULT_FOLLOWED_TAGS, normalizeURI } from 'lbry-redux';
|
||||
import { formatTagTitle } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import ClaimList from 'component/claimList';
|
||||
import FileItem from 'component/fileItem';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import discoverStyle from 'styles/discover';
|
||||
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 ModalPicker from 'component/modalPicker';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class TagPage extends React.PureComponent {
|
||||
state = {
|
||||
tag: null,
|
||||
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);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible, navigation } = this.props;
|
||||
this.setState({ tag: navigation.state.params.tag });
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute, navigation } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.DRAWER_ROUTE_TAG === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
handleSortByItemSelected = 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;
|
||||
}
|
||||
|
||||
this.setState({ currentSortByItem: item, orderBy, showSortPicker: false });
|
||||
};
|
||||
|
||||
handleTimeItemSelected = item => {
|
||||
this.setState({ currentTimeItem: item, time: item.name, showTimePicker: false });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { tag, currentSortByItem, currentTimeItem, showSortPicker, showTimePicker } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} belowOverlay={showSortPicker || showTimePicker} />
|
||||
<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={this.state.currentSortByItem}
|
||||
items={Constants.CLAIM_SEARCH_SORT_BY_ITEMS}
|
||||
/>
|
||||
)}
|
||||
{showTimePicker && (
|
||||
<ModalPicker
|
||||
title={__('Content from')}
|
||||
onOverlayPress={() => this.setState({ showTimePicker: false })}
|
||||
onItemSelected={this.handleTimeItemSelected}
|
||||
selectedItem={this.state.currentTimeItem}
|
||||
items={Constants.CLAIM_SEARCH_TIME_ITEMS}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default TagPage;
|
||||
@@ -1,18 +1,16 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doFetchTrendingUris, selectTrendingUris, selectFetchingTrendingUris } from 'lbryinc';
|
||||
import { selectFollowedTags } from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import TrendingPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
trendingUris: selectTrendingUris(state),
|
||||
fetchingTrendingUris: selectFetchingTrendingUris(state),
|
||||
followedTags: selectFollowedTags(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchTrendingUris: () => dispatch(doFetchTrendingUris()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_TRENDING)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
+70
-32
@@ -1,17 +1,32 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, NativeModules, FlatList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, NativeModules, FlatList, Text, TouchableOpacity, View } from 'react-native';
|
||||
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';
|
||||
import FileItem from 'component/fileItem';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import Link from 'component/link';
|
||||
import ModalPicker from 'component/modalPicker';
|
||||
import ModalTagSelector from 'component/modalTagSelector';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import UriBar from 'component/uriBar';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
const TRENDING_FOR_ITEMS = [
|
||||
{ icon: 'globe-americas', name: 'everyone', label: 'Everyone' },
|
||||
{ icon: 'hashtag', name: 'tags', label: 'Tags you follow' },
|
||||
];
|
||||
|
||||
class TrendingPage extends React.PureComponent {
|
||||
state = {
|
||||
showModalTagSelector: false,
|
||||
showTrendingForPicker: false,
|
||||
currentTrendingForItem: TRENDING_FOR_ITEMS[0],
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
@@ -26,10 +41,9 @@ class TrendingPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { fetchTrendingUris, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
fetchTrendingUris();
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@@ -44,39 +58,63 @@ class TrendingPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handleTrendingForItemSelected = item => {
|
||||
this.setState({ currentTrendingForItem: item, showTrendingForPicker: false });
|
||||
};
|
||||
|
||||
render() {
|
||||
const { trendingUris, fetchingTrendingUris, navigation } = this.props;
|
||||
const hasContent = typeof trendingUris === 'object' && trendingUris.length,
|
||||
failedToLoad = !fetchingTrendingUris && !hasContent;
|
||||
const { followedTags, navigation } = this.props;
|
||||
const { currentTrendingForItem, showModalTagSelector, showTrendingForPicker } = this.state;
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
{!hasContent && fetchingTrendingUris && (
|
||||
<View style={discoverStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<Text style={discoverStyle.title}>Fetching content...</Text>
|
||||
</View>
|
||||
<ClaimList
|
||||
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={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 && <FloatingWalletBalance navigation={navigation} />}
|
||||
{showModalTagSelector && (
|
||||
<ModalTagSelector
|
||||
onOverlayPress={() => this.setState({ showModalTagSelector: false })}
|
||||
onDonePress={() => this.setState({ showModalTagSelector: false })}
|
||||
/>
|
||||
)}
|
||||
{hasContent && (
|
||||
<FlatList
|
||||
style={discoverStyle.trendingContainer}
|
||||
renderItem={({ item }) => (
|
||||
<FileItem
|
||||
style={fileListStyle.fileItem}
|
||||
mediaStyle={fileListStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
compactView={false}
|
||||
/>
|
||||
)}
|
||||
data={trendingUris.map(uri => uri.url)}
|
||||
keyExtractor={(item, index) => item}
|
||||
{showTrendingForPicker && (
|
||||
<ModalPicker
|
||||
title={'Trending for'}
|
||||
onOverlayPress={() => this.setState({ showTrendingForPicker: false })}
|
||||
onItemSelected={this.handleTrendingForItemSelected}
|
||||
selectedItem={currentTrendingForItem}
|
||||
items={TRENDING_FOR_ITEMS}
|
||||
/>
|
||||
)}
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
// @flow
|
||||
import { NativeModules } from 'react-native';
|
||||
import {
|
||||
ACTIONS,
|
||||
batchActions,
|
||||
buildURI,
|
||||
doResolveUri,
|
||||
doUpdateSearchQuery,
|
||||
makeSelectSearchUris,
|
||||
selectSuggestions,
|
||||
makeSelectQueryWithOptions,
|
||||
selectSearchValue,
|
||||
} from 'lbry-redux';
|
||||
|
||||
let CONNECTION_STRING = 'https://lighthouse.lbry.com/';
|
||||
|
||||
const handleNativeFetchResponse = str => {
|
||||
const json = JSON.parse(str);
|
||||
if (json.error) {
|
||||
return Promise.reject(new Error(json.error));
|
||||
}
|
||||
|
||||
return Promise.resolve(json);
|
||||
};
|
||||
|
||||
// Use a native asyncTask to call the lighthouse api
|
||||
export const doNativeSearch = (
|
||||
rawQuery: string, // pass in a query if you don't want to search for what's in the search bar
|
||||
size: ?number, // only pass in if you don't want to use the users setting (ex: related content)
|
||||
from: ?number,
|
||||
isBackgroundSearch: boolean = false
|
||||
) => (dispatch: Dispatch, getState: GetState) => {
|
||||
const query = rawQuery.replace(/^lbry:\/\//i, '').replace(/\//, ' ');
|
||||
|
||||
if (!query) {
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_FAIL,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const state = getState();
|
||||
const queryWithOptions = makeSelectQueryWithOptions(query, size, from, isBackgroundSearch)(state);
|
||||
|
||||
// If we have already searched for something, we don't need to do anything
|
||||
const urisForQuery = makeSelectSearchUris(queryWithOptions)(state);
|
||||
if (urisForQuery && !!urisForQuery.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_START,
|
||||
});
|
||||
|
||||
// If the user is on the file page with a pre-populated uri and they select
|
||||
// the search option without typing anything, searchQuery will be empty
|
||||
// We need to populate it so the input is filled on the search page
|
||||
// isBackgroundSearch means the search is happening in the background, don't update the search query
|
||||
if (!state.search.searchQuery && !isBackgroundSearch) {
|
||||
dispatch(doUpdateSearchQuery(query));
|
||||
}
|
||||
|
||||
const url = `${CONNECTION_STRING}search?${queryWithOptions}`;
|
||||
NativeModules.Requests.get(url)
|
||||
.then(handleNativeFetchResponse)
|
||||
.then((data: Array<{ name: String, claimId: string }>) => {
|
||||
const uris = [];
|
||||
const actions = [];
|
||||
|
||||
data.forEach(result => {
|
||||
if (result.name) {
|
||||
const uri = buildURI({
|
||||
claimName: result.name,
|
||||
claimId: result.claimId,
|
||||
});
|
||||
actions.push(doResolveUri(uri));
|
||||
uris.push(uri);
|
||||
}
|
||||
});
|
||||
|
||||
actions.push({
|
||||
type: ACTIONS.SEARCH_SUCCESS,
|
||||
data: {
|
||||
query: queryWithOptions,
|
||||
uris,
|
||||
},
|
||||
});
|
||||
dispatch(batchActions(...actions));
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
dispatch({
|
||||
type: ACTIONS.SEARCH_FAIL,
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,11 +1,17 @@
|
||||
import { ACTIONS } from 'lbry-redux';
|
||||
|
||||
export function doSetClientSetting(key, value) {
|
||||
return {
|
||||
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
||||
data: {
|
||||
key,
|
||||
value,
|
||||
},
|
||||
return dispatch => {
|
||||
dispatch({
|
||||
type: ACTIONS.CLIENT_SETTING_CHANGED,
|
||||
data: {
|
||||
key,
|
||||
value,
|
||||
},
|
||||
});
|
||||
|
||||
if (window.persistor) {
|
||||
window.persistor.flush();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import Colors from './colors';
|
||||
|
||||
const channelIconStyle = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
marginRight: 16,
|
||||
alignSelf: 'flex-start',
|
||||
},
|
||||
placeholderText: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 14,
|
||||
},
|
||||
thumbnailContainer: {
|
||||
width: 80,
|
||||
height: 80,
|
||||
borderRadius: 160,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
borderedThumbnailContainer: {
|
||||
borderWidth: 1,
|
||||
borderColor: Colors.LighterGrey,
|
||||
},
|
||||
thumbnail: {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
},
|
||||
centered: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
title: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 12,
|
||||
width: 80,
|
||||
marginTop: 4,
|
||||
textAlign: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
export default channelIconStyle;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import Colors from './colors';
|
||||
|
||||
const claimListStyle = StyleSheet.create({
|
||||
horizontalScrollContainer: {
|
||||
marginBottom: 12,
|
||||
},
|
||||
horizontalScrollPadding: {
|
||||
paddingLeft: 16,
|
||||
},
|
||||
verticalScrollContainer: {
|
||||
flex: 1,
|
||||
},
|
||||
verticalScrollPadding: {
|
||||
paddingBottom: 16,
|
||||
},
|
||||
verticalListItem: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
marginLeft: 8,
|
||||
marginRight: 8,
|
||||
marginTop: 4,
|
||||
marginBottom: 4,
|
||||
},
|
||||
verticalLoading: {
|
||||
width: '100%',
|
||||
height: 48,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
});
|
||||
|
||||
export default claimListStyle;
|
||||
+91
-5
@@ -27,8 +27,28 @@ const discoverStyle = StyleSheet.create({
|
||||
},
|
||||
scrollContainer: {
|
||||
flex: 1,
|
||||
paddingTop: 12,
|
||||
marginTop: 60,
|
||||
},
|
||||
titleRow: {
|
||||
flexDirection: 'row',
|
||||
marginTop: 76,
|
||||
marginBottom: 8,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
},
|
||||
rightTitleRow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
pageTitle: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 24,
|
||||
},
|
||||
customizeLink: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 14,
|
||||
marginRight: 48,
|
||||
},
|
||||
trendingContainer: {
|
||||
flex: 1,
|
||||
@@ -47,18 +67,43 @@ const discoverStyle = StyleSheet.create({
|
||||
textAlign: 'center',
|
||||
marginLeft: 10,
|
||||
},
|
||||
categoryTitleRow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
marginTop: 6,
|
||||
marginBottom: 6,
|
||||
},
|
||||
categoryName: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 18,
|
||||
marginLeft: 24,
|
||||
marginTop: 12,
|
||||
marginBottom: 6,
|
||||
color: Colors.Black,
|
||||
},
|
||||
fileItem: {
|
||||
width: fileItemWidth,
|
||||
marginRight: 12,
|
||||
},
|
||||
fileItemMore: {
|
||||
alignSelf: 'flex-start',
|
||||
backgroundColor: Colors.LbryGreen,
|
||||
flexDirection: 'row',
|
||||
width: fileItemWidth,
|
||||
height: fileItemMediaHeight,
|
||||
marginRight: 12,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
moreText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
color: Colors.White,
|
||||
fontSize: 24,
|
||||
},
|
||||
moreIcon: {
|
||||
marginLeft: 12,
|
||||
marginBottom: -4,
|
||||
},
|
||||
fileItemMedia: {
|
||||
width: fileItemMediaWidth,
|
||||
height: fileItemMediaHeight,
|
||||
@@ -163,12 +208,53 @@ const discoverStyle = StyleSheet.create({
|
||||
scrollPadding: {
|
||||
paddingBottom: 24,
|
||||
},
|
||||
listLoading: {
|
||||
flex: 1,
|
||||
height: 64,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
horizontalScrollContainer: {
|
||||
marginBottom: 12,
|
||||
},
|
||||
horizontalScrollPadding: {
|
||||
paddingLeft: 20,
|
||||
},
|
||||
verticalClaimList: {
|
||||
flex: 1,
|
||||
},
|
||||
tagPageTitle: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 24,
|
||||
},
|
||||
tagPageClaimList: {
|
||||
flex: 1,
|
||||
},
|
||||
tagTitleRow: {
|
||||
marginTop: 76,
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
tagSortBy: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginRight: 4,
|
||||
},
|
||||
tagTime: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
tagSortText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 14,
|
||||
marginRight: 4,
|
||||
},
|
||||
tagSortIcon: {
|
||||
marginTop: -6,
|
||||
},
|
||||
});
|
||||
|
||||
export default discoverStyle;
|
||||
@@ -93,6 +93,11 @@ const filePageStyle = StyleSheet.create({
|
||||
fontSize: 14,
|
||||
color: Colors.LbryGreen,
|
||||
},
|
||||
anonChannelName: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 14,
|
||||
color: Colors.DescriptionGrey,
|
||||
},
|
||||
publishDateText: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 12,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import Colors from './colors';
|
||||
|
||||
const modalPickerStyle = StyleSheet.create({
|
||||
overlay: {
|
||||
backgroundColor: '#00000055',
|
||||
flex: 1,
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
zIndex: 300,
|
||||
},
|
||||
overlayTouchArea: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
container: {
|
||||
position: 'absolute',
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
borderRadius: 8,
|
||||
backgroundColor: Colors.White,
|
||||
padding: 12,
|
||||
},
|
||||
title: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 12,
|
||||
marginTop: 4,
|
||||
textTransform: 'uppercase',
|
||||
},
|
||||
listItem: {
|
||||
paddingTop: 10,
|
||||
paddingBottom: 10,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
},
|
||||
divider: {
|
||||
marginTop: 12,
|
||||
marginBottom: 8,
|
||||
borderBottomColor: Colors.LighterGrey,
|
||||
borderBottomWidth: 1,
|
||||
width: '100%',
|
||||
},
|
||||
itemIcon: {
|
||||
marginLeft: 8,
|
||||
marginRight: 4,
|
||||
},
|
||||
itemLabel: {
|
||||
marginLeft: 8,
|
||||
alignSelf: 'flex-start',
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
},
|
||||
itemSelected: {
|
||||
position: 'absolute',
|
||||
right: 8,
|
||||
},
|
||||
});
|
||||
|
||||
export default modalPickerStyle;
|
||||
@@ -0,0 +1,59 @@
|
||||
import { StyleSheet } from 'react-native';
|
||||
import Colors from './colors';
|
||||
|
||||
const modalTagSelectorStyle = StyleSheet.create({
|
||||
overlay: {
|
||||
backgroundColor: '#00000099',
|
||||
flex: 1,
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
zIndex: 300,
|
||||
alignItems: 'center',
|
||||
},
|
||||
overlayTouchArea: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
borderRadius: 8,
|
||||
backgroundColor: Colors.White,
|
||||
padding: 16,
|
||||
position: 'absolute',
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
},
|
||||
tag: {
|
||||
marginRight: 4,
|
||||
marginBottom: 4,
|
||||
},
|
||||
tagList: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
},
|
||||
titleRow: {
|
||||
marginBottom: 12,
|
||||
},
|
||||
title: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 24,
|
||||
},
|
||||
buttons: {
|
||||
marginTop: 16,
|
||||
},
|
||||
doneButton: {
|
||||
alignSelf: 'flex-start',
|
||||
backgroundColor: Colors.LbryGreen,
|
||||
paddingLeft: 16,
|
||||
paddingRight: 16,
|
||||
},
|
||||
});
|
||||
|
||||
export default modalTagSelectorStyle;
|
||||
@@ -326,6 +326,54 @@ const publishStyle = StyleSheet.create({
|
||||
fontSize: 14,
|
||||
marginLeft: 8,
|
||||
},
|
||||
centered: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 60,
|
||||
bottom: 0,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
noPublishes: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 60,
|
||||
bottom: 0,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
padding: 16,
|
||||
},
|
||||
noPublishText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
},
|
||||
publishNowButton: {
|
||||
alignSelf: 'center',
|
||||
backgroundColor: Colors.LbryGreen,
|
||||
marginTop: 16,
|
||||
},
|
||||
publishesList: {
|
||||
flex: 1,
|
||||
marginTop: 60,
|
||||
},
|
||||
publishesScrollPadding: {
|
||||
paddingBottom: 16,
|
||||
},
|
||||
listItem: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
marginTop: 8,
|
||||
marginLeft: 8,
|
||||
marginRight: 8,
|
||||
},
|
||||
noVideos: {
|
||||
color: Colors.White,
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
},
|
||||
});
|
||||
|
||||
export default publishStyle;
|
||||
+117
-9
@@ -12,15 +12,16 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
},
|
||||
suggestedSubsContainer: {
|
||||
flex: 1,
|
||||
marginTop: 60,
|
||||
},
|
||||
suggestedScrollPadding: {
|
||||
paddingTop: 8,
|
||||
},
|
||||
button: {
|
||||
alignSelf: 'flex-start',
|
||||
backgroundColor: Colors.LbryGreen,
|
||||
paddingLeft: 16,
|
||||
paddingRight: 16,
|
||||
marginLeft: 16,
|
||||
marginBottom: 16,
|
||||
marginBottom: 8,
|
||||
},
|
||||
busyContainer: {
|
||||
flex: 1,
|
||||
@@ -38,7 +39,15 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
infoText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
margin: 16,
|
||||
marginTop: 8,
|
||||
marginBottom: 8,
|
||||
},
|
||||
infoArea: {
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
paddingBottom: 4,
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: Colors.LighterGrey,
|
||||
},
|
||||
suggestedContainer: {
|
||||
flex: 1,
|
||||
@@ -91,6 +100,14 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
marginTop: 8,
|
||||
fontSize: 18,
|
||||
},
|
||||
channelList: {
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
marginTop: 8,
|
||||
paddingBottom: 8,
|
||||
borderBottomColor: Colors.LighterGrey,
|
||||
borderBottomWidth: 1,
|
||||
},
|
||||
channelTitle: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 20,
|
||||
@@ -99,11 +116,6 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
marginBottom: 16,
|
||||
color: Colors.LbryGreen,
|
||||
},
|
||||
titleRow: {
|
||||
flex: 1,
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
subscribeButton: {
|
||||
alignSelf: 'flex-start',
|
||||
marginRight: 24,
|
||||
@@ -129,6 +141,102 @@ const subscriptionsStyle = StyleSheet.create({
|
||||
activeMode: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
},
|
||||
claimList: {
|
||||
flex: 1,
|
||||
},
|
||||
pageTitle: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 24,
|
||||
},
|
||||
titleRow: {
|
||||
marginTop: 76,
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
tagSortBy: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginRight: 4,
|
||||
},
|
||||
tagSortText: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 14,
|
||||
marginRight: 4,
|
||||
},
|
||||
tagSortIcon: {
|
||||
marginTop: -6,
|
||||
},
|
||||
centered: {
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
suggestedItem: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
marginBottom: 16,
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
},
|
||||
suggestedItemThumbnailContainer: {
|
||||
width: 70,
|
||||
height: 70,
|
||||
borderRadius: 140,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
suggestedItemThumbnail: {
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
},
|
||||
suggestedItemDetails: {
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
flex: 0.8,
|
||||
},
|
||||
suggestedItemSubscribe: {
|
||||
backgroundColor: Colors.White,
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
top: 0,
|
||||
},
|
||||
suggestedItemTitle: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 16,
|
||||
marginBottom: 4,
|
||||
width: '85%',
|
||||
},
|
||||
suggestedItemName: {
|
||||
fontFamily: 'Inter-UI-SemiBold',
|
||||
fontSize: 14,
|
||||
marginBottom: 4,
|
||||
color: Colors.LbryGreen,
|
||||
width: '95%',
|
||||
},
|
||||
suggestedItemTagList: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
},
|
||||
suggestedSubTitle: {
|
||||
fontFamily: 'Inter-UI-Regular',
|
||||
fontSize: 20,
|
||||
marginLeft: 16,
|
||||
marginRight: 16,
|
||||
marginBottom: 12,
|
||||
},
|
||||
suggestedSectionSeparator: {
|
||||
marginBottom: 16,
|
||||
},
|
||||
tag: {
|
||||
marginRight: 4,
|
||||
marginBottom: 4,
|
||||
},
|
||||
});
|
||||
|
||||
export default subscriptionsStyle;
|
||||
@@ -16,6 +16,8 @@ const uriBarStyle = StyleSheet.create({
|
||||
shadowOffset: {
|
||||
height: StyleSheet.hairlineWidth,
|
||||
},
|
||||
},
|
||||
containerElevated: {
|
||||
elevation: 4,
|
||||
},
|
||||
uriText: {
|
||||
@@ -34,6 +36,8 @@ const uriBarStyle = StyleSheet.create({
|
||||
top: 0,
|
||||
width: '100%',
|
||||
zIndex: 200,
|
||||
},
|
||||
overlayElevated: {
|
||||
elevation: 16,
|
||||
},
|
||||
inFocus: {
|
||||
|
||||
@@ -227,7 +227,7 @@ const walletStyle = StyleSheet.create({
|
||||
marginTop: 16,
|
||||
paddingBottom: 14,
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: Colors.PageBackground
|
||||
borderBottomColor: Colors.PageBackground,
|
||||
},
|
||||
syncDriverLink: {
|
||||
color: Colors.LbryGreen,
|
||||
|
||||
+33
-7
@@ -1,8 +1,9 @@
|
||||
import { NavigationActions, StackActions } from 'react-navigation';
|
||||
import { buildURI, isURIValid } from 'lbry-redux';
|
||||
import { doPopDrawerStack, doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { DrawerRoutes } from 'constants';
|
||||
import Constants from 'constants';
|
||||
import Constants, { DrawerRoutes } from 'constants'; // eslint-disable-line node/no-deprecated-api
|
||||
|
||||
const tagNameLength = 10;
|
||||
|
||||
function getRouteForSpecialUri(uri) {
|
||||
let targetRoute;
|
||||
@@ -35,7 +36,8 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
||||
return;
|
||||
}
|
||||
|
||||
let uriVars = {};
|
||||
let uriVars = {},
|
||||
uriVarsStr;
|
||||
if (uri.indexOf('?') > -1) {
|
||||
uriVarsStr = uri.substring(uri.indexOf('?') + 1);
|
||||
uri = uri.substring(0, uri.indexOf('?'));
|
||||
@@ -49,10 +51,10 @@ export function dispatchNavigateToUri(dispatch, nav, uri, isNavigatingBack) {
|
||||
dispatch(doSetPlayerVisible(true));
|
||||
}
|
||||
|
||||
if (nav && nav.routes && nav.routes.length > 0 && 'Main' === nav.routes[0].routeName) {
|
||||
if (nav && nav.routes && nav.routes.length > 0 && nav.routes[0].routeName === 'Main') {
|
||||
const mainRoute = nav.routes[0];
|
||||
const discoverRoute = mainRoute.routes[0];
|
||||
if (discoverRoute.index > 0 && 'File' === discoverRoute.routes[discoverRoute.index].routeName) {
|
||||
if (discoverRoute.index > 0 && discoverRoute.routes[discoverRoute.index].routeName === 'File') {
|
||||
const fileRoute = discoverRoute.routes[discoverRoute.index];
|
||||
// Currently on a file page, so we can ignore (if the URI is the same) or replace (different URIs)
|
||||
if (uri !== fileRoute.params.uri) {
|
||||
@@ -119,7 +121,8 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
|
||||
return;
|
||||
}
|
||||
|
||||
let uriVars = {};
|
||||
let uriVars = {},
|
||||
uriVarsStr;
|
||||
if (uri.indexOf('?') > -1) {
|
||||
uriVarsStr = uri.substring(uri.indexOf('?') + 1);
|
||||
uri = uri.substring(0, uri.indexOf('?'));
|
||||
@@ -128,7 +131,7 @@ export function navigateToUri(navigation, uri, additionalParams, isNavigatingBac
|
||||
|
||||
const { store } = window;
|
||||
const params = Object.assign({ uri, uriVars }, additionalParams);
|
||||
if ('File' === navigation.state.routeName) {
|
||||
if (navigation.state.routeName === 'File') {
|
||||
const stackAction = StackActions.replace({ routeName: 'File', newKey: uri, params });
|
||||
navigation.dispatch(stackAction);
|
||||
if (store && store.dispatch && !isNavigatingBack) {
|
||||
@@ -182,3 +185,26 @@ export function uriFromFileInfo(fileInfo) {
|
||||
uriParams.claimId = claimId;
|
||||
return buildURI(uriParams);
|
||||
}
|
||||
|
||||
export function formatTagTitle(title) {
|
||||
if (!title) {
|
||||
return null;
|
||||
}
|
||||
return title.charAt(0).toUpperCase() + title.substring(1);
|
||||
}
|
||||
|
||||
export function formatTagName(name) {
|
||||
if (!name) {
|
||||
return null;
|
||||
}
|
||||
if (name.length <= tagNameLength) {
|
||||
return name;
|
||||
}
|
||||
|
||||
return name.substring(0, 7) + '...';
|
||||
}
|
||||
|
||||
// i18n placeholder until we find a good react-native i18n module
|
||||
export function __(str) {
|
||||
return str;
|
||||
}
|
||||
Reference in new issue
Block a user