From 6a0028a8b80b84136867cf367493bc40581cdb29 Mon Sep 17 00:00:00 2001 From: AmirHossein Abdolmotallebi Date: Tue, 16 Jul 2024 15:23:07 +0330 Subject: [PATCH] improve part info section --- .../singleDownloadPage/SingleDownloadPage.kt | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/singleDownloadPage/SingleDownloadPage.kt b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/singleDownloadPage/SingleDownloadPage.kt index beaa3e9..4c8eba8 100644 --- a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/singleDownloadPage/SingleDownloadPage.kt +++ b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/singleDownloadPage/SingleDownloadPage.kt @@ -35,10 +35,8 @@ import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Popup import androidx.compose.ui.window.rememberComponentRectPositionProvider -import com.abdownloadmanager.desktop.ui.widget.menu.MyDropDown import com.abdownloadmanager.utils.compose.useIsInDebugMode import ir.amirab.downloader.downloaditem.DownloadJobStatus import ir.amirab.downloader.monitor.* @@ -257,7 +255,15 @@ fun ColumnScope.RenderPartInfo(itemState: ProcessingDownloadItemState) { itemState.parts .let { parts -> if (onlyActiveParts) { - parts.filter { it.status is PartDownloadStatus.IsActive } + parts.filter { + when(it.status){ + is PartDownloadStatus.Canceled -> true + PartDownloadStatus.Completed -> false + PartDownloadStatus.IDLE -> false + PartDownloadStatus.ReceivingData -> true + PartDownloadStatus.SendGet -> true + } + } } else { parts } @@ -314,7 +320,7 @@ fun ColumnScope.RenderPartInfo(itemState: ProcessingDownloadItemState) { } PartInfoCells.Status -> { - SimpleCellText("${it.value.status}") + SimpleCellText("${prettifyStatus(it.value.status)}") } PartInfoCells.Downloaded -> { @@ -355,6 +361,16 @@ fun ColumnScope.RenderPartInfo(itemState: ProcessingDownloadItemState) { } } +fun prettifyStatus(status: PartDownloadStatus): String { + return when(status){ + is PartDownloadStatus.Canceled -> "Disconnected" + PartDownloadStatus.IDLE -> "IDLE" + PartDownloadStatus.Completed -> "Completed" + PartDownloadStatus.ReceivingData -> "Receiving Data" + PartDownloadStatus.SendGet -> "Send Get" + } +} + @Composable private fun SimpleCellText(text: String) { Text(text, fontSize = myTextSizes.base, maxLines = 1)