|
|
@@ -24,8 +24,10 @@ import androidx.compose.ui.focus.FocusRequester
|
|
|
import androidx.compose.ui.focus.focusRequester
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
+import androidx.compose.ui.res.stringResource
|
|
|
import androidx.compose.ui.text.input.ImeAction
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
+import io.legado.app.R
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
|
import io.legado.app.ui.theme.ThemeResolver
|
|
|
import io.legado.app.ui.widget.components.icon.AppIcon
|
|
|
@@ -41,7 +43,7 @@ fun SearchBar(
|
|
|
query: String,
|
|
|
onQueryChange: (String) -> Unit,
|
|
|
onSearch: (String) -> Unit = {},
|
|
|
- placeholder: String = "搜索...",
|
|
|
+ placeholder: String? = null,
|
|
|
leadingIcon: @Composable (() -> Unit)? = {
|
|
|
AppIcon(
|
|
|
modifier = Modifier.padding(horizontal = 12.dp),
|
|
|
@@ -93,6 +95,7 @@ fun SearchBar(
|
|
|
} else {
|
|
|
if (isMiuix) MiuixTheme.colorScheme.surfaceContainer else MaterialTheme.colorScheme.surfaceContainerLow
|
|
|
}
|
|
|
+ val resolvedPlaceholder = placeholder ?: stringResource(R.string.search_placeholder)
|
|
|
|
|
|
if (isMiuix) {
|
|
|
AppDenseTextField(
|
|
|
@@ -101,7 +104,7 @@ fun SearchBar(
|
|
|
.fillMaxWidth()
|
|
|
.padding(vertical = 4.dp)
|
|
|
.focusRequester(focusRequester),
|
|
|
- placeholder = { AppText(placeholder) },
|
|
|
+ placeholder = { AppText(resolvedPlaceholder) },
|
|
|
leadingIcon = leadingIcon,
|
|
|
trailingIcon = trailingIcon,
|
|
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
|
|
@@ -111,7 +114,7 @@ fun SearchBar(
|
|
|
lineLimits = TextFieldLineLimits.SingleLine,
|
|
|
backgroundColor = resolvedBackgroundColor,
|
|
|
miuixUseSearchBarInputField = true,
|
|
|
- miuixSearchBarLabel = placeholder,
|
|
|
+ miuixSearchBarLabel = resolvedPlaceholder,
|
|
|
miuixOnSearch = onSearch,
|
|
|
)
|
|
|
} else {
|
|
|
@@ -127,7 +130,7 @@ fun SearchBar(
|
|
|
modifier = modifier
|
|
|
.fillMaxWidth()
|
|
|
.focusRequester(focusRequester),
|
|
|
- placeholder = { AppText(placeholder) },
|
|
|
+ placeholder = { AppText(resolvedPlaceholder) },
|
|
|
leadingIcon = leadingIcon,
|
|
|
trailingIcon = trailingIcon,
|
|
|
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|