Move ImageSearchScreen
This commit is contained in:
1 parent
e3ffb9a473
commit
4e3862b1c5
4 files changed
+16
-13
No files matched your search
@@ -50,7 +50,6 @@ import androidx.compose.material.icons.filled.Favorite
|
||||
import androidx.compose.material.icons.filled.FormatListNumbered
|
||||
import androidx.compose.material.icons.filled.History
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.icons.filled.ImageSearch
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.Whatshot
|
||||
import androidx.compose.material3.DrawerDefaults
|
||||
@@ -124,7 +123,6 @@ import com.hippo.ehviewer.ui.destinations.DownloadsScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.FavouritesScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.HistoryScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.HomePageScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.ImageSearchScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.ProgressScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.SettingsScreenDestination
|
||||
import com.hippo.ehviewer.ui.destinations.SignInScreenDestination
|
||||
@@ -176,7 +174,6 @@ private val navItems = arrayOf<Triple<Direction, Int, ImageVector>>(
|
||||
Triple(FavouritesScreenDestination, R.string.favourite, Icons.Default.Favorite),
|
||||
Triple(HistoryScreenDestination, R.string.history, Icons.Default.History),
|
||||
Triple(DownloadsScreenDestination, R.string.downloads, Icons.Default.Download),
|
||||
Triple(ImageSearchScreenDestination, R.string.image_search_title, Icons.Default.ImageSearch),
|
||||
Triple(SettingsScreenDestination, R.string.settings, Icons.Default.Settings),
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hippo.ehviewer.ui.screen
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.focusable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -30,6 +31,7 @@ import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.MenuBook
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.ImageSearch
|
||||
import androidx.compose.material.icons.filled.Menu
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -65,11 +67,13 @@ import com.hippo.ehviewer.collectAsState
|
||||
import com.hippo.ehviewer.dao.Search
|
||||
import com.hippo.ehviewer.dao.SearchDao
|
||||
import com.hippo.ehviewer.ui.LocalNavDrawerState
|
||||
import com.hippo.ehviewer.ui.tools.LocalDialogState
|
||||
import com.hippo.ehviewer.ui.destinations.ImageSearchScreenDestination
|
||||
import com.hippo.ehviewer.ui.tools.DialogState
|
||||
import com.hippo.ehviewer.ui.tools.rememberCompositionActiveState
|
||||
import com.hippo.ehviewer.ui.tools.thenIf
|
||||
import com.jamal.composeprefs3.ui.ifNotNullThen
|
||||
import com.jamal.composeprefs3.ui.ifTrueThen
|
||||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -94,6 +98,7 @@ abstract class Suggestion {
|
||||
suspend fun SearchDao.suggestions(prefix: String, limit: Int) =
|
||||
(if (prefix.isBlank()) list(limit) else rawSuggestions(prefix, limit))
|
||||
|
||||
context(DialogState, DestinationsNavigator)
|
||||
@Composable
|
||||
fun SearchBarScreen(
|
||||
onApplySearch: (String) -> Unit,
|
||||
@@ -114,7 +119,6 @@ fun SearchBarScreen(
|
||||
val mSearchDatabase = searchDatabase.searchDao()
|
||||
val scope = rememberCoroutineScope { Dispatchers.IO }
|
||||
val context = LocalContext.current
|
||||
val dialogState = LocalDialogState.current
|
||||
val animateItems by Settings.animateItems.collectAsState()
|
||||
|
||||
class TagSuggestion(
|
||||
@@ -189,9 +193,7 @@ fun SearchBarScreen(
|
||||
|
||||
fun deleteKeyword(keyword: String) {
|
||||
scope.launch {
|
||||
dialogState.awaitConfirmationOrCancel(
|
||||
confirmText = R.string.delete,
|
||||
) {
|
||||
awaitConfirmationOrCancel(confirmText = R.string.delete) {
|
||||
Text(text = stringResource(id = R.string.delete_search_history, keyword))
|
||||
}
|
||||
mSearchDatabase.deleteQuery(keyword)
|
||||
@@ -244,9 +246,15 @@ fun SearchBarScreen(
|
||||
},
|
||||
trailingIcon = {
|
||||
if (expanded) {
|
||||
if (searchFieldState.text.isNotEmpty()) {
|
||||
IconButton(onClick = { searchFieldState.clearText() }) {
|
||||
Icon(Icons.Default.Close, contentDescription = null)
|
||||
AnimatedContent(targetState = searchFieldState.text.isNotEmpty()) { hasText ->
|
||||
if (hasText) {
|
||||
IconButton(onClick = { searchFieldState.clearText() }) {
|
||||
Icon(Icons.Default.Close, contentDescription = null)
|
||||
}
|
||||
} else {
|
||||
IconButton(onClick = { navigate(ImageSearchScreenDestination) }) {
|
||||
Icon(Icons.Default.ImageSearch, contentDescription = null)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
<string name="gallery_list_empty_hit_subscription">请至 设置->EH->我的标签 订阅标签</string>
|
||||
<string name="keyword_search">关键字搜索</string>
|
||||
<string name="image_search">图片搜索</string>
|
||||
<string name="image_search_title">搜图</string>
|
||||
<string name="search_image">图片搜索</string>
|
||||
<string name="search_sh">已删除</string>
|
||||
<string name="search_sto">有种子</string>
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
<string name="gallery_list_empty_hit_subscription">Subscribe to tags in Settings->EH->My tags</string>
|
||||
<string name="keyword_search">Keyword search</string>
|
||||
<string name="image_search">Image search</string>
|
||||
<string name="image_search_title">Image search</string>
|
||||
<string name="search_image">Image Search</string>
|
||||
<string name="search_sh">Expunged</string>
|
||||
<string name="search_sto">Has Torrent</string>
|
||||
|
||||
Reference in new issue
Block a user