From 8455d6be880d2c4e530e9fd5cf7da210b75dde5a Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Sat, 12 Apr 2025 18:55:04 +0200 Subject: [PATCH] Add credential search (#771) --- mobile-app/app/(tabs)/(credentials)/index.tsx | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/mobile-app/app/(tabs)/(credentials)/index.tsx b/mobile-app/app/(tabs)/(credentials)/index.tsx index 7a6bd81fc..37d5b2173 100644 --- a/mobile-app/app/(tabs)/(credentials)/index.tsx +++ b/mobile-app/app/(tabs)/(credentials)/index.tsx @@ -1,4 +1,4 @@ -import { StyleSheet, View, Text, SafeAreaView, FlatList, ActivityIndicator, useColorScheme, TouchableOpacity } from 'react-native'; +import { StyleSheet, View, Text, SafeAreaView, FlatList, ActivityIndicator, useColorScheme, TouchableOpacity, TextInput } from 'react-native'; import { useState, useEffect } from 'react'; import { router, Stack } from 'expo-router'; @@ -11,6 +11,7 @@ import { Credential } from '@/utils/types/Credential'; export default function CredentialsScreen() { const colorScheme = useColorScheme(); const isDarkMode = colorScheme === 'dark'; + const [searchQuery, setSearchQuery] = useState(''); const dynamicStyles = { credentialItem: { @@ -26,6 +27,10 @@ export default function CredentialsScreen() { emptyText: { color: isDarkMode ? '#9ca3af' : '#6b7280', }, + searchInput: { + backgroundColor: isDarkMode ? '#374151' : '#f3f4f6', + color: isDarkMode ? '#f3f4f6' : '#1f2937', + }, }; const [credentialsList, setCredentialsList] = useState([]); @@ -61,6 +66,15 @@ export default function CredentialsScreen() { loadCredentials(); }, [isAuthenticated, isDatabaseAvailable]); + const filteredCredentials = credentialsList.filter(credential => { + const searchLower = searchQuery.toLowerCase(); + return ( + credential.ServiceName?.toLowerCase().includes(searchLower) || + credential.Username?.toLowerCase().includes(searchLower) || + credential.Alias?.Email?.toLowerCase().includes(searchLower) + ); + }); + return ( @@ -68,12 +82,19 @@ export default function CredentialsScreen() { Credentials + {isLoadingCredentials ? ( ) : ( item.Id} renderItem={({ item }) => ( - No credentials found + {searchQuery ? 'No matching credentials found' : 'No credentials found'} } /> @@ -146,4 +167,10 @@ const styles = StyleSheet.create({ fontSize: 16, marginTop: 24, }, + searchInput: { + padding: 12, + borderRadius: 8, + marginBottom: 16, + fontSize: 16, + }, }); \ No newline at end of file