42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Platform } from "react-native"
|
|
import { useThemeColors } from "@/lib/theme"
|
|
import { Stack } from "expo-router"
|
|
import { useCallback } from "react"
|
|
|
|
import { SearchResults } from "@/components/search-results"
|
|
import { useDebouncedSearch } from "@/hooks/use-debounced-search"
|
|
|
|
export default function SearchScreen() {
|
|
const colors = useThemeColors()
|
|
const { searchQuery, onQueryChange, onSearchSubmit } = useDebouncedSearch()
|
|
|
|
const handleChangeText = useCallback(
|
|
(event: { nativeEvent: { text: string } }) => {
|
|
onQueryChange(event.nativeEvent.text)
|
|
},
|
|
[onQueryChange]
|
|
)
|
|
|
|
return (
|
|
<>
|
|
<Stack.SearchBar
|
|
placeholder="Artists, Albums, Songs, and More"
|
|
onChangeText={handleChangeText}
|
|
onSearchButtonPress={onSearchSubmit}
|
|
autoCapitalize="none"
|
|
{...(Platform.OS === "android"
|
|
? {
|
|
barTintColor: colors.background,
|
|
textColor: colors.foreground,
|
|
tintColor: colors.primary,
|
|
hintTextColor: colors.mutedForeground,
|
|
headerIconColor: colors.foreground,
|
|
}
|
|
: {})}
|
|
/>
|
|
|
|
<SearchResults searchQuery={searchQuery} />
|
|
</>
|
|
)
|
|
}
|