diff --git a/src/components/common/AlbumView.tsx b/src/components/common/AlbumView.tsx index 3191732..8fd1311 100644 --- a/src/components/common/AlbumView.tsx +++ b/src/components/common/AlbumView.tsx @@ -1,7 +1,9 @@ import { useNavigation } from '@react-navigation/native'; import { useAtomValue } from 'jotai/utils'; -import React, { useEffect } from 'react'; -import { ScrollView, Text, useWindowDimensions, View, Image, Pressable, GestureResponderEvent } from 'react-native'; +import React, { useEffect, useState } from 'react'; +import { GestureResponderEvent, Image, Pressable, ScrollView, Text, useWindowDimensions, View } from 'react-native'; +import { TrackPlayerEvents } from 'react-native-track-player'; +import { useCurrentTrackId, useSetQueue } from '../../hooks/player'; import { albumAtomFamily } from '../../state/music'; import colors from '../../styles/colors'; import text from '../../styles/text'; @@ -24,15 +26,21 @@ const Button: React.FC<{ title: string; onPress: (event: GestureResponderEvent) => void; }> = ({ title, onPress }) => { + const [opacity, setOpacity] = useState(1); + return ( setOpacity(0.6)} + onPressOut={() => setOpacity(1)} + onLongPress={() => setOpacity(1)} style={{ backgroundColor: colors.accent, paddingHorizontal: 24, minHeight: 42, justifyContent: 'center', borderRadius: 1000, + opacity, }} > {title} @@ -40,13 +48,90 @@ const Button: React.FC<{ ); } +const songEvents = [ + TrackPlayerEvents.PLAYBACK_STATE, + TrackPlayerEvents.PLAYBACK_TRACK_CHANGED, +] + +const SongItem: React.FC<{ + id: string; + title: string + artist?: string; + onPress: (event: GestureResponderEvent) => void; +}> = ({ id, title, artist, onPress }) => { + const [opacity, setOpacity] = useState(1); + const currentTrackId = useCurrentTrackId(); + + return ( + + setOpacity(0.6)} + onPressOut={() => setOpacity(1)} + onLongPress={() => setOpacity(1)} + style={{ + flex: 1, + opacity, + }} + > + {title} + {artist} + + + {/* {secondsToTime(duration || 0)} */} + + + + + ); +} + const AlbumDetails: React.FC<{ id: string, }> = ({ id }) => { const album = useAtomValue(albumAtomFamily(id)); const layout = useWindowDimensions(); + const setQueue = useSetQueue(); - const coverSize = layout.width - layout.width / 2; + const coverSize = layout.width - layout.width / 2.5; + + if (!album) { + return ( + No Album + ); + } return ( {album?.name} + }}>{album.name} {album?.artist}{album?.year ? ` • ${album.year}` : ''} + }}>{album.artist}{album.year ? ` • ${album.year}` : ''}