import CoverArt from '@app/components/CoverArt' import PressableOpacity from '@app/components/PressableOpacity' import { usePause, usePlay } from '@app/hooks/trackplayer' 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 React, { useCallback } from 'react' import { ActivityIndicator, Pressable, StyleSheet, Text, View, ViewStyle } from 'react-native' import { State } from 'react-native-track-player' import IconFA5 from 'react-native-vector-icons/FontAwesome5' const ProgressBar = React.memo(() => { const { position, duration } = useStore(selectTrackPlayer.progress) let progress = 0 if (duration > 0) { progress = position / duration } return ( ) }) const progressStyles = StyleSheet.create({ container: { height: 2, flexDirection: 'row', }, left: { backgroundColor: colors.text.primary, }, right: { backgroundColor: '#595959', }, }) const Controls = React.memo(() => { const state = useStore(selectTrackPlayer.playerState) const play = usePlay() const pause = usePause() let playPauseIcon: string switch (state) { case State.Playing: playPauseIcon = 'pause' break default: playPauseIcon = 'play' break } const action = useCallback(() => { if (state === State.Playing) { pause() } else { play() } }, [state, play, pause]) return ( {state === State.Buffering ? ( ) : ( )} ) }) const NowPlayingBar = React.memo(() => { const navigation = useNavigation() const track = useStore(selectTrackPlayer.currentTrack) const displayStyle: ViewStyle = { display: track ? 'flex' : 'none' } return ( navigation.navigate('now-playing')} style={[styles.container, displayStyle]}> {track?.title} {track?.artist} ) }) const styles = StyleSheet.create({ container: { width: '100%', backgroundColor: colors.gradient.high, borderBottomColor: colors.gradient.low, borderBottomWidth: 1, }, subContainer: { height: 60, flexDirection: 'row', }, detailsContainer: { flex: 1, height: '100%', justifyContent: 'center', marginLeft: 10, }, detailsTitle: { fontFamily: font.semiBold, fontSize: 13, color: colors.text.primary, }, detailsAlbum: { fontFamily: font.regular, fontSize: 13, color: colors.text.secondary, }, controls: { flexDirection: 'row', height: '100%', justifyContent: 'center', alignItems: 'center', marginRight: 18, marginLeft: 12, }, }) export default NowPlayingBar