Delete and Stop download button tweaks #221
6 changed files with 47 additions and 22 deletions
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text, TouchableOpacity } from 'react-native';
|
import { Text, TouchableOpacity } from 'react-native';
|
||||||
import buttonStyle from '../../styles/button';
|
import buttonStyle from '../../styles/button';
|
||||||
|
import Colors from '../../styles/colors';
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||||
|
|
||||||
export default class Button extends React.PureComponent {
|
export default class Button extends React.PureComponent {
|
||||||
|
@ -10,9 +11,10 @@ export default class Button extends React.PureComponent {
|
||||||
style,
|
style,
|
||||||
text,
|
text,
|
||||||
icon,
|
icon,
|
||||||
|
theme,
|
||||||
onPress
|
onPress
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let styles = [buttonStyle.button, buttonStyle.row];
|
let styles = [buttonStyle.button, buttonStyle.row];
|
||||||
if (style) {
|
if (style) {
|
||||||
if (style.length) {
|
if (style.length) {
|
||||||
|
@ -21,19 +23,25 @@ export default class Button extends React.PureComponent {
|
||||||
styles.push(style);
|
styles.push(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
styles.push(buttonStyle.disabled);
|
styles.push(buttonStyle.disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
const textStyles = [buttonStyle.text];
|
const textStyles = [buttonStyle.text];
|
||||||
if (icon && icon.trim().length > 0) {
|
if (icon && icon.trim().length > 0) {
|
||||||
textStyles.push(buttonStyle.textWithIcon);
|
textStyles.push(buttonStyle.textWithIcon);
|
||||||
}
|
}
|
||||||
|
if (theme === 'light') {
|
||||||
|
textStyles.push(buttonStyle.textDark);
|
||||||
|
} else {
|
||||||
|
// Dark background, default
|
||||||
|
textStyles.push(buttonStyle.textLight);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity disabled={disabled} style={styles} onPress={onPress}>
|
<TouchableOpacity disabled={disabled} style={styles} onPress={onPress}>
|
||||||
{icon && <Icon name={icon} size={18} color='#ffffff' class={buttonStyle.icon} /> }
|
{icon && <Icon name={icon} size={18} color={'light' === theme ? Colors.DarkGrey : Colors.White} />}
|
||||||
{text && (text.trim().length > 0) && <Text style={textStyles}>{text}</Text>}
|
{text && (text.trim().length > 0) && <Text style={textStyles}>{text}</Text>}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
|
|
@ -17,21 +17,21 @@ type Props = {
|
||||||
|
|
||||||
class WalletSend extends React.PureComponent<Props> {
|
class WalletSend extends React.PureComponent<Props> {
|
||||||
amountInput = null;
|
amountInput = null;
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
amount: null,
|
amount: null,
|
||||||
address: null,
|
address: null,
|
||||||
addressChanged: false,
|
addressChanged: false,
|
||||||
addressValid: false
|
addressValid: false
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentWillUpdate(nextProps) {
|
||||||
const { draftTransaction, transactionError } = nextProps;
|
const { draftTransaction, transactionError } = nextProps;
|
||||||
if (transactionError && transactionError.trim().length > 0) {
|
if (transactionError && transactionError.trim().length > 0) {
|
||||||
this.setState({ address: draftTransaction.address, amount: draftTransaction.amount });
|
this.setState({ address: draftTransaction.address, amount: draftTransaction.amount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSend = () => {
|
handleSend = () => {
|
||||||
const { balance, sendToAddress, notify } = this.props;
|
const { balance, sendToAddress, notify } = this.props;
|
||||||
const { address, amount } = this.state;
|
const { address, amount } = this.state;
|
||||||
|
@ -42,7 +42,7 @@ class WalletSend extends React.PureComponent<Props> {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > balance) {
|
if (amount > balance) {
|
||||||
notify({
|
notify({
|
||||||
message: 'Insufficient credits',
|
message: 'Insufficient credits',
|
||||||
|
@ -50,13 +50,13 @@ class WalletSend extends React.PureComponent<Props> {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount && address) {
|
if (amount && address) {
|
||||||
sendToAddress(address, parseFloat(amount));
|
sendToAddress(address, parseFloat(amount));
|
||||||
this.setState({ address: null, amount: null });
|
this.setState({ address: null, amount: null });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAddressInputBlur = () => {
|
handleAddressInputBlur = () => {
|
||||||
if (this.state.addressChanged && !this.state.addressValid) {
|
if (this.state.addressChanged && !this.state.addressValid) {
|
||||||
const { notify } = this.props;
|
const { notify } = this.props;
|
||||||
|
@ -66,7 +66,7 @@ class WalletSend extends React.PureComponent<Props> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleAddressInputSubmit = () => {
|
handleAddressInputSubmit = () => {
|
||||||
if (this.amountInput) {
|
if (this.amountInput) {
|
||||||
this.amountInput.focus();
|
this.amountInput.focus();
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { Lbry, normalizeURI } from 'lbry-redux';
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
Button,
|
|
||||||
Dimensions,
|
Dimensions,
|
||||||
NativeModules,
|
NativeModules,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
|
@ -16,6 +15,7 @@ import {
|
||||||
WebView
|
WebView
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import ImageViewer from 'react-native-image-zoom-viewer';
|
import ImageViewer from 'react-native-image-zoom-viewer';
|
||||||
|
import Button from '../../component/button';
|
||||||
import Colors from '../../styles/colors';
|
import Colors from '../../styles/colors';
|
||||||
import ChannelPage from '../channel';
|
import ChannelPage from '../channel';
|
||||||
import FileDownloadButton from '../../component/fileDownloadButton';
|
import FileDownloadButton from '../../component/fileDownloadButton';
|
||||||
|
@ -332,9 +332,16 @@ class FilePage extends React.PureComponent {
|
||||||
|
|
||||||
{ showActions &&
|
{ showActions &&
|
||||||
<View style={filePageStyle.actions}>
|
<View style={filePageStyle.actions}>
|
||||||
{completed && <Button color="red" title="Delete" onPress={this.onDeletePressed} />}
|
{completed && <Button style={filePageStyle.actionButton}
|
||||||
|
theme={"light"}
|
||||||
|
icon={"trash"}
|
||||||
|
text={"Delete"}
|
||||||
|
onPress={this.onDeletePressed} />}
|
||||||
{!completed && fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes &&
|
{!completed && fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||||
<Button color="red" title="Stop Download" onPress={this.onStopDownloadPressed} />
|
<Button style={filePageStyle.actionButton}
|
||||||
|
theme={"light"}
|
||||||
|
text={"Stop Download"}
|
||||||
|
onPress={this.onStopDownloadPressed} />
|
||||||
}
|
}
|
||||||
</View>}
|
</View>}
|
||||||
<ScrollView style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}>
|
<ScrollView style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import Colors from './colors';
|
||||||
|
|
||||||
const buttonStyle = StyleSheet.create({
|
const buttonStyle = StyleSheet.create({
|
||||||
button: {
|
button: {
|
||||||
|
@ -13,13 +14,21 @@ const buttonStyle = StyleSheet.create({
|
||||||
backgroundColor: '#999999'
|
backgroundColor: '#999999'
|
||||||
},
|
},
|
||||||
row: {
|
row: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row'
|
||||||
},
|
},
|
||||||
icon: {
|
iconLight: {
|
||||||
color: '#ffffff',
|
color: Colors.White,
|
||||||
|
},
|
||||||
|
iconDark: {
|
||||||
|
color: Colors.DarkGrey,
|
||||||
|
},
|
||||||
|
textLight: {
|
||||||
|
color: Colors.White,
|
||||||
|
},
|
||||||
|
textDark: {
|
||||||
|
color: Colors.DarkGrey
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
color: '#ffffff',
|
|
||||||
fontFamily: 'Metropolis-Regular',
|
fontFamily: 'Metropolis-Regular',
|
||||||
fontSize: 14
|
fontSize: 14
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const Colors = {
|
const Colors = {
|
||||||
Black: '#000000',
|
Black: '#000000',
|
||||||
ChannelGrey: '#9b9b9b',
|
ChannelGrey: '#9b9b9b',
|
||||||
|
DarkGrey: '#555555',
|
||||||
DescriptionGrey: '#999999',
|
DescriptionGrey: '#999999',
|
||||||
LbryGreen: '#40b89a',
|
LbryGreen: '#40b89a',
|
||||||
LightGrey: '#cccccc',
|
LightGrey: '#cccccc',
|
||||||
|
|
|
@ -146,9 +146,9 @@ const filePageStyle = StyleSheet.create({
|
||||||
marginTop: -14,
|
marginTop: -14,
|
||||||
width: '50%',
|
width: '50%',
|
||||||
},
|
},
|
||||||
deleteButton: {
|
actionButton: {
|
||||||
backgroundColor: Colors.Red,
|
backgroundColor: Colors.White,
|
||||||
width: 80
|
width: 160
|
||||||
},
|
},
|
||||||
loading: {
|
loading: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|
Loading…
Reference in a new issue