From a0bce41e6055656679ffb162a82e3dd315f1c20f Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Tue, 26 Nov 2024 16:04:46 +0100 Subject: [PATCH] chore: Don't display file size when navigating files --- .../swisstransfer/ui/components/TextDotText.kt | 18 ++++++++++-------- .../ui/screen/newtransfer/FilesSize.kt | 11 ++++++++--- .../importfiles/FilesDetailsScreen.kt | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/TextDotText.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/TextDotText.kt index 2988e9256..1422467e8 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/TextDotText.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/TextDotText.kt @@ -39,14 +39,16 @@ fun TextDotText( ) { Row(modifier) { CustomText(firstText, color, style) - Spacer(Modifier.width(Margin.Mini)) - Text( - text = "•", - color = color, - style = style, - ) - Spacer(Modifier.width(Margin.Mini)) - CustomText(secondText, optionalSecondTextColor ?: color, style) + if (secondText().isNotEmpty()) { + Spacer(Modifier.width(Margin.Mini)) + Text( + text = "•", + color = color, + style = style, + ) + Spacer(Modifier.width(Margin.Mini)) + CustomText(secondText, optionalSecondTextColor ?: color, style) + } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesSize.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesSize.kt index f75301e4e..abca6ddee 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesSize.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/FilesSize.kt @@ -41,16 +41,21 @@ import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.formatSpaceL import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils.getSpaceLeft @Composable -fun FilesSize(files: List, withSpaceLeft: Boolean) { +fun FilesSize(files: List, withFileSize: Boolean, withSpaceLeft: Boolean) { Row(modifier = Modifier.padding(vertical = Margin.Medium)) { Spacer(Modifier.size(Margin.Medium)) val context = LocalContext.current + val secondText = if (withFileSize) { + HumanReadableSizeUtils.getHumanReadableSize(context, files.sumOf { it.fileSize }) + } else { + "" + } TextDotText( firstText = { val filesCount = files.count() pluralStringResource(R.plurals.filesCount, filesCount, filesCount) }, - secondText = { HumanReadableSizeUtils.getHumanReadableSize(context, files.sumOf { it.fileSize }) }, + secondText = { secondText }, ) if (withSpaceLeft) { val spaceLeft = formatSpaceLeft { context.getSpaceLeft(files) } @@ -71,7 +76,7 @@ fun FilesSize(files: List, withSpaceLeft: Boolean) { fun FileSizePreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List) { SwissTransferTheme { Surface { - FilesSize(files, withSpaceLeft = true) + FilesSize(files, withFileSize = false, withSpaceLeft = true) } } } diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt index f4785a858..ad59d51da 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/importfiles/FilesDetailsScreen.kt @@ -85,7 +85,7 @@ private fun FilesDetailsScreen( TopAppBarButton.closeButton { onCloseClicked() }, ) - FilesSize(files, withSpaceLeft) + FilesSize(files, withFileSize = false, withSpaceLeft) FileItemList( modifier = Modifier.padding(horizontal = Margin.Medium), files = files,