From d9011fa94f37ae21844ddf92d7959968ee9c2ea7 Mon Sep 17 00:00:00 2001 From: Vincent TE Date: Tue, 26 Nov 2024 17:06:11 +0100 Subject: [PATCH] chore: Optimize TransferInfo --- .../main/transferdetails/components/TransferInfo.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt index 7c1ad3929..261d72fe1 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/components/TransferInfo.kt @@ -52,6 +52,9 @@ fun TransferInfo(getTransfer: () -> TransferUi) { val filesCount by remember { derivedStateOf { getTransfer().files.count() } } val downloadedCount by remember { derivedStateOf { getTransfer().downloadLimit - getTransfer().downloadLeft } } + val expiresInDays by remember { derivedStateOf { getTransfer().expiresInDays } } + val downloadLimit by remember { derivedStateOf { getTransfer().downloadLimit } } + val sizeUploaded by remember { derivedStateOf { getTransfer().sizeUploaded } } Row(verticalAlignment = Alignment.CenterVertically) { Icon( @@ -62,7 +65,7 @@ fun TransferInfo(getTransfer: () -> TransferUi) { Spacer(Modifier.width(Margin.Mini)) TextDotText( firstText = { pluralStringResource(R.plurals.filesCount, filesCount, filesCount) }, - secondText = { Formatter.formatShortFileSize(LocalContext.current, getTransfer().sizeUploaded) }, + secondText = { Formatter.formatShortFileSize(LocalContext.current, sizeUploaded) }, color = SwissTransferTheme.colors.primaryTextColor, ) } @@ -71,14 +74,14 @@ fun TransferInfo(getTransfer: () -> TransferUi) { IconText( icon = AppIcons.Clock, - text = stringResource(R.string.expiresIn, getTransfer().expiresInDays), + text = stringResource(R.string.expiresIn, expiresInDays), ) HorizontalDivider(modifier = Modifier.padding(vertical = Margin.Medium)) IconText( icon = AppIcons.ArrowDownFile, - text = stringResource(R.string.downloadedTransferLabel, downloadedCount, getTransfer().downloadLimit), + text = stringResource(R.string.downloadedTransferLabel, downloadedCount, downloadLimit), ) }