From b9cd266f82a702ab7cf6a18816b47b6363e2e8d1 Mon Sep 17 00:00:00 2001 From: markus Date: Thu, 26 Oct 2017 07:40:54 +0800 Subject: [PATCH] Updated README --- README.md | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b56d35c..bc6a039 100644 --- a/README.md +++ b/README.md @@ -14,14 +14,14 @@ React Native search component with filter function. Complete example available [here](/example). ```js -import React from 'react' -import { StyleSheet, Text, View, ScrollView } from 'react-native' -import SearchInput, { createFilter } from 'react-native-search-filter' -import emails from './mails' -const KEYS_TO_FILTERS = ['user.name', 'subject'] - -export default class App extends React.Component { - constructor(props) { +import React, { Component } from 'react'; +import { StyleSheet, Text, View, ScrollView, TouchableOpacity } from 'react-native'; +import SearchInput, { createFilter } from 'react-native-search-filter'; +import emails from './mails'; +const KEYS_TO_FILTERS = ['user.name', 'subject']; + +export default class App extends Component<{}> { + constructor(props) { super(props); this.state = { searchTerm: '' @@ -34,14 +34,20 @@ export default class App extends React.Component { const filteredEmails = emails.filter(createFilter(this.state.searchTerm, KEYS_TO_FILTERS)) return ( - { this.searchUpdated(term) }} /> + { this.searchUpdated(term) }} + style={styles.searchInput} + placeholder="Type a message to search" + /> {filteredEmails.map(email => { return ( - - {email.user.name} - {email.subject} - + alert(email.user.name)} key={email.id} style={styles.emailItem}> + + {email.user.name} + {email.subject} + + ) })} @@ -54,16 +60,20 @@ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', - justifyContent: 'flex-start', - margin: 10, - marginTop: 50 + justifyContent: 'flex-start' }, emailItem:{ borderBottomWidth: 0.5, - borderColor: 'rgba(0,0,0,0.3)' + borderColor: 'rgba(0,0,0,0.3)', + padding: 10 }, emailSubject: { color: 'rgba(0,0,0,0.5)' + }, + searchInput:{ + padding: 10, + borderColor: '#CCC', + borderWidth: 1 } }); ```