Skip to content

Commit

Permalink
library: Add MiuixSearchBar [6/N]
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Sep 12, 2024
1 parent 7db526d commit 0779ef5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions composeApp/src/commonMain/kotlin/MainPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fun MainPage(
onSearch = { expanded = false },
expanded = expanded,
onExpandedChange = { expanded = it },
label = "Search",
leadingIcon = {
Image(
modifier = Modifier.padding(horizontal = 14.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.zIndex
import kotlinx.coroutines.delay
import top.yukonga.miuix.kmp.basic.MiuixBox
import top.yukonga.miuix.kmp.basic.MiuixSurface
import top.yukonga.miuix.kmp.basic.MiuixText
import top.yukonga.miuix.kmp.theme.MiuixTheme
import top.yukonga.miuix.kmp.utils.BackHandler
import top.yukonga.miuix.kmp.utils.squircleshape.SquircleShape
Expand Down Expand Up @@ -95,6 +96,7 @@ fun MiuixSearchBar(
* @param query the query text to be shown in the input field.
* @param onQueryChange the callback to be invoked when the input service updates the query. An
* updated text comes as a parameter of the callback.
* @param label the label to be shown when the input field is not focused.
* @param onSearch the callback to be invoked when the input service triggers the
* [ImeAction.Search] action. The current [query] comes as a parameter of the callback.
* @param expanded whether the search bar is expanded and showing search results.
Expand All @@ -115,6 +117,7 @@ fun MiuixSearchBar(
fun MiuixInputField(
query: String,
onQueryChange: (String) -> Unit,
label: String = "",
onSearch: (String) -> Unit,
expanded: Boolean,
onExpandedChange: (Boolean) -> Unit,
Expand Down Expand Up @@ -175,9 +178,15 @@ fun MiuixInputField(
}
MiuixBox(
modifier = Modifier
.weight(1f)
.then(paddingModifier),
contentAlignment = Alignment.Center
) {

MiuixText(
text = if (!focused) label else "",
color = MiuixTheme.colorScheme.textFieldSub
)

innerTextField()
}
if (trailingIcon != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import top.yukonga.miuix.kmp.utils.rememberOverscrollFlingBehavior
* A [LazyColumn] that supports over-scroll and top app bar scroll behavior.
*
* @param modifier The modifier to apply to this layout.
* @param enableOverScroll Whether to enable over-scroll.
* @param state The state of the [LazyColumn].
* @param contentPadding The padding to apply to the content.
* @param userScrollEnabled Whether the user can scroll the [LazyColumn].
* @param enableOverScroll Whether to enable over-scroll.
* @param topAppBarScrollBehavior The scroll behavior of the top app bar.
* @param content The [Composable] content of the [LazyColumn].
*/
Expand Down

0 comments on commit 0779ef5

Please sign in to comment.