From a1143f3696a0b272018f7eea43ee23a674c618e1 Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Sat, 28 Sep 2024 13:46:22 +0530
Subject: Add context menu for apps (fav,settings,uninstall)

---
 src/screens/AppList.tsx | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

(limited to 'src/screens/AppList.tsx')

diff --git a/src/screens/AppList.tsx b/src/screens/AppList.tsx
index 81c8f4f..e6b3e6e 100644
--- a/src/screens/AppList.tsx
+++ b/src/screens/AppList.tsx
@@ -2,16 +2,13 @@ import {matchSorter} from 'match-sorter';
 import React, {useEffect, useMemo, useRef, useState} from 'react';
 import {ScrollView, Text, TextInput, View} from 'react-native';
 import {AppDetail} from 'react-native-launcher-kit/typescript/Interfaces/InstalledApps';
-import {useFavorites} from '../hooks/useFavorites';
-import {TouchableOpacity} from 'react-native-gesture-handler';
 import Icon from 'react-native-vector-icons/MaterialIcons';
+import {AppMenu} from '../components/AppMenu';
 
-export const AppList: React.FC<{apps: AppDetail[]; isActive: boolean}> = ({
+export const AppList: React.FC<{apps: AppDetail[]; active: boolean}> = ({
   apps,
-  isActive,
+  active,
 }) => {
-  const {addToFavorites} = useFavorites();
-
   const textInputRef = useRef<TextInput>(null);
   const [searchText, setSearchText] = useState('');
 
@@ -24,8 +21,8 @@ export const AppList: React.FC<{apps: AppDetail[]; isActive: boolean}> = ({
   // Autofocus
   useEffect(() => {
     if (!textInputRef.current) return;
-    if (isActive) TextInput.State.focusTextInput(textInputRef.current);
-  }, [isActive]);
+    if (active) TextInput.State.focusTextInput(textInputRef.current);
+  }, [active]);
 
   return (
     <View>
@@ -44,15 +41,14 @@ export const AppList: React.FC<{apps: AppDetail[]; isActive: boolean}> = ({
       <ScrollView contentInsetAdjustmentBehavior="automatic">
         <View className="flex-1">
           {filteredApps.map((app, index) => (
-            <View className="mt-4 px-4" key={app.packageName + index}>
-              <TouchableOpacity
-                onLongPress={() => addToFavorites(app.packageName)}>
+            <AppMenu app={app} key={app.packageName + index}>
+              <View className="mt-4 px-4">
                 <Text className="text-md font-bold dark:text-white">
                   {app.label}
                 </Text>
                 <Text className="text-xs">{app.packageName}</Text>
-              </TouchableOpacity>
-            </View>
+              </View>
+            </AppMenu>
           ))}
         </View>
       </ScrollView>
-- 
cgit v1.3.1

