💄 Optimize uploader
This commit is contained in:
parent
498bb0e5fb
commit
221b97901f
@ -14,7 +14,7 @@ class AttachmentUploadTask {
|
|||||||
Map<String, dynamic>? metadata;
|
Map<String, dynamic>? metadata;
|
||||||
Map<String, int>? chunkFiles;
|
Map<String, int>? chunkFiles;
|
||||||
|
|
||||||
double progress = 0;
|
double? progress;
|
||||||
bool isUploading = false;
|
bool isUploading = false;
|
||||||
bool isCompleted = false;
|
bool isCompleted = false;
|
||||||
dynamic error;
|
dynamic error;
|
||||||
@ -76,6 +76,7 @@ class AttachmentUploaderController extends GetxController {
|
|||||||
|
|
||||||
_startProgressSyncTimer();
|
_startProgressSyncTimer();
|
||||||
queueOfUpload[queueIndex].isUploading = true;
|
queueOfUpload[queueIndex].isUploading = true;
|
||||||
|
queueOfUpload[queueIndex].progress = 0;
|
||||||
|
|
||||||
final task = queueOfUpload[queueIndex];
|
final task = queueOfUpload[queueIndex];
|
||||||
try {
|
try {
|
||||||
@ -121,6 +122,7 @@ class AttachmentUploaderController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queueOfUpload[idx].isUploading = true;
|
queueOfUpload[idx].isUploading = true;
|
||||||
|
queueOfUpload[idx].progress = 0;
|
||||||
|
|
||||||
final task = queueOfUpload[idx];
|
final task = queueOfUpload[idx];
|
||||||
try {
|
try {
|
||||||
|
@ -174,7 +174,7 @@ const i18nEnglish = {
|
|||||||
'attachmentAttached': 'Exists Files',
|
'attachmentAttached': 'Exists Files',
|
||||||
'attachmentUploadBlocked':
|
'attachmentUploadBlocked':
|
||||||
'Upload blocked, there is currently a task in progress...',
|
'Upload blocked, there is currently a task in progress...',
|
||||||
'attachmentAdd': 'Attach attachments',
|
'attachmentAdd': 'Attach file',
|
||||||
'attachmentAddGalleryPhoto': 'Gallery photo',
|
'attachmentAddGalleryPhoto': 'Gallery photo',
|
||||||
'attachmentAddGalleryVideo': 'Gallery video',
|
'attachmentAddGalleryVideo': 'Gallery video',
|
||||||
'attachmentAddCameraPhoto': 'Capture photo',
|
'attachmentAddCameraPhoto': 'Capture photo',
|
||||||
|
@ -64,7 +64,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
|||||||
final AuthProvider auth = Get.find();
|
final AuthProvider auth = Get.find();
|
||||||
if (auth.isAuthorized.isFalse) return;
|
if (auth.isAuthorized.isFalse) return;
|
||||||
|
|
||||||
if (widget.singleMode) {
|
if (!widget.singleMode) {
|
||||||
final medias = await _imagePicker.pickMultiImage(
|
final medias = await _imagePicker.pickMultiImage(
|
||||||
maxWidth: widget.imageMaxWidth,
|
maxWidth: widget.imageMaxWidth,
|
||||||
maxHeight: widget.imageMaxHeight,
|
maxHeight: widget.imageMaxHeight,
|
||||||
@ -341,9 +341,25 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
|||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: element.file.length(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (!snapshot.hasData) return const SizedBox();
|
||||||
|
return Text(
|
||||||
|
_formatBytes(snapshot.data!),
|
||||||
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
if (element.progress != null)
|
||||||
Text(
|
Text(
|
||||||
'In queue #${index + 1}',
|
'${(element.progress! * 100).toStringAsFixed(2)}%',
|
||||||
style: const TextStyle(fontSize: 12),
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -590,16 +606,14 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Text(
|
||||||
child: Text(
|
|
||||||
'attachmentAdd'.tr,
|
'attachmentAdd'.tr,
|
||||||
style:
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
Theme.of(context).textTheme.headlineSmall,
|
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (_uploadController.isUploading.value) {
|
if (_uploadController.isUploading.value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user