Skip to content

Commit

Permalink
Changing connectToState function nonsense.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tj committed Jun 15, 2017
1 parent ffb64b3 commit 3e2f4d5
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 217 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./src/";
export { CreditCardInput } from "./src/CreditCardInput.js";
52 changes: 51 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "react-native-credit-card-input",
"version": "0.3.3",
"description": "React native credit card input component",
"main": "index.js",
"main": "./src/CreditCardInput.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint --ext .js ."
Expand Down Expand Up @@ -47,5 +47,55 @@
"eslint": "~2.2.0",
"eslint-config-airbnb": "6.0.2",
"eslint-plugin-react": "^4.2.0"
},
"react-native": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify"
},
"browser": {
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"http": "react-native-http",
"https": "https-browserify",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tty": "tty-browserify",
"vm": "vm-browserify"
}
}
56 changes: 28 additions & 28 deletions src/CCInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export default class CCInput extends Component {
}

_onFocus() {
this.props.onFocus(this.props.field);
setTimeout(() => {
this.props.onFocus(this.props.field);
}, 50);
}

_onChange(value) {
Expand All @@ -82,33 +84,31 @@ export default class CCInput extends Component {
validColor, invalidColor, placeholderColor } = this.props;

return (
<TouchableOpacity onPress={this.focus}
activeOpacity={0.99}>
<View style={[containerStyle]}>
{ !!label && <Text style={[labelStyle]}>{label}</Text>}
<TextInput ref={(ref) => {this.input = ref}}
autoFocus={(field == "number")}
keyboardType={keyboardType}
returnKeyType={keyboardType === 'numbers-and-punctuation' ? "done" : "default"}
autoCapitalise="words"
autoCorrect={false}
style={[
s.baseInputStyle,
inputStyle,
((validColor && status === "valid") ? { color: validColor } :
(status !== "valid" && field === "number" && (value.length > 0 && value.match(/\d/g).length >= 16)) ? { color: invalidColor } :
(invalidColor && status === "invalid") ? { color: invalidColor } :
{}),
]}
underlineColorAndroid={"transparent"}
placeholderTextColor={placeholderColor}
placeholder={placeholder}
value={value}
onFocus={this._onFocus.bind(this)}
onChangeText={this._onChange.bind(this)}
onSubmitEditing={(event) => {this.props._handleSubmit();}}/>
</View>
</TouchableOpacity>
<View onPress={this.focus}
style={containerStyle}>
{ !!label && <Text style={[labelStyle]}>{label}</Text>}
<TextInput ref={(ref) => {this.input = ref}}
autoFocus={(field == "number")}
keyboardType={keyboardType}
returnKeyType={keyboardType === 'numbers-and-punctuation' ? "done" : "default"}
autoCapitalise="words"
autoCorrect={false}
style={[
s.baseInputStyle,
inputStyle,
((validColor && status === "valid") ? { color: validColor } :
(status !== "valid" && field === "number" && (value.length > 0 && value.match(/\d/g).length >= 16)) ? { color: invalidColor } :
(invalidColor && status === "invalid") ? { color: invalidColor } :
{}),
]}
underlineColorAndroid={"transparent"}
placeholderTextColor={placeholderColor}
placeholder={placeholder}
value={value}
onFocus={this._onFocus.bind(this)}
onChangeText={this._onChange.bind(this)}
onSubmitEditing={(event) => {this.props._handleSubmit();}}/>
</View>
);
}
}
Loading

0 comments on commit 3e2f4d5

Please sign in to comment.