|
@@ -1,8 +1,22 @@
|
|
|
package eu.kanade.presentation.browse
|
|
|
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.horizontalScroll
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
|
+import androidx.compose.foundation.rememberScrollState
|
|
|
+import androidx.compose.material.icons.Icons
|
|
|
+import androidx.compose.material.icons.outlined.DoneAll
|
|
|
+import androidx.compose.material.icons.outlined.FilterList
|
|
|
+import androidx.compose.material.icons.outlined.PushPin
|
|
|
+import androidx.compose.material3.FilterChip
|
|
|
+import androidx.compose.material3.FilterChipDefaults
|
|
|
+import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
@@ -16,19 +30,23 @@ import eu.kanade.presentation.browse.components.GlobalSearchResultItem
|
|
|
import eu.kanade.presentation.browse.components.GlobalSearchToolbar
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
|
|
+import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchFilter
|
|
|
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchState
|
|
|
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SearchItemResult
|
|
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
|
|
import tachiyomi.domain.manga.model.Manga
|
|
|
+import tachiyomi.presentation.core.components.material.Divider
|
|
|
import tachiyomi.presentation.core.components.material.Scaffold
|
|
|
import tachiyomi.presentation.core.components.material.padding
|
|
|
|
|
|
@Composable
|
|
|
fun GlobalSearchScreen(
|
|
|
state: GlobalSearchState,
|
|
|
+ items: Map<CatalogueSource, SearchItemResult>,
|
|
|
navigateUp: () -> Unit,
|
|
|
onChangeSearchQuery: (String?) -> Unit,
|
|
|
onSearch: (String) -> Unit,
|
|
|
+ onChangeFilter: (GlobalSearchFilter) -> Unit,
|
|
|
getManga: @Composable (Manga) -> State<Manga>,
|
|
|
onClickSource: (CatalogueSource) -> Unit,
|
|
|
onClickItem: (Manga) -> Unit,
|
|
@@ -36,19 +54,78 @@ fun GlobalSearchScreen(
|
|
|
) {
|
|
|
Scaffold(
|
|
|
topBar = { scrollBehavior ->
|
|
|
- GlobalSearchToolbar(
|
|
|
- searchQuery = state.searchQuery,
|
|
|
- progress = state.progress,
|
|
|
- total = state.total,
|
|
|
- navigateUp = navigateUp,
|
|
|
- onChangeSearchQuery = onChangeSearchQuery,
|
|
|
- onSearch = onSearch,
|
|
|
- scrollBehavior = scrollBehavior,
|
|
|
- )
|
|
|
+ Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) {
|
|
|
+ GlobalSearchToolbar(
|
|
|
+ searchQuery = state.searchQuery,
|
|
|
+ progress = state.progress,
|
|
|
+ total = state.total,
|
|
|
+ navigateUp = navigateUp,
|
|
|
+ onChangeSearchQuery = onChangeSearchQuery,
|
|
|
+ onSearch = onSearch,
|
|
|
+ scrollBehavior = scrollBehavior,
|
|
|
+ )
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .horizontalScroll(rememberScrollState())
|
|
|
+ .padding(horizontal = MaterialTheme.padding.small),
|
|
|
+ horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
|
+ ) {
|
|
|
+ FilterChip(
|
|
|
+ selected = state.searchFilter == GlobalSearchFilter.All,
|
|
|
+ onClick = { onChangeFilter(GlobalSearchFilter.All) },
|
|
|
+ leadingIcon = {
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Outlined.DoneAll,
|
|
|
+ contentDescription = "",
|
|
|
+ modifier = Modifier
|
|
|
+ .size(FilterChipDefaults.IconSize),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ label = {
|
|
|
+ Text(text = stringResource(id = R.string.all))
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ FilterChip(
|
|
|
+ selected = state.searchFilter == GlobalSearchFilter.PinnedOnly,
|
|
|
+ onClick = { onChangeFilter(GlobalSearchFilter.PinnedOnly) },
|
|
|
+ leadingIcon = {
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Outlined.PushPin,
|
|
|
+ contentDescription = "",
|
|
|
+ modifier = Modifier
|
|
|
+ .size(FilterChipDefaults.IconSize),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ label = {
|
|
|
+ Text(text = stringResource(id = R.string.pinned_sources))
|
|
|
+ },
|
|
|
+ )
|
|
|
+
|
|
|
+ FilterChip(
|
|
|
+ selected = state.searchFilter == GlobalSearchFilter.AvailableOnly,
|
|
|
+ onClick = { onChangeFilter(GlobalSearchFilter.AvailableOnly) },
|
|
|
+ leadingIcon = {
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Outlined.FilterList,
|
|
|
+ contentDescription = "",
|
|
|
+ modifier = Modifier
|
|
|
+ .size(FilterChipDefaults.IconSize),
|
|
|
+ )
|
|
|
+ },
|
|
|
+ label = {
|
|
|
+ Text(text = stringResource(id = R.string.has_results))
|
|
|
+ },
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Divider()
|
|
|
+ }
|
|
|
},
|
|
|
) { paddingValues ->
|
|
|
GlobalSearchContent(
|
|
|
- items = state.items,
|
|
|
+ items = items,
|
|
|
contentPadding = paddingValues,
|
|
|
getManga = getManga,
|
|
|
onClickSource = onClickSource,
|