import React from 'react'
import { View, TextInput, StyleSheet } from 'react-native'
import Button from '../components/Button'

// redux
import { bindActionCreatorsExt } from '../utils/bindActionCreatorsExt'
import { connect } from 'react-redux'
import { ActionCreators } from '../actions'

class LoginPrivateKey extends React.Component {
    _walletLogin() {
        let privateKey = this.txtPrivateKey._lastNativeText
        this.props.wallet.loginWithPrivateKey(privateKey)
    }

    render() {
        return (
            <View style={styles.container}>
                <View style={styles.loginForm}>
                    <TextInput
                        ref={txtInput => {
                            this.txtPrivateKey = txtInput
                        }}
                        multiline={false}
                        placeholder="Enter your private key (WIF) here"
                        placeholderTextColor="#636363"
                        returnKeyType="done"
                        style={styles.inputBox}
                        autoCorrect={false}
                        secureTextEntry={true}
                    />
                    <Button title="Login" onPress={this._walletLogin.bind(this)} />
                </View>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1
    },
    inputBox: {
        marginHorizontal: 20,
        marginVertical: 5,
        paddingLeft: 10,
        height: 30,
        fontSize: 14,
        backgroundColor: '#E8F4E5',
        color: '#333333'
    },
    loginForm: {
        marginTop: 5
    }
})

function mapStateToProps(state, ownProps) {
    return {}
}

const mapDispatchToProps = dispatch => {
    return bindActionCreatorsExt(ActionCreators, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(LoginPrivateKey)

@@ -119,16 +119,73 @@
 /Button'
+%0Aimport %7B DropDownHolder %7D from '../utils/DropDownHolder'
 %0A%0A// red
@@ -341,16 +341,64 @@
 tions'%0A%0A
+import %7B getPrivateKeyFromWIF %7D from 'neon-js'%0A%0A
 class Lo
@@ -437,16 +437,421 @@
 onent %7B%0A
+    _isValidWIF(wif) %7B%0A        const ENCODING_ERROR = -1%0A        const WIF_VERIFICATION_FAILED = -2%0A        let result = false%0A%0A        if (wif != undefined && wif.length == 52) %7B%0A            const response = getPrivateKeyFromWIF(wif)%0A%0A            if (response != ENCODING_ERROR && response != WIF_VERIFICATION_FAILED) %7B%0A                result = true%0A            %7D%0A        %7D%0A%0A        return result%0A    %7D%0A%0A
     _wal
@@ -923,16 +923,64 @@
 iveText%0A
+        if (this._isValidWIF(privateKey)) %7B%0A    
         
@@ -1029,16 +1029,131 @@
 ateKey)%0A
+        %7D else %7B%0A            DropDownHolder.getDropDown().alertWithType('error', 'Error', 'Invalid key')%0A        %7D%0A
     %7D%0A%0A 

Add validation checks to WIF login