Code Monkey home page Code Monkey logo

cnilton / react-native-floating-label-input Goto Github PK

View Code? Open in Web Editor NEW
260.0 3.0 58.0 711 KB

A customizable React Native TextInput with its placeholder always shown. Includes masks, global styles, character count, and a bunch else.

License: MIT License

JavaScript 3.26% TypeScript 62.15% Starlark 1.58% Java 17.36% Ruby 3.87% Objective-C 11.78%
mask floatinglabeltextfield floating customizable textinput react-native floating-label-input floating-label label

react-native-floating-label-input's People

Contributors

buxxe avatar canbyk avatar cnilton avatar dependabot[bot] avatar diego-franco avatar erheron avatar filipejuan avatar gamma169 avatar gsantiago avatar hrmoller avatar komod0 avatar kyonru avatar peterlazar1993 avatar psenechal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-floating-label-input's Issues

LabelStyle is overriden either if we use custom values

Right now, if I use LabelStyle with CustomLabelStyles the custom values are override by the defaultt values we have in the code. let me explain:

the code for style (LabelStyle) looks like:

 const style: TextStyle = {
    left: labelStyles?.left !== undefined ? labelStyles?.left : 10,
    fontSize: staticLabel? (customLabelStyles?.fontSizeFocused !== undefined ? customLabelStyles.fontSizeFocused : 10) : !isFocused
      ? customLabelStyles.fontSizeBlurred
      : customLabelStyles.fontSizeFocused,
    color: !isFocused
      ? customLabelStyles.colorBlurred
      : customLabelStyles.colorFocused,
    ...setGlobalStyles?.labelStyles,
    ...labelStyles,
    position: 'absolute',
    flex:1,
    zIndex: 999,
  };

We need to move ...labelStyles and ...setGlobalStyles?.labelStyles to the top and then override with custom values if we have it. Something like:

const style: TextStyle = {
    ...labelStyles,
    ...setGlobalStyles?.labelStyles,
    left: labelStyles?.left !== undefined ? labelStyles?.left : 10,
    fontSize: staticLabel? (customLabelStyles?.fontSizeFocused !== undefined ? customLabelStyles.fontSizeFocused : 10) : !isFocused
      ? customLabelStyles.fontSizeBlurred
      : customLabelStyles.fontSizeFocused,
    color: !isFocused
      ? customLabelStyles.colorBlurred
      : customLabelStyles.colorFocused,
    position: 'absolute',
    flex:1,
    zIndex: 999,
  };

this is a problem if we have labelStyles where fontSize value can be use it and fontSizeBlurred or fontSizeFocused it will be override by the labelStyles values.

Enable autoFocus for InputComponent

Right now we have setFocus function, but we don't have a way to set autoFocus for the input field, we can added because we have the TextInput props.

Problemas com leftFocused & topFocused

leftFocused & topFocused não fazem sentido se staticLabel for true, por que só teria left e top, não existiria focused nesse caso.

leftFocused & topFocused não funcionam no customLabelStyles se staticLabel for false, caso default dele.

customLabelStyles not working

Hi, thanks for this library!
So, the issue is customLabelStyles is expecting an object that can't really be matched, because it's expecting it's children's types to be the intended default values. When it receives the props on index.tsx it looks like this, when it should be specifying numbers and strings:
image

Then what happens in my code is I try to pass the values and this comes up:
image

Label tap focus issue

If we have two input fields in the same screen, and we tap in the label the first is focused, but if we try to focus the second one tapping in the label, the second input field is not focused immediately

it could be possible we need to do some logic in our side instead, but it was weird this is not happening if we click in the container (input box)

using the sample from the ReadMe

<FloatingLabelInput
	label="Login"
	value={appleValue}
	onChangeText={value => setAppleValue(value)} />
<FloatingLabelInput
	label="Login"
	value={appleValue}
	onChangeText={value => setAppleValue(value)} />
label_tap_issue.mov

Label behavior issue with text

Hello @Cnilton,

I'm using the latest version and I have issues with the label overlapping on the text both on ios and android (see videos), especially on ios where the label goes below and then on top of the text. Wouldn't it be preferable to remove the animation when the text input is filled?

Also label is focused when the text is empty (see picture).

Thanks

142293570_1488179231387871_6536176645881936061_n

android.mp4
ios.mp4

Label animation is not smooth

This is more a question/request, right now when the input field is not focused and gain the focus, we're just changing the fontSize of the label and then we use translateX and translateY.

