0.1.0 • Published 6 years ago

react-native-animated-button-textinput v0.1.0

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

react-native-animated-button-textinput

A react-native component for animating button to text-input

Install

npm install react-native-animated-button-textinput;

and then in your code :

import { AnimatedButtonTextInput } from "react-native-animated-button-textinput";

And then :

<AnimatedButtonTextInput
  rightButtonContent={() => (
    <Text style={{ fontWeight: "bold", color: "white" }}>Send</Text>
  )}
  rightButtonProps={{
    style: {
      backgroundColor: "green",
      height: 32,
      paddingHorizontal: 10,
      borderRadius: 20,
      justifyContent: "center",
      alignItems: "center",
      marginRight: 4
    }
  }}
  collapsedContent={() => <Text>Send</Text>}
  onExpandedPress={() => console.log("hello world")}
  textInputProps={{
    onChangeText: text => console.log(text)
  }}
/>

API

This component doesn't use native drivers for animationns since it anitmates width and height which is not supported by native drivers in react-native right now.

Note :

  • Collapsed means when the component is in "button only" mode
  • Expanded means when the component is in "text input" mode
Props nameTypeDescription
animationDurationnumberDuration of the animations
collapsedWidthnumberWidth of the button when collapsed
collapsedHeightnumberHeight of the button when collapsed
expandedWidthnumberWidth of the button when expanded
expandedHeightnumberHeight of the button when expanded
collapsedContent() => React.ReactNodeContent inside the button when collapsed
collapsedPropsViewPropsProps of Touchable when collapsed
rightButtonContent() => React.ReactNodeContent inside the right button when expanded
rightButtonPropsTouchableOpacityPropsProps of the right button when expanded
textInputPropsTextInputPropsProps of the left text input when expanded
componentPropsViewPropsProps of the component shared between collaspsed and expanded
onCollapsedPress() => voidFunction called when the button is pressed when collapsed
onExpandedPress() => voidFunction called when the right button is pressed when expanded

Credits

Thanks to Jason Brown for providing the idea of this component

Licence

MIT

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago