aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-05-12 17:51:35 +0530
committerAkshay Nair <phenax5@gmail.com>2024-09-29 16:16:38 +0530
commit8995438b9a8649d30d870826d0f8fbf283d68933 (patch)
treef43c9b4247a0551230e959709c5404150745c09c
parentec6782ba68d15706b1d5e3490704aa98c216a3d7 (diff)
downloaddaft-launcher-8995438b9a8649d30d870826d0f8fbf283d68933.tar.gz
daft-launcher-8995438b9a8649d30d870826d0f8fbf283d68933.zip
Fix problem with autofocus in textinput
-rw-r--r--App.tsx10
-rw-r--r--src/screens/AppList.tsx6
2 files changed, 12 insertions, 4 deletions
diff --git a/App.tsx b/App.tsx
index a0eda25..1b42456 100644
--- a/App.tsx
+++ b/App.tsx
@@ -5,7 +5,9 @@ import Swiper from 'react-native-swiper';
import {AppList} from './src/screens/AppList';
function App(): React.JSX.Element {
- const [apps, _setApps] = useState(() => InstalledApps.getSortedApps());
+ const [apps, setApps] = useState(() => InstalledApps.getSortedApps());
+ const refreshApps = () => setApps(InstalledApps.getSortedApps());
+ const [screenIndex, setScreenIndex] = useState(0);
return (
<SafeAreaView className="flex flex-1 bg-slate-100 dark:bg-black">
@@ -15,12 +17,14 @@ function App(): React.JSX.Element {
loop={false}
loadMinimal
dot={<></>}
- activeDot={<></>}>
+ activeDot={<></>}
+ index={screenIndex}
+ onIndexChanged={setScreenIndex}>
<View>
<Text>Wow</Text>
</View>
- <AppList apps={apps} />
+ <AppList apps={apps} screenIndex={screenIndex} />
</Swiper>
</SafeAreaView>
);
diff --git a/src/screens/AppList.tsx b/src/screens/AppList.tsx
index 187fbed..ec83124 100644
--- a/src/screens/AppList.tsx
+++ b/src/screens/AppList.tsx
@@ -3,7 +3,10 @@ import React, {useMemo, useState} from 'react';
import {ScrollView, Text, TextInput, View} from 'react-native';
import {AppDetail} from 'react-native-launcher-kit/typescript/Interfaces/InstalledApps';
-export const AppList: React.FC<{apps: AppDetail[]}> = ({apps}) => {
+export const AppList: React.FC<{apps: AppDetail[]; screenIndex: number}> = ({
+ apps,
+ screenIndex,
+}) => {
const [searchText, setSearchText] = useState('');
const filteredApps = useMemo(() => {
@@ -16,6 +19,7 @@ export const AppList: React.FC<{apps: AppDetail[]}> = ({apps}) => {
<View>
<View>
<TextInput
+ key={screenIndex}
autoFocus
autoCorrect={false}
value={searchText}