Skip to content

Commit

Permalink
Merge pull request #1464 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-4934: Release ArDrive Flutter v2.24.0
  • Loading branch information
matibat authored Nov 2, 2023
2 parents ed2827a + dc05ee8 commit f4828bc
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 136 deletions.
3 changes: 3 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/75.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Updates the design of video file previews in the share page.
- Updates the design of image file previews in the share page.
- Fixes the issue of attempting to show a preview for a folder.
35 changes: 30 additions & 5 deletions lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:ardrive/models/models.dart';
import 'package:ardrive/pages/pages.dart';
import 'package:ardrive/services/services.dart';
import 'package:ardrive/utils/constants.dart';
import 'package:ardrive/utils/mime_lookup.dart';
import 'package:ardrive_http/ardrive_http.dart';
import 'package:ardrive_io/ardrive_io.dart';
import 'package:ardrive_utils/ardrive_utils.dart';
import 'package:cryptography/cryptography.dart';
import 'package:drift/drift.dart';
Expand Down Expand Up @@ -79,7 +79,12 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {
final data = await _getPreviewData(file, previewUrl);

if (data != null) {
emit(FsEntryPreviewImage(imageBytes: data, previewUrl: previewUrl));
emit(FsEntryPreviewImage(
imageBytes: data,
previewUrl: previewUrl,
filename: file.name,
contentType: file.contentType,
));
} else {
emit(FsEntryPreviewUnavailable());
}
Expand Down Expand Up @@ -206,6 +211,8 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {
}
}
});
} else {
emit(FsEntryPreviewUnavailable());
}
} else {
emit(FsEntryPreviewUnavailable());
Expand Down Expand Up @@ -278,7 +285,13 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {
switch (drive.privacy) {
case DrivePrivacyTag.public:
emit(
FsEntryPreviewImage(imageBytes: dataBytes, previewUrl: dataUrl),
FsEntryPreviewImage(
imageBytes: dataBytes,
previewUrl: dataUrl,
filename: file.name,
contentType: file.dataContentType ??
lookupMimeTypeWithDefaultType(file.name),
),
);
break;
case DrivePrivacyTag.private:
Expand All @@ -289,7 +302,13 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {

if (isPinFile) {
emit(
FsEntryPreviewImage(imageBytes: dataBytes, previewUrl: dataUrl),
FsEntryPreviewImage(
imageBytes: dataBytes,
previewUrl: dataUrl,
filename: file.name,
contentType: file.dataContentType ??
lookupMimeTypeWithDefaultType(file.name),
),
);
break;
}
Expand All @@ -314,7 +333,13 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {
fileKey,
);
emit(
FsEntryPreviewImage(imageBytes: decodedBytes, previewUrl: dataUrl),
FsEntryPreviewImage(
imageBytes: decodedBytes,
previewUrl: dataUrl,
filename: file.name,
contentType: file.dataContentType ??
lookupMimeTypeWithDefaultType(file.name),
),
);
break;

Expand Down
4 changes: 4 additions & 0 deletions lib/blocs/fs_entry_preview/fs_entry_preview_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ class FsEntryPreviewLoading extends FsEntryPreviewSuccess {

class FsEntryPreviewImage extends FsEntryPreviewSuccess {
final Uint8List imageBytes;
final String filename;
final String contentType;

const FsEntryPreviewImage({
required this.imageBytes,
required this.filename,
required this.contentType,
required String previewUrl,
}) : super(previewUrl: previewUrl);

Expand Down
Loading

0 comments on commit f4828bc

Please sign in to comment.