[feat] Comic Tags

This commit is contained in:
acite
2025-09-07 13:09:25 +08:00
parent 514e99d7db
commit aacd226260
7 changed files with 243 additions and 53 deletions

View File

@@ -20,6 +20,28 @@ class ComicScreenViewModel : ViewModel() {
var imageLoader: ImageLoader? = null;
val comics = mutableStateListOf<Comic>()
val excluded = mutableStateListOf<String>()
val included = mutableStateListOf<String>()
val tags = mutableStateListOf<String>()
private val counter = mutableMapOf<String, Int>()
fun insertItem(newItem: String) {
val newCount = (counter[newItem] ?: 0) + 1
counter[newItem] = newCount
if (newItem !in tags) {
val insertIndex = tags.indexOfFirst { counter[it]!! < newCount }
.takeIf { it >= 0 } ?: tags.size
tags.add(insertIndex, newItem)
} else {
var currentIndex = tags.indexOf(newItem)
while (currentIndex > 0 && counter[tags[currentIndex - 1]]!! < newCount) {
tags[currentIndex] = tags[currentIndex - 1]
tags[currentIndex - 1] = newItem
currentIndex--
}
}
}
@Composable
fun SetupClient()
@@ -38,8 +60,13 @@ class ComicScreenViewModel : ViewModel() {
for(i in l)
{
val m = MediaManager.queryComicInfo(i)
if(m != null)
if(m != null) {
comics.add(m)
for(i in m.comic.tags)
{
insertItem(i)
}
}
}
}
}