const React = require('react'); const { Component } = require('react'); const { StyleSheet, FlatList, View, Button, Text, TouchableOpacity, Platform } = require('react-native'); const { Navigation } = require('react-native-navigation'); const testIDs = require('../testIDs'); const ITEMS = []; for(let i = 0; i < 200; i++) { ITEMS.push({key: `Item ${i}`}); } class SearchScreen extends Component { static options() { return { topBar: { title: { text: 'Search' }, largeTitle: { visible: true }, searchBar: true, background: { translucent: true }, searchBarPlaceholder: 'Start Typing', hideNavBarOnFocusSearchBar: false } }; } constructor(props) { super(props); this.state = { query: '' }; Navigation.events().bindComponent(this); } filteredData() { return ITEMS.filter( item => this.state.query.length === 0 || item.key.indexOf(this.state.query) > -1 ); } highlight(text, query) { if (query.length > 0 && text.indexOf(query) > -1) { const before = text.split(query)[0]; const after = text.split(query)[1]; return ( {before} {query} {after} ); } return text; } onItemPressed = () => { Navigation.push(this.props.componentId, { component: { name: 'navigation.playground.PushedScreen', options: { topBar: { title: { text: 'PushedScreen' }, largeTitle: { visible: true }, background: { translucent: true } } } }, }); } render() { return ( ( {this.highlight(item.key, this.state.query)} )} /> ); } searchBarUpdated({text, isFocused}) { this.setState({ query: text, isFocused }); } } module.exports = SearchScreen; const styles = StyleSheet.create({ contentContainer: {}, row: { height: 60, padding: 15, justifyContent: 'center' }, rowText: { fontSize: 18 } });