Skip to content

Commit

Permalink
make DownloadItem icons smaller so I can fit more of them (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanLobbenmeier authored Jan 27, 2025
1 parent 2074da4 commit 890bb2f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
28 changes: 28 additions & 0 deletions src/main/kotlin/de/lobbenmeier/stefan/common/ui/SmallIconButton.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.lobbenmeier.stefan.common.ui

import androidx.compose.foundation.layout.padding
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.IconButton
import androidx.compose.material.LocalMinimumInteractiveComponentEnforcement
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun SmallIconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
content: @Composable () -> Unit,
) {
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
IconButton(
onClick = onClick,
modifier = modifier.padding(4.dp),
enabled = enabled,
content = content,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.width
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.LinearProgressIndicator
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
Expand All @@ -24,6 +23,7 @@ import androidx.compose.ui.unit.dp
import compose.icons.FeatherIcons
import compose.icons.feathericons.Download
import compose.icons.feathericons.XCircle
import de.lobbenmeier.stefan.common.ui.SmallIconButton
import de.lobbenmeier.stefan.downloadlist.business.DownloadCompleted
import de.lobbenmeier.stefan.downloadlist.business.DownloadFailed
import de.lobbenmeier.stefan.downloadlist.business.DownloadItem
Expand Down Expand Up @@ -66,13 +66,13 @@ fun DownloadItemTopView(downloadItem: DownloadItem, removeItem: (DownloadItem) -
InformationRow(metadata, downloadItem)
}
Divider(Modifier.fillMaxHeight().width(1.dp))
Column {
IconButton(onClick = { downloadItem.download() }) {
Column(modifier = Modifier.padding(8.dp)) {
SmallIconButton(onClick = { downloadItem.download() }) {
Icon(FeatherIcons.Download, "Download")
}
val file = downloadItem.getTargetFile().collectAsState().value
if (file == null) {
IconButton(onClick = { removeItem(downloadItem) }) {
SmallIconButton(onClick = { removeItem(downloadItem) }) {
Icon(FeatherIcons.XCircle, "Delete")
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.lobbenmeier.stefan.downloadlist.ui

import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.runtime.Composable
import compose.icons.FeatherIcons
import compose.icons.feathericons.Folder
import compose.icons.feathericons.Play
import de.lobbenmeier.stefan.common.ui.SmallIconButton
import io.github.oshai.kotlinlogging.KotlinLogging
import java.awt.Desktop
import java.io.File
Expand All @@ -15,7 +15,7 @@ val logger = KotlinLogging.logger {}
@Composable
fun OpenFileButton(file: File?) {

IconButton(
SmallIconButton(
enabled = file != null,
onClick = {
if (file != null) {
Expand All @@ -34,7 +34,7 @@ fun OpenFileButton(file: File?) {
@Composable
fun BrowseFileButton(file: File?) {

IconButton(
SmallIconButton(
enabled = file != null,
onClick = {
if (file != null) {
Expand Down

0 comments on commit 890bb2f

Please sign in to comment.