aboutsummaryrefslogtreecommitdiff
path: root/src/components/common
diff options
context:
space:
mode:
authorJustin Shillingford <jgs272@cornell.edu>2020-06-29 19:36:50 -0400
committerJustin Shillingford <jgs272@cornell.edu>2020-06-29 19:36:50 -0400
commitff9dba9a4241a799970ef36866b595d6f6940531 (patch)
tree508ced0d2d508a20c06409ff5c4297d2506727a7 /src/components/common
parenta382ff32a0a6d6a15402c74e18ad471d9f689107 (diff)
Added validationWarnings to LoginInput component
Diffstat (limited to 'src/components/common')
-rw-r--r--src/components/common/LoginInput.tsx117
1 files changed, 64 insertions, 53 deletions
diff --git a/src/components/common/LoginInput.tsx b/src/components/common/LoginInput.tsx
index 12bf0b3c..ba519480 100644
--- a/src/components/common/LoginInput.tsx
+++ b/src/components/common/LoginInput.tsx
@@ -1,61 +1,66 @@
import React from 'react';
-import {TextInput, StyleSheet} from 'react-native';
+import {Text, TextInput, StyleSheet} from 'react-native';
import PropTypes from 'prop-types';
const LoginInput = (props: LoginInputProps) => {
return (
- <TextInput
- accessibilityLabel={
- props.isUsername
- ? 'Username text entry box'
- : props.isPassword
- ? 'Password text entry box'
- : undefined
- }
- accessibilityHint={
- props.isUsername
- ? 'Enter your tagg username here'
- : props.isPassword
- ? 'Enter your tagg password here'
- : undefined
- }
- style={styles.credentials}
- placeholder={
- props.isUsername
- ? 'Username'
- : props.isPassword
- ? 'Password'
- : undefined
- }
- placeholderTextColor="#FFFFFF"
- autoCompleteType={
- props.isUsername ? 'username' : props.isPassword ? 'password' : 'off'
- }
- textContentType={
- props.isUsername ? 'username' : props.isPassword ? 'password' : 'none'
- }
- returnKeyType={
- props.isUsername ? 'next' : props.isPassword ? 'go' : 'default'
- }
- keyboardType={
- props.isUsername
- ? 'ascii-capable'
- : props.isPassword
- ? 'default'
- : undefined
- }
- onChangeText={(input) => props.onChangeText(input)}
- defaultValue={props.type}
- onSubmitEditing={props.onSubmitEditing}
- blurOnSubmit={
- props.isUsername ? false : props.isPassword ? undefined : undefined
- }
- // ref={props.isUsername ? undefined : useRef()}
- secureTextEntry={
- props.isUsername ? false : props.isPassword ? true : false
- }
- // focus={props.isUsername ? undefined : props.focusPasswordInput}
- />
+ <>
+ <TextInput
+ accessibilityLabel={
+ props.isUsername
+ ? 'Username text entry box'
+ : props.isPassword
+ ? 'Password text entry box'
+ : undefined
+ }
+ accessibilityHint={
+ props.isUsername
+ ? 'Enter your tagg username here'
+ : props.isPassword
+ ? 'Enter your tagg password here'
+ : undefined
+ }
+ style={styles.credentials}
+ placeholder={
+ props.isUsername
+ ? 'Username'
+ : props.isPassword
+ ? 'Password'
+ : undefined
+ }
+ placeholderTextColor="#FFFFFF"
+ autoCompleteType={
+ props.isUsername ? 'username' : props.isPassword ? 'password' : 'off'
+ }
+ textContentType={
+ props.isUsername ? 'username' : props.isPassword ? 'password' : 'none'
+ }
+ returnKeyType={
+ props.isUsername ? 'next' : props.isPassword ? 'go' : 'default'
+ }
+ keyboardType={
+ props.isUsername
+ ? 'ascii-capable'
+ : props.isPassword
+ ? 'default'
+ : undefined
+ }
+ onChangeText={(input) => props.onChangeText(input)}
+ defaultValue={props.type}
+ onSubmitEditing={props.onSubmitEditing}
+ blurOnSubmit={
+ props.isUsername ? false : props.isPassword ? undefined : undefined
+ }
+ // ref={props.isUsername ? undefined : useRef()}
+ secureTextEntry={
+ props.isUsername ? false : props.isPassword ? true : false
+ }
+ // focus={props.isUsername ? undefined : props.focusPasswordInput}
+ />
+ {!props.isValid && (
+ <Text style={styles.invalidCredentials}>{props.validationWarning}</Text>
+ )}
+ </>
);
};
@@ -72,6 +77,10 @@ const styles = StyleSheet.create({
paddingLeft: 13,
marginVertical: 15,
},
+ invalidCredentials: {
+ top: 180,
+ color: '#F4DDFF',
+ },
});
LoginInput.propTypes = {
@@ -82,6 +91,8 @@ LoginInput.propTypes = {
onSubmitEditing: PropTypes.func,
// ref: PropTypes.any,
focusPasswordInput: PropTypes.bool,
+ isValid: PropTypes.bool,
+ validationWarning: PropTypes.string,
};
export default LoginInput;