diff --git a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/ShowAddDownloadDialogs.kt b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/ShowAddDownloadDialogs.kt index 70cf05a..43439e2 100644 --- a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/ShowAddDownloadDialogs.kt +++ b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/ShowAddDownloadDialogs.kt @@ -60,8 +60,8 @@ fun ShowAddDownloadDialogs(component: AddDownloadDialogManager) { } is AddMultiDownloadComponent -> { - val h = 400 - val w = 700 + val h = 450 + val w = 800 val state = rememberWindowState( height = h.dp, width = w.dp, diff --git a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiDownloadComponent.kt b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiDownloadComponent.kt index 0fd9892..ca0f0e6 100644 --- a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiDownloadComponent.kt +++ b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiDownloadComponent.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import com.abdownloadmanager.desktop.pages.addDownload.multiple.AddMultiItemSaveMode.* import com.abdownloadmanager.desktop.utils.asState +import com.abdownloadmanager.utils.FileIconProvider import com.abdownloadmanager.utils.category.Category import com.abdownloadmanager.utils.category.CategoryManager import com.abdownloadmanager.utils.category.CategorySelectionMode @@ -44,6 +45,9 @@ class AddMultiDownloadComponent( private val appSettings by inject() private val client by inject() val downloadSystem by inject() + val fileIconProvider: FileIconProvider by inject() + + private val _folder = MutableStateFlow(appSettings.saveLocation.value) val folder = _folder.asStateFlow() fun setFolder(folder: String) { diff --git a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiItemTable.kt b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiItemTable.kt index 0abbc1c..8068966 100644 --- a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiItemTable.kt +++ b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/addDownload/multiple/AddMultiItemTable.kt @@ -13,7 +13,9 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.* +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.key.Key @@ -23,6 +25,8 @@ import androidx.compose.ui.input.key.onKeyEvent import androidx.compose.ui.input.pointer.isShiftPressed import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import com.abdownloadmanager.utils.FileIconProvider +import com.abdownloadmanager.utils.compose.widget.MyIcon @Composable fun AddMultiDownloadTable( @@ -33,6 +37,7 @@ fun AddMultiDownloadTable( val lastSelectedId = component.lastSelectedId val context = AddMultiItemListContext(component, component.isAllSelected) + val iconProvider = component.fileIconProvider CompositionLocalProvider( LocalAddMultiItemListContext provides context, ) { @@ -129,7 +134,7 @@ fun AddMultiDownloadTable( it.border(1.dp, Color.Transparent) } } - .padding(vertical = 2.dp, horizontal = itemHorizontalPadding) + .padding(vertical = 8.dp, horizontal = itemHorizontalPadding) ) { content() } @@ -148,7 +153,10 @@ fun AddMultiDownloadTable( } AddMultiItemTableCells.Name -> { - NameCell(item) + NameCell( + downloadUiChecker = item, + iconProvider = iconProvider, + ) } AddMultiItemTableCells.Link -> { @@ -194,8 +202,8 @@ sealed class AddMultiItemTableCells : TableCell { return listOf( Check, Name, - Link, SizeCell, + Link, ) } } @@ -218,17 +226,17 @@ sealed class AddMultiItemTableCells : TableCell { data object Name : AddMultiItemTableCells() { override val name: String = "Name" - override val size: CellSize = CellSize.Resizeable(120.dp..300.dp, 160.dp) + override val size: CellSize = CellSize.Resizeable(120.dp..1000.dp, 350.dp) } data object Link : AddMultiItemTableCells() { override val name: String = "Link" - override val size: CellSize = CellSize.Resizeable(120.dp..300.dp, 120.dp) + override val size: CellSize = CellSize.Resizeable(120.dp..2000.dp, 240.dp) } data object SizeCell : AddMultiItemTableCells() { override val name: String = "Size" - override val size: CellSize = CellSize.Resizeable(120.dp..180.dp) + override val size: CellSize = CellSize.Resizeable(100.dp..180.dp, 100.dp) } } @@ -247,15 +255,28 @@ private fun CellText( @Composable private fun NameCell( - it: DownloadUiChecker + downloadUiChecker: DownloadUiChecker, + iconProvider: FileIconProvider, ) { - val name by it.name.collectAsState() - CellText(name) + val name by downloadUiChecker.name.collectAsState() + val icon = iconProvider.rememberIcon(name) + Row( + verticalAlignment = Alignment.CenterVertically, + ) { + MyIcon( + icon = icon, + contentDescription = null, + modifier = Modifier.size(16.dp).alpha(0.75f) + ) + Spacer(Modifier.width(8.dp)) + CellText(name) + } + } @Composable private fun LinkCell( - downloadChecker: DownloadUiChecker + downloadChecker: DownloadUiChecker, ) { val credentials by downloadChecker.credentials.collectAsState() CellText(credentials.link) @@ -263,7 +284,7 @@ private fun LinkCell( @Composable private fun SizeCell( - downloadChecker: DownloadUiChecker + downloadChecker: DownloadUiChecker, ) { val length by downloadChecker.length.collectAsState() CellText(