could be possible to add a scale for the fontSize? then the animation will look smoother.

I'm trying to make it work on my side, but if anyone can help with this too would be nice

TypeError: undefined is not an object (evaluating '_reactNativeReanimated.EasingNode.linear'

Hello, I am trying to use this library but it keeps crashing and giving an error
---TypeError: undefined is not an object (evaluating '_reactNativeReanimated.EasingNode.linear')
Saying the issues is in \node_modules\react-native-floating-label-input\src\index.tsx with code line 439
and node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js line 15561.
Can any one help me out

ispassword= true is not working in android

<FloatingLabelInput
label="Password"
value={password}
isFocused={isPassFocused}
labelStyles={{ color: isPassFocused ? '#B6254E' : '#333333', fontSize: wp("4%"), marginLeft: 25 }}
containerStyles={{ borderWidth: 0, paddingLeft: 35, height: wp("15%"), }}
onFocus={() => {
setIsPassFocused(true);
}}
onBlur={() => {
password === '' && setIsPassFocused(false);
}}
isPassword={true}
inputStyles={{ borderBottomWidth: 0, borderBottomColor: 'grey' }}
onChangeText={value => setPassword(value)}
/>

Upgrade reanimated to version 2

I propose reanimated upgrade to version 2. To do that all usages of Easing have to be changed into EasingNode. To keep compatibility I would propose to publish

  • library for reanimated 2 as 2.x.x
  • library for reanimated 1 as 1.x.x.

This way it would be possible to use it with both versions.

Additionally I think it would be a good idea to clean the released files - delete:

  • eslint config
  • prettier
  • watchman
  • app.json
  • jest
  • babel
  • metro

from the released package.

Overriding onBlur and onFocus blocks label animation

Using:

const { isFocused } = this.state;
<FloatingLabelInput
	ref={this.inputRef}
	label={placeholder}
	value={value}
	isFocused={isFocused}
	onChangeText={this.onChangeText}
	onFocus={this.onFocus}
	onBlur={this.onBlur} />

it blocks the animation for the label and it doesn't move at all

No podspec file was found.

I install version ^4.2.0 and when pod install, I receive this message.
use_native_modules! skipped the react-native dependency 'react-native-floating-label-input'. No podspec file was found.
- Check to see if there is an updated version that contains the necessary podspec file
- Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven
podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec

Android and iOS device border textfiled need to lable and textinput center align

Hello team, I am using this plugon in my project and i used rounded border textfield in my whole app. My actual UI is as below
Screenshot 2021-04-29 at 12 04 14 PM

But currently in my application i got below textfiled with bottom gap
AA

Below is my code for my textfield
<View style={{ marginTop: 10 }}>
<FloatingLabelInput
label={"FirstName}
value={firstName}
onChangeText={(value) => {
this.setFirstName(value)
}}
labelStyles={{
fontFamily: globals.ProximaNovaRegular,
color: 'black',
marginLeft:(Platform.OS == 'ios') ? -5 : 0
}}
/>

For tectfield border i change style as below in plugin style.js
container: {
flexDirection: 'row',
color: colors.darkWarmGrey,
borderColor: colors.darkWarmGrey,
borderWidth: 1,
borderRadius: 30,
paddingTop:(Platform.OS==='android') ? 0 : 5,
paddingLeft:20,
paddingRight:20,
paddingBottom:(Platform.OS==='android') ? 0 : 5,
marginTop:(Platform.OS==='android') ? 5 : 5,
alignContent: 'center',
justifyContent: 'center',
},

Any idea how I can make center align both as i want in real desgin

conflicts with react-native-reanimated

Animated node with ID 2 already exists, thats the error i get whenever i try to use this package in my react native project already having the react-native-reanimated package. something about two instances of reanimated

Enhancement - Enable multiline to create autosize textarea

While I was looking through your code, I realized how incredibly easy it would be to make a small alteration to enable your library to also become an autosizing Textarea control.

I added a new attribute to Props interface in index.tsx at line 71

  isMultiline?: true | false | undefined;

and then applied that attribute to the TextInput at line 318

        multiline={props.multiline}

instant autosizing textarea using floating label and I don't have to roll my own. I even added a nifty "### characters left" on mine.

Just thought I would throw that out there in case you were interested in expanding the libraries functionality. I can create pull request with the changes if you like. Thanks =)

Use hint prop when non staticLabel is use it

Right now, the prop hint is only use it when staticLabel is used in the code, we can use hint too when we use the normal floating label, for example:

Entering a date or birth we should display date of birth in the label and the hint could be mm/dd/yyyy to explain the users the input format.

Currency format not working well

I'm typing "100" and It stucks on "1,00" format.
(I make currencyDivider=".")

To change 1,00 to 100,00, I have to click on begining of the input and start typing.
But that's not good for UX.

How can I use it well?

not working with reanimated2

when using reanimated2 the app crash,
animated node with id 2 already
please make a version with reanimated2 dependency

onBlur is not working

hi , thanks for the wonderful library ...it helped a lot. But in this library onBlur is not working . I want to validate the entered input when the input field gets out of focus. Actually we can acheive this using onBlur for normal input field , but i am not able to find any props to achieve this in this library .

is there any prop to achieve this...Please help me out with this.

Vertically aligning text in multirow field

Hi
Maybe it's just me not understanding how to do it, but i can not make the text in a multiline input field align top. It is always centered vertically. How can i adjust this?

How to maximize width of container?

Screen Shot 2020-11-13 at 9 17 39 AM

I want my input container to not have any spaces on the sides. How to achieve this?
I have added margin:0 and padding: 0 in containerStyles but doesnt work

thanks

Add prop for show/hide password passing a prop

Imagine we have a password field filled by default, and you want to show/hide when you present it into the screen, this probably is a unique case, but could be use it for different situations

Floating Label is not centered in the container

Looks like the Floating label is not center either if We pass styles or we use the default values.

As we can see in the "login" input is still not centered

Screen Shot 2020-12-08 at 4 48 09 PM

Code for the previous image:

<FloatingLabelInput
	placeholder="Enter a fruit name"
	showErrorMessage={messages.showError}
	value={value}
	onChangeText={onChangeText}
        containerStyles={containerStyle}
	labelStyles={styles.labelStyle}
	inputStyles={styles.inputStyle}
	customLabelStyles={CUSTOM_LABEL_STYLE} />
<FloatingLabelInput
	label="Login"
	value={value}
	onChangeText={nValue => setValue(nValue)}
	customLabelStyles={CUSTOM_LABEL_STYLE}/>

Styles code:

const CUSTOM_LABEL_STYLE = {
	fontSizeFocused: 12,
	fontSizeBlurred: 16,
	colorBlurred: 'grey',
	colorFocused: 'grey',
	leftFocused: 0,
	leftBlurred: 0,
	topFocused: 0,
	topBlurred: 0,
};
container: {
		height: 64,
		borderWidth: 2,
		borderRadius: 8,
		alignContent: 'center',
		paddingVertical: 8,
		paddingHorizontal: 16
	},
labelStyle: {
		left: 0, 
		marginLeft: 8
	},
inputStyle: {
		color: 'black',
	},

mask and maskType

I have a question about using mask and maskType.
I want to use the text input for credit card input, I set the maskType to 'card', but what should be the mask for the card?
I want it to appear divided into groups of 4 digits. Can I achieve it with the properties?

Animation

Hello...thanks for writing this library!

I noticed in the GIF example you have on the README, the labels do a nice little animated bounce when the input field is clicked on. In my implementation, I don't see that animation...the labels just instantly jump to their position. Is there some additional configuration I can add to duplicate the animation effect that you have in your GIF example?

Thanks =)

