Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-6985: add preview icon #1902

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ Widget _buildDataListContent(
lastUpdated: row.lastUpdated,
dateCreated: row.dateCreated,
dataTableItem: row,
context: context,
license: row.licenseType == null
? ''
: context
.read<LicenseService>()
.read<LicenseService>()
.licenseMetaByType(row.licenseType!)
.shortName,
isHidden: row.isHidden,
Expand Down
27 changes: 26 additions & 1 deletion lib/pages/drive_detail/components/drive_explorer_item_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DriveExplorerItemTile extends TableRowWidget {
required ArdriveTypographyNew typography,
required ArDriveDataTableItem dataTableItem,
required ArDriveColorTokens colorTokens,
required BuildContext context,
}) : super(
[
Padding(
Expand All @@ -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<DriveDetailCubit>()
.launchPreview(dataTableItem.dataTxId);
},
),
),
),
),
],
],
),
),
Expand Down
6 changes: 6 additions & 0 deletions lib/pages/drive_detail/models/data_table_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,6 +90,7 @@ class FileDataTableItem extends ArDriveDataTableItem {
final String? pinnedDataOwnerAddress;
final Thumbnail? thumbnail;
final List<String>? assignedNames;
final bool isManifest;

FileDataTableItem(
{required super.driveId,
Expand All @@ -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,
Expand Down Expand Up @@ -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!))
Expand Down Expand Up @@ -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!))
Expand Down Expand Up @@ -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!))
Expand Down
1 change: 1 addition & 0 deletions test/test_utils/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ FileDataTableItem createMockFileDataTableItem(
index: index,
pinnedDataOwnerAddress: pinnedDataOwnerAddress,
isOwner: isOwner,
isManifest: false,
);
}

Expand Down
Loading