-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96dae13
commit d7899a2
Showing
11 changed files
with
172 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
Text, | ||
View, | ||
Dimensions, | ||
Animated, | ||
TouchableWithoutFeedback, | ||
} from 'react-native'; | ||
import type { Track } from 'react-native-track-player'; | ||
import Image from 'react-native-fast-image'; | ||
|
||
import { useNoxSetting } from '@hooks/useSetting'; | ||
import { getCurrentTPQueue } from '@stores/playingList'; | ||
import SongMenuButton from './SongMenuButton'; | ||
import FavReloadButton from './FavReloadButton'; | ||
|
||
interface Props { | ||
track?: Track; | ||
windowWidth?: number; | ||
onImagePress?: () => void; | ||
children?: React.JSX.Element; | ||
} | ||
const TrackInfoTemplate: React.FC<Props> = ({ | ||
track, | ||
windowWidth, | ||
onImagePress = () => undefined, | ||
children, | ||
}) => { | ||
const playerSetting = useNoxSetting(state => state.playerSetting); | ||
const playerStyle = useNoxSetting(state => state.playerStyle); | ||
const currentPlayingList = useNoxSetting(state => state.currentPlayingList); | ||
const dimension = Dimensions.get('window'); | ||
const albumArtSize = | ||
windowWidth || Math.min(dimension.width, dimension.height); | ||
|
||
const getTrackLocation = () => { | ||
const currentTPQueue = getCurrentTPQueue(); | ||
return track?.song | ||
? `#${ | ||
currentPlayingList.songList.findIndex( | ||
song => song.id === track.song.id | ||
) + 1 | ||
} - ${ | ||
currentTPQueue.findIndex(song => song.id === track.song.id) + 1 | ||
}/${currentTPQueue.length}` | ||
: ''; | ||
}; | ||
|
||
const AlbumArt = () => ( | ||
<TouchableWithoutFeedback onPress={onImagePress}> | ||
<Animated.View style={styles.container}> | ||
<Image | ||
style={[ | ||
styles.artwork, | ||
{ width: albumArtSize, height: albumArtSize }, | ||
]} | ||
source={ | ||
playerSetting.hideCoverInMobile | ||
? 0 | ||
: { | ||
uri: `${track?.artwork}`, | ||
} | ||
} | ||
/> | ||
</Animated.View> | ||
</TouchableWithoutFeedback> | ||
); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
{children || <AlbumArt />} | ||
<Text style={[styles.titleText, { color: playerStyle.colors.primary }]}> | ||
{track?.title} | ||
</Text> | ||
<View style={styles.infoContainer}> | ||
<View style={styles.favoriteButtonContainer}> | ||
<FavReloadButton track={track} /> | ||
</View> | ||
<View style={styles.artistInfoContainer}> | ||
<Text | ||
style={[styles.artistText, { color: playerStyle.colors.secondary }]} | ||
> | ||
{track?.artist} | ||
</Text> | ||
<Text | ||
style={[styles.artistText, { color: playerStyle.colors.secondary }]} | ||
> | ||
{currentPlayingList.title} | ||
</Text> | ||
<Text | ||
style={[styles.artistText, { color: playerStyle.colors.secondary }]} | ||
> | ||
{getTrackLocation()} | ||
</Text> | ||
</View> | ||
<View style={styles.songMenuButtonContainer}> | ||
<SongMenuButton track={track} /> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
export default TrackInfoTemplate; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
}, | ||
artwork: { | ||
marginTop: 15, | ||
opacity: 1, | ||
}, | ||
lyric: { | ||
opacity: 1, | ||
}, | ||
titleText: { | ||
fontSize: 18, | ||
fontWeight: '600', | ||
color: 'grey', | ||
marginTop: 15, | ||
paddingHorizontal: 5, | ||
}, | ||
artistText: { | ||
fontSize: 16, | ||
fontWeight: '200', | ||
}, | ||
infoContainer: { | ||
flexDirection: 'row', | ||
}, | ||
favoriteButtonContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
artistInfoContainer: { | ||
flex: 4, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
songMenuButtonContainer: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './PlayerControls'; | ||
export * from './PlayPauseButton'; | ||
export * from './Progress'; | ||
export * from './TrackInfo/TrackInfo'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters