mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 01:19:28 +01:00
artist context menu
This commit is contained in:
parent
26749d0458
commit
19c862b983
@ -1,5 +1,5 @@
|
|||||||
import PressableOpacity from '@app/components/PressableOpacity'
|
import PressableOpacity from '@app/components/PressableOpacity'
|
||||||
import { AlbumListItem, Song } from '@app/models/music'
|
import { AlbumListItem, Artist, Song } from '@app/models/music'
|
||||||
import colors from '@app/styles/colors'
|
import colors from '@app/styles/colors'
|
||||||
import font from '@app/styles/font'
|
import font from '@app/styles/font'
|
||||||
import { NavigationProp, useNavigation } from '@react-navigation/native'
|
import { NavigationProp, useNavigation } from '@react-navigation/native'
|
||||||
@ -100,15 +100,12 @@ const ContextMenuIconTextOption = React.memo<ContextMenuIconTextOptionProps>(
|
|||||||
|
|
||||||
const MenuHeader = React.memo<{
|
const MenuHeader = React.memo<{
|
||||||
coverArt?: string
|
coverArt?: string
|
||||||
|
artistId?: string
|
||||||
title: string
|
title: string
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
}>(({ coverArt, title, subtitle }) => (
|
}>(({ coverArt, artistId, title, subtitle }) => (
|
||||||
<View style={styles.menuHeader}>
|
<View style={styles.menuHeader}>
|
||||||
{coverArt ? (
|
<CoverArt artistId={artistId} coverArt={coverArt} style={styles.coverArt} resizeMode={FastImage.resizeMode.cover} />
|
||||||
<CoverArt coverArt={coverArt} style={styles.coverArt} resizeMode={FastImage.resizeMode.cover} />
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
)}
|
|
||||||
<View style={styles.menuHeaderText}>
|
<View style={styles.menuHeaderText}>
|
||||||
<Text numberOfLines={1} style={styles.menuTitle}>
|
<Text numberOfLines={1} style={styles.menuTitle}>
|
||||||
{title}
|
{title}
|
||||||
@ -223,6 +220,28 @@ export const SongContextPressable: React.FC<SongContextPressableProps> = props =
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ArtistContextPressableProps = ContextMenuProps & {
|
||||||
|
artist: Artist
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ArtistContextPressable: React.FC<ArtistContextPressableProps> = props => {
|
||||||
|
const { artist, children } = props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ContextMenu
|
||||||
|
{...props}
|
||||||
|
menuHeader={<MenuHeader title={artist.name} artistId={artist.id} />}
|
||||||
|
menuOptions={
|
||||||
|
<>
|
||||||
|
<OptionStar />
|
||||||
|
<OptionDownload itemType={artist.itemType} />
|
||||||
|
</>
|
||||||
|
}>
|
||||||
|
{children}
|
||||||
|
</ContextMenu>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
optionsContainer: {
|
optionsContainer: {
|
||||||
backgroundColor: 'rgba(45, 45, 45, 0.95)',
|
backgroundColor: 'rgba(45, 45, 45, 0.95)',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { AlbumListItem, ListableItem, Song } from '@app/models/music'
|
import { AlbumListItem, Artist, ListableItem, Song } from '@app/models/music'
|
||||||
import { useStore } from '@app/state/store'
|
import { useStore } from '@app/state/store'
|
||||||
import { selectTrackPlayer } from '@app/state/trackplayer'
|
import { selectTrackPlayer } from '@app/state/trackplayer'
|
||||||
import colors from '@app/styles/colors'
|
import colors from '@app/styles/colors'
|
||||||
@ -10,7 +10,7 @@ import FastImage from 'react-native-fast-image'
|
|||||||
import IconFA from 'react-native-vector-icons/FontAwesome'
|
import IconFA from 'react-native-vector-icons/FontAwesome'
|
||||||
import IconFA5 from 'react-native-vector-icons/FontAwesome5'
|
import IconFA5 from 'react-native-vector-icons/FontAwesome5'
|
||||||
import IconMat from 'react-native-vector-icons/MaterialIcons'
|
import IconMat from 'react-native-vector-icons/MaterialIcons'
|
||||||
import { AlbumContextPressable, SongContextPressable } from './ContextMenu'
|
import { AlbumContextPressable, ArtistContextPressable, SongContextPressable } from './ContextMenu'
|
||||||
import CoverArt from './CoverArt'
|
import CoverArt from './CoverArt'
|
||||||
import PressableOpacity from './PressableOpacity'
|
import PressableOpacity from './PressableOpacity'
|
||||||
|
|
||||||
@ -106,12 +106,22 @@ const ListItem: React.FC<{
|
|||||||
),
|
),
|
||||||
[item, onPress],
|
[item, onPress],
|
||||||
)
|
)
|
||||||
|
const artistPressable = useCallback(
|
||||||
|
({ children }) => (
|
||||||
|
<ArtistContextPressable artist={item as Artist} onPress={onPress} triggerWrapperStyle={styles.item}>
|
||||||
|
{children}
|
||||||
|
</ArtistContextPressable>
|
||||||
|
),
|
||||||
|
[item, onPress],
|
||||||
|
)
|
||||||
|
|
||||||
let PressableComponent = itemPressable
|
let PressableComponent = itemPressable
|
||||||
if (item.itemType === 'album') {
|
if (item.itemType === 'album') {
|
||||||
PressableComponent = albumPressable
|
PressableComponent = albumPressable
|
||||||
} else if (item.itemType === 'song') {
|
} else if (item.itemType === 'song') {
|
||||||
PressableComponent = songPressable
|
PressableComponent = songPressable
|
||||||
|
} else if (item.itemType === 'artist') {
|
||||||
|
PressableComponent = artistPressable
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user