diff --git a/app/components/HeaderBar.tsx b/app/components/HeaderBar.tsx index ac51ad6..9f40090 100644 --- a/app/components/HeaderBar.tsx +++ b/app/components/HeaderBar.tsx @@ -8,14 +8,48 @@ import Animated from 'react-native-reanimated' import PressableOpacity from './PressableOpacity' import IconMat from 'react-native-vector-icons/MaterialIcons' import { ReactComponentLike } from 'prop-types' -import { Song } from '@app/models/music' -import { NowPlayingContextPressable } from './ContextMenu' +import { AlbumListItem, Song } from '@app/models/music' +import { AlbumContextPressable, NowPlayingContextPressable } from './ContextMenu' + +export type HeaderContextItem = Song | AlbumListItem + +const More = React.memo<{ contextItem?: HeaderContextItem }>(({ contextItem }) => { + let context: JSX.Element + switch (contextItem?.itemType) { + case 'song': + context = ( + + + + ) + break + case 'album': + context = ( + + + + ) + break + default: + context = <> + } + + return context +}) const HeaderBar = React.memo<{ title?: string headerStyle?: Animated.AnimatedStyleProp | Animated.AnimatedStyleProp[] HeaderCenter?: ReactComponentLike - contextItem?: Song + contextItem?: HeaderContextItem }>(({ title, headerStyle, HeaderCenter, contextItem }) => { const navigation = useNavigation() @@ -25,20 +59,6 @@ const HeaderBar = React.memo<{ const _headerStyle = Array.isArray(headerStyle) ? headerStyle : [headerStyle] - const moreIcon = - let more = <> - if (contextItem) { - more = ( - - {moreIcon} - - ) - } - return ( @@ -53,7 +73,7 @@ const HeaderBar = React.memo<{ )} - {more} + ) }) diff --git a/app/components/ImageGradientBackground.tsx b/app/components/ImageGradientBackground.tsx index 676c00c..15bf056 100644 --- a/app/components/ImageGradientBackground.tsx +++ b/app/components/ImageGradientBackground.tsx @@ -6,13 +6,24 @@ import { AndroidImageColors } from 'react-native-image-colors/lib/typescript/typ import colors from '@app/styles/colors' import GradientBackground from '@app/components/GradientBackground' -const ImageGradientBackground: React.FC<{ +export type ImageGradientBackgroundProps = { height?: number | string width?: number | string position?: 'relative' | 'absolute' style?: ViewStyle imagePath?: string -}> = ({ height, width, position, style, imagePath, children }) => { + onGetColor?: (color: string) => void +} + +const ImageGradientBackground: React.FC = ({ + height, + width, + position, + style, + imagePath, + children, + onGetColor, +}) => { const [highColor, setHighColor] = useState(colors.gradient.high) const navigation = useNavigation() @@ -60,6 +71,10 @@ const ImageGradientBackground: React.FC<{ }) }, [navigation, highColor]) + useEffect(() => { + onGetColor && onGetColor(highColor) + }, [onGetColor, highColor]) + return ( = props => { +const ImageGradientScrollView: React.FC = props => { const layout = useWindowDimensions() const minHeight = layout.height - (dimensions.top() + dimensions.bottom()) @@ -20,7 +20,7 @@ const ImageGradientScrollView: React.FC - + {props.children} ) diff --git a/app/navigation/BottomTabNavigator.tsx b/app/navigation/BottomTabNavigator.tsx index 04f3c52..556e6a6 100644 --- a/app/navigation/BottomTabNavigator.tsx +++ b/app/navigation/BottomTabNavigator.tsx @@ -102,9 +102,9 @@ function createTabStackNavigator(Component: React.ComponentType) { return ( - + - + ) diff --git a/app/screens/SongListView.tsx b/app/screens/SongListView.tsx index aae8d3d..b8c29ca 100644 --- a/app/screens/SongListView.tsx +++ b/app/screens/SongListView.tsx @@ -1,5 +1,6 @@ import CoverArt from '@app/components/CoverArt' import GradientBackground from '@app/components/GradientBackground' +import HeaderBar from '@app/components/HeaderBar' import ImageGradientScrollView from '@app/components/ImageGradientScrollView' import ListItem from '@app/components/ListItem' import ListPlayerControls from '@app/components/ListPlayerControls' @@ -12,7 +13,7 @@ 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, { useEffect } from 'react' +import React, { useEffect, useState } from 'react' import { ActivityIndicator, StyleSheet, Text, View } from 'react-native' type SongListType = 'album' | 'playlist' @@ -71,45 +72,58 @@ const Songs = React.memo<{ }) const SongListDetails = React.memo<{ + title: string type: SongListType songList?: AlbumWithSongs | PlaylistWithSongs subtitle?: string -}>(({ songList, subtitle, type }) => { +}>(({ title, songList, subtitle, type }) => { const coverArtFile = useCoverArtFile(songList?.coverArt, 'thumbnail') + const [headerColor, setHeaderColor] = useState(undefined) if (!songList) { return } return ( - - - - {songList.name} - {subtitle ? {subtitle} : <>} - {songList.songs.length > 0 ? ( - - ) : ( - - )} - - + + {songList.itemType === 'album' && ( + + )} + + + + {songList.name} + {subtitle ? {subtitle} : <>} + {songList.songs.length > 0 ? ( + + ) : ( + + )} + + + ) }) const PlaylistView = React.memo<{ id: string -}>(({ id }) => { + title: string +}>(({ id, title }) => { const playlist = usePlaylistWithSongs(id) - return + return }) const AlbumView = React.memo<{ id: string -}>(({ id }) => { + title: string +}>(({ id, title }) => { const album = useAlbumWithSongs(id) return ( : + return type === 'album' ? : }) const styles = StyleSheet.create({