You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
977 B
38 lines
977 B
import { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
|
import React, { useCallback } from 'react';
|
|
import { useSelect } from 'App/SelectContext';
|
|
import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton';
|
|
|
|
interface MovieIndexSelectModeButtonProps {
|
|
label: string;
|
|
iconName: IconDefinition;
|
|
isSelectMode: boolean;
|
|
overflowComponent: React.FunctionComponent<never>;
|
|
onPress: () => void;
|
|
}
|
|
|
|
function MovieIndexSelectModeButton(props: MovieIndexSelectModeButtonProps) {
|
|
const { label, iconName, isSelectMode, onPress } = props;
|
|
const [, selectDispatch] = useSelect();
|
|
|
|
const onPressWrapper = useCallback(() => {
|
|
if (isSelectMode) {
|
|
selectDispatch({
|
|
type: 'reset',
|
|
});
|
|
}
|
|
|
|
onPress();
|
|
}, [isSelectMode, onPress, selectDispatch]);
|
|
|
|
return (
|
|
<PageToolbarButton
|
|
label={label}
|
|
iconName={iconName}
|
|
onPress={onPressWrapper}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default MovieIndexSelectModeButton;
|