2023-01-15 18:47:40 +00:00
|
|
|
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
|
|
|
import React, { useCallback } from 'react';
|
2023-03-25 00:41:17 +00:00
|
|
|
import { useSelect } from 'App/SelectContext';
|
2023-01-15 18:47:40 +00:00
|
|
|
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
|
|
|
|
|
|
|
|
interface ArtistIndexSelectModeButtonProps {
|
|
|
|
label: string;
|
|
|
|
iconName: IconDefinition;
|
|
|
|
isSelectMode: boolean;
|
2023-04-04 16:21:34 +00:00
|
|
|
overflowComponent: React.FunctionComponent<never>;
|
2023-01-15 18:47:40 +00:00
|
|
|
onPress: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ArtistIndexSelectModeButton(props: ArtistIndexSelectModeButtonProps) {
|
|
|
|
const { label, iconName, isSelectMode, onPress } = props;
|
|
|
|
const [, selectDispatch] = useSelect();
|
|
|
|
|
|
|
|
const onPressWrapper = useCallback(() => {
|
|
|
|
if (isSelectMode) {
|
|
|
|
selectDispatch({
|
2023-03-25 00:41:17 +00:00
|
|
|
type: 'reset',
|
2023-01-15 18:47:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onPress();
|
|
|
|
}, [isSelectMode, onPress, selectDispatch]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<PageToolbarButton
|
|
|
|
label={label}
|
|
|
|
iconName={iconName}
|
|
|
|
onPress={onPressWrapper}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ArtistIndexSelectModeButton;
|