|
|
@ -1,45 +1,43 @@ |
|
|
|
import React, { useEffect, useCallback, useMemo, useState, useRef } from 'react'; |
|
|
|
import React from 'react'; |
|
|
|
import { List, Divider, Text, TouchableRipple, Searchbar } from 'react-native-paper'; |
|
|
|
import { List, Searchbar, TouchableRipple } from 'react-native-paper'; |
|
|
|
import { StyleSheet, View, ScrollView } from 'react-native'; |
|
|
|
import { StyleSheet, View, ScrollView } from 'react-native'; |
|
|
|
import { colors } from '../utils/color' |
|
|
|
|
|
|
|
import { useRoute } from '@react-navigation/native'; |
|
|
|
import { useRoute } from '@react-navigation/native'; |
|
|
|
|
|
|
|
import { colors } from '../utils/color'; |
|
|
|
|
|
|
|
import Icon from 'react-native-vector-icons/AntDesign'; |
|
|
|
|
|
|
|
|
|
|
|
export default function SearchPage({ navigation }) { |
|
|
|
export default function SearchPage({ navigation }) { |
|
|
|
const [searchQuery, setSearchQuery] = React.useState(''); |
|
|
|
const [searchQuery, setSearchQuery] = React.useState(''); |
|
|
|
const route = useRoute(); |
|
|
|
const route = useRoute(); |
|
|
|
const { dummyData } = route.params; |
|
|
|
const { dataListProjectCharters, onSelect } = route.params; |
|
|
|
|
|
|
|
|
|
|
|
const handleProjectSelect = (project) => { |
|
|
|
const handleProjectSelect = (project) => { |
|
|
|
console.log("project", project); |
|
|
|
onSelect(project); |
|
|
|
navigation.goBack() |
|
|
|
navigation.goBack(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const filteredData = dummyData.filter(item => |
|
|
|
const filteredData = dataListProjectCharters.filter(item => |
|
|
|
item.name.toLowerCase().includes(searchQuery.toLowerCase()) |
|
|
|
item.project_name.toLowerCase().includes(searchQuery.toLowerCase()) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<View style={styles.container}> |
|
|
|
<View style={styles.container}> |
|
|
|
<Searchbar |
|
|
|
<Searchbar |
|
|
|
mode='bar' |
|
|
|
|
|
|
|
placeholder="Cari Project" |
|
|
|
placeholder="Cari Project" |
|
|
|
onChangeText={setSearchQuery} |
|
|
|
onChangeText={setSearchQuery} |
|
|
|
value={searchQuery} |
|
|
|
value={searchQuery} |
|
|
|
traileringIconColor={colors.white} |
|
|
|
|
|
|
|
style={{ backgroundColor: colors.white }} |
|
|
|
style={{ backgroundColor: colors.white }} |
|
|
|
showDivider={true} |
|
|
|
|
|
|
|
elevation={2} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
<ScrollView style={styles.listData}> |
|
|
|
<ScrollView style={styles.listData}> |
|
|
|
<View> |
|
|
|
<View> |
|
|
|
{filteredData.map(item => ( |
|
|
|
{filteredData.map(item => ( |
|
|
|
<> |
|
|
|
<TouchableRipple key={item.id} onPress={() => handleProjectSelect(item)}> |
|
|
|
<TouchableRipple onPress={() => handleProjectSelect(item)}> |
|
|
|
|
|
|
|
<List.Item |
|
|
|
<List.Item |
|
|
|
title={item.name} |
|
|
|
title={item.sicn} |
|
|
|
|
|
|
|
titleNumberOfLines={3} |
|
|
|
|
|
|
|
left={() => <Icon name="search1" size={20} color={colors.black} />} |
|
|
|
right={() => <List.Icon icon="arrow-top-left" />} |
|
|
|
right={() => <List.Icon icon="arrow-top-left" />} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</TouchableRipple> |
|
|
|
</TouchableRipple> |
|
|
|
</> |
|
|
|
|
|
|
|
))} |
|
|
|
))} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
</ScrollView> |
|
|
|
</ScrollView> |
|
|
@ -47,17 +45,15 @@ export default function SearchPage({ navigation }) { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
container: { |
|
|
|
flex: 1, |
|
|
|
flex: 1, |
|
|
|
marginTop: 50, |
|
|
|
marginTop: 50, |
|
|
|
marginHorizontal: 10, |
|
|
|
marginHorizontal: 10, |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
listData: { |
|
|
|
listData: { |
|
|
|
flex: 1, |
|
|
|
flex: 1, |
|
|
|
marginTop: 20, |
|
|
|
marginTop: 20, |
|
|
|
marginHorizontal: 10 |
|
|
|
marginHorizontal: 10, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |