import colors from '@app/styles/colors'
import dimensions from '@app/styles/dimensions'
import font from '@app/styles/font'
import { useNavigation } from '@react-navigation/core'
import React, { useCallback } from 'react'
import { View, StatusBar, Text, StyleSheet, ViewStyle } from 'react-native'
import Animated from 'react-native-reanimated'
import PressableOpacity from './PressableOpacity'
import IconMat from 'react-native-vector-icons/MaterialIcons'
import { ReactComponentLike } from 'prop-types'
import { AlbumContextPressable, NowPlayingContextPressable } from './ContextMenu'
import { Album, Song } from '@app/models/library'
export type HeaderContextItem = Song | Album
const More = React.memo<{ contextItem?: HeaderContextItem }>(({ contextItem }) => {
const moreIcon =
let context: JSX.Element
switch (contextItem?.itemType) {
case 'song':
context = (
{moreIcon}
)
break
case 'album':
context = (
{moreIcon}
)
break
default:
context = <>>
}
return context
})
const HeaderBar = React.memo<{
title?: string
headerStyle?: Animated.AnimateStyle | Animated.AnimateStyle[]
HeaderCenter?: ReactComponentLike
contextItem?: HeaderContextItem
}>(({ title, headerStyle, HeaderCenter, contextItem }) => {
const navigation = useNavigation()
const back = useCallback(() => {
navigation.goBack()
}, [navigation])
const _headerStyle = Array.isArray(headerStyle) ? headerStyle : [headerStyle]
return (
{HeaderCenter ? (
) : (
{title}
)}
)
})
const styles = StyleSheet.create({
container: {
height: dimensions.top(),
paddingTop: StatusBar.currentHeight,
backgroundColor: colors.gradient.high,
width: '100%',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
},
icons: {
height: 42,
width: 42,
marginHorizontal: 8,
alignItems: 'center',
justifyContent: 'center',
},
center: {
flex: 1,
},
title: {
fontFamily: font.semiBold,
fontSize: 18,
color: colors.text.primary,
flex: 1,
textAlignVertical: 'center',
paddingLeft: 14,
},
})
export default HeaderBar