diff options
| author | Akshay Nair <phenax5@gmail.com> | 2024-09-28 13:46:22 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2024-09-29 16:16:39 +0530 |
| commit | a1143f3696a0b272018f7eea43ee23a674c618e1 (patch) | |
| tree | 2289e6a1fbf47d339cb41849f9554d403bd837cc /src/screens | |
| parent | 5d456899ea444301870e1d3c721d139c9251c531 (diff) | |
| download | daft-launcher-a1143f3696a0b272018f7eea43ee23a674c618e1.tar.gz daft-launcher-a1143f3696a0b272018f7eea43ee23a674c618e1.zip | |
Add context menu for apps (fav,settings,uninstall)
Diffstat (limited to 'src/screens')
| -rw-r--r-- | src/screens/AppList.tsx | 22 | ||||
| -rw-r--r-- | src/screens/Home.tsx | 7 |
2 files changed, 14 insertions, 15 deletions
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> diff --git a/src/screens/Home.tsx b/src/screens/Home.tsx index 00a4b1f..7bd1a3f 100644 --- a/src/screens/Home.tsx +++ b/src/screens/Home.tsx @@ -4,11 +4,14 @@ import {Clock} from '../components/Clock'; import {AppDetail} from 'react-native-launcher-kit/typescript/Interfaces/InstalledApps'; import {Favorites} from '../components/Favorites'; -export const Home: React.FC<{apps: AppDetail[]}> = ({apps}) => { +export const Home: React.FC<{apps: AppDetail[]; active: boolean}> = ({ + apps, + active, +}) => { return ( <View> <Clock /> - <Favorites apps={apps} /> + <Favorites apps={apps} active={active} /> </View> ); }; |
