|
|
|
@ -1,24 +1,26 @@
|
|
|
|
|
import { Button, FlatList, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
|
|
|
import { FlatList, StyleSheet, Text, View } from 'react-native';
|
|
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
|
|
import { SearchBar } from '@rneui/base';
|
|
|
|
|
import { TouchableHighlight } from 'react-native-gesture-handler';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { TEAMS } from '../stub/stub';
|
|
|
|
|
import TeamListItem from '../components/TeamCmp';
|
|
|
|
|
import { Team } from '../core/Team';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function Team_Browser(props: { navigation: any }) {
|
|
|
|
|
const { navigation } = props;
|
|
|
|
|
const state = {
|
|
|
|
|
search: '',
|
|
|
|
|
};
|
|
|
|
|
const [search, setSearch] = useState('');
|
|
|
|
|
|
|
|
|
|
const updateSearch = (search: string) => {
|
|
|
|
|
state.search=search;
|
|
|
|
|
const handlePress = (item: Team) => {
|
|
|
|
|
setSearch('');
|
|
|
|
|
navigation.navigate('Info', { "": item }); // A revoir
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const { search } = state;
|
|
|
|
|
const filteredData = search !== '' ? TEAMS.filter((item) =>
|
|
|
|
|
item.getName().toLowerCase().includes(search.toLowerCase())
|
|
|
|
|
) : TEAMS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SafeAreaView style={styles.container}>
|
|
|
|
@ -27,10 +29,12 @@ export default function Team_Browser(props: { navigation: any }) {
|
|
|
|
|
<SearchBar
|
|
|
|
|
platform="default"
|
|
|
|
|
lightTheme
|
|
|
|
|
value={search}
|
|
|
|
|
onChangeText={setSearch}
|
|
|
|
|
/>
|
|
|
|
|
<FlatList
|
|
|
|
|
data={TEAMS}
|
|
|
|
|
renderItem={({ item }) => <TeamListItem team={item} />} />
|
|
|
|
|
data={filteredData}
|
|
|
|
|
renderItem={({ item }) => <TeamListItem team={item} onPress={handlePress}/>} />
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
</SafeAreaView>
|
|
|
|
|