UNPKG

5.94 kBMarkdownView Raw
1# react-native-custom-keyboard-mroads
2
3![](updatedGif.gif)
4
5This is a Custom keyboard which can be used in a React Native project for text input. This keyboard comes with few inbuilt features which is commonly not available with the device keyboard.
6
7The keyboard has the following features:
8
91. There are 6 sizes supported which can be used as per the requirement in different screens and different components namely "xsmall", "small", "medium", "large", "xlarge" and "xxl". The default size is set to large. Refer the below snippet to get comfortable with the syntax of using size. This is an optional prop.
10```bash
11<Keyboard size="large" />
12```
13
142. The keyboard presently comes with two different themes namely "light" and "dark" which can be adjusted at any point of time simply by passing the theme as a prop. This is again an optional prop.
15
16```bash
17<Keyboard theme="dark" />
18```
19
203. Two input formats are currently available with the keyboard. The inputType prop could be set either to "email" or "text". When set to "email", we get some domain suggestions which can be used handy. An optional prop again.
21
22```bash
23<Keyboard inputType="email" />
24```
25
26NOTE: Make sure you are passing the exact names mentioned above as prop when choosing different size, theme and inputType. The keyboard needs to have the two required props along with the other optional props. Refer the below table for more details.
27
28## Installation
29
30Use the package manager to install.
31
32```bash
33`$ npm install react-native-custom-keyboard-mroads --save`
34```
35 or
36
37```bash
38`$ yarn add react-native-custom-keyboard-mroads`
39```
40
41## Usage
42
43### Props
44##### Props you need to pass while implementing.
45
46| Prop | Required| Default | Type | Description |
47| :---------------- | :-------------: | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------- |
48| theme | False | dark | `String` | Determines the theme of the keyboard, either 'Dark' or 'Light'.|
49| size | False | xlarge | `String` | Determines the size of the keyboard. |
50| input type | False | text | `String` | Determines the type of the input you require. Is either 'email' or 'text'. |
51| onInput | True | () => {} | `Function` | Called when there is a text change on keyboard button press. |
52| value | True | - | String | The value entered using the keyboard. |
53|disableEnterButton | False | false | Boolean | The enter or return button on keyboard can be disaled when required. |
54|disableCapsLock | False | false | Boolean | Removes the Caps lock button on the keyboard when passed as true. |
55|keysToDisable | False | [] |Array | The characters passed to this props as array will remove them from the keyboard. Thus, giving flexibility of choosing buttons visibility on keyboard. The characters passed should all be in lowercase. |
56
57### Sizes Available
58| xsmall | small | medium | large | xlarge | xxl |
59| :------------- | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------- |:------------- |:------------- |
60### Theme Available
61| dark | light |
62| :------------- | :-------------: |
63
64
65### Basic
66```javascript
67
68import React from 'react';
69import Keyboard from 'react-native-custom-keyboard-mroads';
70
71state = {
72 textContent: '',
73};
74
75changeTextHandler = value => {
76 this.setState({ textContent: value });
77 }
78
79class MyKeyboard extends React.Component() {
80 render(){
81 return (
82 <Keyboard
83 onInput={this.changeTextHandler}
84 value={this.state.textContent}
85 />
86 );
87 }
88 }
89
90export default MyKeyboard;
91```
92
93### Advanced
94```javascript
95
96import React from 'react';
97import Keyboard from 'react-native-custom-keyboard-mroads';
98import { StyleSheet, SafeAreaView, Text, View, } from 'react-native';
99
100class MyKeyboard extends React.Component{
101
102 state = {
103 textContent: '',
104};
105
106changeTextHandler = value => {
107 this.setState({ textContent: value });
108}
109
110 render(){
111
112 return (
113 <>
114 <SafeAreaView>
115 <View style={styles.mainView}>
116 <View style={styles.keyboardWrapper}>
117 <View style={styles.enteredTextContainer}>
118 <Text style={styles.enteredText}>{this.state.textContent}</Text>
119 </View>
120 </View>
121 <View style={{ justifyContent: 'flex-end', width: 'auto', height: '65%' }}>
122 <Keyboard
123 onInput={this.changeTextHandler}
124 inputType="email"
125 size="xlarge"
126 theme="dark"
127 value={this.state.textContent}
128 disableEnterButton /* Disables the enter button on keyboard */
129 disableCapsLock /* Disables the Caps Lock button.*/
130 keysToDisable={['!', '?', '@']} /* Removes !, ? and @ from the keyboard. */
131 />
132 </View>
133 </View>
134 </SafeAreaView>
135 </>
136 );
137 }
138}
139
140const styles = StyleSheet.create({
141 mainView: {height: '100%', justifyContent: 'space-between', alignItems: 'center', padding: 7 },
142 keyboardWrapper: { width: '100%', height: '15%' },
143 enteredTextContainer: { width: '100%', height: 60, backgroundColor: '#EEEEEE', justifyContent: 'center', alignItems: 'center'},
144 enteredText: { width: '100%', textAlign: 'center', fontSize: 25},
145});
146
147export default MyKeyboard;
\No newline at end of file