Coverage Summary for Class: SurferSearchFieldKt (com.georgeci.moneysurfer.uikit.components)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| SurferSearchFieldKt |
100%
(1/1)
|
100%
(1/1)
|
50%
(8/16)
|
95.5%
(21/22)
|
91.9%
(353/384)
|
package com.georgeci.moneysurfer.uikit.components
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.georgeci.moneysurfer.uikit.icons.SurferIcons
import com.georgeci.moneysurfer.uikit.semantics.SurferSemantics
import com.georgeci.moneysurfer.uikit.theme.AppTheme
/**
* Rounded, indicator-less search text field with a leading search glyph, used by the
* currency and category pickers. [containerColor] tunes the fill to the surrounding surface.
*
* [trailing] fills the field's trailing slot — the transactions list puts its filter button
* there, which is what keeps the button inside the field rather than beside it.
*/
@Composable
fun SurferSearchField(
value: String,
onValueChange: (String) -> Unit,
placeholder: String,
modifier: Modifier = Modifier,
containerColor: Color = AppTheme.materialColors.surfaceContainerHigh,
trailing: @Composable (() -> Unit)? = null,
) {
OutlinedTextField(
value = value,
onValueChange = onValueChange,
placeholder = { Text(placeholder) },
trailingIcon = trailing,
leadingIcon = {
Icon(
imageVector = SurferIcons.Search,
contentDescription = SurferSemantics.Decorative,
)
},
singleLine = true,
// Same corner as SurferCard, like every other input in the app — a search field rounder
// than the rows under it reads as a control from a different screen.
shape = AppTheme.shapes.large,
colors = TextFieldDefaults.colors(
focusedContainerColor = containerColor,
unfocusedContainerColor = containerColor,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
),
modifier = modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
.heightIn(min = 44.dp),
)
}