forked from bdryanovski/react-native-writebox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
72 lines (61 loc) · 1.62 KB
/
Copy pathApp.js
File metadata and controls
72 lines (61 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import { StyleSheet, Text, View, FlatList } from 'react-native';
import Writebox from 'react-native-writebox'
import faker from 'faker'
const NUMBER_OF_ITEMS = 20
export default class App extends React.Component {
renderItem(item) {
const color = this.randomColor();
return (
<View style={ [ styles.item, { backgroundColor: color } ] }>
<Text key={item}>
{ faker.lorem.paragraphs() }
</Text>
</View>
)
}
randomColor() {
let letters = '0123456789ABCDEF';
let color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
render() {
const items = new Array(NUMBER_OF_ITEMS).fill(1).map((value, index) => { return index + 1 })
return (
<Writebox
inputLimit={150}
onFocus={ () => { console.log('Input is on focus ...') } }
onBlur={ () => { console.log('Input lost focus ...') } }
onSubmit={ (data) => { console.log('Input submit ', data) } }
submitLabel={ 'Send' }
placeholder={ 'Write here ...' }
clearOnSubmit={ true }
>
<View style={styles.container}>
<FlatList
data={ items }
keyExtractor={ item => item }
renderItem={this.renderItem.bind(this)}
/>
</View>
</Writebox>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
item: {
margin: 5,
padding: 10,
borderRadius: 10,
borderColor: '#FFFFFF',
}
});