mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 15:02:42 +01:00
search item press events
This commit is contained in:
@@ -2,26 +2,13 @@ import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import { Artist } from '@app/models/music'
|
||||
import { artistsAtom, artistsUpdatingAtom, useUpdateArtists } from '@app/state/music'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useEffect } from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
|
||||
const ArtistItem = React.memo<{ item: Artist }>(({ item }) => {
|
||||
const navigation = useNavigation()
|
||||
|
||||
return (
|
||||
<ListItem
|
||||
item={item}
|
||||
showArt={true}
|
||||
showStar={false}
|
||||
listStyle="big"
|
||||
onPress={() => navigation.navigate('ArtistView', { id: item.id, title: item.name })}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
const ArtistRenderItem: React.FC<{ item: Artist }> = ({ item }) => <ArtistItem item={item} />
|
||||
const ArtistRenderItem: React.FC<{ item: Artist }> = ({ item }) => (
|
||||
<ListItem item={item} showArt={true} showStar={false} listStyle="big" />
|
||||
)
|
||||
|
||||
const ArtistsList = () => {
|
||||
const artists = useAtomValue(artistsAtom)
|
||||
|
||||
@@ -2,27 +2,13 @@ import GradientFlatList from '@app/components/GradientFlatList'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import { PlaylistListItem } from '@app/models/music'
|
||||
import { playlistsAtom, playlistsUpdatingAtom, useUpdatePlaylists } from '@app/state/music'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
import React, { useEffect } from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
|
||||
const PlaylistItem = React.memo<{ item: PlaylistListItem }>(({ item }) => {
|
||||
const navigation = useNavigation()
|
||||
|
||||
return (
|
||||
<ListItem
|
||||
item={item}
|
||||
showArt={true}
|
||||
showStar={false}
|
||||
listStyle="big"
|
||||
subtitle={item.comment}
|
||||
onPress={() => navigation.navigate('PlaylistView', { id: item.id, title: item.name })}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
const PlaylistRenderItem: React.FC<{ item: PlaylistListItem }> = ({ item }) => <PlaylistItem item={item} />
|
||||
const PlaylistRenderItem: React.FC<{ item: PlaylistListItem }> = ({ item }) => (
|
||||
<ListItem item={item} showArt={true} showStar={false} listStyle="big" />
|
||||
)
|
||||
|
||||
const PlaylistsList = () => {
|
||||
const playlists = useAtomValue(playlistsAtom)
|
||||
|
||||
@@ -2,8 +2,9 @@ import GradientScrollView from '@app/components/GradientScrollView'
|
||||
import Header from '@app/components/Header'
|
||||
import ListItem from '@app/components/ListItem'
|
||||
import NothingHere from '@app/components/NothingHere'
|
||||
import { ListableItem, SearchResults } from '@app/models/music'
|
||||
import { ListableItem, SearchResults, Song } from '@app/models/music'
|
||||
import { searchResultsAtom, searchResultsUpdatingAtom, useUpdateSearchResults } from '@app/state/music'
|
||||
import { useSetQueue } from '@app/state/trackplayer'
|
||||
import colors from '@app/styles/colors'
|
||||
import font from '@app/styles/font'
|
||||
import { useAtomValue } from 'jotai/utils'
|
||||
@@ -11,17 +12,18 @@ import debounce from 'lodash.debounce'
|
||||
import React, { useCallback, useMemo, useState } from 'react'
|
||||
import { ActivityIndicator, StatusBar, StyleSheet, TextInput, View } from 'react-native'
|
||||
|
||||
function getSubtitle(item: ListableItem) {
|
||||
switch (item.itemType) {
|
||||
case 'playlist':
|
||||
return item.comment
|
||||
case 'album':
|
||||
case 'song':
|
||||
return item.artist
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
const SongItem = React.memo<{ item: Song }>(({ item }) => {
|
||||
const setQueue = useSetQueue()
|
||||
|
||||
return (
|
||||
<ListItem
|
||||
item={item}
|
||||
showArt={true}
|
||||
showStar={false}
|
||||
onPress={() => setQueue([item], `Search: ${item.title}`, 0)}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
const ResultsCategory = React.memo<{
|
||||
name: string
|
||||
@@ -34,9 +36,13 @@ const ResultsCategory = React.memo<{
|
||||
return (
|
||||
<>
|
||||
<Header>{name}</Header>
|
||||
{items.map(a => (
|
||||
<ListItem key={a.id} item={a} showArt={true} showStar={false} subtitle={getSubtitle(a)} />
|
||||
))}
|
||||
{items.map(a =>
|
||||
a.itemType === 'song' ? (
|
||||
<SongItem key={a.id} item={a} />
|
||||
) : (
|
||||
<ListItem key={a.id} item={a} showArt={true} showStar={false} />
|
||||
),
|
||||
)}
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user