Commit 4ac4e509 by Tonk

update search by timer name

parent d0ee40db
...@@ -83,6 +83,7 @@ class TimerScreen extends Component { ...@@ -83,6 +83,7 @@ class TimerScreen extends Component {
...initState, ...initState,
pickerSelectData: [], pickerSelectData: [],
subBreakerList: [], subBreakerList: [],
data: [],
}; };
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -138,6 +139,15 @@ class TimerScreen extends Component { ...@@ -138,6 +139,15 @@ class TimerScreen extends Component {
updateSearch = search => { updateSearch = search => {
this.setState({ search }); this.setState({ search });
const newData = this.props.allTimers.filter(item => {
const itemData = `${item.name.toUpperCase()}`;
const textData = search.toUpperCase();
return itemData.indexOf(textData) > -1;
});
this.setState({
data: newData,
});
}; };
createNewOrEditTimer = async () => { createNewOrEditTimer = async () => {
...@@ -264,7 +274,7 @@ class TimerScreen extends Component { ...@@ -264,7 +274,7 @@ class TimerScreen extends Component {
<Text style={[theme.normalText, theme.textDark, theme.mt2]}>Set Time</Text> <Text style={[theme.normalText, theme.textDark, theme.mt2]}>Set Time</Text>
<DatePicker <DatePicker
date={this.state.timer} date={new Date(this.state.timer)}
onDateChange={date => this.setState({ timer: date })} onDateChange={date => this.setState({ timer: date })}
mode="time" mode="time"
locale="fr" locale="fr"
...@@ -414,7 +424,7 @@ class TimerScreen extends Component { ...@@ -414,7 +424,7 @@ class TimerScreen extends Component {
{/* List Timer */} {/* List Timer */}
<FlatList <FlatList
contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }} contentContainerStyle={{ paddingBottom: isIphoneX() ? 90 : 55 }}
data={this.props.allTimers} data={this.state.search ? this.state.data : this.props.allTimers}
refreshing={this.props.isLoading} refreshing={this.props.isLoading}
onRefresh={this.props.getTimers} onRefresh={this.props.getTimers}
ListEmptyComponent={() => ( ListEmptyComponent={() => (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment