feat: add file view (#1064)

This commit is contained in:
Aman Harwara
2022-06-06 21:30:51 +05:30
committed by GitHub
parent c20f0ad78b
commit 92024ec7ca
33 changed files with 661 additions and 382 deletions

View File

@@ -10,7 +10,8 @@ import { DisplayableListItemProps } from './Types/DisplayableListItemProps'
const FileListItem: FunctionComponent<DisplayableListItemProps> = ({
application,
viewControllerManager,
filesController,
selectionController,
hideDate,
hideIcon,
hideTags,
@@ -21,40 +22,28 @@ const FileListItem: FunctionComponent<DisplayableListItemProps> = ({
}) => {
const openFileContextMenu = useCallback(
(posX: number, posY: number) => {
viewControllerManager.filesController.setFileContextMenuLocation({
filesController.setFileContextMenuLocation({
x: posX,
y: posY,
})
viewControllerManager.filesController.setShowFileContextMenu(true)
filesController.setShowFileContextMenu(true)
},
[viewControllerManager.filesController],
[filesController],
)
const openContextMenu = useCallback(
async (posX: number, posY: number) => {
const { didSelect } = await viewControllerManager.selectionController.selectItem(item.uuid)
const { didSelect } = await selectionController.selectItem(item.uuid)
if (didSelect) {
openFileContextMenu(posX, posY)
}
},
[viewControllerManager.selectionController, item.uuid, openFileContextMenu],
[selectionController, item.uuid, openFileContextMenu],
)
const onClick = useCallback(() => {
void viewControllerManager.selectionController.selectItem(item.uuid, true).then(({ didSelect }) => {
if (didSelect && viewControllerManager.selectionController.selectedItemsCount < 2) {
viewControllerManager.filePreviewModalController.activate(
item as FileItem,
viewControllerManager.filesController.allFiles,
)
}
})
}, [
viewControllerManager.filePreviewModalController,
viewControllerManager.filesController.allFiles,
viewControllerManager.selectionController,
item,
])
void selectionController.selectItem(item.uuid, true)
}, [item.uuid, selectionController])
const IconComponent = () =>
getFileIconComponent(