From 8995438b9a8649d30d870826d0f8fbf283d68933 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 12 May 2024 17:51:35 +0530 Subject: Fix problem with autofocus in textinput --- App.tsx | 10 +++++++--- src/screens/AppList.tsx | 6 +++++- 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 ( @@ -15,12 +17,14 @@ function App(): React.JSX.Element { loop={false} loadMinimal dot={<>} - activeDot={<>}> + activeDot={<>} + index={screenIndex} + onIndexChanged={setScreenIndex}> Wow - + ); 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}) => {