display follower and view counts #99

Merged
akinwale merged 2 commits from sub-view-counts into master 2019-12-18 10:30:07 +01:00
12 changed files with 121 additions and 10 deletions
Showing only changes of commit b17ce45f22 - Show all commits

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { CLAIM_VALUES, isNameValid } from 'lbry-redux'; import { CLAIM_VALUES, formatCredits, isNameValid } from 'lbry-redux';
import { ActivityIndicator, NativeModules, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { ActivityIndicator, NativeModules, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native';
import { logPublish } from 'utils/helper'; import { logPublish } from 'utils/helper';
import Button from 'component/button'; import Button from 'component/button';
@ -14,6 +14,7 @@ export default class ChannelSelector extends React.PureComponent {
super(props); super(props);
this.state = { this.state = {
creditsInputFocused: false,
currentSelectedValue: Constants.ITEM_ANONYMOUS, currentSelectedValue: Constants.ITEM_ANONYMOUS,
newChannelName: '', newChannelName: '',
newChannelBid: 0.1, newChannelBid: 0.1,
@ -188,7 +189,7 @@ export default class ChannelSelector extends React.PureComponent {
render() { render() {
const channel = this.state.addingChannel ? 'new' : this.props.channel; const channel = this.state.addingChannel ? 'new' : this.props.channel;
const { enabled, fetchingChannels, channels = [] } = this.props; const { balance, enabled, fetchingChannels, channels = [] } = this.props;
const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat( const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(
channels ? channels.map(ch => ch.name) : [] channels ? channels.map(ch => ch.name) : []
); );
@ -244,11 +245,19 @@ export default class ChannelSelector extends React.PureComponent {
style={channelSelectorStyle.bidAmountInput} style={channelSelectorStyle.bidAmountInput}
value={String(newChannelBid)} value={String(newChannelBid)}
onChangeText={this.handleNewChannelBidChange} onChangeText={this.handleNewChannelBidChange}
onFocus={() => this.setState({ creditsInputFocused: true })}
onBlur={() => this.setState({ creditsInputFocused: false })}
placeholder={'0.00'} placeholder={'0.00'}
keyboardType={'number-pad'} keyboardType={'number-pad'}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
/> />
<Text style={channelSelectorStyle.currency}>LBC</Text> <Text style={channelSelectorStyle.currency}>LBC</Text>
<View style={channelSelectorStyle.balance}>
{this.state.creditsInputFocused && <Icon name="coins" size={12} />}
{this.state.creditsInputFocused && (
<Text style={channelSelectorStyle.balanceText}>{formatCredits(parseFloat(balance), 1, true)}</Text>
)}
</View>
</View> </View>
<Text style={channelSelectorStyle.helpText}> <Text style={channelSelectorStyle.helpText}>
{__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')} {__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')}

View file

@ -1,9 +1,10 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { regexAddress } from 'lbry-redux'; import { formatCredits, regexAddress } from 'lbry-redux';
import { Alert, Clipboard, TextInput, Text, View } from 'react-native'; import { Alert, Clipboard, TextInput, Text, View } from 'react-native';
import Button from 'component/button'; import Button from 'component/button';
import Colors from 'styles/colors'; import Colors from 'styles/colors';
import Icon from 'react-native-vector-icons/FontAwesome5';
import walletStyle from 'styles/wallet'; import walletStyle from 'styles/wallet';
type DraftTransaction = { type DraftTransaction = {
@ -24,6 +25,7 @@ class WalletSend extends React.PureComponent<Props> {
address: null, address: null,
addressChanged: false, addressChanged: false,
addressValid: false, addressValid: false,
creditsInputFocused: false,
}; };
componentWillUpdate(nextProps) { componentWillUpdate(nextProps) {
@ -118,6 +120,8 @@ class WalletSend extends React.PureComponent<Props> {
<TextInput <TextInput
ref={ref => (this.amountInput = ref)} ref={ref => (this.amountInput = ref)}
onChangeText={value => this.setState({ amount: value })} onChangeText={value => this.setState({ amount: value })}
onFocus={() => this.setState({ creditsInputFocused: true })}
onBlur={() => this.setState({ creditsInputFocused: false })}
keyboardType={'numeric'} keyboardType={'numeric'}
placeholder={'0'} placeholder={'0'}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
@ -125,6 +129,12 @@ class WalletSend extends React.PureComponent<Props> {
style={[walletStyle.input, walletStyle.amountInput]} style={[walletStyle.input, walletStyle.amountInput]}
/> />
<Text style={[walletStyle.text, walletStyle.currency]}>LBC</Text> <Text style={[walletStyle.text, walletStyle.currency]}>LBC</Text>
<View style={walletStyle.balanceFocus}>
{this.state.creditsInputFocused && <Icon name="coins" size={12} />}
{this.state.creditsInputFocused && (
<Text style={walletStyle.balanceText}>{formatCredits(parseFloat(balance), 1, true)}</Text>
)}
</View>
</View> </View>
<Button <Button
text={__('Send')} text={__('Send')}

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { CLAIM_VALUES, isNameValid, regexInvalidURI } from 'lbry-redux'; import { CLAIM_VALUES, formatCredits, isNameValid, regexInvalidURI } from 'lbry-redux';
import { import {
ActivityIndicator, ActivityIndicator,
Alert, Alert,
@ -38,6 +38,7 @@ export default class ChannelCreator extends React.PureComponent {
autoStyle: null, autoStyle: null,
canSave: true, canSave: true,
claimId: null, claimId: null,
creditsInputFocused: false,
currentSelectedValue: Constants.ITEM_ANONYMOUS, currentSelectedValue: Constants.ITEM_ANONYMOUS,
currentPhase: null, currentPhase: null,
displayName: null, displayName: null,
@ -960,11 +961,19 @@ export default class ChannelCreator extends React.PureComponent {
style={channelCreatorStyle.bidAmountInput} style={channelCreatorStyle.bidAmountInput}
value={String(newChannelBid)} value={String(newChannelBid)}
onChangeText={this.handleNewChannelBidChange} onChangeText={this.handleNewChannelBidChange}
onFocus={() => this.setState({ creditsInputFocused: true })}
onBlur={() => this.setState({ creditsInputFocused: false })}
placeholder={'0.00'} placeholder={'0.00'}
keyboardType={'number-pad'} keyboardType={'number-pad'}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
/> />
<Text style={channelCreatorStyle.currency}>LBC</Text> <Text style={channelCreatorStyle.currency}>LBC</Text>
<View style={channelCreatorStyle.balance}>
{this.state.creditsInputFocused && <Icon name="coins" size={12} />}
{this.state.creditsInputFocused && (
<Text style={channelCreatorStyle.balanceText}>{formatCredits(parseFloat(balance), 1, true)}</Text>
)}
</View>
</View> </View>
<Text style={channelCreatorStyle.helpText}> <Text style={channelCreatorStyle.helpText}>
{__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')} {__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')}

View file

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Lbry, normalizeURI, parseURI } from 'lbry-redux'; import { Lbry, formatCredits, normalizeURI, parseURI } from 'lbry-redux';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import { import {
ActivityIndicator, ActivityIndicator,
@ -66,6 +66,7 @@ class FilePage extends React.PureComponent {
autoOpened: false, autoOpened: false,
autoDownloadStarted: false, autoDownloadStarted: false,
autoPlayMedia: false, autoPlayMedia: false,
creditsInputFocused: false,
downloadButtonShown: false, downloadButtonShown: false,
downloadPressed: false, downloadPressed: false,
didSearchRecommended: false, didSearchRecommended: false,
@ -1177,6 +1178,8 @@ class FilePage extends React.PureComponent {
editable={!this.state.sendTipStarted} editable={!this.state.sendTipStarted}
ref={ref => (this.tipAmountInput = ref)} ref={ref => (this.tipAmountInput = ref)}
onChangeText={value => this.setState({ tipAmount: value })} onChangeText={value => this.setState({ tipAmount: value })}
onFocus={() => this.setState({ creditsInputFocused: true })}
onBlur={() => this.setState({ creditsInputFocused: false })}
underlineColorAndroid={Colors.NextLbryGreen} underlineColorAndroid={Colors.NextLbryGreen}
keyboardType={'numeric'} keyboardType={'numeric'}
placeholder={'0'} placeholder={'0'}
@ -1185,6 +1188,12 @@ class FilePage extends React.PureComponent {
style={[filePageStyle.input, filePageStyle.tipAmountInput]} style={[filePageStyle.input, filePageStyle.tipAmountInput]}
/> />
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text> <Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
<View style={filePageStyle.balance}>
{this.state.creditsInputFocused && <Icon name="coins" size={12} />}
{this.state.creditsInputFocused && (
<Text style={filePageStyle.balanceText}>{formatCredits(parseFloat(balance), 1, true)}</Text>
)}
</View>
</View> </View>
{this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />} {this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
<Link <Link
@ -1234,9 +1243,10 @@ class FilePage extends React.PureComponent {
</ScrollView> </ScrollView>
</View> </View>
)} )}
{!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView && ( {!this.state.creditsInputFocused &&
<FloatingWalletBalance navigation={navigation} /> !this.state.fullscreenMode &&
)} !this.state.showImageViewer &&
!this.state.showWebView && <FloatingWalletBalance navigation={navigation} />}
</View> </View>
); );
} }

View file

@ -19,6 +19,7 @@ import {
isNameValid, isNameValid,
batchActions, batchActions,
buildURI, buildURI,
formatCredits,
normalizeURI, normalizeURI,
parseURI, parseURI,
regexInvalidURI, regexInvalidURI,
@ -83,6 +84,7 @@ class PublishPage extends React.PureComponent {
state = { state = {
canPublish: true, canPublish: true,
canUseCamera: false, canUseCamera: false,
creditsInputFocused: false,
documentPickerOpen: false, documentPickerOpen: false,
editMode: false, editMode: false,
titleFocused: false, titleFocused: false,
@ -1133,8 +1135,16 @@ class PublishPage extends React.PureComponent {
keyboardType={'numeric'} keyboardType={'numeric'}
value={String(this.state.bid)} value={String(this.state.bid)}
onChangeText={this.handleBidChange} onChangeText={this.handleBidChange}
onFocus={() => this.setState({ creditsInputFocused: true })}
onBlur={() => this.setState({ creditsInputFocused: false })}
/> />
<Text style={publishStyle.currency}>LBC</Text> <Text style={publishStyle.currency}>LBC</Text>
<View style={publishStyle.balance}>
{this.state.creditsInputFocused && <Icon name="coins" size={12} />}
{this.state.creditsInputFocused && (
<Text style={publishStyle.balanceText}>{formatCredits(parseFloat(balance), 1, true)}</Text>
)}
</View>
</View> </View>
<Text style={publishStyle.helpText}> <Text style={publishStyle.helpText}>
{__('This LBC remains yours and the deposit can be undone at any time.')} {__('This LBC remains yours and the deposit can be undone at any time.')}

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
doChannelUnsubscribe,
doFetchMySubscriptions, doFetchMySubscriptions,
doSetViewMode, doSetViewMode,
doFetchRecommendedSubscriptions, doFetchRecommendedSubscriptions,
@ -36,6 +37,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
channelUnsubscribe: subscription => dispatch(doChannelUnsubscribe(subscription)),
doFetchMySubscriptions: () => dispatch(doFetchMySubscriptions()), doFetchMySubscriptions: () => dispatch(doFetchMySubscriptions()),
doFetchRecommendedSubscriptions: () => dispatch(doFetchRecommendedSubscriptions()), doFetchRecommendedSubscriptions: () => dispatch(doFetchRecommendedSubscriptions()),
doSetViewMode: viewMode => dispatch(doSetViewMode(viewMode)), doSetViewMode: viewMode => dispatch(doSetViewMode(viewMode)),

View file

@ -82,6 +82,8 @@ class SubscriptionsPage extends React.PureComponent {
if (Constants.DRAWER_ROUTE_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) { if (Constants.DRAWER_ROUTE_SUBSCRIPTIONS === currentRoute && currentRoute !== prevRoute) {
this.onComponentFocused(); this.onComponentFocused();
} }
this.unsubscribeShortChannelUrls();
} }
handleSortByItemSelected = item => { handleSortByItemSelected = item => {
@ -109,6 +111,16 @@ class SubscriptionsPage extends React.PureComponent {
return [Constants.ALL_PLACEHOLDER].concat(channelUris); return [Constants.ALL_PLACEHOLDER].concat(channelUris);
}; };
// Added in 0.12.1. Can be dropped on or after 1 Feb 2020.
unsubscribeShortChannelUrls = () => {
// this should only have to happen once
const { subscribedChannels, channelUnsubscribe } = this.props;
const badSubs = subscribedChannels.filter(sub => sub.uri.split('#')[1].length < 5);
if (badSubs.length > 0) {
badSubs.forEach(sub => channelUnsubscribe(sub));
}
};
render() { render() {
const { const {
suggestedChannels, suggestedChannels,

View file

@ -30,6 +30,16 @@ const channelCreatorStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
fontSize: 16, fontSize: 16,
}, },
balance: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 24,
},
balanceText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 14,
marginLeft: 4,
},
channelNameInput: { channelNameInput: {
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
fontSize: 16, fontSize: 16,

View file

@ -24,6 +24,16 @@ const channelSelectorStyle = StyleSheet.create({
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
fontSize: 16, fontSize: 16,
}, },
balance: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 24,
},
balanceText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 14,
marginLeft: 4,
},
channelNameInput: { channelNameInput: {
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',
fontSize: 16, fontSize: 16,

View file

@ -277,6 +277,7 @@ const filePageStyle = StyleSheet.create({
amountRow: { amountRow: {
flexDirection: 'row', flexDirection: 'row',
flex: 0.75, flex: 0.75,
alignItems: 'center',
}, },
button: { button: {
backgroundColor: Colors.LbryGreen, backgroundColor: Colors.LbryGreen,
@ -299,9 +300,7 @@ const filePageStyle = StyleSheet.create({
letterSpacing: 1, letterSpacing: 1,
}, },
currency: { currency: {
alignSelf: 'flex-start',
fontSize: 12, fontSize: 12,
marginTop: 15,
marginLeft: 4, marginLeft: 4,
}, },
descriptionToggle: { descriptionToggle: {
@ -454,6 +453,16 @@ const filePageStyle = StyleSheet.create({
marginLeft: 12, marginLeft: 12,
marginRight: 12, marginRight: 12,
}, },
balance: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 24,
},
balanceText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 14,
marginLeft: 4,
},
}); });
export default filePageStyle; export default filePageStyle;

View file

@ -466,6 +466,16 @@ const publishStyle = StyleSheet.create({
fontFamily: 'Inter-UI-SemiBold', fontFamily: 'Inter-UI-SemiBold',
fontSize: 12, fontSize: 12,
}, },
balance: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 24,
},
balanceText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 14,
marginLeft: 4,
},
}); });
export default publishStyle; export default publishStyle;

View file

@ -126,6 +126,16 @@ const walletStyle = StyleSheet.create({
marginLeft: 16, marginLeft: 16,
marginBottom: 16, marginBottom: 16,
}, },
balanceFocus: {
alignItems: 'center',
flexDirection: 'row',
marginLeft: 24,
},
balanceText: {
fontFamily: 'Inter-UI-SemiBold',
fontSize: 14,
marginLeft: 4,
},
infoText: { infoText: {
color: '#aaaaaa', color: '#aaaaaa',
fontFamily: 'Inter-UI-Regular', fontFamily: 'Inter-UI-Regular',