'alignItems' container style breaks the input fields

Hi!
When you place FloatingLabelInputs inside a View container which has the alignItems style set to something different than 'stretch' (default), these inputs don't work properly. They are very narrow, placeholders go out of borders and the user input itself isn't visible.
I've tried setting width for the inputs to fix it, but it doesn't solve the issue - entered text gets cropped and is still not visible.

On the image below, the password field has it's style set to width: '80%' and the style of the container View is set to alignItems: 'center'
floating-labels-input-bug

RTL support

What if I want the floating label to be on the right side for hebrew/arabic?
I tried to play with containerStyles, labelStyles and inputStyles, but I couldn't set the label to appear from the right.
Does this library support rtl, how can I achieve it?

Edit:
The only way I could put the label on the right is this styling:
labelStyles={{width:'100%', textAlign:'right'}}

But I'm not sure this is the correct way to do it.

Typescript issue with opacity value

in the Line 350, we have opacity props, in Typescript is returning a warning, this is the warning:

Type 'number | AnimatedInterpolation' is not assignable to type 'number | undefined'.
  Type 'AnimatedInterpolation' is not assignable to type 'number'

The expected type comes from property 'opacity' which is declared here on type 'TextStyle'

Can't disabled input when it contains default value

Hi,
I used editable={false} and selectTextOnFocus={false} but it doesn't work if input was set default value (I set default value from previous screen props at mounted using UseEffect)

