mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Cleanup Library after Compose changes (#7584)
This commit is contained in:
parent
fc328e141c
commit
9f2ddaadde
@ -6,6 +6,7 @@ import eu.kanade.presentation.components.LibraryBottomActionMenu
|
||||
import eu.kanade.presentation.components.Scaffold
|
||||
import eu.kanade.presentation.library.components.LibraryContent
|
||||
import eu.kanade.presentation.library.components.LibraryToolbar
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||
|
||||
@Composable
|
||||
@ -44,7 +45,7 @@ fun LibraryScreen(
|
||||
onMarkAsReadClicked = onMarkAsReadClicked,
|
||||
onMarkAsUnreadClicked = onMarkAsUnreadClicked,
|
||||
onDownloadClicked = onDownloadClicked,
|
||||
onDeleteClicked = onDeleteClicked,
|
||||
onDeleteClicked = onDeleteClicked.takeIf { presenter.selection.none { it.source == LocalSource.ID } },
|
||||
)
|
||||
},
|
||||
) { paddingValues ->
|
||||
|
@ -6,13 +6,19 @@ import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.asPaddingValues
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import eu.kanade.presentation.components.TextButton
|
||||
import eu.kanade.presentation.util.bottomNavPaddingValues
|
||||
import eu.kanade.presentation.util.plus
|
||||
import eu.kanade.tachiyomi.R
|
||||
|
||||
@Composable
|
||||
fun LazyLibraryGrid(
|
||||
@ -29,3 +35,19 @@ fun LazyLibraryGrid(
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
|
||||
fun LazyGridScope.globalSearchItem(
|
||||
searchQuery: String?,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
) {
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
if (searchQuery.isNullOrEmpty().not()) {
|
||||
TextButton(onClick = onGlobalSearchClicked) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_global_search_query, searchQuery!!),
|
||||
modifier = Modifier.zIndex(99f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,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.GridItemSpan
|
||||
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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import eu.kanade.domain.manga.model.MangaCover
|
||||
import eu.kanade.presentation.components.TextButton
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||
|
||||
@ -32,16 +27,8 @@ fun LibraryComfortableGrid(
|
||||
LazyLibraryGrid(
|
||||
columns = columns,
|
||||
) {
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
if (searchQuery.isNullOrEmpty().not()) {
|
||||
TextButton(onClick = onGlobalSearchClicked) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_global_search_query, searchQuery!!),
|
||||
modifier = Modifier.zIndex(99f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
globalSearchItem(searchQuery, onGlobalSearchClicked)
|
||||
|
||||
items(
|
||||
items = items,
|
||||
key = {
|
||||
|
@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
@ -18,12 +17,8 @@ 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.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import eu.kanade.presentation.components.TextButton
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||
|
||||
@ -40,16 +35,7 @@ fun LibraryCompactGrid(
|
||||
LazyLibraryGrid(
|
||||
columns = columns,
|
||||
) {
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
if (searchQuery.isNullOrEmpty().not()) {
|
||||
TextButton(onClick = onGlobalSearchClicked) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_global_search_query, searchQuery!!),
|
||||
modifier = Modifier.zIndex(99f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
globalSearchItem(searchQuery, onGlobalSearchClicked)
|
||||
|
||||
items(
|
||||
items = items,
|
||||
|
@ -7,9 +7,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import com.google.accompanist.pager.rememberPagerState
|
||||
import com.google.accompanist.swiperefresh.SwipeRefresh
|
||||
import com.google.accompanist.swiperefresh.rememberSwipeRefreshState
|
||||
@ -22,7 +20,6 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||
import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.widget.EmptyView
|
||||
|
||||
@Composable
|
||||
@ -45,8 +42,6 @@ fun LibraryContent(
|
||||
getColumnsForOrientation: (Boolean) -> PreferenceMutableState<Int>,
|
||||
getLibraryForPage: @Composable (Int) -> State<List<LibraryItem>>,
|
||||
) {
|
||||
val nestedScrollInterop = rememberNestedScrollInteropConnection()
|
||||
|
||||
val pagerState = rememberPagerState(currentPage)
|
||||
|
||||
val categories = state.categories
|
||||
@ -83,7 +78,6 @@ fun LibraryContent(
|
||||
|
||||
SwipeRefresh(
|
||||
state = rememberSwipeRefreshState(isRefreshing = false),
|
||||
modifier = Modifier.nestedScroll(nestedScrollInterop),
|
||||
onRefresh = onRefresh,
|
||||
indicator = { s, trigger ->
|
||||
SwipeRefreshIndicator(
|
||||
@ -93,12 +87,12 @@ fun LibraryContent(
|
||||
},
|
||||
) {
|
||||
if (state.searchQuery.isNullOrEmpty() && isLibraryEmpty) {
|
||||
val context = LocalContext.current
|
||||
val handler = LocalUriHandler.current
|
||||
EmptyScreen(
|
||||
R.string.information_empty_library,
|
||||
listOf(
|
||||
EmptyView.Action(R.string.getting_started_guide, R.drawable.ic_help_24dp) {
|
||||
context.openInBrowser("https://tachiyomi.org/help/guides/getting-started")
|
||||
handler.openUri("https://tachiyomi.org/help/guides/getting-started")
|
||||
},
|
||||
),
|
||||
)
|
||||
|
@ -1,15 +1,9 @@
|
||||
package eu.kanade.presentation.library.components
|
||||
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.items
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.zIndex
|
||||
import eu.kanade.presentation.components.TextButton
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||
|
||||
@ -26,16 +20,8 @@ fun LibraryCoverOnlyGrid(
|
||||
LazyLibraryGrid(
|
||||
columns = columns,
|
||||
) {
|
||||
item(span = { GridItemSpan(maxLineSpan) }) {
|
||||
if (searchQuery.isNullOrEmpty().not()) {
|
||||
TextButton(onClick = onGlobalSearchClicked) {
|
||||
Text(
|
||||
text = stringResource(R.string.action_global_search_query, searchQuery!!),
|
||||
modifier = Modifier.zIndex(99f),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
globalSearchItem(searchQuery, onGlobalSearchClicked)
|
||||
|
||||
items(
|
||||
items = items,
|
||||
key = {
|
||||
|
@ -411,7 +411,7 @@ class LibraryPresenter(
|
||||
* @return an observable of the categories and its manga.
|
||||
*/
|
||||
private fun getLibraryObservable(): Observable<Library> {
|
||||
return combine(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga ->
|
||||
return combine(getCategoriesFlow(), getLibraryMangasFlow()) { dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0)) {
|
||||
arrayListOf(Category.default(context)) + dbCategories
|
||||
} else {
|
||||
@ -435,7 +435,7 @@ class LibraryPresenter(
|
||||
*
|
||||
* @return an observable of the categories.
|
||||
*/
|
||||
private fun getCategoriesObservable(): Flow<List<Category>> {
|
||||
private fun getCategoriesFlow(): Flow<List<Category>> {
|
||||
return getCategories.subscribe()
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ class LibraryPresenter(
|
||||
* @return an observable containing a map with the category id as key and a list of manga as the
|
||||
* value.
|
||||
*/
|
||||
private fun getLibraryMangasObservable(): Flow<LibraryMap> {
|
||||
private fun getLibraryMangasFlow(): Flow<LibraryMap> {
|
||||
return getLibraryManga.subscribe()
|
||||
.map { list ->
|
||||
list.map { libraryManga ->
|
||||
|
Loading…
Reference in New Issue
Block a user