瀏覽代碼

Minor library view cleanup

- Clean up unused code
- Add text shadow in compact mode
- Tweak some paddings to better match stable
arkon 2 年之前
父節點
當前提交
fa73e2403b

+ 3 - 3
app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt

@@ -22,9 +22,9 @@ fun LazyLibraryGrid(
     LazyVerticalGrid(
         modifier = modifier,
         columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns),
-        contentPadding = PaddingValues(8.dp) + WindowInsets.navigationBars.asPaddingValues(),
-        verticalArrangement = Arrangement.spacedBy(8.dp),
-        horizontalArrangement = Arrangement.spacedBy(8.dp),
+        contentPadding = PaddingValues(12.dp) + WindowInsets.navigationBars.asPaddingValues(),
+        verticalArrangement = Arrangement.spacedBy(12.dp),
+        horizontalArrangement = Arrangement.spacedBy(12.dp),
         content = content,
     )
 }

+ 3 - 0
app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt

@@ -2,12 +2,14 @@ package eu.kanade.presentation.library.components
 
 import androidx.compose.foundation.combinedClickable
 import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.lazy.grid.items
 import androidx.compose.material3.LocalTextStyle
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
 import eu.kanade.domain.manga.model.MangaCover
 import eu.kanade.tachiyomi.data.database.models.LibraryManga
 import eu.kanade.tachiyomi.ui.library.LibraryItem
@@ -73,6 +75,7 @@ fun LibraryComfortableGridItem(
                 language = item.sourceLanguage,
             )
             Text(
+                modifier = Modifier.padding(4.dp),
                 text = manga.title,
                 maxLines = 2,
                 style = LocalTextStyle.current.copy(fontWeight = FontWeight.SemiBold),

+ 9 - 1
app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt

@@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
 import androidx.compose.ui.draw.clip
 import androidx.compose.ui.graphics.Brush
 import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.Shadow
 import androidx.compose.ui.text.font.FontWeight
 import androidx.compose.ui.unit.dp
 import eu.kanade.tachiyomi.data.database.models.LibraryManga
@@ -98,7 +99,14 @@ fun LibraryCompactGridItem(
                 .padding(8.dp)
                 .align(Alignment.BottomStart),
             maxLines = 2,
-            style = LocalTextStyle.current.copy(color = Color.White, fontWeight = FontWeight.SemiBold),
+            style = LocalTextStyle.current.copy(
+                color = Color.White,
+                fontWeight = FontWeight.SemiBold,
+                shadow = Shadow(
+                    color = Color.Black,
+                    blurRadius = 4f,
+                ),
+            ),
         )
     }
 }

+ 0 - 1
app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt

