Skip to content

Commit 29dd8a8

Browse files
committed
created Kohana
1 parent a6eac8f commit 29dd8a8

File tree

4 files changed

+111
-2
lines changed

4 files changed

+111
-2
lines changed

Example/TextInputEffectsExample.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Madoka,
1515
Akira,
1616
Hideo,
17+
Kohana,
1718
} from 'react-native-textinput-effects';
1819

1920
export default class TextInputEffectsExample extends Component {
@@ -61,10 +62,18 @@ export default class TextInputEffectsExample extends Component {
6162
borderColor={'#7A7593'}
6263
/>
6364
<Hideo
65+
style={styles.input}
6466
iconClass={FontAwesomeIcon}
6567
iconName={'envelope'}
6668
iconColor={'white'}
6769
/>
70+
<Kohana
71+
style={styles.input}
72+
label={'Phone'}
73+
iconClass={FontAwesomeIcon}
74+
iconName={'phone'}
75+
iconColor={'#ddd'}
76+
/>
6877
</ScrollView>
6978
);
7079
}

lib/Hideo.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ export default class Akira extends BaseInput {
3131
* Passed to react-native-vector-icons library as color prop
3232
*/
3333
iconColor: PropTypes.string,
34-
height: PropTypes.number,
3534
};
3635

3736
static defaultProps = {
@@ -48,7 +47,6 @@ export default class Akira extends BaseInput {
4847
iconName,
4948
iconBackgroundColor,
5049
style: containerStyle,
51-
height: inputHeight,
5250
inputStyle,
5351
} = this.props;
5452
const {

lib/Kohana.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import React, { PropTypes, Component } from 'react';
2+
import {
3+
Animated,
4+
Easing,
5+
Text,
6+
TextInput,
7+
TouchableWithoutFeedback,
8+
View,
9+
StyleSheet,
10+
} from 'react-native';
11+
12+
import BaseInput from './BaseInput';
13+
14+
export default class Kohana extends BaseInput {
15+
16+
static defaultProps = {
17+
easing: Easing.bezier(0.2, 1, 0.3, 1),
18+
};
19+
20+
render() {
21+
const {
22+
iconClass: Icon,
23+
iconColor,
24+
iconName,
25+
label,
26+
style: containerStyle,
27+
inputStyle,
28+
labelStyle,
29+
} = this.props;
30+
const { focusedAnim, value } = this.state;
31+
32+
return (
33+
<View style={[containerStyle, styles.container]} onLayout={this._onLayout}>
34+
<TouchableWithoutFeedback onPress={this._focus}>
35+
<Animated.View style={{
36+
justifyContent: 'center',
37+
padding: 16,
38+
marginLeft: focusedAnim.interpolate({
39+
inputRange: [0, 1],
40+
outputRange: [-40, 0],
41+
}),
42+
}}>
43+
<Icon
44+
name={iconName}
45+
color={iconColor}
46+
size={25}
47+
/>
48+
</Animated.View>
49+
</TouchableWithoutFeedback>
50+
<TouchableWithoutFeedback onPress={this._focus}>
51+
<Animated.View style={{
52+
position: 'absolute',
53+
left: focusedAnim.interpolate({
54+
inputRange: [0, 1],
55+
outputRange: [0, 80],
56+
}),
57+
opacity: focusedAnim.interpolate({
58+
inputRange: [0, 1],
59+
outputRange: [1, 0],
60+
}),
61+
}}>
62+
<Text style={[styles.label, labelStyle]}>
63+
{label}
64+
</Text>
65+
</Animated.View>
66+
</TouchableWithoutFeedback>
67+
<TextInput
68+
ref="input"
69+
{...this.props}
70+
style={[styles.textInput, inputStyle]}
71+
value={value}
72+
onBlur={this._onBlur}
73+
onFocus={this._onFocus}
74+
onChange={this._onChange}
75+
/>
76+
</View>
77+
);
78+
}
79+
}
80+
81+
const styles = StyleSheet.create({
82+
container: {
83+
flex: 1,
84+
flexDirection: 'row',
85+
backgroundColor: 'white',
86+
},
87+
label: {
88+
padding: 16,
89+
fontSize: 18,
90+
fontFamily: 'Arial',
91+
fontWeight: 'bold',
92+
color: '#D2D2D2',
93+
},
94+
textInput: {
95+
flex: 1,
96+
paddingHorizontal: 16,
97+
color: 'black',
98+
fontSize: 18,
99+
},
100+
});

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Isao from './Isao';
55
import Madoka from './Madoka';
66
import Akira from './Akira';
77
import Hideo from './Hideo';
8+
import Kohana from './Kohana';
89

910
export {
1011
Kaede,
@@ -14,4 +15,5 @@ export {
1415
Madoka,
1516
Akira,
1617
Hideo,
18+
Kohana,
1719
};

0 commit comments

Comments
 (0)