fix: typo and render data
This commit is contained in:
parent
55ae233a94
commit
69e05326ce
|
@ -39,7 +39,7 @@ export const Categories = ({ flatListRef, scrollNav }: CategoriesProps) => {
|
||||||
[disabledCategory, flatListRef]
|
[disabledCategory, flatListRef]
|
||||||
);
|
);
|
||||||
|
|
||||||
const rendarItem = React.useCallback(
|
const renderItem = React.useCallback(
|
||||||
({ item, index }: { item: CategoryNavigationItem; index: number }) => (
|
({ item, index }: { item: CategoryNavigationItem; index: number }) => (
|
||||||
<CategoryItem
|
<CategoryItem
|
||||||
item={item}
|
item={item}
|
||||||
|
@ -66,9 +66,6 @@ export const Categories = ({ flatListRef, scrollNav }: CategoriesProps) => {
|
||||||
),
|
),
|
||||||
[activeCategoryContainerColor, scrollNav]
|
[activeCategoryContainerColor, scrollNav]
|
||||||
);
|
);
|
||||||
const isRecentlyUsedHidden = (category: CategoryTypes) =>
|
|
||||||
category === 'recently_used' &&
|
|
||||||
(keyboardState.recentlyUsed.length === 0 || !enableRecentlyUsed);
|
|
||||||
|
|
||||||
const getStylesBasedOnPosition = () => {
|
const getStylesBasedOnPosition = () => {
|
||||||
const style: ViewStyle[] = [styles.navigation];
|
const style: ViewStyle[] = [styles.navigation];
|
||||||
|
@ -96,17 +93,29 @@ export const Categories = ({ flatListRef, scrollNav }: CategoriesProps) => {
|
||||||
return style;
|
return style;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderData = React.useMemo(() => {
|
||||||
|
const isRecentlyUsedHidden = (category: CategoryTypes) =>
|
||||||
|
category === 'recently_used' &&
|
||||||
|
(keyboardState.recentlyUsed.length === 0 || !enableRecentlyUsed);
|
||||||
|
return CATEGORIES_NAVIGATION.filter(({ category }) => {
|
||||||
|
if (searchPhrase === '' && category === 'search') return false;
|
||||||
|
if (isRecentlyUsedHidden(category)) return false;
|
||||||
|
return !disabledCategory.includes(category);
|
||||||
|
});
|
||||||
|
}, [
|
||||||
|
disabledCategory,
|
||||||
|
enableRecentlyUsed,
|
||||||
|
keyboardState.recentlyUsed.length,
|
||||||
|
searchPhrase,
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[categoryPosition === 'floating' && styles.floating]}>
|
<View style={[categoryPosition === 'floating' && styles.floating]}>
|
||||||
<View style={getStylesBasedOnPosition()}>
|
<View style={getStylesBasedOnPosition()}>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={CATEGORIES_NAVIGATION.filter(({ category }) => {
|
data={renderData}
|
||||||
if (searchPhrase === '' && category === 'search') return false;
|
|
||||||
if (isRecentlyUsedHidden(category)) return false;
|
|
||||||
return !disabledCategory.includes(category);
|
|
||||||
})}
|
|
||||||
keyExtractor={(item) => item.category}
|
keyExtractor={(item) => item.category}
|
||||||
renderItem={rendarItem}
|
renderItem={renderItem}
|
||||||
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
ItemSeparatorComponent={() => <View style={styles.separator} />}
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
horizontal={true}
|
horizontal={true}
|
||||||
|
|
Loading…
Reference in New Issue