feat: move leading icon creation into the caller
This commit is contained in:
parent
81d3c9450b
commit
eada6ea992
@ -1,6 +1,7 @@
|
||||
package com.jetpackduba.gitnuro.ui
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material.Text
|
||||
@ -8,6 +9,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.ui.components.AdjustableOutlinedTextField
|
||||
import com.jetpackduba.gitnuro.ui.components.gitnuroViewModel
|
||||
@ -30,13 +32,22 @@ fun BranchFilter(
|
||||
onValueChange = { branchFilterViewModel.newBranchFilter(keyword = it) },
|
||||
hint = "Filter Branches",
|
||||
textStyle = MaterialTheme.typography.caption,
|
||||
leadingIconResourcePath = "branch_filter.svg",
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.wrapContentHeight()
|
||||
.fillMaxWidth()
|
||||
.heightIn(min = 8.dp)
|
||||
.defaultMinSize(minHeight = 8.dp),
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painter = painterResource("branch_filter.svg"),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
.size(16.dp),
|
||||
tint = MaterialTheme.typography.caption.color,
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ fun AdjustableOutlinedTextField(
|
||||
shape: Shape = RoundedCornerShape(4.dp),
|
||||
backgroundColor: Color = MaterialTheme.colors.background,
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
leadingIconResourcePath: String = "",
|
||||
leadingIcon: (@Composable () -> Unit)? = null,
|
||||
) {
|
||||
val textColor = textStyle.color.takeOrElse {
|
||||
colors.textColor(enabled).value
|
||||
@ -87,16 +87,7 @@ fun AdjustableOutlinedTextField(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.wrapContentHeight(),
|
||||
) {
|
||||
if (leadingIconResourcePath.isNotEmpty()) {
|
||||
Icon(
|
||||
painter = painterResource(leadingIconResourcePath),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
.size(16.dp),
|
||||
tint = textColor,
|
||||
)
|
||||
}
|
||||
leadingIcon?.invoke()
|
||||
|
||||
Box(
|
||||
contentAlignment = Alignment.CenterStart,
|
||||
|
Loading…
Reference in New Issue
Block a user