mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
add download resume support in ui with a colored property name
This commit is contained in:
parent
8895b16410
commit
a8034cfbd5
@ -386,10 +386,9 @@ sealed class PartInfoCells : TableCell<IndexedValue<UiPart>> {
|
||||
|
||||
|
||||
@Composable
|
||||
fun RenderPropertyItem(
|
||||
title: String,
|
||||
value: String,
|
||||
) {
|
||||
fun RenderPropertyItem(propertyItem: SingleDownloadPagePropertyItem) {
|
||||
val title= propertyItem.name
|
||||
val value= propertyItem.value
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@ -400,7 +399,6 @@ fun RenderPropertyItem(
|
||||
modifier = Modifier.weight(0.3f),
|
||||
maxLines = 1,
|
||||
fontSize = myTextSizes.base
|
||||
|
||||
)
|
||||
}
|
||||
WithContentAlpha(1f) {
|
||||
@ -410,7 +408,12 @@ fun RenderPropertyItem(
|
||||
.basicMarquee()
|
||||
.weight(0.7f),
|
||||
maxLines = 1,
|
||||
fontSize = myTextSizes.base
|
||||
fontSize = myTextSizes.base,
|
||||
color = when(propertyItem.valueState){
|
||||
SingleDownloadPagePropertyItem.ValueType.Normal -> LocalContentColor.current
|
||||
SingleDownloadPagePropertyItem.ValueType.Error -> myColors.error
|
||||
SingleDownloadPagePropertyItem.ValueType.Success -> myColors.success
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -426,9 +429,9 @@ fun RenderInfo(
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(top = 8.dp)
|
||||
) {
|
||||
for ((title, value) in singleDownloadComponent.extraDownloadInfo.collectAsState().value) {
|
||||
for (propertyItem in singleDownloadComponent.extraDownloadInfo.collectAsState().value) {
|
||||
Spacer(Modifier.height(2.dp))
|
||||
RenderPropertyItem(title, value)
|
||||
RenderPropertyItem(propertyItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.abdownloadmanager.desktop.pages.singleDownloadPage
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.abdownloadmanager.desktop.pages.settings.configurable.IntConfigurable
|
||||
import com.abdownloadmanager.desktop.pages.settings.configurable.SpeedLimitConfigurable
|
||||
import com.abdownloadmanager.desktop.utils.*
|
||||
@ -24,6 +25,14 @@ sealed interface SingleDownloadEffects {
|
||||
data object BringToFront : SingleDownloadEffects
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class SingleDownloadPagePropertyItem(
|
||||
val name: String,
|
||||
val value: String,
|
||||
val valueState: ValueType = ValueType.Normal,
|
||||
) {
|
||||
enum class ValueType { Normal, Error, Success }
|
||||
}
|
||||
class SingleDownloadComponent(
|
||||
ctx: ComponentContext,
|
||||
val onDismiss: () -> Unit,
|
||||
@ -41,28 +50,36 @@ class SingleDownloadComponent(
|
||||
val showPartInfo = mutableStateOf(false)
|
||||
|
||||
|
||||
val extraDownloadInfo: StateFlow<List<Pair<String, String>>> = itemStateFlow
|
||||
val extraDownloadInfo: StateFlow<List<SingleDownloadPagePropertyItem>> = itemStateFlow
|
||||
.filterNotNull()
|
||||
.map {
|
||||
buildList {
|
||||
add("Name" to it.name)
|
||||
add("Status" to createStatusString(it))
|
||||
add("Size" to convertSizeToHumanReadable(it.contentLength))
|
||||
add(SingleDownloadPagePropertyItem("Name", it.name))
|
||||
add(SingleDownloadPagePropertyItem("Status", createStatusString(it)))
|
||||
add(SingleDownloadPagePropertyItem("Size", convertSizeToHumanReadable(it.contentLength)))
|
||||
when (it) {
|
||||
is CompletedDownloadItemState -> {
|
||||
}
|
||||
|
||||
is ProcessingDownloadItemState -> {
|
||||
add("Downloaded" to convertBytesToHumanReadable(it.progress).orEmpty())
|
||||
add("Speed" to convertSpeedToHumanReadable(it.speed))
|
||||
add("Remaining Time" to (it.remainingTime?.let { remainingTime ->
|
||||
add(SingleDownloadPagePropertyItem("Downloaded" , convertBytesToHumanReadable(it.progress).orEmpty()))
|
||||
add(SingleDownloadPagePropertyItem("Speed" , convertSpeedToHumanReadable(it.speed)))
|
||||
add(SingleDownloadPagePropertyItem("Remaining Time" , (it.remainingTime?.let { remainingTime ->
|
||||
convertTimeRemainingToHumanReadable(remainingTime, TimeNames.ShortNames)
|
||||
}.orEmpty()))
|
||||
add("Resume Support" to when(it.supportResume){
|
||||
true->"Yes"
|
||||
false->"No"
|
||||
null->"Unknown"
|
||||
})
|
||||
}.orEmpty())))
|
||||
add(SingleDownloadPagePropertyItem(
|
||||
"Resume Support",
|
||||
when (it.supportResume) {
|
||||
true -> "Yes"
|
||||
false -> "No"
|
||||
null -> "Unknown"
|
||||
},
|
||||
when (it.supportResume) {
|
||||
true -> SingleDownloadPagePropertyItem.ValueType.Success
|
||||
false -> SingleDownloadPagePropertyItem.ValueType.Error
|
||||
null -> SingleDownloadPagePropertyItem.ValueType.Normal
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user