From 34b8c1f962a5c835351dc6f4369757259998af16 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Sep 2024 22:19:31 +0530 Subject: Finish up app menu + fix drag interaction --- src/components/Favorites.tsx | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'src/components/Favorites.tsx') diff --git a/src/components/Favorites.tsx b/src/components/Favorites.tsx index c2adae7..6ee99cb 100644 --- a/src/components/Favorites.tsx +++ b/src/components/Favorites.tsx @@ -9,12 +9,23 @@ import DraggableFlatList, { } from 'react-native-draggable-flatlist'; import Icon from 'react-native-vector-icons/MaterialIcons'; import {AppMenu} from './AppMenu'; +import {useInstalledApps} from '../hooks/useInstalledApps'; -export const Favorites: React.FC<{apps: AppDetail[]; active: boolean}> = ({ - apps, - active, -}) => { - const {favoriteAppNames, setFavorites, refreshFavorites} = useFavorites(); +const AppLabel: React.FC<{app: AppDetail}> = React.memo(({app}) => { + return ( + + + + {app.label} + + + + ); +}); + +export const Favorites: React.FC<{active: boolean}> = (_) => { + const {apps} = useInstalledApps(); + const {favoriteAppNames, setFavorites} = useFavorites(); const appByName = useMemo( () => Object.fromEntries(apps.map((app) => [app.packageName, app])), @@ -33,40 +44,33 @@ export const Favorites: React.FC<{apps: AppDetail[]; active: boolean}> = ({ [setFavorites], ); - useEffect(() => { - if (!active) return; - refreshFavorites(); - }, [active, refreshFavorites]); - return ( item.packageName} + keyExtractor={(app) => app.packageName} renderItem={({item: app, drag, isActive}) => ( - + - - - {app.label} - - - - - - - + + + + + + + )} - renderPlaceholder={() => } + renderPlaceholder={() => } /> ); -- cgit v1.3.1