From fa5f96758c113964220ab4cccb4f463e51d26ba5 Mon Sep 17 00:00:00 2001 From: "DHNGL-ABHISHEKP\\Abhishek P" Date: Sun, 31 Mar 2024 21:17:29 +0530 Subject: [PATCH] Added single line expression --- .../lessons/lesson_23/TabScreen.kt | 3 ++- .../ui/components/InputFields.kt | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/lessons/lesson_23/TabScreen.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/lessons/lesson_23/TabScreen.kt index c39c4489..38dfe05b 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/lessons/lesson_23/TabScreen.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/lessons/lesson_23/TabScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Tab import androidx.compose.material3.TabRow import androidx.compose.material3.TabRowDefaults +import androidx.compose.material3.TabRowDefaults.SecondaryIndicator import androidx.compose.material3.TabRowDefaults.tabIndicatorOffset import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -77,7 +78,7 @@ fun Tabs( selectedTabIndex = selectedTabIndex, // Index of the currently selected tab indicator = { tabPositions -> // Customizing tab indicator position - TabRowDefaults.Indicator( + SecondaryIndicator( modifier = Modifier.tabIndicatorOffset(tabPositions[selectedTabIndex]), // Offset based on selected tab position color = Color.Black // Color of the indicator ) diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/InputFields.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/InputFields.kt index 1f5c1428..1724b960 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/InputFields.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/InputFields.kt @@ -246,7 +246,9 @@ fun AutoCompleteSearchBar( OutlinedTextField( value = text, onValueChange = onChange, - modifier = Modifier.fillMaxWidth().padding(dp_15), + modifier = Modifier + .fillMaxWidth() + .padding(dp_15), enabled = enabled, label = label?.run { { Text(this) } }, trailingIcon = { @@ -271,21 +273,15 @@ fun AutoCompleteSearchBar( } - @Preview @Composable -private fun SimpleSearchBarPreview() { - SimpleSearchBar( - "Testing testing...", - - ) {} -} +private fun SimpleSearchBarPreview() = SimpleSearchBar("Testing testing..."){} @Preview @Composable private fun AutocompleteSearchBarPreview() { AutoCompleteSearchBar( "Testing testing...", - listOf("1","222222....","3. Hey Bob the mic is not working.") + listOf("1", "222222....", "3. Hey Bob the mic is not working.") ) {} } \ No newline at end of file