Skip to content

Commit

Permalink
Merge pull request #1860 from ardriveapp/PE-6777-display-the-file-s-s…
Browse files Browse the repository at this point in the history
…ize-s-instead-of-data-items-or-bundle-sizes

PE-6777: feat(upload): display original file sizes on the upload modal
  • Loading branch information
thiagocarvalhodev authored Sep 19, 2024
2 parents 09b04a0 + 30a4a9e commit d6839f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class UploadCubit extends Cubit<UploadState> {
showArnsCheckbox: showArnsCheckbox,
showArnsNameSelection: false,
loadingArNSNames: true,
totalSize: await _getTotalSize(),
),
);

Expand Down Expand Up @@ -156,6 +157,7 @@ class UploadCubit extends Cubit<UploadState> {
isArConnect: (state as UploadReadyToPrepare).isArConnect,
showArnsCheckbox: showArnsCheckbox,
showArnsNameSelection: false,
totalSize: await _getTotalSize(),
),
);
}
Expand All @@ -176,6 +178,16 @@ class UploadCubit extends Cubit<UploadState> {
}
}

Future<int> _getTotalSize() async {
int size = 0;

for (final file in files) {
size += await file.ioFile.length;
}

return size;
}

void initialScreenNext({required LicenseCategory licenseCategory}) {
if (state is UploadReady) {
final readyState = state as UploadReady;
Expand Down
5 changes: 4 additions & 1 deletion lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class UploadReady extends UploadState {
final bool showArnsNameSelection;
final bool loadingArNSNames;
final bool loadingArNSNamesError;
final int totalSize;

final bool isArConnect;

Expand All @@ -112,6 +113,7 @@ class UploadReady extends UploadState {
required this.showArnsNameSelection,
this.loadingArNSNames = false,
this.loadingArNSNamesError = false,
required this.totalSize,
});

// copyWith
Expand All @@ -129,6 +131,7 @@ class UploadReady extends UploadState {
bool? showArnsNameSelection,
bool? loadingArNSNames,
bool? loadingArNSNamesError,
int? totalSize,
}) {
return UploadReady(
loadingArNSNames: loadingArNSNames ?? this.loadingArNSNames,
Expand All @@ -144,6 +147,7 @@ class UploadReady extends UploadState {
showArnsNameSelection ?? this.showArnsNameSelection,
loadingArNSNamesError:
loadingArNSNamesError ?? this.loadingArNSNamesError,
totalSize: totalSize ?? this.totalSize,
);
}

Expand All @@ -155,7 +159,6 @@ class UploadReady extends UploadState {
loadingArNSNamesError,
loadingArNSNames,
showArnsCheckbox,

];

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ class _StatsScreenState extends State<StatsScreen> {
),
TextSpan(
text: filesize(
widget.readyState.paymentInfo.totalSize,
widget.readyState.totalSize,
),
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
Expand Down

0 comments on commit d6839f1

Please sign in to comment.