diff --git a/example/App.js b/example/App.js index 892e5bf..1565c0f 100644 --- a/example/App.js +++ b/example/App.js @@ -1,69 +1,65 @@ import React, { Component } from 'react'; -import { Button, View, StyleSheet, ScrollView, Text, TouchableOpacity } from 'react-native'; +import { Button, View, StyleSheet, ScrollView, Text, TouchableOpacity, TouchableHighlight } from 'react-native'; import SearchInput, { createFilter } from 'react-native-search-filter'; import DeviceInfo from 'react-native-device-info'; import DatePicker from 'react-native-date-picker-x'; import locales from './locales'; +import MinimalExample from './MinimalExample'; +import ExtendedExample from './ExtendedExample'; -Date.prototype.addHours = function(h) { - this.setTime(this.getTime() + (h*60*60*1000)); - return this; -} - -export default class App extends Component { +const MINIMAL_EXAMPLE = 'MINIMAL_EXAMPLE'; +const EXTENDED_EXAMPLE = 'EXTENDED_EXAMPLE'; - searchUpdated(term) { - this.setState({ searchTerm: term }) +const examples = { + [MINIMAL_EXAMPLE]: { + buttonTitle: 'Show minimal example', + component: + }, + [EXTENDED_EXAMPLE]: { + buttonTitle: 'Show extended example', + component: } +} - state = { - chosenDate: new Date(), - searchTerm: '', - locale: DeviceInfo.getDeviceLocale(), - } +export default class App extends Component { - setDate = (newDate) => this.setState({ chosenDate: newDate }) + state = { picker: undefined } render() { - const result = locales.filter(createFilter(this.state.searchTerm)).slice(0, 5); - return ( - + {!this.state.picker && this.renderButtons()} + {!!this.state.picker && this.renderBackButton()} + {!!this.state.picker && this.renderPicker()} + + ); + } - Current locale: {this.state.locale} - Current date: {this.state.chosenDate.toISOString()} - + renderPicker = () => examples[this.state.picker].component -