-
Notifications
You must be signed in to change notification settings - Fork 256
Migrate to TopSearchBar #2148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
revonateB0T
wants to merge
9
commits into
main
Choose a base branch
from
zoom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Migrate to TopSearchBar #2148
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,11 +31,13 @@ import androidx.compose.material.icons.outlined.Bookmarks | |||||||||
| import androidx.compose.material3.Icon | ||||||||||
| import androidx.compose.material3.IconButton | ||||||||||
| import androidx.compose.material3.ListItem | ||||||||||
| import androidx.compose.material3.SearchBarDefaults | ||||||||||
| import androidx.compose.material3.SwipeToDismissBoxValue | ||||||||||
| import androidx.compose.material3.Text | ||||||||||
| import androidx.compose.material3.TopAppBar | ||||||||||
| import androidx.compose.material3.fork.SwipeToDismissBox | ||||||||||
| import androidx.compose.material3.fork.SwipeToDismissBoxState | ||||||||||
| import androidx.compose.material3.rememberSearchBarState | ||||||||||
| import androidx.compose.runtime.Composable | ||||||||||
| import androidx.compose.runtime.LaunchedEffect | ||||||||||
| import androidx.compose.runtime.Stable | ||||||||||
|
|
@@ -124,7 +126,6 @@ import com.ramcosta.composedestinations.spec.Direction | |||||||||
| import eu.kanade.tachiyomi.util.lang.launchIO | ||||||||||
| import eu.kanade.tachiyomi.util.lang.withIOContext | ||||||||||
| import eu.kanade.tachiyomi.util.lang.withUIContext | ||||||||||
| import kotlin.math.roundToInt | ||||||||||
| import kotlin.random.Random | ||||||||||
| import kotlinx.coroutines.delay | ||||||||||
| import kotlinx.coroutines.launch | ||||||||||
|
|
@@ -153,15 +154,15 @@ fun AnimatedVisibilityScope.ToplistScreen(navigator: DestinationsNavigator) = Ga | |||||||||
| @Composable | ||||||||||
| fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: DestinationsNavigator) = Screen(navigator) { | ||||||||||
| val searchFieldState = rememberTextFieldState() | ||||||||||
| val searchBarState = rememberSearchBarState() | ||||||||||
| val scrollBehaviour = SearchBarDefaults.enterAlwaysSearchBarScrollBehavior() | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| var urlBuilder by rememberSaveable(lub) { mutableStateOf(lub) } | ||||||||||
| var searchBarExpanded by rememberSaveable { mutableStateOf(false) } | ||||||||||
| var searchBarOffsetY by remember { mutableIntStateOf(0) } | ||||||||||
| val animateItems by Settings.animateItems.collectAsState() | ||||||||||
|
|
||||||||||
| var category by rememberMutableStateInDataStore("SearchCategory") { EhUtils.ALL_CATEGORY } | ||||||||||
| var advancedSearchOption by rememberMutableStateInDataStore("AdvancedSearchOption") { AdvancedSearchOption() } | ||||||||||
|
|
||||||||||
| DrawerHandle(!searchBarExpanded) | ||||||||||
| DrawerHandle(!searchBarState.expanded) | ||||||||||
|
|
||||||||||
| LaunchedEffect(urlBuilder) { | ||||||||||
| if (urlBuilder.category != EhUtils.NONE) category = urlBuilder.category | ||||||||||
|
|
@@ -460,6 +461,9 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
|
|
||||||||||
| var fabExpanded by remember { mutableStateOf(false) } | ||||||||||
| var fabHidden by remember { mutableStateOf(false) } | ||||||||||
| LaunchedEffect(searchBarState) { | ||||||||||
| snapshotFlow { searchBarState.expanded }.collect { fabHidden = it } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| val openGalleryKeyword = stringResource(R.string.gallery_list_search_bar_open_gallery) | ||||||||||
| abstract class UrlSuggestion : Suggestion() { | ||||||||||
|
|
@@ -505,11 +509,6 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
|
|
||||||||||
| SearchBarScreen( | ||||||||||
| onApplySearch = ::onApplySearch, | ||||||||||
| expanded = searchBarExpanded, | ||||||||||
| onExpandedChange = { | ||||||||||
| searchBarExpanded = it | ||||||||||
| fabHidden = it | ||||||||||
| }, | ||||||||||
| title = suitableTitle, | ||||||||||
| searchFieldHint = searchBarHint, | ||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| searchFieldState = searchFieldState, | ||||||||||
|
|
@@ -521,7 +520,6 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
| } | ||||||||||
| }, | ||||||||||
| tagNamespace = true, | ||||||||||
| searchBarOffsetY = { searchBarOffsetY }, | ||||||||||
| trailingIcon = { | ||||||||||
| val sheetState = LocalSideSheetState.current | ||||||||||
| IconButton(onClick = { launch { sheetState.open() } }) { | ||||||||||
|
|
@@ -544,7 +542,6 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
| val showPages by Settings.showGalleryPages.collectAsState() | ||||||||||
| val searchBarConnection = remember { | ||||||||||
| val slop = ViewConfiguration.get(implicit<Context>()).scaledTouchSlop | ||||||||||
| val topPaddingPx = with(density) { contentPadding.calculateTopPadding().roundToPx() } | ||||||||||
| object : NestedScrollConnection { | ||||||||||
| override fun onPostScroll(consumed: Offset, available: Offset, source: NestedScrollSource): Offset { | ||||||||||
| val dy = -consumed.y | ||||||||||
|
|
@@ -553,7 +550,6 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
| } else if (dy <= -slop / 2) { | ||||||||||
| fabHidden = false | ||||||||||
| } | ||||||||||
| searchBarOffsetY = (searchBarOffsetY - dy).roundToInt().coerceIn(-topPaddingPx, 0) | ||||||||||
| return Offset.Zero // We never consume it | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
@@ -582,12 +578,11 @@ fun AnimatedVisibilityScope.GalleryListScreen(lub: ListUrlBuilder, navigator: De | |||||||||
| showPages = showPages, | ||||||||||
| ) | ||||||||||
| }, | ||||||||||
| searchBarOffsetY = { searchBarOffsetY }, | ||||||||||
| scrollBehavior = scrollBehaviour, | ||||||||||
| onRefresh = { | ||||||||||
| urlBuilder.setRange(0) | ||||||||||
| data.refresh() | ||||||||||
| }, | ||||||||||
| onLoading = { searchBarOffsetY = 0 }, | ||||||||||
| ) | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.