-
Notifications
You must be signed in to change notification settings - Fork 19
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-4949: feat(bdi strategy upload) #1490
Changes from all commits
bce1ba5
205f3e4
bc8e08e
c55f67e
ce40324
683c3aa
a73f08c
af19f79
21e59fd
e384bb8
c248a8d
4903a2f
f3d7c10
f7c2a62
b2fdffa
8a19c25
249484e
a548e9c
99cd461
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,6 +731,7 @@ class _UploadFormState extends State<UploadForm> { | |
], | ||
); | ||
} else if (state is UploadFailure) { | ||
logger.e('Upload failed: ${state.error}'); | ||
if (state.error == UploadErrors.turboTimeout) { | ||
return ArDriveStandardModal( | ||
title: appLocalizationsOf(context).uploadFailed, | ||
|
@@ -746,14 +747,26 @@ class _UploadFormState extends State<UploadForm> { | |
} | ||
|
||
return ArDriveStandardModal( | ||
title: appLocalizationsOf(context).uploadFailed, | ||
width: kLargeDialogWidth, | ||
title: 'Problem with Upload', | ||
description: appLocalizationsOf(context).yourUploadFailed, | ||
actions: [ | ||
ModalAction( | ||
action: () => Navigator.of(context).pop(false), | ||
title: appLocalizationsOf(context).okEmphasized, | ||
), | ||
], | ||
content: state.failedTasks != null | ||
? _failedUploadList(state.failedTasks!) | ||
: null, | ||
actions: state.failedTasks == null | ||
? null | ||
: [ | ||
ModalAction( | ||
action: () => Navigator.of(context).pop(false), | ||
title: 'Do Not Fix', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has to be localized. |
||
), | ||
ModalAction( | ||
action: () { | ||
context.read<UploadCubit>().retryUploads(); | ||
}, | ||
title: 'Re-Upload', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has to be localized. |
||
), | ||
], | ||
); | ||
} else if (state is UploadShowingWarning) { | ||
return ArDriveStandardModal( | ||
|
@@ -937,8 +950,10 @@ class _UploadFormState extends State<UploadForm> { | |
if (task.status == UploadStatus.inProgress || | ||
task.status == UploadStatus.complete || | ||
task.status == UploadStatus.failed) { | ||
progressText = | ||
'${filesize(((task.uploadItem!.size) * task.progress).ceil())}/${filesize(task.uploadItem!.size)}'; | ||
if (task.uploadItem != null) { | ||
progressText = | ||
'${filesize(((task.uploadItem!.size) * task.progress).ceil())}/${filesize(task.uploadItem!.size)}'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could factor this out into its own testable and atomic function. |
||
} | ||
} | ||
} else { | ||
if (task.status == UploadStatus.inProgress) { | ||
|
@@ -1150,6 +1165,101 @@ class _UploadFormState extends State<UploadForm> { | |
); | ||
} | ||
|
||
Widget _failedUploadList(List<UploadTask> tasks) { | ||
return ConstrainedBox( | ||
constraints: const BoxConstraints( | ||
maxHeight: 256 * 1.5, minWidth: kLargeDialogWidth), | ||
child: Container( | ||
padding: const EdgeInsets.all(8), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text( | ||
'It seems there was a partial failure uploading the following file(s). The file(s) will show as failed in your drive. Please re-upload to fix.', | ||
Comment on lines
+1177
to
+1178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has to be localized. |
||
style: ArDriveTypography.body.buttonLargeBold()), | ||
const SizedBox(height: 8), | ||
Expanded( | ||
child: ArDriveScrollBar( | ||
child: ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: tasks.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
final task = tasks[index]; | ||
|
||
if (task.content != null) { | ||
for (var file in task.content!) { | ||
return ListTile( | ||
leading: file is ARFSFileUploadMetadata | ||
? getIconForContentType( | ||
file.dataContentType, | ||
size: 24, | ||
) | ||
: file is ARFSFolderUploadMetatadata | ||
? getIconForContentType( | ||
'folder', | ||
size: 24, | ||
) | ||
: null, | ||
contentPadding: EdgeInsets.zero, | ||
title: Row( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
mainAxisSize: MainAxisSize.max, | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Flexible( | ||
flex: 1, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
file.name, | ||
style: ArDriveTypography.body | ||
.buttonNormalBold( | ||
color: ArDriveTheme.of(context) | ||
.themeData | ||
.colors | ||
.themeFgDefault, | ||
) | ||
.copyWith( | ||
fontWeight: FontWeight.bold), | ||
), | ||
AnimatedSwitcher( | ||
duration: const Duration(seconds: 1), | ||
child: Column( | ||
children: [ | ||
if (file is ARFSFileUploadMetadata) | ||
Text( | ||
filesize(file.size), | ||
style: ArDriveTypography.body | ||
.buttonNormalBold( | ||
color: ArDriveTheme.of(context) | ||
.themeData | ||
.colors | ||
.themeFgOnDisabled, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
return const SizedBox(); | ||
}, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Color _getUploadStatusColor( | ||
BuildContext context, UploadTask uploadStatusColor) { | ||
final themeColors = ArDriveTheme.of(context).themeData.colors; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has to be localized.