BlueWallet/BlueComponents.js

1103 lines
28 KiB
JavaScript
Raw Normal View History

2018-01-30 23:42:38 +01:00
/** @type {AppStorage} */
2018-03-17 21:39:21 +01:00
import React, { Component } from 'react';
2018-06-25 00:22:46 +02:00
import Ionicons from 'react-native-vector-icons/Ionicons';
import { Icon, Button, FormLabel, FormInput, Text, Header, List, ListItem } from 'react-native-elements';
2018-12-12 04:33:28 +01:00
import {
TouchableOpacity,
TouchableWithoutFeedback,
Animated,
ActivityIndicator,
View,
StyleSheet,
Dimensions,
Image,
SafeAreaView,
Clipboard,
Platform,
TextInput,
2018-12-12 04:33:28 +01:00
} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
2018-07-14 21:53:43 +02:00
import { WatchOnlyWallet, LegacyWallet } from './class';
2018-06-25 00:22:46 +02:00
import Carousel from 'react-native-snap-carousel';
import DeviceInfo from 'react-native-device-info';
import { HDLegacyP2PKHWallet } from './class/hd-legacy-p2pkh-wallet';
import { HDLegacyBreadwalletWallet } from './class/hd-legacy-breadwallet-wallet';
import { HDSegwitP2SHWallet } from './class/hd-segwit-p2sh-wallet';
2018-08-19 16:54:15 +02:00
import { LightningCustodianWallet } from './class/lightning-custodian-wallet';
2018-06-25 00:22:46 +02:00
let loc = require('./loc/');
2018-05-22 19:10:53 +02:00
/** @type {AppStorage} */
2018-03-17 21:39:21 +01:00
let BlueApp = require('./BlueApp');
2018-05-12 22:27:34 +02:00
const { height, width } = Dimensions.get('window');
const aspectRatio = height / width;
let isIpad;
if (aspectRatio > 1.6) {
isIpad = false;
} else {
isIpad = true;
}
2018-01-30 23:42:38 +01:00
export class BlueButton extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-07-14 20:54:27 +02:00
// eslint-disable-next-line
this.props.buttonStyle = this.props.buttonStyle || {};
2018-01-30 23:42:38 +01:00
return (
<Button
2018-06-30 15:36:13 +02:00
activeOpacity={0.1}
delayPressIn={0}
2018-01-30 23:42:38 +01:00
{...this.props}
2018-03-17 21:39:21 +01:00
style={{
borderWidth: 0.7,
2018-06-30 15:36:13 +02:00
borderColor: 'transparent',
2018-03-17 21:39:21 +01:00
}}
2018-07-14 20:54:27 +02:00
buttonStyle={Object.assign(
{
backgroundColor: '#ccddf9',
minHeight: 45,
2018-07-14 20:54:27 +02:00
height: 45,
borderWidth: 0,
borderRadius: 25,
},
this.props.buttonStyle,
)}
color="#0c2550"
/>
);
}
}
export class BitcoinButton extends Component {
render() {
return (
<TouchableOpacity
onPress={() => {
// eslint-disable-next-line
if (this.props.onPress) this.props.onPress();
}}
>
<View
style={{
// eslint-disable-next-line
borderColor: (this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2',
borderWidth: 0.5,
borderRadius: 5,
backgroundColor: '#f5f5f5',
// eslint-disable-next-line
width: this.props.style.width,
// eslint-disable-next-line
height: this.props.style.height,
}}
>
<View style={{ paddingTop: 30 }}>
<Icon name="btc" size={32} type="font-awesome" color={(this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2'} />
<Text style={{ textAlign: 'center', color: (this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2' }}>
2018-07-28 21:14:08 +02:00
{loc.wallets.add.bitcoin}
2018-07-14 20:54:27 +02:00
</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
export class LightningButton extends Component {
render() {
return (
<TouchableOpacity
onPress={() => {
// eslint-disable-next-line
if (this.props.onPress) this.props.onPress();
}}
>
<View
style={{
// eslint-disable-next-line
borderColor: (this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2',
borderWidth: 0.5,
borderRadius: 5,
backgroundColor: '#f5f5f5',
// eslint-disable-next-line
width: this.props.style.width,
// eslint-disable-next-line
height: this.props.style.height,
}}
>
<View style={{ paddingTop: 30 }}>
<Icon name="bolt" size={32} type="font-awesome" color={(this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2'} />
<Text style={{ textAlign: 'center', color: (this.props.active && BlueApp.settings.foregroundColor) || '#d2d2d2' }}>
2018-12-17 21:02:33 +01:00
{loc.wallets.add.lightning}
2018-07-14 20:54:27 +02:00
</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
export class BlueButtonLink extends Component {
render() {
// eslint-disable-next-line
this.props.buttonStyle = this.props.buttonStyle || {};
return (
<Button
activeOpacity={0.1}
delayPressIn={0}
{...this.props}
style={{
marginTop: 20,
borderWidth: 0.7,
borderColor: 'transparent',
}}
buttonStyle={{
2018-09-18 08:48:53 +02:00
height: 45,
width: width / 1.5,
2018-07-14 20:54:27 +02:00
}}
backgroundColor="transparent"
2018-06-30 15:36:13 +02:00
color="#0c2550"
2018-01-30 23:42:38 +01:00
/>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
export const BlueNavigationStyle = (navigation, withNavigationCloseButton = false, customCloseButtonFunction = undefined) => ({
headerStyle: {
backgroundColor: '#FFFFFF',
borderBottomWidth: 0,
elevation: 0,
},
headerTitleStyle: {
fontWeight: '600',
color: '#0c2550',
},
headerTintColor: '#0c2550',
headerRight: withNavigationCloseButton ? (
<TouchableOpacity
style={{ width: 40, height: 40, padding: 14 }}
onPress={customCloseButtonFunction === undefined ? () => navigation.goBack(null) : customCloseButtonFunction}
>
2018-11-10 00:44:34 +01:00
<Image style={{ alignSelf: 'center' }} source={require('./img/close.png')} />
</TouchableOpacity>
) : null,
headerBackTitle: null,
});
2018-09-29 06:58:09 +02:00
export const BlueCopyToClipboardButton = ({ stringToCopy }) => {
return (
<TouchableOpacity {...this.props} onPress={() => Clipboard.setString(stringToCopy)}>
<Text style={{ fontSize: 13, fontWeight: '400', color: '#68bbe1' }}>{loc.transactions.details.copy}</Text>
</TouchableOpacity>
);
};
2018-01-30 23:42:38 +01:00
export class SafeBlueArea extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
<SafeAreaView
{...this.props}
2018-03-17 21:39:21 +01:00
forceInset={{ horizontal: 'always' }}
style={{ flex: 1, backgroundColor: BlueApp.settings.brandingColor }}
2018-01-30 23:42:38 +01:00
/>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
export class BlueCard extends Component {
2018-03-17 21:39:21 +01:00
render() {
return <View {...this.props} style={{ padding: 20 }} />;
2018-01-30 23:42:38 +01:00
}
}
export class BlueText extends Component {
2018-03-17 21:39:21 +01:00
render() {
return (
<Text
style={Object.assign(
{
color: BlueApp.settings.foregroundColor,
},
// eslint-disable-next-line
this.props.style,
)}
{...this.props}
/>
);
2018-01-30 23:42:38 +01:00
}
}
2018-07-14 20:54:27 +02:00
export class BlueTextCentered extends Component {
render() {
return <Text {...this.props} style={{ color: BlueApp.settings.foregroundColor, textAlign: 'center' }} />;
}
}
2018-01-30 23:42:38 +01:00
export class BlueListItem extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
<ListItem
bottomDivider
2018-05-06 19:36:48 +02:00
containerStyle={{
2018-06-25 00:22:46 +02:00
backgroundColor: 'transparent',
borderBottomStartRadius: 20,
borderBottomEndRadius: 20,
borderBottomColor: '#ededed',
2018-05-06 19:36:48 +02:00
}}
2018-06-25 00:22:46 +02:00
titleStyle={{
color: BlueApp.settings.foregroundColor,
fontSize: 16,
fontWeight: '500',
}}
subtitleStyle={{ color: '#9aa0aa' }}
subtitleNumberOfLines={1}
{...this.props}
2018-01-30 23:42:38 +01:00
/>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
export class BlueFormLabel extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-07-14 20:54:27 +02:00
return <FormLabel {...this.props} labelStyle={{ color: BlueApp.settings.foregroundColor, fontWeight: '400' }} />;
2018-01-30 23:42:38 +01:00
}
}
export class BlueFormInput extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-05-06 19:14:22 +02:00
return (
<FormInput
{...this.props}
inputStyle={{ color: BlueApp.settings.foregroundColor, maxWidth: width - 105 }}
containerStyle={{
marginTop: 5,
borderColor: '#d2d2d2',
borderBottomColor: '#d2d2d2',
borderWidth: 0.5,
borderBottomWidth: 0.5,
backgroundColor: '#f5f5f5',
}}
/>
);
}
}
export class BlueFormMultiInput extends Component {
render() {
return (
<TextInput
multiline
underlineColorAndroid="transparent"
numberOfLines={4}
style={{
2018-07-14 20:54:27 +02:00
marginTop: 5,
marginHorizontal: 20,
2018-07-14 20:54:27 +02:00
borderColor: '#d2d2d2',
borderBottomColor: '#d2d2d2',
borderWidth: 0.5,
2018-05-22 19:12:16 +02:00
borderBottomWidth: 0.5,
2018-07-14 20:54:27 +02:00
backgroundColor: '#f5f5f5',
height: 200,
color: BlueApp.settings.foregroundColor,
2018-05-22 19:12:16 +02:00
}}
autoCorrect={false}
autoCapitalize="none"
spellCheck={false}
{...this.props}
2018-05-06 19:14:22 +02:00
/>
);
2018-05-06 19:12:14 +02:00
}
}
export class BlueFormInputAddress extends Component {
render() {
2018-05-06 19:14:22 +02:00
return (
<FormInput
{...this.props}
2018-05-22 19:12:16 +02:00
inputStyle={{
2018-08-19 00:10:12 +02:00
maxWidth: width - 110,
2018-05-22 19:12:16 +02:00
color: BlueApp.settings.foregroundColor,
2018-07-18 00:43:23 +02:00
fontSize: (isIpad && 10) || ((is.iphone8() && 12) || 14),
2018-05-22 19:12:16 +02:00
}}
containerStyle={{
2018-07-18 00:43:23 +02:00
marginTop: 5,
borderColor: '#d2d2d2',
borderBottomColor: '#d2d2d2',
borderWidth: 0.5,
2018-05-22 19:12:16 +02:00
borderBottomWidth: 0.5,
2018-07-18 00:43:23 +02:00
backgroundColor: '#f5f5f5',
2018-05-22 19:12:16 +02:00
}}
2018-05-06 19:14:22 +02:00
/>
);
2018-01-30 23:42:38 +01:00
}
}
export class BlueHeader extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
<Header
{...this.props}
2018-06-25 00:22:46 +02:00
backgroundColor="transparent"
outerContainerStyles={{
borderBottomColor: 'transparent',
borderBottomWidth: 0,
}}
2018-06-28 03:43:28 +02:00
statusBarProps={{ barStyle: 'default' }}
/>
);
}
}
export class BlueHeaderDefaultSub extends Component {
render() {
return (
<SafeAreaView style={{ backgroundColor: '#FFFFFF' }}>
<Header
backgroundColor="#FFFFFF"
outerContainerStyles={{
borderBottomColor: 'transparent',
borderBottomWidth: 0,
}}
statusBarProps={{ barStyle: 'default' }}
leftComponent={
<Text
2018-10-04 03:49:29 +02:00
adjustsFontSizeToFit
style={{
fontWeight: 'bold',
fontSize: 34,
color: BlueApp.settings.foregroundColor,
}}
>
{
// eslint-disable-next-line
this.props.leftText
}
</Text>
}
rightComponent={
<TouchableOpacity
onPress={() => {
// eslint-disable-next-line
if (this.props.onClose) this.props.onClose();
}}
>
<View style={stylesBlueIcon.box}>
<View style={stylesBlueIcon.ballTransparrent}>
<Image source={require('./img/close.png')} />
</View>
2018-06-28 03:43:28 +02:00
</View>
</TouchableOpacity>
}
{...this.props}
/>
</SafeAreaView>
2018-06-28 03:43:28 +02:00
);
}
}
export class BlueHeaderDefaultMain extends Component {
render() {
return (
<SafeAreaView style={{ backgroundColor: '#FFFFFF' }}>
<Header
{...this.props}
backgroundColor="#FFFFFF"
outerContainerStyles={{
borderBottomColor: 'transparent',
borderBottomWidth: 0,
}}
statusBarProps={{ barStyle: 'default' }}
leftComponent={
<Text
2018-10-04 03:49:29 +02:00
numberOfLines={0}
style={{
fontWeight: 'bold',
fontSize: 34,
color: BlueApp.settings.foregroundColor,
}}
>
{
// eslint-disable-next-line
this.props.leftText
}
</Text>
}
rightComponent={
<TouchableOpacity
onPress={this.props.onNewWalletPress}
style={{
height: 48,
alignSelf: 'flex-end',
}}
>
<BluePlusIcon />
</TouchableOpacity>
}
/>
</SafeAreaView>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
export class BlueSpacing extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-07-07 15:04:32 +02:00
return <View {...this.props} style={{ height: 60, backgroundColor: BlueApp.settings.brandingColor }} />;
2018-01-30 23:42:38 +01:00
}
}
2018-06-29 00:17:14 +02:00
2018-05-12 22:27:34 +02:00
export class BlueSpacing40 extends Component {
render() {
2018-07-07 15:04:32 +02:00
return <View {...this.props} style={{ height: 50, backgroundColor: BlueApp.settings.brandingColor }} />;
2018-05-12 22:27:34 +02:00
}
}
2018-01-30 23:42:38 +01:00
2018-06-29 00:17:14 +02:00
export class BlueSpacingVariable extends Component {
render() {
if (isIpad) {
return <BlueSpacing40 {...this.props} />;
} else {
return <BlueSpacing {...this.props} />;
}
}
}
export class is {
static ipad() {
return isIpad;
}
2018-07-18 00:43:23 +02:00
static iphone8() {
2018-11-10 00:44:34 +01:00
if (Platform.OS !== 'ios') {
return false;
}
return DeviceInfo.getDeviceId() === 'iPhone10,4';
2018-07-18 00:43:23 +02:00
}
2018-06-29 00:17:14 +02:00
}
2018-01-30 23:42:38 +01:00
export class BlueSpacing20 extends Component {
2018-06-25 00:22:46 +02:00
render() {
return <View {...this.props} style={{ height: 20, opacity: 0 }} />;
}
}
export class BlueList extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
2018-06-25 00:22:46 +02:00
<List
2018-01-30 23:42:38 +01:00
{...this.props}
2018-06-25 00:22:46 +02:00
containerStyle={{
backgroundColor: BlueApp.settings.brandingColor,
borderTopColor: 'transparent',
borderTopWidth: 0,
flex: 1,
2018-06-25 00:22:46 +02:00
}}
2018-01-30 23:42:38 +01:00
/>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
2018-06-25 00:22:46 +02:00
export class BlueLoading extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-06-25 00:22:46 +02:00
return (
<SafeBlueArea>
<View style={{ flex: 1, paddingTop: 200 }}>
<ActivityIndicator />
</View>
</SafeBlueArea>
);
2018-01-30 23:42:38 +01:00
}
}
2018-06-25 00:22:46 +02:00
const stylesBlueIcon = StyleSheet.create({
container: {
flex: 1,
},
box1: {
position: 'relative',
top: 15,
},
2018-06-28 03:43:28 +02:00
box: {
alignSelf: 'flex-end',
paddingHorizontal: 14,
paddingTop: 8,
2018-06-28 03:43:28 +02:00
},
2018-06-25 00:22:46 +02:00
boxIncomming: {
position: 'relative',
},
ball: {
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: '#ccddf9',
},
ballIncomming: {
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: '#d2f8d6',
transform: [{ rotate: '-45deg' }],
},
ballReceive: {
width: 30,
height: 30,
borderBottomLeftRadius: 15,
backgroundColor: '#d2f8d6',
transform: [{ rotate: '-45deg' }],
},
ballOutgoing: {
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: '#f8d2d2',
transform: [{ rotate: '225deg' }],
},
ballTransparrent: {
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: 'transparent',
},
ballDimmed: {
width: 30,
height: 30,
borderRadius: 15,
backgroundColor: 'gray',
},
});
export class BluePlusIcon extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
2018-06-25 00:22:46 +02:00
<View {...this.props} style={stylesBlueIcon.container}>
<View style={stylesBlueIcon.box1}>
<View style={stylesBlueIcon.ball}>
<Ionicons
{...this.props}
name={'ios-add'}
size={26}
style={{
color: BlueApp.settings.foregroundColor,
backgroundColor: 'transparent',
left: 8,
top: 1,
}}
/>
</View>
</View>
</View>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}
2018-06-25 00:22:46 +02:00
export class BlueTransactionIncommingIcon extends Component {
2018-03-17 21:39:21 +01:00
render() {
2018-01-30 23:42:38 +01:00
return (
<View {...this.props}>
2018-06-25 00:22:46 +02:00
<View style={stylesBlueIcon.boxIncomming}>
<View style={stylesBlueIcon.ballIncomming}>
<Icon {...this.props} name="arrow-down" size={16} type="font-awesome" color="#37c0a1" iconStyle={{ left: 0, top: 8 }} />
2018-06-25 00:22:46 +02:00
</View>
2018-01-30 23:42:38 +01:00
</View>
2018-06-25 00:22:46 +02:00
</View>
);
}
}
export class BlueTransactionPendingIcon extends Component {
render() {
return (
<View {...this.props}>
2018-09-25 23:22:11 +02:00
<View style={stylesBlueIcon.boxIncomming}>
2018-06-25 00:22:46 +02:00
<View style={stylesBlueIcon.ball}>
<Icon
{...this.props}
name="ellipsis-h"
size={16}
type="font-awesome"
color={BlueApp.settings.foregroundColor}
iconStyle={{ left: 0, top: 6 }}
/>
</View>
</View>
</View>
);
}
}
export class BlueTransactionOnchainIcon extends Component {
render() {
return (
<View {...this.props}>
<View style={stylesBlueIcon.boxIncomming}>
<View style={stylesBlueIcon.ballIncomming}>
<Icon
{...this.props}
name="link"
size={16}
type="font-awesome"
color="#37c0a1"
iconStyle={{ left: 0, top: 7, transform: [{ rotate: '-45deg' }] }}
/>
</View>
</View>
</View>
);
}
}
2018-09-05 00:18:24 +02:00
export class BlueTransactionOffchainIcon extends Component {
render() {
return (
<View {...this.props}>
2018-09-05 00:18:24 +02:00
<View style={stylesBlueIcon.boxIncomming}>
<View style={stylesBlueIcon.ballOutgoing}>
<Icon
{...this.props}
name="bolt"
size={16}
type="font-awesome"
color="#d0021b"
2018-09-26 23:16:52 +02:00
iconStyle={{ left: 0, top: 7, transform: [{ rotate: '155deg' }] }}
2018-09-05 00:18:24 +02:00
/>
</View>
</View>
</View>
);
}
}
export class BlueTransactionOffchainIncomingIcon extends Component {
render() {
return (
<View {...this.props}>
2018-09-05 00:18:24 +02:00
<View style={stylesBlueIcon.boxIncomming}>
<View style={stylesBlueIcon.ballIncomming}>
<Icon
{...this.props}
name="bolt"
size={16}
type="font-awesome"
color="#37c0a1"
iconStyle={{ left: 0, top: 7, transform: [{ rotate: '45deg' }] }}
/>
</View>
</View>
</View>
);
}
}
2018-06-25 00:22:46 +02:00
export class BlueTransactionOutgoingIcon extends Component {
render() {
return (
<View {...this.props}>
2018-06-25 00:22:46 +02:00
<View style={stylesBlueIcon.boxIncomming}>
<View style={stylesBlueIcon.ballOutgoing}>
<Icon {...this.props} name="arrow-down" size={16} type="font-awesome" color="#d0021b" iconStyle={{ left: 0, top: 8 }} />
2018-06-25 00:22:46 +02:00
</View>
</View>
</View>
);
}
}
2018-06-29 00:17:14 +02:00
//
2018-06-25 00:22:46 +02:00
export class BlueReceiveButtonIcon extends Component {
render() {
return (
<TouchableOpacity {...this.props}>
2018-06-29 00:17:14 +02:00
<View>
2018-06-25 00:22:46 +02:00
<View
style={{
flex: 1,
flexDirection: 'row',
minWidth: 110,
minHeight: 40,
2018-06-25 00:22:46 +02:00
position: 'relative',
backgroundColor: '#ccddf9',
alignItems: 'center',
2018-06-25 00:22:46 +02:00
}}
>
<View
style={{
minWidth: 30,
minHeight: 30,
2018-06-25 00:22:46 +02:00
backgroundColor: 'transparent',
transform: [{ rotate: '-45deg' }],
alignItems: 'center',
2018-06-25 00:22:46 +02:00
}}
>
<Icon {...this.props} name="arrow-down" size={16} type="font-awesome" color="#2f5fb3" iconStyle={{ left: 5, top: 12 }} />
2018-06-25 00:22:46 +02:00
</View>
<Text
style={{
2018-06-30 15:36:13 +02:00
color: '#2f5fb3',
2018-06-29 00:17:14 +02:00
fontSize: (isIpad && 10) || 16,
2018-06-25 00:22:46 +02:00
fontWeight: '500',
left: 5,
backgroundColor: 'transparent',
}}
>
2018-10-02 05:40:23 +02:00
{loc.receive.header.toLowerCase()}
2018-06-25 00:22:46 +02:00
</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
export class BlueSendButtonIcon extends Component {
render() {
return (
<TouchableOpacity {...this.props}>
2018-06-29 00:17:14 +02:00
<View>
2018-06-25 00:22:46 +02:00
<View
style={{
flex: 1,
flexDirection: 'row',
width: 110,
height: 40,
backgroundColor: '#ccddf9',
alignItems: 'center',
paddingLeft: 15,
2018-06-25 00:22:46 +02:00
}}
>
<View
style={{
minWidth: 30,
minHeight: 30,
2018-06-25 00:22:46 +02:00
left: 5,
backgroundColor: 'transparent',
transform: [{ rotate: '225deg' }],
}}
>
<Icon {...this.props} name="arrow-down" size={16} type="font-awesome" color="#2f5fb3" iconStyle={{ left: 2, top: 6 }} />
2018-06-25 00:22:46 +02:00
</View>
<Text
style={{
2018-06-30 15:36:13 +02:00
color: '#2f5fb3',
2018-06-29 00:17:14 +02:00
fontSize: (isIpad && 10) || 16,
2018-06-25 00:22:46 +02:00
fontWeight: '500',
backgroundColor: 'transparent',
}}
>
2018-10-02 05:40:23 +02:00
{loc.send.header.toLowerCase()}
2018-06-25 00:22:46 +02:00
</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
export class ManageFundsBigButton extends Component {
render() {
return (
2018-10-02 05:40:23 +02:00
<TouchableOpacity {...this.props}>
<View>
<View
style={{
flex: 1,
flexDirection: 'row',
minWidth: 160,
minHeight: 40,
backgroundColor: '#ccddf9',
2018-10-02 05:40:23 +02:00
alignItems: 'center',
}}
>
<View
style={{
backgroundColor: 'transparent',
transform: [{ rotate: '90deg' }],
2018-10-02 05:40:23 +02:00
marginHorizontal: 10,
}}
>
2018-10-02 05:40:23 +02:00
<Icon {...this.props} name="link" size={16} type="font-awesome" color="#2f5fb3" />
</View>
<Text
style={{
color: '#2f5fb3',
fontSize: (isIpad && 10) || 16,
fontWeight: '500',
backgroundColor: 'transparent',
}}
>
2018-10-04 00:32:42 +02:00
{loc.lnd.title}
</Text>
</View>
</View>
</TouchableOpacity>
);
}
}
2018-06-25 00:22:46 +02:00
export class BluePlusIconDimmed extends Component {
render() {
return (
<View {...this.props} style={stylesBlueIcon.container}>
<View style={stylesBlueIcon.box1}>
<View style={stylesBlueIcon.ballDimmed}>
<Ionicons
{...this.props}
name={'ios-add'}
size={26}
style={{
color: 'white',
backgroundColor: 'transparent',
left: 8,
top: 1,
}}
/>
</View>
</View>
</View>
);
}
}
export class NewWalletPanel extends Component {
2018-06-25 00:22:46 +02:00
constructor(props) {
super(props);
// WalletsCarousel.handleClick = props.handleClick // because cant access `this` from _renderItem
// eslint-disable-next-line
this.handleClick = props.onPress;
}
render() {
return (
<TouchableOpacity
{...this.props}
onPress={() => {
if (this.handleClick) {
this.handleClick();
}
}}
2018-11-10 00:44:34 +01:00
style={{ marginVertical: 17 }}
2018-06-25 00:22:46 +02:00
>
<LinearGradient
colors={['#eef0f4', '#eef0f4']}
style={{
padding: 15,
borderRadius: 10,
minHeight: 164,
2018-06-25 00:22:46 +02:00
justifyContent: 'center',
alignItems: 'center',
}}
>
<BluePlusIconDimmed />
<Text
style={{
backgroundColor: 'transparent',
fontWeight: 'bold',
fontSize: 20,
color: '#9aa0aa',
}}
>
{loc.wallets.list.create_a_wallet}
</Text>
<Text style={{ backgroundColor: 'transparent' }} />
<Text
style={{
backgroundColor: 'transparent',
fontSize: 13,
color: '#9aa0aa',
}}
>
{loc.wallets.list.create_a_wallet1}
</Text>
<Text
style={{
backgroundColor: 'transparent',
fontSize: 13,
color: '#9aa0aa',
}}
>
{loc.wallets.list.create_a_wallet2}
</Text>
</LinearGradient>
</TouchableOpacity>
);
}
}
const sliderWidth = width * 1;
const itemWidth = width * 0.82;
const sliderHeight = 190;
2018-06-25 00:22:46 +02:00
export class WalletsCarousel extends Component {
constructor(props) {
super(props);
// eslint-disable-next-line
WalletsCarousel.handleClick = props.handleClick; // because cant access `this` from _renderItem
WalletsCarousel.handleLongPress = props.handleLongPress;
2018-06-25 00:22:46 +02:00
// eslint-disable-next-line
this.onSnapToItem = props.onSnapToItem;
}
_renderItem({ item, index }) {
2018-12-12 04:33:28 +01:00
let scaleValue = new Animated.Value(1.0);
this.onPressedIn = () => {
2018-12-14 05:31:13 +01:00
Animated.spring(scaleValue, { toValue: 0.9, duration: 100, useNativeDriver: Platform.OS === 'android' }).start();
2018-12-12 04:33:28 +01:00
};
this.onPressedOut = () => {
2018-12-13 17:50:18 +01:00
Animated.spring(scaleValue, { toValue: 1.0, duration: 100, useNativeDriver: Platform.OS === 'android' }).start();
2018-12-12 04:33:28 +01:00
};
2018-06-25 00:22:46 +02:00
if (!item) {
return (
<NewWalletPanel
2018-06-25 00:22:46 +02:00
onPress={() => {
if (WalletsCarousel.handleClick) {
WalletsCarousel.handleClick(index);
}
}}
/>
);
}
2018-07-14 21:53:43 +02:00
let gradient1 = '#65ceef';
let gradient2 = '#68bbe1';
if (WatchOnlyWallet.type === item.type) {
2018-07-14 21:53:43 +02:00
gradient1 = '#7d7d7d';
gradient2 = '#4a4a4a';
}
if (LegacyWallet.type === item.type) {
2018-07-14 21:53:43 +02:00
gradient1 = '#40fad1';
gradient2 = '#15be98';
}
if (HDLegacyP2PKHWallet.type === item.type) {
gradient1 = '#e36dfa';
gradient2 = '#bd10e0';
}
if (HDLegacyBreadwalletWallet.type === item.type) {
gradient1 = '#fe6381';
gradient2 = '#f99c42';
}
if (HDSegwitP2SHWallet.type === item.type) {
gradient1 = '#c65afb';
gradient2 = '#9053fe';
}
if (LightningCustodianWallet.type === item.type) {
2018-08-19 16:54:15 +02:00
gradient1 = '#f1be07';
gradient2 = '#f79056';
}
2018-06-25 00:22:46 +02:00
return (
2018-12-12 04:33:28 +01:00
<Animated.View
style={{ paddingRight: 10, marginVertical: 17, transform: [{ scale: scaleValue }] }}
shadowOpacity={40 / 100}
shadowOffset={{ width: 0, height: 0 }}
shadowRadius={5}
>
2018-12-12 04:33:28 +01:00
<TouchableWithoutFeedback
onPressIn={this.onPressedIn}
onPressOut={this.onPressedOut}
onLongPress={WalletsCarousel.handleLongPress}
onPress={() => {
if (WalletsCarousel.handleClick) {
WalletsCarousel.handleClick(index, [gradient1, gradient2]);
}
}}
>
<LinearGradient
shadowColor="#000000"
colors={[gradient1, gradient2]}
2018-11-10 00:44:34 +01:00
style={{
padding: 15,
borderRadius: 10,
minHeight: 164,
2018-11-10 00:44:34 +01:00
elevation: 5,
}}
2018-06-25 00:22:46 +02:00
>
<Image
source={(LightningCustodianWallet.type === item.type && require('./img/lnd-shape.png')) || require('./img/btc-shape.png')}
style={{
width: 99,
height: 94,
position: 'absolute',
bottom: 0,
right: 0,
}}
/>
<Text style={{ backgroundColor: 'transparent' }} />
<Text
numberOfLines={1}
style={{
backgroundColor: 'transparent',
fontSize: 19,
color: '#fff',
}}
>
{item.getLabel()}
</Text>
<Text
numberOfLines={1}
adjustsFontSizeToFit
style={{
backgroundColor: 'transparent',
fontWeight: 'bold',
fontSize: 36,
color: '#fff',
}}
>
{loc.formatBalance(Number(item.getBalance()), item.getPreferredBalanceUnit())}
</Text>
<Text style={{ backgroundColor: 'transparent' }} />
<Text
numberOfLines={1}
style={{
backgroundColor: 'transparent',
fontSize: 13,
color: '#fff',
}}
>
{loc.wallets.list.latest_transaction}
</Text>
<Text
numberOfLines={1}
style={{
backgroundColor: 'transparent',
fontWeight: 'bold',
fontSize: 16,
color: '#fff',
}}
>
{loc.transactionTimeToReadable(item.getLatestTransactionTime())}
</Text>
</LinearGradient>
2018-12-12 04:33:28 +01:00
</TouchableWithoutFeedback>
</Animated.View>
2018-06-25 00:22:46 +02:00
);
}
render() {
return (
<Carousel
{...this.props}
ref={c => {
WalletsCarousel.carousel = c;
}}
renderItem={this._renderItem}
sliderWidth={sliderWidth}
sliderHeight={sliderHeight}
itemWidth={itemWidth}
inactiveSlideScale={1}
inactiveSlideOpacity={0.7}
contentContainerCustomStyle={{ left: -20 }}
onSnapToItem={index => {
if (this.onSnapToItem) {
this.onSnapToItem(index);
}
console.log('snapped to card #', index);
}}
/>
2018-03-17 21:39:21 +01:00
);
2018-01-30 23:42:38 +01:00
}
}