Skip to content

Commit

Permalink
feat(uploader)
Browse files Browse the repository at this point in the history
- pass the driveKey when uploading
  • Loading branch information
thiagocarvalhodev committed Sep 27, 2023
1 parent 4a27335 commit 2e64c86
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 55 deletions.
16 changes: 1 addition & 15 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -785,24 +785,10 @@ class UploadCubit extends Cubit<UploadState> {
if (!hasEmittedError) {
addError(error);
hasEmittedError = true;
}
}
},
);

return uploader;
}
}

// double calculateTotalPercentage(List<UploadProgress> progressList) {
// double totalProgress = 0;
// int totalSize = 0;

// for (var item in progressList) {
// totalProgress += item.progress * item.totalSize;
// totalSize += item.totalSize;
// }

// if (totalSize == 0) return 0.0; // Avoid division by zero

// return totalProgress / totalSize;
// }
72 changes: 35 additions & 37 deletions lib/pages/drive_detail/components/drive_explorer_item_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DriveExplorerItemTileLeading extends StatelessWidget {
children: [
Align(
alignment: Alignment.center,
child: _getIconForContentType(
child: getIconForContentType(
item.contentType,
),
),
Expand Down Expand Up @@ -110,43 +110,41 @@ class DriveExplorerItemTileLeading extends StatelessWidget {
),
);
}
}

ArDriveIcon _getIconForContentType(String contentType) {
const size = 18.0;

if (contentType == 'folder') {
return ArDriveIcons.folderOutline(
size: size,
);
} else if (FileTypeHelper.isZip(contentType)) {
return ArDriveIcons.zip(
size: size,
);
} else if (FileTypeHelper.isImage(contentType)) {
return ArDriveIcons.image(
size: size,
);
} else if (FileTypeHelper.isVideo(contentType)) {
return ArDriveIcons.video(
size: size,
);
} else if (FileTypeHelper.isAudio(contentType)) {
return ArDriveIcons.music(
size: size,
);
} else if (FileTypeHelper.isDoc(contentType)) {
return ArDriveIcons.fileOutlined(
size: size,
);
} else if (FileTypeHelper.isCode(contentType)) {
return ArDriveIcons.fileOutlined(
size: size,
);
} else {
return ArDriveIcons.fileOutlined(
size: size,
);
}
ArDriveIcon getIconForContentType(String contentType, {double size = 18}) {
if (contentType == 'folder') {
return ArDriveIcons.folderOutline(
size: size,
);
} else if (FileTypeHelper.isZip(contentType)) {
return ArDriveIcons.zip(
size: size,
);
} else if (FileTypeHelper.isImage(contentType)) {
return ArDriveIcons.image(
size: size,
);
} else if (FileTypeHelper.isVideo(contentType)) {
return ArDriveIcons.video(
size: size,
);
} else if (FileTypeHelper.isAudio(contentType)) {
return ArDriveIcons.music(
size: size,
);
} else if (FileTypeHelper.isDoc(contentType)) {
return ArDriveIcons.fileOutlined(
size: size,
);
} else if (FileTypeHelper.isCode(contentType)) {
return ArDriveIcons.fileOutlined(
size: size,
);
} else {
return ArDriveIcons.fileOutlined(
size: size,
);
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/ardrive_uploader/lib/src/ardrive_uploader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,16 @@ class _ArDriveUploader implements ArDriveUploader {
);

/// Attaches the upload controller to the upload service
_uploadFiles(files: files, wallet: wallet, controller: uploadController);
_uploadFiles(
files: files,
wallet: wallet,
controller: uploadController,
driveKey: driveKey,
);

return uploadController;
}

// TODO: broken logic.
Future _uploadFiles({
required List<(ARFSUploadMetadataArgs, IOFile)> files,
required Wallet wallet,
Expand Down
2 changes: 1 addition & 1 deletion packages/ardrive_uploader/lib/src/upload_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class _UploadController implements UploadController {
late StreamSubscription subscription;

subscription =
_progressStream.stream.debounceTime(Duration(milliseconds: 50)).listen(
_progressStream.stream.debounceTime(Duration(milliseconds: 100)).listen(
(event) async {
_start ??= DateTime.now();

Expand Down

0 comments on commit 2e64c86

Please sign in to comment.