Skip to content

Commit 5dfae0c

Browse files
committed
v3: 添加收藏功能
1 parent 0de232b commit 5dfae0c

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

app/src/main/java/com/quickfilemanager/ui/components/FileListItem.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ fun FileListItem(
3131
file: FileItem,
3232
isSelected: Boolean,
3333
isSelectionMode: Boolean,
34+
isFavorite: Boolean = false,
3435
onClick: () -> Unit,
3536
onLongClick: () -> Unit,
37+
onFavoriteClick: (() -> Unit)? = null,
3638
modifier: Modifier = Modifier
3739
) {
3840
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault())
@@ -133,6 +135,17 @@ fun FileListItem(
133135
tint = MaterialTheme.colorScheme.onSurfaceVariant
134136
)
135137
}
138+
139+
// 收藏图标
140+
if (!file.isDirectory && onFavoriteClick != null && !isSelectionMode) {
141+
IconButton(onClick = onFavoriteClick) {
142+
Icon(
143+
imageVector = if (isFavorite) Icons.Default.Favorite else Icons.Default.FavoriteBorder,
144+
contentDescription = if (isFavorite) "取消收藏" else "收藏",
145+
tint = if (isFavorite) Color.Red else MaterialTheme.colorScheme.onSurfaceVariant
146+
)
147+
}
148+
}
136149
}
137150
}
138151
}

0 commit comments

Comments
 (0)