Please help me to check this case. thanks so much

Default show/hide-password image conflicting with custom behaviour.

@Cnilton - Here on line 457 this is what is currently in index.tsx:

457  let imgSource = darkTheme
458    ? secureText
459      ? customShowPasswordImage || makeInvisibleBlack
460      : customHidePasswordImage || makeVisibleBlack
461    : secureText
462    ? customShowPasswordImage || makeInvisibleWhite
463    : customHidePasswordImage || makeVisibleWhite;

On line 459 we have our customShowPasswordImage but if it doesn't exist we have the 'makeInvisible' default image. This is conflicting, they should both be an image to 'show password'. Consequently lines 460, 462, 463 should change too.

Proposed changes:

457  let imgSource = darkTheme
458    ? secureText
459      ? customShowPasswordImage || makeVisibleBlack
460      : customHidePasswordImage || makeInvisibleBlack
461    : secureText
462    ? customShowPasswordImage || makeVisibleWhite
463    : customHidePasswordImage || makeInvisibleWhite;

Make Component Props public

Right now we have interface Props in the component, if people is going to use this component and want to extends from this, we should be able to export the props instead of copying in the code.

We have: interface Props extends TextInputProps

We can create: export interface FloatinLabelInputProps extends TextInputProps

Enhancement: Update Currency Mask Rules

I noticed the currency mask allows multiple decimals and the number of decimal places is also not limited.

I think it would help to only allow one use of the decimal and default the number of decimal places to 2 with an override available for currencies that have zero or 3.

I might see if I can work up a pull request for this if I have time.

Use string instead of images for password field

Right now in the Readme file you have

import showPassword from '../assets/images/yourImage';
import hidePassword from '../assets/images/yourImage2';
// ...
<FloatingLabelInput
  label="Password"
  value={password}
  isPassword={true}
  onChangeText={text => setPassword(text)}
  customShowPasswordImage={showPassword}
  customHidePasswordImage={hidePassword}
/>

Where We need to pass an image when a password field is used, can we add new params and use strings ( component) instead? something like Show and Hide could be use it.

How to remove border and keep only underline bottom border

Hi. I've just discovered your component. On your home page you are displaying simple usages of this component.
I'm trying to get this look (just the underline bottom border):

image

The default look of the component is the full border. Is there a flag I should toggle or should I apply some styling? It is not clear from the documentation.

Thanks for your assistance

`fontSize` and `fontColor` not being recognized in `labelStyles` and `inputStyles` props

Before I start complaining, this is a great package that really filled a void for us.
However there are two seemingly minor but very problematic issues.

  1. Problem with some styles in the labelStyles prop not being recognized:

Here's our component code :

      <FloatingLabelInput
        labelStyles={{
          fontFamily: loaded ? "poppins-medium" : null,
          fontSize: 16,
          color: "#BDBDBD",
        }}
        inputStyles={{
          fontFamily: loaded ? "poppins-medium" : null,
          fontSize: 16,
          color: "#666666",
        }}
        label={title}
        value={text}
        onChangeText={(value) => setText(value)}
      />

The fontFamily in the labelStyles prop is being read correctly, but the fontSize and color attributes are not reflected in the app, font color and size remain at default values - 14px and dark grayish blue. At the same time both font size and color from the inputStyles are correctly reflected in the user input text.

  1. When setting the same styles to globalStyles.js they are not being read at all, and the color of the user input defaults to the focused label color for some reason. The containerStyles are read globally and locally just fine.

Please advise! Thanks in advance

Textinput text overlap in Android Modal

Hi team, i used thi splugin for floating effect in my textinput and i used it latest version 1.3.5 but i afce issue like when i have pre defined text in textinput it will be overlap like below screenshots

Android

My code as below

<FloatingLabelInput
label={textTranslation.shippingAddress.FLATNAME}
value={flateName}
onChangeText={(value) => {
this.setState({ flateName: value });
}}
labelStyles={{
fontFamily: globals.ProximaNovaRegular,
color: colors.darkWarmGrey,
}}
/>

Any idea how i can solve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.