From 25b95a4b65040f83e8c81d9945eb48b31cd8598a Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Thu, 19 Aug 2021 09:20:40 +0900 Subject: [PATCH] added search results "more" screen --- app/navigation/BottomTabNavigator.tsx | 14 ++++ app/screens/Search.tsx | 63 +++++++++++++----- app/screens/SearchResultsView.tsx | 93 +++++++++++++++++++++++++++ app/state/music.ts | 76 ++++++++++------------ 4 files changed, 187 insertions(+), 59 deletions(-) create mode 100644 app/screens/SearchResultsView.tsx diff --git a/app/navigation/BottomTabNavigator.tsx b/app/navigation/BottomTabNavigator.tsx index 2f3154d..04f3c52 100644 --- a/app/navigation/BottomTabNavigator.tsx +++ b/app/navigation/BottomTabNavigator.tsx @@ -13,12 +13,14 @@ import { RouteProp, StackActions } from '@react-navigation/native' import React, { useEffect } from 'react' import { StyleSheet } from 'react-native' import { createNativeStackNavigator, NativeStackNavigationProp } from 'react-native-screens/native-stack' +import SearchResultsView from '@app/screens/SearchResultsView' type TabStackParamList = { main: undefined album: { id: string; title: string } artist: { id: string; title: string } playlist: { id: string; title: string } + results: { query: string; type: 'album' | 'song' | 'artist' } } type AlbumScreenNavigationProp = NativeStackNavigationProp @@ -54,6 +56,17 @@ const PlaylistScreen: React.FC = ({ route }) => ( ) +type ResultsScreenNavigationProp = NativeStackNavigationProp +type ResultsScreenRouteProp = RouteProp +type ResultsScreenProps = { + route: ResultsScreenRouteProp + navigation: ResultsScreenNavigationProp +} + +const ResultsScreen: React.FC = ({ route }) => ( + +) + const styles = StyleSheet.create({ stackheaderStyle: { backgroundColor: colors.gradient.high, @@ -92,6 +105,7 @@ function createTabStackNavigator(Component: React.ComponentType) { + ) } diff --git a/app/screens/Search.tsx b/app/screens/Search.tsx index 0b85053..450dddb 100644 --- a/app/screens/Search.tsx +++ b/app/screens/Search.tsx @@ -1,3 +1,4 @@ +import Button from '@app/components/Button' import GradientScrollView from '@app/components/GradientScrollView' import Header from '@app/components/Header' import ListItem from '@app/components/ListItem' @@ -9,6 +10,7 @@ import { useStore } from '@app/state/store' import { selectTrackPlayer } from '@app/state/trackplayer' import colors from '@app/styles/colors' import font from '@app/styles/font' +import { useNavigation } from '@react-navigation/native' import debounce from 'lodash.debounce' import React, { useCallback, useMemo, useState } from 'react' import { ActivityIndicator, StatusBar, StyleSheet, TextInput, View } from 'react-native' @@ -30,8 +32,11 @@ const SongItem = React.memo<{ item: Song }>(({ item }) => { const ResultsCategory = React.memo<{ name: string + query: string items: ListableItem[] -}>(({ name, items }) => { +}>(({ name, query, items }) => { + const navigation = useNavigation() + if (items.length === 0) { return <> } @@ -46,39 +51,53 @@ const ResultsCategory = React.memo<{ ), )} + {items.length === 5 && ( +