Skip to content

Commit

Permalink
Merge pull request #1767 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-6348: Release ArDrive v2.48.0
  • Loading branch information
thiagocarvalhodev authored Jun 26, 2024
2 parents 7caa8f3 + 5881839 commit 9de0338
Show file tree
Hide file tree
Showing 58 changed files with 2,853 additions and 667 deletions.
1 change: 1 addition & 0 deletions android/fastlane/metadata/android/en-US/changelogs/131.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- New Feature: Thumbnails for image files now supported and displayed in drive explorer
16 changes: 16 additions & 0 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class UploadCubit extends Cubit<UploadState> {
late Drive _targetDrive;
late FolderEntry _targetFolder;
UploadMethod? _uploadMethod;
bool _uploadThumbnail = true;

void changeUploadThumbnailOption(bool uploadThumbnail) {
_uploadThumbnail = uploadThumbnail;
}

void setUploadMethod(
UploadMethod? method,
Expand Down Expand Up @@ -601,6 +606,7 @@ class UploadCubit extends Cubit<UploadState> {
final uploadController = await ardriveUploader.uploadEntities(
entities: entities,
wallet: _auth.currentUser.wallet,
uploadThumbnail: _uploadThumbnail,
type:
_uploadMethod == UploadMethod.ar ? UploadType.d2n : UploadType.turbo,
driveKey: driveKey,
Expand Down Expand Up @@ -722,6 +728,7 @@ class UploadCubit extends Cubit<UploadState> {
files: uploadFiles,
wallet: _auth.currentUser.wallet,
driveKey: driveKey,
uploadThumbnail: _uploadThumbnail,
type:
_uploadMethod == UploadMethod.ar ? UploadType.d2n : UploadType.turbo,
);
Expand Down Expand Up @@ -817,6 +824,14 @@ class UploadCubit extends Cubit<UploadState> {
? RevisionAction.uploadNewVersion
: RevisionAction.create;

Thumbnail? thumbnail;

if (fileMetadata.thumbnailInfo != null) {
thumbnail = Thumbnail(variants: [
Variant.fromJson(fileMetadata.thumbnailInfo!.first.toJson())
]);
}

final entity = FileEntity(
dataContentType: fileMetadata.dataContentType,
dataTxId: fileMetadata.dataTxId,
Expand All @@ -827,6 +842,7 @@ class UploadCubit extends Cubit<UploadState> {
name: fileMetadata.name,
parentFolderId: fileMetadata.parentFolderId,
size: fileMetadata.size,
thumbnail: thumbnail,
// TODO: pinnedDataOwnerAddress
);

Expand Down
1 change: 0 additions & 1 deletion lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class UploadReady extends UploadState {
final bool isDragNDrop;
final bool uploadIsPublic;
final int numberOfFiles;

final UploadParams params;

final bool isArConnect;
Expand Down
64 changes: 47 additions & 17 deletions lib/components/details_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:ardrive/components/truncated_address.dart';
import 'package:ardrive/core/arfs/entities/arfs_entities.dart';
import 'package:ardrive/core/crypto/crypto.dart';
import 'package:ardrive/download/multiple_file_download_modal.dart';
import 'package:ardrive/drive_explorer/thumbnail_creation/page/thumbnail_creation_modal.dart';
import 'package:ardrive/l11n/l11n.dart';
import 'package:ardrive/misc/resources.dart';
import 'package:ardrive/models/models.dart';
Expand All @@ -25,6 +26,7 @@ import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/filesize.dart';
import 'package:ardrive/utils/num_to_string_parsers.dart';
import 'package:ardrive/utils/open_url.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
import 'package:ardrive/utils/size_constants.dart';
import 'package:ardrive/utils/user_utils.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
Expand Down Expand Up @@ -303,6 +305,27 @@ class _DetailsPanelState extends State<DetailsPanel> {
size: 32,
),
},
if (widget.item is FileDataTableItem &&
FileTypeHelper.isImage(widget.item.contentType) &&
(widget.item as FileDataTableItem).thumbnail ==
null) ...{
ArDriveIconButton(
icon: ArDriveIcons.image(),
tooltip: 'Create Thumbnail',
onPressed: () {
showArDriveDialog(
context,
content: BlocProvider.value(
value: context.read<DriveDetailCubit>(),
child: ThumbnailCreationModal(
fileDataTableItem:
widget.item as FileDataTableItem,
),
),
);
},
)
},
if (widget.currentDrive != null)
ScreenTypeLayout.builder(
desktop: (context) => const SizedBox.shrink(),
Expand Down Expand Up @@ -716,15 +739,11 @@ class _DetailsPanelState extends State<DetailsPanel> {
leading: Row(
mainAxisSize: MainAxisSize.min,
children: [
ArDriveIconButton(
tooltip: appLocalizationsOf(context).viewOnViewBlock,
icon: ArDriveIcons.newWindow(size: 20),
onPressed: () {
openUrl(
url:
'https://viewblock.io/arweave/tx/${state.metadataTxId}',
);
},
Text(
'${state.metadataTxId.substring(0, 4)}...',
style: ArDriveTypography.body
.buttonNormalRegular()
.copyWith(decoration: TextDecoration.underline),
),
const SizedBox(width: 12),
CopyButton(
Expand All @@ -739,14 +758,25 @@ class _DetailsPanelState extends State<DetailsPanel> {
leading: Row(
mainAxisSize: MainAxisSize.min,
children: [
ArDriveIconButton(
tooltip: appLocalizationsOf(context).viewOnViewBlock,
icon: ArDriveIcons.newWindow(size: 20),
onPressed: () {
openUrl(
url: 'https://viewblock.io/arweave/tx/${item.dataTxId}',
);
},
// only first 4 characters of the data tx id are shown
ArDriveClickArea(
child: GestureDetector(
onTap: () {
openUrl(
url: 'https://viewblock.io/arweave/tx/${item.dataTxId}',
);
},
child: Tooltip(
message: item.dataTxId,
child: Text(
'${item.dataTxId.substring(0, 4)}...',
style:
ArDriveTypography.body.buttonNormalRegular().copyWith(
decoration: TextDecoration.underline,
),
),
),
),
),
const SizedBox(width: 12),
CopyButton(
Expand Down
40 changes: 20 additions & 20 deletions lib/components/side_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ class _AppSideBarState extends State<AppSideBar> {
}

Widget _buildAccordion(DrivesLoadSuccess state, bool isMobile) {
final typography = ArDriveTypographyNew.of(context);

return ArDriveAccordion(
contentPadding: isMobile ? const EdgeInsets.all(4) : null,
key: ValueKey(state.userDrives.map((e) => e.name)),
Expand All @@ -291,9 +293,9 @@ class _AppSideBarState extends State<AppSideBar> {
isExpanded: true,
Text(
appLocalizationsOf(context).publicDrives,
style: ArDriveTypography.body.buttonLargeBold().copyWith(
fontWeight: FontWeight.w700,
),
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
state.userDrives
.where((element) => element.isPublic)
Expand All @@ -319,9 +321,9 @@ class _AppSideBarState extends State<AppSideBar> {
isExpanded: true,
Text(
appLocalizationsOf(context).privateDrives,
style: ArDriveTypography.body
.buttonLargeBold()
.copyWith(fontWeight: FontWeight.w700),
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
state.userDrives
.where((element) => element.isPrivate)
Expand All @@ -342,9 +344,9 @@ class _AppSideBarState extends State<AppSideBar> {
isExpanded: true,
Text(
appLocalizationsOf(context).sharedDrives,
style: ArDriveTypography.body
.buttonLargeBold()
.copyWith(fontWeight: FontWeight.w700),
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
state.sharedDrives
.map(
Expand Down Expand Up @@ -675,6 +677,8 @@ class DriveListTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
final typography = ArDriveTypographyNew.of(context);

return GestureDetector(
key: key,
onTap: onTap,
Expand All @@ -693,19 +697,15 @@ class DriveListTile extends StatelessWidget {
child: Text(
drive.name,
style: isSelected
? ArDriveTypography.body
.buttonNormalBold(
color: ArDriveTheme.of(context)
.themeData
.colors
.themeFgDefault,
)
.copyWith(fontWeight: FontWeight.w700)
: ArDriveTypography.body.buttonNormalRegular(
? typography.paragraphNormal(
fontWeight: ArFontWeight.semiBold,
)
: typography.paragraphNormal(
fontWeight: ArFontWeight.semiBold,
color: ArDriveTheme.of(context)
.themeData
.colors
.themeAccentDisabled,
.colorTokens
.textLow,
),
),
),
Expand Down
31 changes: 31 additions & 0 deletions lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ class _UploadFormState extends State<UploadForm> {
),
);
} else if (state is UploadReady) {
final typography = ArDriveTypographyNew.of(context);
return ReactiveForm(
formGroup: context.watch<UploadCubit>().licenseCategoryForm,
child: ReactiveFormConsumer(builder: (_, form, __) {
Expand Down Expand Up @@ -478,6 +479,33 @@ class _UploadFormState extends State<UploadForm> {
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Row(
children: [
ArDriveCheckBox(
title: 'Upload with thumbnails',
checked: true,
titleStyle: typography.paragraphLarge(
fontWeight: ArFontWeight.semiBold,
),
onChange: (value) {
context
.read<UploadCubit>()
.changeUploadThumbnailOption(value);
},
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: ArDriveIconButton(
icon: ArDriveIcons.info(),
tooltip:
'Uploading with thumbnails is free, but may make your upload take longer.\nYou can always attach a thumbnail later.',
),
)
],
),
),
SizedBox(
child: ReactiveForm(
formGroup:
Expand Down Expand Up @@ -954,6 +982,9 @@ class _UploadFormState extends State<UploadForm> {
case UploadStatus.creatingBundle:
status =
'We are preparing your upload. Preparation step 2/2';
case UploadStatus.uploadingThumbnail:
status = 'Uploading thumbnail...';
break;
}

final statusAvailableForShowingProgress =
Expand Down
Loading

0 comments on commit 9de0338

Please sign in to comment.