From c0a1cbae2c62d5979b048c616a54abac4dc3a417 Mon Sep 17 00:00:00 2001 From: jhg3410 <80373033+jhg3410@users.noreply.github.com> Date: Wed, 25 Jan 2023 03:18:06 +0900 Subject: [PATCH] #2 - Search bar - Modifiers --- .../com/codelab/basiclayouts/MainActivity.kt | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/BasicLayoutsCodelab/app/src/main/java/com/codelab/basiclayouts/MainActivity.kt b/BasicLayoutsCodelab/app/src/main/java/com/codelab/basiclayouts/MainActivity.kt index e779da6..7185680 100644 --- a/BasicLayoutsCodelab/app/src/main/java/com/codelab/basiclayouts/MainActivity.kt +++ b/BasicLayoutsCodelab/app/src/main/java/com/codelab/basiclayouts/MainActivity.kt @@ -21,9 +21,15 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.annotation.DrawableRes import androidx.annotation.StringRes +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding +import androidx.compose.material.* +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Search import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.codelab.basiclayouts.ui.theme.MySootheTheme @@ -40,7 +46,25 @@ class MainActivity : ComponentActivity() { fun SearchBar( modifier: Modifier = Modifier ) { - // Implement composable here + TextField( + value = "", + onValueChange = {}, + leadingIcon = { + Icon( + imageVector = Icons.Default.Search, + contentDescription = null + ) + }, + colors = TextFieldDefaults.textFieldColors( + backgroundColor = MaterialTheme.colors.surface + ), + placeholder = { + Text(stringResource(id = R.string.placeholder_search)) + }, + modifier = modifier + .fillMaxWidth() + .heightIn(min = 56.dp) + ) } // Step: Align your body - Alignment