mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fix card sort and filter
This commit is contained in:
parent
96d077fd66
commit
ae12bf4ffb
@ -57,6 +57,29 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
<View style={styles.title}>
|
||||||
|
{ state.sort && (
|
||||||
|
<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>
|
||||||
|
</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>
|
||||||
|
@ -5,7 +5,7 @@ import { AccountContext } from 'context/AccountContext';
|
|||||||
import { ProfileContext } from 'context/ProfileContext';
|
import { ProfileContext } from 'context/ProfileContext';
|
||||||
import { getLanguageStrings } from 'constants/Strings';
|
import { getLanguageStrings } from 'constants/Strings';
|
||||||
|
|
||||||
export function useCards(filter, sort) {
|
export function useCards() {
|
||||||
|
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
cards: [],
|
cards: [],
|
||||||
@ -58,10 +58,10 @@ export function useCards(filter, sort) {
|
|||||||
if (item.blocked) {
|
if (item.blocked) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!filter) {
|
if (!state.filter) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const lower = filter.toLowerCase();
|
const lower = state.filter.toLowerCase();
|
||||||
if (item.name) {
|
if (item.name) {
|
||||||
if (item.name.toLowerCase().includes(lower)) {
|
if (item.name.toLowerCase().includes(lower)) {
|
||||||
return true;
|
return true;
|
||||||
@ -74,7 +74,7 @@ export function useCards(filter, sort) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
if (sort) {
|
if (state.sort) {
|
||||||
filtered.sort((a, b) => {
|
filtered.sort((a, b) => {
|
||||||
const aName = a?.name?.toLowerCase();
|
const aName = a?.name?.toLowerCase();
|
||||||
const bName = b?.name?.toLowerCase();
|
const bName = b?.name?.toLowerCase();
|
||||||
@ -99,7 +99,7 @@ export function useCards(filter, sort) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateState({ cards: filtered });
|
updateState({ cards: filtered });
|
||||||
}, [card, filter, sort]);
|
}, [card, state.filter, state.sort]);
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
call: async (card) => {
|
call: async (card) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user