From fa73e2403b79deca40590d8f4fa15f00a70e316e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 16 Jul 2022 15:36:38 -0400 Subject: [PATCH] Minor library view cleanup - Clean up unused code - Add text shadow in compact mode - Tweak some paddings to better match stable --- .../library/components/LazyLibraryGrid.kt | 6 +++--- .../library/components/LibraryComfortableGrid.kt | 3 +++ .../library/components/LibraryCompactGrid.kt | 10 +++++++++- .../library/components/LibraryList.kt | 1 - .../kanade/tachiyomi/ui/library/LibraryAdapter.kt | 2 -- .../tachiyomi/ui/library/LibraryController.kt | 3 +-- .../eu/kanade/tachiyomi/ui/library/LibraryItem.kt | 3 +-- .../tachiyomi/ui/library/LibraryMangaEvent.kt | 9 +-------- .../tachiyomi/ui/library/LibraryPresenter.kt | 15 ++++----------- 9 files changed, 22 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt index 90e2d7398f..745ad9f82f 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LazyLibraryGrid.kt +++ b/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, ) } diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt index 5b3dc42383..bf1f774561 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryComfortableGrid.kt +++ b/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), diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt index bc83558ac7..4fc8ace80a 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryCompactGrid.kt +++ b/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, + ), + ), ) } } diff --git a/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt b/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt index f2ed0957e5..a30990306c 100644 --- a/app/src/main/java/eu/kanade/presentation/library/components/LibraryList.kt +++ b/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, - columns: Int, selection: List, onClick: (LibraryManga) -> Unit, onLongClick: (LibraryManga) -> Unit, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt index 44a8ac56d9..ee175b2f4b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryAdapter.kt +++ b/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 = { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 461ad2281d..8e90d1ed3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt index a386e86226..21d6c63176 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryItem.kt +++ b/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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMangaEvent.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMangaEvent.kt index 54d70effce..fa7ad06b8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryMangaEvent.kt +++ b/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? { - return mangas[category.id] - } -} +class LibraryMangaEvent(val mangas: LibraryMap) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index e6c0b11a39..5bda485086 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/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 = 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 { - val defaultLibraryDisplayMode = preferences.libraryDisplayMode() - val shouldSetFromCategory = preferences.categorizedDisplaySettings() - return getLibraryManga.subscribe().asObservable() .map { list -> list.map { libraryManga ->