@@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.ui.library.LibraryItem
 @Composable
 fun LibraryList(
     items: List<LibraryItem>,
-    columns: Int,
     selection: List<LibraryManga>,
     onClick: (LibraryManga) -> Unit,
     onLongClick: (LibraryManga) -> Unit,

+ 0 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt

@@ -40,7 +40,6 @@ import uy.kohesive.injekt.api.get
  * @constructor creates an instance of the adapter.
  */
 class LibraryAdapter(
-    private val controller: LibraryController,
     private val presenter: LibraryPresenter,
     private val onClickManga: (LibraryManga) -> Unit,
     private val preferences: PreferencesHelper = Injekt.get(),
@@ -142,7 +141,6 @@ class LibraryAdapter(
                                 DisplayModeSetting.LIST -> {
                                     LibraryList(
                                         items = mangaList,
-                                        columns = presenter.columns,
                                         selection = presenter.selection,
                                         onClick = onClickManga,
                                         onLongClick = {

+ 1 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt

@@ -142,7 +142,6 @@ class LibraryController(
         super.onViewCreated(view)
 
         adapter = LibraryAdapter(
-            controller = this,
             presenter = presenter,
             onClickManga = {
                 openManga(it.id!!)
@@ -466,7 +465,7 @@ class LibraryController(
         actionMode = null
     }
 
-    fun openManga(mangaId: Long) {
+    private fun openManga(mangaId: Long) {
         // Notify the presenter a manga is being opened.
         presenter.onOpenManga()
 

+ 1 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt

@@ -7,10 +7,9 @@ import uy.kohesive.injekt.api.get
 
 class LibraryItem(
     val manga: LibraryManga,
+    private val sourceManager: SourceManager = Injekt.get(),
 ) {
 
-    private val sourceManager: SourceManager = Injekt.get()
-
     var displayMode: Long = -1
     var downloadCount = -1
     var unreadCount = -1

+ 1 - 8
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMangaEvent.kt

@@ -1,10 +1,3 @@
 package eu.kanade.tachiyomi.ui.library
 
-import eu.kanade.domain.category.model.Category
-
-class LibraryMangaEvent(val mangas: LibraryMap) {
-
-    fun getMangaForCategory(category: Category): List<LibraryItem>? {
-        return mangas[category.id]
-    }
-}
+class LibraryMangaEvent(val mangas: LibraryMap)

+ 4 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt

@@ -18,7 +18,6 @@ import eu.kanade.domain.category.interactor.SetMangaCategories
 import eu.kanade.domain.category.model.Category
 import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
 import eu.kanade.domain.chapter.interactor.SetReadStatus
-import eu.kanade.domain.chapter.interactor.UpdateChapter
 import eu.kanade.domain.chapter.model.toDbChapter
 import eu.kanade.domain.manga.interactor.GetLibraryManga
 import eu.kanade.domain.manga.interactor.UpdateManga
@@ -46,9 +45,7 @@ import eu.kanade.tachiyomi.util.removeCovers
 import eu.kanade.tachiyomi.widget.ExtendedNavigationView.Item.TriStateGroup.State
 import kotlinx.coroutines.flow.MutableStateFlow
 import kotlinx.coroutines.flow.drop
-import kotlinx.coroutines.flow.filter
 import kotlinx.coroutines.flow.launchIn
-import kotlinx.coroutines.flow.map
 import kotlinx.coroutines.flow.onEach
 import kotlinx.coroutines.runBlocking
 import rx.Observable
@@ -82,7 +79,6 @@ class LibraryPresenter(
     private val getCategories: GetCategories = Injekt.get(),
     private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
     private val setReadStatus: SetReadStatus = Injekt.get(),
-    private val updateChapter: UpdateChapter = Injekt.get(),
     private val updateManga: UpdateManga = Injekt.get(),
     private val setMangaCategories: SetMangaCategories = Injekt.get(),
     private val preferences: PreferencesHelper = Injekt.get(),
@@ -109,11 +105,11 @@ class LibraryPresenter(
 
     val selection: MutableList<LibraryManga> = mutableStateListOf()
 
-    val isPerCategory by mutableStateOf(preferences.categorizedDisplaySettings().get())
+    val isPerCategory by preferences.categorizedDisplaySettings().asState()
 
     var columns by mutableStateOf(0)
 
-    var currentDisplayMode by mutableStateOf(preferences.libraryDisplayMode().get())
+    var currentDisplayMode by preferences.libraryDisplayMode().asState()
 
     /**
      * Relay used to apply the UI filters to the last emission of the library.
@@ -234,8 +230,8 @@ class LibraryPresenter(
 
             if (!containsExclude.any() && !containsInclude.any()) return@tracking true
 
-            val exclude = trackedManga?.filterKeys { containsExclude.containsKey(it.toLong()) }?.values ?: emptyList()
-            val include = trackedManga?.filterKeys { containsInclude.containsKey(it.toLong()) }?.values ?: emptyList()
+            val exclude = trackedManga?.filterKeys { containsExclude.containsKey(it) }?.values ?: emptyList()
+            val include = trackedManga?.filterKeys { containsInclude.containsKey(it) }?.values ?: emptyList()
 
             if (containsInclude.any() && containsExclude.any()) {
                 return@tracking if (exclude.isNotEmpty()) !exclude.any() else include.any()
@@ -449,9 +445,6 @@ class LibraryPresenter(
      * value.
      */
     private fun getLibraryMangasObservable(): Observable<LibraryMap> {
-        val defaultLibraryDisplayMode = preferences.libraryDisplayMode()
-        val shouldSetFromCategory = preferences.categorizedDisplaySettings()
-
         return getLibraryManga.subscribe().asObservable()
             .map { list ->
                 list.map { libraryManga ->