From e8cf6f8975f838bce6c73c26af4ab5a924f77734 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:12:13 -0300 Subject: [PATCH] add preview icon --- .../components/drive_detail_data_list.dart | 3 ++- .../components/drive_explorer_item_tile.dart | 27 ++++++++++++++++++- .../drive_detail/models/data_table_item.dart | 6 +++++ test/test_utils/mocks.dart | 1 + 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/pages/drive_detail/components/drive_detail_data_list.dart b/lib/pages/drive_detail/components/drive_detail_data_list.dart index 5341111bce..124959521b 100644 --- a/lib/pages/drive_detail/components/drive_detail_data_list.dart +++ b/lib/pages/drive_detail/components/drive_detail_data_list.dart @@ -203,10 +203,11 @@ Widget _buildDataListContent( lastUpdated: row.lastUpdated, dateCreated: row.dateCreated, dataTableItem: row, + context: context, license: row.licenseType == null ? '' : context - .read() + .read() .licenseMetaByType(row.licenseType!) .shortName, isHidden: row.isHidden, diff --git a/lib/pages/drive_detail/components/drive_explorer_item_tile.dart b/lib/pages/drive_detail/components/drive_explorer_item_tile.dart index dc8010551a..519f3fa44b 100644 --- a/lib/pages/drive_detail/components/drive_explorer_item_tile.dart +++ b/lib/pages/drive_detail/components/drive_explorer_item_tile.dart @@ -38,6 +38,7 @@ class DriveExplorerItemTile extends TableRowWidget { required ArdriveTypographyNew typography, required ArDriveDataTableItem dataTableItem, required ArDriveColorTokens colorTokens, + required BuildContext context, }) : super( [ Padding( @@ -63,7 +64,31 @@ class DriveExplorerItemTile extends TableRowWidget { Transform( transform: Matrix4.translationValues(0, 2, 0), child: AntIcon(fileDataTableItem: dataTableItem)), - ] + ], + if (dataTableItem is FileDataTableItem && + dataTableItem.isManifest && + (dataTableItem.assignedNames == null || + dataTableItem.assignedNames!.isEmpty)) ...[ + const SizedBox(width: 8), + Transform( + transform: Matrix4.translationValues(0, 2, 0), + child: ArDriveTooltip( + message: 'Open manifest', + child: ArDriveClickArea( + child: GestureDetector( + child: ArDriveIcons.newWindow( + size: 18, + ), + onTap: () { + context + .read() + .launchPreview(dataTableItem.dataTxId); + }, + ), + ), + ), + ), + ], ], ), ), diff --git a/lib/pages/drive_detail/models/data_table_item.dart b/lib/pages/drive_detail/models/data_table_item.dart index d1ca0351bd..7c11c04b49 100644 --- a/lib/pages/drive_detail/models/data_table_item.dart +++ b/lib/pages/drive_detail/models/data_table_item.dart @@ -7,6 +7,7 @@ import 'package:ardrive/models/database/database.dart'; import 'package:ardrive/models/license.dart'; import 'package:ardrive/services/license/license_state.dart'; import 'package:ardrive_ui/ardrive_ui.dart'; +import 'package:ardrive_utils/ardrive_utils.dart'; abstract class ArDriveDataTableItem extends IndexedItem { final String name; @@ -89,6 +90,7 @@ class FileDataTableItem extends ArDriveDataTableItem { final String? pinnedDataOwnerAddress; final Thumbnail? thumbnail; final List? assignedNames; + final bool isManifest; FileDataTableItem( {required super.driveId, @@ -108,6 +110,7 @@ class FileDataTableItem extends ArDriveDataTableItem { required this.metadataTx, required this.dataTx, required this.pinnedDataOwnerAddress, + required this.isManifest, this.assignedNames, this.thumbnail, super.licenseType, @@ -149,6 +152,7 @@ class DriveDataTableItemMapper { index: index, pinnedDataOwnerAddress: file.pinnedDataOwnerAddress, isHidden: file.isHidden, + isManifest: FileTypeHelper.isManifest(file.dataContentType ?? ''), assignedNames: parseAssignedNamesFromString(file.assignedNames), thumbnail: file.thumbnail != null && file.thumbnail != 'null' ? Thumbnail.fromJson(jsonDecode(file.thumbnail!)) @@ -179,6 +183,7 @@ class DriveDataTableItemMapper { index: 0, pinnedDataOwnerAddress: fileEntry.pinnedDataOwnerAddress, isHidden: fileEntry.isHidden, + isManifest: FileTypeHelper.isManifest(fileEntry.dataContentType ?? ''), assignedNames: parseAssignedNamesFromString(fileEntry.assignedNames), thumbnail: fileEntry.thumbnail != null && fileEntry.thumbnail != 'null' ? Thumbnail.fromJson(jsonDecode(fileEntry.thumbnail!)) @@ -247,6 +252,7 @@ class DriveDataTableItemMapper { index: 0, pinnedDataOwnerAddress: revision.pinnedDataOwnerAddress, isHidden: revision.isHidden, + isManifest: FileTypeHelper.isManifest(revision.dataContentType ?? ''), assignedNames: parseAssignedNamesFromString(revision.assignedNames), thumbnail: revision.thumbnail != null && revision.thumbnail != 'null' ? Thumbnail.fromJson(jsonDecode(revision.thumbnail!)) diff --git a/test/test_utils/mocks.dart b/test/test_utils/mocks.dart index 2b49e7d662..9673921c63 100644 --- a/test/test_utils/mocks.dart +++ b/test/test_utils/mocks.dart @@ -238,6 +238,7 @@ FileDataTableItem createMockFileDataTableItem( index: index, pinnedDataOwnerAddress: pinnedDataOwnerAddress, isOwner: isOwner, + isManifest: false, ); }