diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt index 2076684be..1b996b9d0 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/transfer/TransferItem.kt @@ -38,6 +38,7 @@ import com.infomaniak.swisstransfer.ui.theme.Margin import com.infomaniak.swisstransfer.ui.theme.SwissTransferTheme import com.infomaniak.swisstransfer.ui.utils.HumanReadableSizeUtils import com.infomaniak.swisstransfer.ui.utils.PreviewAllWindows +import com.infomaniak.swisstransfer.ui.utils.isExpired import java.util.Calendar import java.util.Date import java.util.UUID @@ -47,15 +48,12 @@ import java.util.UUID fun TransferItem(transfer: TransferUi, onClick: () -> Unit) { val createdDate = Date(transfer.createdDateTimestamp).format(FORMAT_DATE_TITLE) - val remainingDays = transfer.expiresInDays - val remainingDownloads = transfer.downloadLeft val uploadedSize = HumanReadableSizeUtils.getHumanReadableSize(LocalContext.current, transfer.sizeUploaded) val files = transfer.files - val filesCount = files.count() - val (expiryText, expiryColor) = if (remainingDays < 0 || remainingDownloads == 0) { + val (expiryText, expiryColor) = if (transfer.isExpired) { stringResource(R.string.transferExpired) to SwissTransferTheme.materialColors.error } else { - stringResource(R.string.expiresIn, remainingDays) to SwissTransferTheme.colors.secondaryTextColor + stringResource(R.string.expiresIn, transfer.expiresInDays) to SwissTransferTheme.colors.secondaryTextColor } Card( @@ -87,7 +85,7 @@ fun TransferItem(transfer: TransferUi, onClick: () -> Unit) { Spacer(modifier = Modifier.height(Margin.Mini)) ContextualFlowRow( - itemCount = filesCount, + itemCount = files.count(), maxLines = 1, horizontalArrangement = Arrangement.spacedBy(Margin.Mini), overflow = ContextualFlowRowOverflow.expandIndicator { TransferFilePreview(remainingFilesCount = totalItemCount - shownItemCount) }, diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiExt.kt similarity index 100% rename from app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiItemExt.kt rename to app/src/main/java/com/infomaniak/swisstransfer/ui/utils/FileUiExt.kt diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/TransferUiExt.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/TransferUiExt.kt new file mode 100644 index 000000000..5ef5d1457 --- /dev/null +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/utils/TransferUiExt.kt @@ -0,0 +1,22 @@ +/* + * Infomaniak SwissTransfer - Android + * Copyright (C) 2024 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.swisstransfer.ui.utils + +import com.infomaniak.multiplatform_swisstransfer.common.interfaces.ui.TransferUi + +val TransferUi.isExpired: Boolean get() = expiresInDays < 0 || downloadLeft <= 0