diff --git a/app/Clubs.js b/app/Clubs.js index f415419..be69279 100644 --- a/app/Clubs.js +++ b/app/Clubs.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { SafeAreaView, StyleSheet, @@ -8,6 +8,7 @@ import { StatusBar, ActivityIndicator, FlatList, + TouchableOpacity } from 'react-native'; import { @@ -20,12 +21,15 @@ import { import { SearchBar } from 'react-native-elements'; const ClubElement = ({item}) => { - //console.log(item) + const [visible, setVisible] = useState(0) + const extra = visible?({'\n'}Location: {item.item.loc} {"\n\n"}Sponsor: {item.item.sponsor}):(<>); return( - - {item.item.name} - Location: {item.item.loc} {"\n"}Sponsor: {item.item.sponsor} - + + setVisible(!visible)}> + {item.item.name} + {extra} + + ) } class Clubs extends React.Component { @@ -66,14 +70,12 @@ class Clubs extends React.Component { } updateSearch = (search) => { this.setState({ search:search }); - ds = this.state.dataSearch.filter((thing)=>{return thing.name.startsWith(search)}) + const searchPool = search.startsWith(this.state.search)?this.state.dataSearch:this.state.data; + const ds = searchPool.filter((thing)=>{return thing.name.toLowerCase().startsWith(search.toLowerCase())}) this.setState({dataSearch: ds}) - if (search == ""){ - this.setState({dataSearch:this.state.data}) - } }; clearSearch = (search)=>{ - ds = this.state.data; + const ds = this.state.data; this.setState({dataSearch:ds}) } render() { @@ -85,7 +87,7 @@ class Clubs extends React.Component {