mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-10-22 00:54:37 -04:00
* Some initial drafts * Finising the first draft on non-indexed locations * Minor tweaks * Fix warnings * Adding date_created and date_modified to non indexed path entries * Add id and path properties to NonIndexedPathItem * Working ephemeral location (hardcoded home for now) * Fix UI for ephemeral locations * Fix windows * Passing ephemeral thumbnails to thumbnails remover * Indexing rules for ephemeral paths walking * Animate Location button when path text overflow it's size * Fix Linux not showing all volumes * Fix Linux - Add some missing no_os_protected rules for macOS - Improve ephemeral location names * Remove unecessary import * Fix Mobile * Improve resizing behaviour for ephemeral location topbar path button - Improve Search View (Replace custom empty component with Explorer's emptyNotice ) - Improve how TopBar children positioning * Hide EphemeralSection if there is no volume or home - Disable Ephemeral topbar path button animation when text is not overflowing * minor fixes * Introducing ordering for ephemeral paths * TS Format * Ephemeral locations UI fixes - Fix indexed Locations having no metadata - Remove date indexed/accessed options for sorting Ephemeral locations - Remove empty three dots from SideBar element when no settings is linked * Add tooltip to add location button in ephemeral locations * Fix indexed Locations selecting other folder/files in Ephemeral location * Minor fixes * Fix app breaking due to wrong logic to get item full path in Explorer * Revert some recent changes to Thumb.tsx * Fix original not loading for overview items - Fix QuickPreview name broken for overview items * Improve imports * Revert replace useEffect with useLayoutEffect for locked logic in ListView It was causing the component to full reload when clicking a header to sort per column * Changes from feedback * Hide some unused Inspector metadata fields on NonIndexedPaths - Merge formatDate functions while retaining original behaviour * Use tauri api for getting user home * Change ThumbType to a string enum to allow for string comparisons * Improve ObjectKind typing --------- Co-authored-by: Vítor Vasconcellos <vasconcellos.dev@gmail.com> Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
85 lines
2.1 KiB
TypeScript
85 lines
2.1 KiB
TypeScript
import clsx from 'clsx';
|
|
import { memo } from 'react';
|
|
import { type ExplorerItem, byteSize, getItemFilePath, getItemLocation } from '@sd/client';
|
|
import { ViewItem } from '.';
|
|
import { useExplorerContext } from '../Context';
|
|
import { FileThumb } from '../FilePath/Thumb';
|
|
import { useExplorerViewContext } from '../ViewContext';
|
|
import GridList from './GridList';
|
|
import RenamableItemText from './RenamableItemText';
|
|
|
|
interface GridViewItemProps {
|
|
data: ExplorerItem;
|
|
selected: boolean;
|
|
isRenaming: boolean;
|
|
cut: boolean;
|
|
renamable: boolean;
|
|
}
|
|
|
|
const GridViewItem = memo(({ data, selected, cut, isRenaming, renamable }: GridViewItemProps) => {
|
|
const explorer = useExplorerContext();
|
|
const { showBytesInGridView, gridItemSize } = explorer.useSettingsSnapshot();
|
|
|
|
const filePathData = getItemFilePath(data);
|
|
const location = getItemLocation(data);
|
|
|
|
const showSize =
|
|
!filePathData?.is_dir &&
|
|
!location &&
|
|
showBytesInGridView &&
|
|
(!isRenaming || (isRenaming && !selected));
|
|
|
|
return (
|
|
<ViewItem data={data} className="h-full w-full">
|
|
<div
|
|
className={clsx('mb-1 aspect-square rounded-lg', selected && 'bg-app-selectedItem')}
|
|
>
|
|
<FileThumb
|
|
data={data}
|
|
frame
|
|
blackBars
|
|
extension
|
|
className={clsx('px-2 py-1', cut && 'opacity-60')}
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex flex-col justify-center">
|
|
<RenamableItemText
|
|
item={data}
|
|
selected={selected}
|
|
style={{ maxHeight: gridItemSize / 3 }}
|
|
disabled={!renamable}
|
|
/>
|
|
{showSize && filePathData?.size_in_bytes_bytes && (
|
|
<span
|
|
className={clsx(
|
|
'cursor-default truncate rounded-md px-1.5 py-[1px] text-center text-tiny text-ink-dull '
|
|
)}
|
|
>
|
|
{`${byteSize(filePathData.size_in_bytes_bytes)}`}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</ViewItem>
|
|
);
|
|
});
|
|
|
|
export default () => {
|
|
const explorer = useExplorerContext();
|
|
const explorerView = useExplorerViewContext();
|
|
|
|
return (
|
|
<GridList>
|
|
{({ item, selected, cut }) => (
|
|
<GridViewItem
|
|
data={item}
|
|
selected={selected}
|
|
cut={cut}
|
|
isRenaming={explorerView.isRenaming}
|
|
renamable={explorer.selectedItems.size === 1}
|
|
/>
|
|
)}
|
|
</GridList>
|
|
);
|
|
};
|