0.7.0 • Published 4 years ago

@dooboo-ui/native-edit-text v0.7.0

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

EditText

Npm Version Downloads

EditText component is an enhanced version on pure react-native TextInput component.

Preview

DefaultRow
underlinedunderlined_defaultunderlined_row
boxdefaultrow

Props

necessarytypesdefault
testIDstring
typestringunderlined
errorTestIDstring
isRowbooleanfalse
styleViewStyle
labelstring
labelTextStyleTextStyle
valueTextInputProps
inputContainerRadiusstring3
borderStyleViewStyle
borderWidthnumber0.6
borderColorstring#eaeaf9
inputLeftMarginnumber110
textStyleTextStyle
placeholderstring
placeholderTextColorstring
secureTextEntryboolean
onChangeText(e) => {}
onSubmitEditingfunc
leftElementReactElement
leftElementStyleViewStyle
rightElementReactElement
rightElementStyleViewStyle
textInputPropsTextInputProps
focusedLabelStyleTextStylefontWeight: 'bold'
focusedBorderWidthnumber1
focusColorstring#79B3F5
errorColorstring#FF8989
errorTextstring
errorTextStyleTextStyle

Installation

yarn add @dooboo-ui/native

or

yarn add @dooboo-ui/native-edit-text

Getting started

  • Import

    import { EditText } from '@dooboo-ui/native';
    // or
    import EditText from '@dooboo-ui/native-edit-text';
  • Usage

    function Page(props: Props) {
      const validateEmail = (email: string) => {
        const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
      };
    
      const fontStyle: TextStyle = {
        fontWeight: 'bold',
        fontSize: 13,
      };
    
      const [email, setEmail] = useState('');
      const [password, setPassword] = useState('');
      const [errorEmail, setErrorEmail] = useState('');
    
      const onSignIn = () => {
        if (!validateEmail(email)) {
          setErrorEmail('Not a valid email address');
        } else {
          setErrorEmail('');
        }
      };
    
      const onTextChanged = (type: string, text: string) => {
        type === 'EMAIL' ? setEmail(text) : setPassword(text);
    
        if (type === 'EMAIL' && text === '') {
          setErrorEmail('');
        }
      };
    
      return (
        <StyledScrollView
          contentContainerStyle={{
            marginTop: 8,
            paddingHorizontal: 20,
            paddingBottom: 40,
          }}
        >
          <Container>
            <HeaderTitle>Sign in with Email</HeaderTitle>
            <EditText
              testID="EMAIL_INPUT"
              textStyle={{
                color: '#495057',
              }}
              label="Email"
              placeholder="Write email address"
              placeholderTextColor="#ADB5BD"
              value={email}
              onChangeText={(text: string) => onTextChanged('EMAIL', text)}
              style={{ marginTop: 50 }}
              errorText={errorEmail}
              onSubmitEditing={onSignIn}
            />
            <EditText
              testID="PASSWORD_INPUT"
              textStyle={{
                color: '#ADB5BD',
              }}
              secureTextEntry={true}
              label="Password"
              placeholder="Please write your password"
              placeholderTextColor="#ADB5BD"
              value={password}
              onChangeText={(text: string) => onTextChanged('PASSWORD', text)}
              style={{ marginTop: 36 }}
              onSubmitEditing={onSignIn}
            />
            <StyledSignInButton
              testID="btnEmail"
              onPress={() => onSignIn()}
              textStyle={fontStyle}
              text="Login"
            />
            {/* Email SignUp text */}
            <View
              style={{
                marginTop: 20,
                flexDirection: 'row',
                justifyContent: 'center',
                alignItems: 'center',
              }}
            >
              <StyledText testID="NO_ACCOUNT">
                Do not have and account?{' '}
              </StyledText>
              <TouchableOpacity onPress={() => null} style={{ padding: 4 }}>
                <StyledAccentText>Find</StyledAccentText>
              </TouchableOpacity>
            </View>
          </Container>
        </StyledScrollView>
      );
    }
0.7.0

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago