From 1ed9ac087082f995d8e8efb10d4929bdc326323c Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Fri, 23 Jul 2021 17:46:29 +0900 Subject: [PATCH] better/shared list player controls w/shuffle also faked download list/song (by star for now, also faked) --- app/components/Button.tsx | 27 +++++++++---- app/components/ListPlayerControls.tsx | 58 +++++++++++++++++++++++++++ app/components/SongItem.tsx | 48 ++++++++++++++++++---- app/screens/AlbumView.tsx | 10 +---- app/screens/PlaylistView.tsx | 12 +++--- 5 files changed, 128 insertions(+), 27 deletions(-) create mode 100644 app/components/ListPlayerControls.tsx diff --git a/app/components/Button.tsx b/app/components/Button.tsx index 658c5e0..13b32a7 100644 --- a/app/components/Button.tsx +++ b/app/components/Button.tsx @@ -5,12 +5,15 @@ import { GestureResponderEvent, StyleSheet, Text } from 'react-native' import PressableOpacity from './PressableOpacity' const Button: React.FC<{ - title: string + title?: string + buttonStyle?: 'hollow' | 'highlight' onPress: (event: GestureResponderEvent) => void -}> = ({ title, onPress }) => { +}> = ({ title, buttonStyle, onPress, children }) => { return ( - - {title} + + {title ? {title} : children} ) } @@ -18,16 +21,26 @@ const Button: React.FC<{ const styles = StyleSheet.create({ container: { backgroundColor: colors.accent, - paddingHorizontal: 24, + paddingHorizontal: 10, minHeight: 42, justifyContent: 'center', borderRadius: 1000, }, + hollow: { + backgroundColor: 'transparent', + borderColor: colors.text.secondary, + borderWidth: 1.5, + }, + highlight: { + borderColor: colors.text.primary, + borderWidth: 1.5, + }, text: { - fontSize: 15, + fontSize: 16, fontFamily: font.bold, color: colors.text.primary, + paddingHorizontal: 14, }, }) -export default React.memo(Button) +export default Button diff --git a/app/components/ListPlayerControls.tsx b/app/components/ListPlayerControls.tsx new file mode 100644 index 0000000..3d5f6ff --- /dev/null +++ b/app/components/ListPlayerControls.tsx @@ -0,0 +1,58 @@ +import Button from '@app/components/Button' +import { Song } from '@app/models/music' +import { useSetQueue } from '@app/state/trackplayer' +import colors from '@app/styles/colors' +import React, { useState } from 'react' +import { StyleSheet, View, ViewStyle } from 'react-native' +import Icon from 'react-native-vector-icons/Ionicons' +import IconMat from 'react-native-vector-icons/MaterialIcons' + +const ListPlayerControls = React.memo<{ + songs: Song[] + typeName: string + queueName: string + style?: ViewStyle +}>(({ songs, typeName, queueName, style }) => { + const [downloaded, setDownloaded] = useState(false) + const setQueue = useSetQueue() + + return ( + + + + + + + + + ) +}) + +const styles = StyleSheet.create({ + controls: { + flexDirection: 'row', + }, + controlsSide: { + flex: 4, + flexDirection: 'row', + justifyContent: 'center', + }, + controlsCenter: { + flexDirection: 'row', + justifyContent: 'center', + alignItems: 'center', + }, +}) + +export default ListPlayerControls diff --git a/app/components/SongItem.tsx b/app/components/SongItem.tsx index dc9c4b9..e61b255 100644 --- a/app/components/SongItem.tsx +++ b/app/components/SongItem.tsx @@ -3,9 +3,11 @@ import { currentTrackAtom } from '@app/state/trackplayer' import colors from '@app/styles/colors' import font from '@app/styles/font' import { useAtomValue } from 'jotai/utils' -import React from 'react' +import React, { useState } from 'react' import { GestureResponderEvent, StyleSheet, Text, View } from 'react-native' import IconFA from 'react-native-vector-icons/FontAwesome' +import IconFA5 from 'react-native-vector-icons/FontAwesome5' +import IconMat from 'react-native-vector-icons/MaterialIcons' import CoverArt from './CoverArt' import PressableOpacity from './PressableOpacity' @@ -16,23 +18,42 @@ const SongItem: React.FC<{ subtitle?: 'artist' | 'album' }> = ({ song, onPress, showArt, subtitle }) => { const currentTrack = useAtomValue(currentTrackAtom) + const [starred, setStarred] = useState(false) subtitle = subtitle || 'artist' + const playing = currentTrack?.id === song.id return ( {showArt ? : <>} - - {song.title} - - {song[subtitle]} + + {playing ? : <>} + {song.title} + + + {starred ? ( + + ) : ( + <> + )} + {song[subtitle]} + - - + setStarred(!starred)}> + {starred ? ( + + ) : ( + + )} @@ -60,10 +81,23 @@ const styles = StyleSheet.create({ text: { flex: 1, }, + textLine: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'flex-start', + }, title: { fontSize: 16, fontFamily: font.semiBold, }, + playingIcon: { + marginRight: 5, + marginLeft: 1, + }, + downloadedIcon: { + marginRight: 2, + marginLeft: -3, + }, subtitle: { fontSize: 14, fontFamily: font.regular, diff --git a/app/screens/AlbumView.tsx b/app/screens/AlbumView.tsx index 0b167ee..755d145 100644 --- a/app/screens/AlbumView.tsx +++ b/app/screens/AlbumView.tsx @@ -1,7 +1,7 @@ -import Button from '@app/components/Button' import CoverArt from '@app/components/CoverArt' import GradientBackground from '@app/components/GradientBackground' import ImageGradientScrollView from '@app/components/ImageGradientScrollView' +import ListPlayerControls from '@app/components/ListPlayerControls' import NothingHere from '@app/components/NothingHere' import SongItem from '@app/components/SongItem' import { albumAtomFamily } from '@app/state/music' @@ -25,10 +25,7 @@ const AlbumDetails: React.FC<{ const Songs = () => ( <> - -