fixing cards filter

This commit is contained in:
Roland Osborne 2023-10-06 16:07:42 -07:00
parent fec1f9e2cf
commit 8d7e88d12b
2 changed files with 26 additions and 23 deletions

View File

@ -28,7 +28,7 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) {
)} )}
<View style={styles.inputwrapper}> <View style={styles.inputwrapper}>
<AntIcons style={styles.icon} name="search1" size={16} color={Colors.inputPlaceholder} /> <AntIcons style={styles.icon} name="search1" size={16} color={Colors.inputPlaceholder} />
<TextInput placeholder={ state.strings.contactFilter } placeholderTextColor={Colors.inputPlaceholder} value={state.filter} <TextInput placeholder={ state.strings.contactFilter } placeholderTextColor={Colors.inputPlaceholder}
style={styles.inputfield} autoCapitalize={'none'} spellCheck={false} onChangeText={actions.setFilter} /> style={styles.inputfield} autoCapitalize={'none'} spellCheck={false} onChangeText={actions.setFilter} />
<View style={styles.space} /> <View style={styles.space} />
</View> </View>
@ -40,7 +40,7 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) {
), ),
}); });
} }
}, [navigation]); }, [navigation, state.sort]);
const call = async (contact) => { const call = async (contact) => {
try { try {
@ -57,29 +57,30 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) {
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View style={styles.title}> { !navigation && (
{ state.sort && ( <View style={styles.title}>
<TouchableOpacity style={styles.sort} onPress={() => actions.setSort(false)}> { state.sort && (
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.text} /> <TouchableOpacity style={styles.sort} onPress={() => actions.setSort(false)}>
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.text} />
</TouchableOpacity>
)}
{ !state.sort && (
<TouchableOpacity style={styles.sort} onPress={() => actions.setSort(true)}>
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.unsetText} />
</TouchableOpacity>
)}
<View style={styles.inputwrapper}>
<AntIcons style={styles.icon} name="search1" size={16} color={Colors.inputPlaceholder} />
<TextInput placeholder={ state.strings.contactFilter } placeholderTextColor={Colors.inputPlaceholder} value={state.filter}
style={styles.inputfield} autoCapitalize={'none'} spellCheck={false} onChangeText={actions.setFilter} />
<View style={styles.space} />
</View>
<TouchableOpacity style={styles.add} onPress={() => openRegistry(navigation)}>
<AntIcons name={'adduser'} size={16} color={Colors.primaryButtonText} style={[styles.box, { transform: [ { rotateY: "180deg" }, ]} ]}/>
<Text style={styles.newtext}>{ state.strings.add }</Text>
</TouchableOpacity> </TouchableOpacity>
)}
{ !state.sort && (
<TouchableOpacity style={styles.sort} onPress={() => actions.setSort(true)}>
<MatIcons style={styles.icon} name="sort-ascending" size={24} color={Colors.unsetText} />
</TouchableOpacity>
)}
<View style={styles.inputwrapper}>
<AntIcons style={styles.icon} name="search1" size={16} color={Colors.inputPlaceholder} />
<TextInput placeholder={ state.strings.contactFilter } placeholderTextColor={Colors.inputPlaceholder} value={state.filter}
style={styles.inputfield} autoCapitalize={'none'} spellCheck={false} onChangeText={actions.setFilter} />
<View style={styles.space} />
</View> </View>
<TouchableOpacity style={styles.add} onPress={() => openRegistry(navigation)}> )}
<AntIcons name={'adduser'} size={16} color={Colors.primaryButtonText} style={[styles.box, { transform: [ { rotateY: "180deg" }, ]} ]}/>
<Text style={styles.newtext}>{ state.strings.add }</Text>
</TouchableOpacity>
</View>
{ state.cards.length == 0 && ( { state.cards.length == 0 && (
<View style={styles.notfound}> <View style={styles.notfound}>
<Text style={styles.notfoundtext}>{ state.strings.noContacts }</Text> <Text style={styles.notfoundtext}>{ state.strings.noContacts }</Text>

View File

@ -111,6 +111,8 @@ export function useCards() {
updateState({ filter }); updateState({ filter });
}, },
setSort: (sort) => { setSort: (sort) => {
console.log("SETTTING : ", sort);
updateState({ sort }); updateState({ sort });
}, },
}; };