import PressableOpacity from '@app/components/PressableOpacity' import { AlbumListItem } from '@app/models/music' import colors from '@app/styles/colors' import font from '@app/styles/font' import { useNavigation } from '@react-navigation/native' import { ReactComponentLike } from 'prop-types' import React from 'react' import { ScrollView, StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native' import FastImage from 'react-native-fast-image' import { Menu, MenuOption, MenuOptions, MenuTrigger, renderers } from 'react-native-popup-menu' import IconFA from 'react-native-vector-icons/FontAwesome' import IconMat from 'react-native-vector-icons/MaterialIcons' import CoverArt from './CoverArt' const { SlideInMenu } = renderers type ContextMenuProps = { menuStyle?: StyleProp triggerWrapperStyle?: StyleProp triggerOuterWrapperStyle?: StyleProp triggerTouchableStyle?: StyleProp onPress?: () => void } type InternalContextMenuProps = ContextMenuProps & { menuHeader: React.ReactNode menuOptions: React.ReactNode } const ContextMenu: React.FC = ({ menuStyle, triggerWrapperStyle, triggerOuterWrapperStyle, triggerTouchableStyle, onPress, menuHeader, menuOptions, children, }) => { menuStyle = menuStyle || { flex: 1 } triggerWrapperStyle = triggerWrapperStyle || { flex: 1 } triggerOuterWrapperStyle = triggerOuterWrapperStyle || { flex: 1 } triggerTouchableStyle = triggerTouchableStyle || { flex: 1 } return ( {children} ( {menuHeader} {options} )}> {menuOptions} ) } type ContextMenuOptionProps = { onSelect?: () => void } const ContextMenuOption: React.FC = ({ onSelect, children }) => ( {children} ) type ContextMenuIconTextOptionProps = ContextMenuOptionProps & { IconComponent: ReactComponentLike name: string size: number color?: string text: string } const ContextMenuIconTextOption = React.memo( ({ onSelect, IconComponent, name, color, size, text }) => ( {text} ), ) export type AlbumContextPressableProps = ContextMenuProps & { album: AlbumListItem } export const AlbumContextPressable: React.FC = ({ menuStyle, triggerWrapperStyle, triggerOuterWrapperStyle, triggerTouchableStyle, onPress, album, children, }) => { const navigation = useNavigation() return ( {album.name} {album.artist ? ( {album.artist} ) : ( <> )} } menuOptions={ <> navigation.navigate('artist', { id: album.artistId, title: album.artist })} /> }> {children} ) } const styles = StyleSheet.create({ optionsContainer: { backgroundColor: 'rgba(45, 45, 45, 0.95)', maxHeight: 365, }, optionsWrapper: { // marginBottom: 10, }, menuHeader: { paddingTop: 14, paddingBottom: 10, paddingHorizontal: 20, flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', }, coverArt: { width: 42, height: 42, }, menuHeaderText: { flex: 1, marginLeft: 10, }, menuTitle: { fontFamily: font.semiBold, fontSize: 16, color: colors.text.primary, }, menuSubtitle: { fontFamily: font.regular, fontSize: 14, color: colors.text.secondary, }, option: { paddingVertical: 10, paddingHorizontal: 20, flexDirection: 'row', alignItems: 'center', }, icon: { marginRight: 10, width: 32, height: 32, justifyContent: 'center', alignItems: 'center', // backgroundColor: 'red', }, optionText: { fontFamily: font.semiBold, fontSize: 16, color: colors.text.primary, // backgroundColor: 'green', }, })