feat: connect file actions and media recognition

This commit is contained in:
ngfchl
2026-07-18 11:16:02 +08:00
parent 676f5057cb
commit c37fbe9e7f
4 changed files with 207 additions and 25 deletions
+39 -3
View File
@@ -311,6 +311,37 @@ class _TopBar extends StatelessWidget {
}
}
void _showRenameDialog(BuildContext context, WidgetRef ref, CloudFile file) {
final controller = TextEditingController(text: file.name);
showShadDialog(
context: context,
builder: (dialogContext) => ShadDialog(
title: const Text('重命名'),
description: Text(file.name),
actions: [
ShadButton.outline(
onPressed: () => Navigator.of(dialogContext).pop(),
child: const Text('取消'),
),
ShadButton(
onPressed: () {
final name = controller.text.trim();
if (name.isEmpty || name == file.name) return;
ref.read(fileProvider.notifier).renameFile(file, name);
Navigator.of(dialogContext).pop();
},
child: const Text('保存'),
),
],
child: ShadInput(
controller: controller,
autofocus: true,
placeholder: const Text('文件名称'),
),
),
);
}
class _SegmentButton extends StatelessWidget {
final IconData icon;
final String label;
@@ -1041,12 +1072,15 @@ class _PrimaryFilePane extends ConsumerWidget {
onOpen: file.isDirectory
? () => notifier.navigateToFolder(file)
: () => notifier.downloadFile(file),
onRename: () {},
onRename: () => _showRenameDialog(context, ref, file),
onCopy: () => notifier.copyToClipboard([file]),
onCut: () => notifier.cutToClipboard([file]),
onDownload: () => notifier.downloadFile(file),
onShare: () {},
onDelete: () => notifier.deleteFiles([file]),
onShare: () => notifier.createShare(file),
isRecycleItem: state.section == WorkspaceSection.recycle,
onDelete: () => state.section == WorkspaceSection.recycle
? notifier.restoreFiles([file])
: notifier.deleteFiles([file]),
);
return Draggable<_DraggedCloudFiles>(
data: _DraggedCloudFiles([file], _PaneIdentity.primary),
@@ -1241,8 +1275,10 @@ class _SecondaryFilePaneState extends ConsumerState<_SecondaryFilePane> {
ref.read(fileProvider.notifier).copyToClipboard([file]),
onCut: () =>
ref.read(fileProvider.notifier).cutToClipboard([file]),
onRename: () => _showRenameDialog(context, ref, file),
onDownload: () =>
ref.read(fileProvider.notifier).downloadFile(file),
onShare: () => ref.read(fileProvider.notifier).createShare(file),
onDelete: () =>
ref.read(fileProvider.notifier).deleteFiles([file]),
);