Giter Club home page Giter Club logo

done-bar's Introduction

done-bar

NPM

A React Native component that dismisses the keyboard. Especially useful for the iOS numeric keyboard as there is no return or done button by default. Works in both landscape and portrait orientations.

Installation

npm install --save done-bar

Importation

import DoneBar from 'done-bar';

Usagation

  1. make sure the parent of DoneBar extends all the way to the bottom of the screen. Else DoneBar could possibly appear on the screen when the keyboard isn't visible.
  2. make sure to have a local (or redux) state to pass to DoneBar that indicates the type of keyboard currently being displayed. In order for DoneBar to display, the keyboardType prop passed to it must be numeric or blank (numeric by default)
  3. make sure your TextInputs set their keyboard type in state on their focus

Examplelation

export default class Example extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      keyboardType: 'default' // this is important
    };
  }
  render() {
    return (
      <KeyboardAvoidingView
        style={styles.container}
        behavior="padding" // this is important; currently only works when behavior is padding
        >
        <TextInput
          keyboardType="default"
          onFocus={() => this.setState({ keyboardType: 'default' })} // these are important
          style={styles.input}
        />
        <TextInput
          keyboardType="numeric"
          onFocus={() => this.setState({ keyboardType: 'numeric' })} // these are important
          style={styles.input}
        />
        <DoneBar
          keyboardType={this.state.keyboardType} // this is important
        />
      </KeyboardAvoidingView>
    );
  }
}

Props

prop type default
keyboardType string 'numeric'
includeLayoutAnimation boolean true

done-bar's People

Contributors

mileung avatar wchampi avatar

Watchers

 avatar  avatar

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.