Render selection fab in case only one category exists (#553)
This commit is contained in:
@@ -95,6 +95,27 @@ export function Library() {
|
|||||||
[selectedItemIds.length, mangas],
|
[selectedItemIds.length, mangas],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const selectionFab = useMemo(() => {
|
||||||
|
if (!isSelectModeActive) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectionFAB selectedItemsCount={selectedItemIds.length} title="manga.title">
|
||||||
|
{(handleClose, setHideMenu) => (
|
||||||
|
<MangaActionMenuItems
|
||||||
|
selectedMangas={selectedMangas}
|
||||||
|
onClose={(selectionModeState) => {
|
||||||
|
handleClose();
|
||||||
|
setIsSelectModeActive(selectionModeState);
|
||||||
|
}}
|
||||||
|
setHideMenu={setHideMenu}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</SelectionFAB>
|
||||||
|
);
|
||||||
|
}, [isSelectModeActive, selectedMangas]);
|
||||||
|
|
||||||
const { setTitle, setAction } = useContext(NavBarContext);
|
const { setTitle, setAction } = useContext(NavBarContext);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const title = t('library.title');
|
const title = t('library.title');
|
||||||
@@ -172,6 +193,7 @@ export function Library() {
|
|||||||
|
|
||||||
if (tabs.length === 1) {
|
if (tabs.length === 1) {
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<LibraryMangaGrid
|
<LibraryMangaGrid
|
||||||
mangas={mangas}
|
mangas={mangas}
|
||||||
message={t('library.error.label.empty')}
|
message={t('library.error.label.empty')}
|
||||||
@@ -181,17 +203,14 @@ export function Library() {
|
|||||||
handleSelection={handleSelect}
|
handleSelection={handleSelect}
|
||||||
showFilteredOutMessage={showFilteredOutMessage}
|
showFilteredOutMessage={showFilteredOutMessage}
|
||||||
/>
|
/>
|
||||||
|
{selectionFab}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<TabsWrapper>
|
<TabsWrapper>
|
||||||
<TabsMenu
|
<TabsMenu value={activeTab.order} onChange={(e, newTab) => handleTabChange(newTab)} tabsCount={tabs.length}>
|
||||||
value={activeTab.order}
|
|
||||||
onChange={(e, newTab) => handleTabChange(newTab)}
|
|
||||||
tabsCount={tabs.length}
|
|
||||||
>
|
|
||||||
{tabs.map((tab) => (
|
{tabs.map((tab) => (
|
||||||
<Tab
|
<Tab
|
||||||
sx={{ display: 'flex' }}
|
sx={{ display: 'flex' }}
|
||||||
@@ -227,21 +246,7 @@ export function Library() {
|
|||||||
))}
|
))}
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
))}
|
))}
|
||||||
|
{selectionFab}
|
||||||
</TabsWrapper>
|
</TabsWrapper>
|
||||||
{isSelectModeActive && (
|
|
||||||
<SelectionFAB selectedItemsCount={selectedItemIds.length} title="manga.title">
|
|
||||||
{(handleClose, setHideMenu) => (
|
|
||||||
<MangaActionMenuItems
|
|
||||||
selectedMangas={selectedMangas}
|
|
||||||
onClose={(selectionModeState) => {
|
|
||||||
handleClose();
|
|
||||||
setIsSelectModeActive(selectionModeState);
|
|
||||||
}}
|
|
||||||
setHideMenu={setHideMenu}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</SelectionFAB>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user