mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 17:39:27 +01:00
switch more to icons
setupPlayer before every set just in case? docs say to i guess even though it works without...
This commit is contained in:
parent
5fdadfe598
commit
8f62a26093
@ -6,8 +6,9 @@ import { currentTrackAtom, playerStateAtom, usePause, usePlay, useProgress } fro
|
|||||||
import CoverArt from './common/CoverArt'
|
import CoverArt from './common/CoverArt'
|
||||||
import colors from '../styles/colors'
|
import colors from '../styles/colors'
|
||||||
import { Font } from '../styles/text'
|
import { Font } from '../styles/text'
|
||||||
import PressableImage from './common/PressableImage'
|
|
||||||
import { State } from 'react-native-track-player'
|
import { State } from 'react-native-track-player'
|
||||||
|
import PressableOpacity from './common/PressableOpacity'
|
||||||
|
import IconFA5 from 'react-native-vector-icons/FontAwesome5'
|
||||||
|
|
||||||
const ProgressBar = () => {
|
const ProgressBar = () => {
|
||||||
const { position, duration } = useProgress()
|
const { position, duration } = useProgress()
|
||||||
@ -45,18 +46,18 @@ const NowPlayingBar = () => {
|
|||||||
const play = usePlay()
|
const play = usePlay()
|
||||||
const pause = usePause()
|
const pause = usePause()
|
||||||
|
|
||||||
let playPauseIcon: number
|
let playPauseIcon: string
|
||||||
let playPauseAction: () => void
|
let playPauseAction: () => void
|
||||||
|
|
||||||
switch (playerState) {
|
switch (playerState) {
|
||||||
case State.Playing:
|
case State.Playing:
|
||||||
case State.Buffering:
|
case State.Buffering:
|
||||||
case State.Connecting:
|
case State.Connecting:
|
||||||
playPauseIcon = require('../../res/pause-fill.png')
|
playPauseIcon = 'pause'
|
||||||
playPauseAction = pause
|
playPauseAction = pause
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
playPauseIcon = require('../../res/play-fill.png')
|
playPauseIcon = 'play'
|
||||||
playPauseAction = play
|
playPauseAction = play
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -82,13 +83,9 @@ const NowPlayingBar = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.controls}>
|
<View style={styles.controls}>
|
||||||
<PressableImage
|
<PressableOpacity onPress={playPauseAction} hitSlop={14}>
|
||||||
onPress={playPauseAction}
|
<IconFA5 name={playPauseIcon} size={28} color="white" />
|
||||||
source={playPauseIcon}
|
</PressableOpacity>
|
||||||
style={styles.play}
|
|
||||||
tintColor="white"
|
|
||||||
hitSlop={14}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
@ -111,7 +108,6 @@ const styles = StyleSheet.create({
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
// backgroundColor: 'green',
|
|
||||||
},
|
},
|
||||||
detailsTitle: {
|
detailsTitle: {
|
||||||
fontFamily: Font.semiBold,
|
fontFamily: Font.semiBold,
|
||||||
@ -128,13 +124,9 @@ const styles = StyleSheet.create({
|
|||||||
height: '100%',
|
height: '100%',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginRight: 14,
|
marginRight: 18,
|
||||||
marginLeft: 12,
|
marginLeft: 12,
|
||||||
},
|
},
|
||||||
play: {
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default NowPlayingBar
|
export default NowPlayingBar
|
||||||
|
|||||||
@ -1,23 +1,18 @@
|
|||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import { useAtomValue } from 'jotai/utils'
|
import { useAtomValue } from 'jotai/utils'
|
||||||
import React, { useEffect, useState } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import {
|
import { ActivityIndicator, GestureResponderEvent, StyleSheet, Text, useWindowDimensions, View } from 'react-native'
|
||||||
ActivityIndicator,
|
import IconFA from 'react-native-vector-icons/FontAwesome'
|
||||||
GestureResponderEvent,
|
import IconMat from 'react-native-vector-icons/MaterialIcons'
|
||||||
Image,
|
|
||||||
Pressable,
|
|
||||||
Text,
|
|
||||||
useWindowDimensions,
|
|
||||||
View,
|
|
||||||
} from 'react-native'
|
|
||||||
import { albumAtomFamily } from '../../state/music'
|
import { albumAtomFamily } from '../../state/music'
|
||||||
import { currentTrackAtom, useSetQueue } from '../../state/trackplayer'
|
import { currentTrackAtom, useSetQueue } from '../../state/trackplayer'
|
||||||
import colors from '../../styles/colors'
|
import colors from '../../styles/colors'
|
||||||
import text from '../../styles/text'
|
import text, { Font } from '../../styles/text'
|
||||||
import AlbumArt from './AlbumArt'
|
import AlbumArt from './AlbumArt'
|
||||||
import Button from './Button'
|
import Button from './Button'
|
||||||
import GradientBackground from './GradientBackground'
|
import GradientBackground from './GradientBackground'
|
||||||
import ImageGradientScrollView from './ImageGradientScrollView'
|
import ImageGradientScrollView from './ImageGradientScrollView'
|
||||||
|
import PressableOpacity from './PressableOpacity'
|
||||||
|
|
||||||
const SongItem: React.FC<{
|
const SongItem: React.FC<{
|
||||||
id: string
|
id: string
|
||||||
@ -26,67 +21,59 @@ const SongItem: React.FC<{
|
|||||||
track?: number
|
track?: number
|
||||||
onPress: (event: GestureResponderEvent) => void
|
onPress: (event: GestureResponderEvent) => void
|
||||||
}> = ({ id, title, artist, onPress }) => {
|
}> = ({ id, title, artist, onPress }) => {
|
||||||
const [opacity, setOpacity] = useState(1)
|
|
||||||
const currentTrack = useAtomValue(currentTrackAtom)
|
const currentTrack = useAtomValue(currentTrackAtom)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={songStyles.container}>
|
||||||
style={{
|
<PressableOpacity onPress={onPress} style={songStyles.text}>
|
||||||
marginTop: 20,
|
<Text style={{ ...songStyles.title, color: currentTrack?.id === id ? colors.accent : colors.text.primary }}>
|
||||||
marginLeft: 4,
|
|
||||||
flexDirection: 'row',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
}}>
|
|
||||||
<Pressable
|
|
||||||
onPress={onPress}
|
|
||||||
onPressIn={() => setOpacity(0.6)}
|
|
||||||
onPressOut={() => setOpacity(1)}
|
|
||||||
onLongPress={() => setOpacity(1)}
|
|
||||||
style={{
|
|
||||||
flex: 1,
|
|
||||||
opacity,
|
|
||||||
}}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
...text.songListTitle,
|
|
||||||
color: currentTrack?.id === id ? colors.accent : colors.text.primary,
|
|
||||||
}}>
|
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={text.songListSubtitle}>{artist}</Text>
|
<Text style={songStyles.subtitle}>{artist}</Text>
|
||||||
</Pressable>
|
</PressableOpacity>
|
||||||
<View
|
<View style={songStyles.controls}>
|
||||||
style={{
|
<PressableOpacity onPress={undefined}>
|
||||||
flexDirection: 'row',
|
<IconFA name="star-o" size={26} color={colors.text.primary} />
|
||||||
alignItems: 'center',
|
</PressableOpacity>
|
||||||
marginLeft: 10,
|
<PressableOpacity onPress={undefined} style={songStyles.more}>
|
||||||
}}>
|
<IconMat name="more-vert" size={32} color="white" />
|
||||||
{/* <Text style={text.songListSubtitle}>{secondsToTime(duration || 0)}</Text> */}
|
</PressableOpacity>
|
||||||
<Image
|
|
||||||
source={require('../../../res/star.png')}
|
|
||||||
style={{
|
|
||||||
height: 28,
|
|
||||||
width: 28,
|
|
||||||
tintColor: colors.text.secondary,
|
|
||||||
marginLeft: 10,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Image
|
|
||||||
source={require('../../../res/more_vertical.png')}
|
|
||||||
style={{
|
|
||||||
height: 28,
|
|
||||||
width: 28,
|
|
||||||
tintColor: colors.text.secondary,
|
|
||||||
marginLeft: 12,
|
|
||||||
marginRight: 2,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const songStyles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
marginTop: 20,
|
||||||
|
marginLeft: 10,
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
fontSize: 16,
|
||||||
|
fontFamily: Font.semiBold,
|
||||||
|
},
|
||||||
|
subtitle: {
|
||||||
|
fontSize: 14,
|
||||||
|
fontFamily: Font.regular,
|
||||||
|
color: colors.text.secondary,
|
||||||
|
},
|
||||||
|
controls: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
marginLeft: 10,
|
||||||
|
},
|
||||||
|
more: {
|
||||||
|
marginLeft: 8,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const AlbumDetails: React.FC<{
|
const AlbumDetails: React.FC<{
|
||||||
id: string
|
id: string
|
||||||
}> = ({ id }) => {
|
}> = ({ id }) => {
|
||||||
|
|||||||
@ -222,6 +222,7 @@ export const useSetQueue = () => {
|
|||||||
|
|
||||||
return async (songs: Song[], name: string, playId?: string) =>
|
return async (songs: Song[], name: string, playId?: string) =>
|
||||||
trackPlayerCommands.enqueue(async () => {
|
trackPlayerCommands.enqueue(async () => {
|
||||||
|
await TrackPlayer.setupPlayer()
|
||||||
await reset()
|
await reset()
|
||||||
const tracks = songs.map(s => mapSongToTrack(s, name))
|
const tracks = songs.map(s => mapSongToTrack(s, name))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user