Skip to content

Commit

Permalink
chore: Don't display file size when navigating files
Browse files Browse the repository at this point in the history
  • Loading branch information
tevincent committed Nov 27, 2024
1 parent 90ccfb9 commit a0bce41
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FileUi>, withSpaceLeft: Boolean) {
fun FilesSize(files: List<FileUi>, 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) }
Expand All @@ -71,7 +76,7 @@ fun FilesSize(files: List<FileUi>, withSpaceLeft: Boolean) {
fun FileSizePreview(@PreviewParameter(FileUiListPreviewParameter::class) files: List<FileUi>) {
SwissTransferTheme {
Surface {
FilesSize(files, withSpaceLeft = true)
FilesSize(files, withFileSize = false, withSpaceLeft = true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a0bce41

Please sign in to comment.