Minor library view cleanup
- Clean up unused code - Add text shadow in compact mode - Tweak some paddings to better match stable (cherry picked from commit fa73e2403b79deca40590d8f4fa15f00a70e316e) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt
This commit is contained in:
parent
d8042f7182
commit
9b47b7f204
@ -22,9 +22,9 @@ fun LazyLibraryGrid(
|
|||||||
LazyVerticalGrid(
|
LazyVerticalGrid(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns),
|
columns = if (columns == 0) GridCells.Adaptive(128.dp) else GridCells.Fixed(columns),
|
||||||
contentPadding = PaddingValues(8.dp) + WindowInsets.navigationBars.asPaddingValues(),
|
contentPadding = PaddingValues(12.dp) + WindowInsets.navigationBars.asPaddingValues(),
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
content = content,
|
content = content,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,14 @@ package eu.kanade.presentation.library.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.combinedClickable
|
import androidx.compose.foundation.combinedClickable
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.grid.items
|
import androidx.compose.foundation.lazy.grid.items
|
||||||
import androidx.compose.material3.LocalTextStyle
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.domain.manga.model.MangaCover
|
import eu.kanade.domain.manga.model.MangaCover
|
||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||||
@ -86,6 +88,7 @@ fun LibraryComfortableGridItem(
|
|||||||
// SY <--
|
// SY <--
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.padding(4.dp),
|
||||||
text = manga.title,
|
text = manga.title,
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
style = LocalTextStyle.current.copy(fontWeight = FontWeight.SemiBold),
|
style = LocalTextStyle.current.copy(fontWeight = FontWeight.SemiBold),
|
||||||
|
@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Brush
|
import androidx.compose.ui.graphics.Brush
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.Shadow
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
@ -114,7 +115,14 @@ fun LibraryCompactGridItem(
|
|||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
.align(Alignment.BottomStart),
|
.align(Alignment.BottomStart),
|
||||||
maxLines = 2,
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ import eu.kanade.tachiyomi.ui.library.LibraryItem
|
|||||||
@Composable
|
@Composable
|
||||||
fun LibraryList(
|
fun LibraryList(
|
||||||
items: List<LibraryItem>,
|
items: List<LibraryItem>,
|
||||||
columns: Int,
|
|
||||||
selection: List<LibraryManga>,
|
selection: List<LibraryManga>,
|
||||||
onClick: (LibraryManga) -> Unit,
|
onClick: (LibraryManga) -> Unit,
|
||||||
onLongClick: (LibraryManga) -> Unit,
|
onLongClick: (LibraryManga) -> Unit,
|
||||||
|
@ -40,7 +40,6 @@ import uy.kohesive.injekt.api.get
|
|||||||
* @constructor creates an instance of the adapter.
|
* @constructor creates an instance of the adapter.
|
||||||
*/
|
*/
|
||||||
class LibraryAdapter(
|
class LibraryAdapter(
|
||||||
private val controller: LibraryController,
|
|
||||||
private val presenter: LibraryPresenter,
|
private val presenter: LibraryPresenter,
|
||||||
private val onClickManga: (LibraryManga) -> Unit,
|
private val onClickManga: (LibraryManga) -> Unit,
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -145,7 +144,6 @@ class LibraryAdapter(
|
|||||||
DisplayModeSetting.LIST -> {
|
DisplayModeSetting.LIST -> {
|
||||||
LibraryList(
|
LibraryList(
|
||||||
items = mangaList,
|
items = mangaList,
|
||||||
columns = presenter.columns,
|
|
||||||
selection = presenter.selection,
|
selection = presenter.selection,
|
||||||
onClick = onClickManga,
|
onClick = onClickManga,
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
|
@ -177,7 +177,6 @@ class LibraryController(
|
|||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
adapter = LibraryAdapter(
|
adapter = LibraryAdapter(
|
||||||
controller = this,
|
|
||||||
presenter = presenter,
|
presenter = presenter,
|
||||||
onClickManga = {
|
onClickManga = {
|
||||||
openManga(it.id!!)
|
openManga(it.id!!)
|
||||||
@ -573,7 +572,7 @@ class LibraryController(
|
|||||||
actionMode = null
|
actionMode = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openManga(mangaId: Long) {
|
private fun openManga(mangaId: Long) {
|
||||||
// Notify the presenter a manga is being opened.
|
// Notify the presenter a manga is being opened.
|
||||||
presenter.onOpenManga()
|
presenter.onOpenManga()
|
||||||
|
|
||||||
|
@ -7,10 +7,9 @@ import uy.kohesive.injekt.api.get
|
|||||||
|
|
||||||
class LibraryItem(
|
class LibraryItem(
|
||||||
val manga: LibraryManga,
|
val manga: LibraryManga,
|
||||||
|
private val sourceManager: SourceManager = Injekt.get(),
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val sourceManager: SourceManager = Injekt.get()
|
|
||||||
|
|
||||||
var displayMode: Long = -1
|
var displayMode: Long = -1
|
||||||
var downloadCount = -1
|
var downloadCount = -1
|
||||||
var unreadCount = -1
|
var unreadCount = -1
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
package eu.kanade.tachiyomi.ui.library
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import eu.kanade.domain.category.model.Category
|
class LibraryMangaEvent(val mangas: LibraryMap)
|
||||||
|
|
||||||
class LibraryMangaEvent(val mangas: LibraryMap) {
|
|
||||||
|
|
||||||
fun getMangaForCategory(category: Category): List<LibraryItem>? {
|
|
||||||
return mangas[category.id]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -19,7 +19,6 @@ import eu.kanade.domain.category.model.Category
|
|||||||
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
import eu.kanade.domain.chapter.interactor.GetChapterByMangaId
|
||||||
import eu.kanade.domain.chapter.interactor.GetMergedChapterByMangaId
|
import eu.kanade.domain.chapter.interactor.GetMergedChapterByMangaId
|
||||||
import eu.kanade.domain.chapter.interactor.SetReadStatus
|
import eu.kanade.domain.chapter.interactor.SetReadStatus
|
||||||
import eu.kanade.domain.chapter.interactor.UpdateChapter
|
|
||||||
import eu.kanade.domain.chapter.model.Chapter
|
import eu.kanade.domain.chapter.model.Chapter
|
||||||
import eu.kanade.domain.chapter.model.toDbChapter
|
import eu.kanade.domain.chapter.model.toDbChapter
|
||||||
import eu.kanade.domain.manga.interactor.GetIdsOfFavoriteMangaWithMetadata
|
import eu.kanade.domain.manga.interactor.GetIdsOfFavoriteMangaWithMetadata
|
||||||
@ -109,7 +108,6 @@ class LibraryPresenter(
|
|||||||
private val getCategories: GetCategories = Injekt.get(),
|
private val getCategories: GetCategories = Injekt.get(),
|
||||||
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
private val getChapterByMangaId: GetChapterByMangaId = Injekt.get(),
|
||||||
private val setReadStatus: SetReadStatus = Injekt.get(),
|
private val setReadStatus: SetReadStatus = Injekt.get(),
|
||||||
private val updateChapter: UpdateChapter = Injekt.get(),
|
|
||||||
private val updateManga: UpdateManga = Injekt.get(),
|
private val updateManga: UpdateManga = Injekt.get(),
|
||||||
private val setMangaCategories: SetMangaCategories = Injekt.get(),
|
private val setMangaCategories: SetMangaCategories = Injekt.get(),
|
||||||
private val preferences: PreferencesHelper = Injekt.get(),
|
private val preferences: PreferencesHelper = Injekt.get(),
|
||||||
@ -145,11 +143,11 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
val selection: MutableList<LibraryManga> = mutableStateListOf()
|
val selection: MutableList<LibraryManga> = mutableStateListOf()
|
||||||
|
|
||||||
val isPerCategory by mutableStateOf(preferences.categorizedDisplaySettings().get())
|
val isPerCategory by preferences.categorizedDisplaySettings().asState()
|
||||||
|
|
||||||
var columns by mutableStateOf(0)
|
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.
|
* Relay used to apply the UI filters to the last emission of the library.
|
||||||
@ -307,8 +305,8 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
if (!containsExclude.any() && !containsInclude.any()) return@tracking true
|
if (!containsExclude.any() && !containsInclude.any()) return@tracking true
|
||||||
|
|
||||||
val exclude = trackedManga?.filter { containsExclude.containsKey(it.key.toLong()) && it.value }?.values ?: emptyList()
|
val exclude = trackedManga?.filter { containsExclude.containsKey(it.key) && it.value }?.values ?: emptyList()
|
||||||
val include = trackedManga?.filter { containsInclude.containsKey(it.key.toLong()) && it.value }?.values ?: emptyList()
|
val include = trackedManga?.filter { containsInclude.containsKey(it.key) && it.value }?.values ?: emptyList()
|
||||||
|
|
||||||
if (containsInclude.any() && containsExclude.any()) {
|
if (containsInclude.any() && containsExclude.any()) {
|
||||||
return@tracking if (exclude.isNotEmpty()) !exclude.any() else include.any()
|
return@tracking if (exclude.isNotEmpty()) !exclude.any() else include.any()
|
||||||
@ -618,9 +616,6 @@ class LibraryPresenter(
|
|||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
private fun getLibraryMangasObservable(): Observable<LibraryMap> {
|
private fun getLibraryMangasObservable(): Observable<LibraryMap> {
|
||||||
val defaultLibraryDisplayMode = preferences.libraryDisplayMode()
|
|
||||||
val shouldSetFromCategory = preferences.categorizedDisplaySettings()
|
|
||||||
|
|
||||||
return getLibraryManga.subscribe().asObservable()
|
return getLibraryManga.subscribe().asObservable()
|
||||||
.map { list ->
|
.map { list ->
|
||||||
list.map { libraryManga ->
|
list.map { libraryManga ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user