From 9d0a91e4e848a2d172e2eb41bce5e7188c1f2339 Mon Sep 17 00:00:00 2001 From: Radhika canopas <74301808+cp-radhika-s@users.noreply.github.com> Date: Fri, 2 Jun 2023 08:03:09 +0530 Subject: [PATCH] Refactor country code picker (#10) * Refactor picker * Upgrade dependencies * Cleanup * Update README.md * Upgrade gradle --- .idea/compiler.xml | 6 - .idea/inspectionProfiles/Project_Default.xml | 20 --- .idea/misc.xml | 9 -- README.md | 55 ++++---- app/build.gradle | 31 +++-- .../campose/jetcountypicker/MainActivity.kt | 30 ++--- build.gradle | 10 +- countrypicker/build.gradle | 20 +-- .../countrypicker/CountryPickerBottomSheet.kt | 122 +++++++++--------- .../countrypicker/CountryPickerTextField.kt | 39 +++--- .../countrypicker/CountrySearchView.kt | 103 ++++++--------- gradle/wrapper/gradle-wrapper.properties | 6 +- 12 files changed, 202 insertions(+), 249 deletions(-) delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index fb7f4a8..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 2842237..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 6199cc2..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 14f9a93..7d8a3be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JetCountryPicker -Country code bottomsheet picker in Jetpack Compose with Search functionality. +Country code bottom sheet picker in Jetpack Compose with Search functionality. @@ -10,47 +10,46 @@ Available on [Maven Central](https://repo1.maven.org/maven2/com/canopas/jetcount Add the dependency ```gradle - implementation 'com.canopas.jetcountrypicker:jetcountrypicker:1.0.4' + implementation 'com.canopas.jetcountrypicker:jetcountrypicker:1.0.5' ``` ## How to use ? -```kotlin - Box { - var expanded by remember { mutableStateOf(false) } - var selectedCountry by remember { mutableStateOf(null) } - val focusManager = LocalFocusManager.current - CountryPickerBottomSheet(title = { +```kotlin + Box { + var selectedCountry by remember { mutableStateOf(null) } + val modalBottomSheetState = rememberModalBottomSheetState( + initialValue = ModalBottomSheetValue.Hidden + ) + + CountryPickerBottomSheet( + sheetState = modalBottomSheetState, + bottomSheetTitle = { Text( modifier = Modifier .fillMaxWidth() .padding(16.dp), - text = "Select Country", textAlign = TextAlign.Center, + text = stringResource(R.string.select_country_text), + textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, fontSize = 20.sp ) - }, expanded, onDismissRequest = { - expanded = false - }, onItemSelected = { + }, + onItemSelected = { selectedCountry = it - expanded = false - focusManager.clearFocus() - }) { - CountryTextField( - label = "Select country", - modifier = Modifier - .padding(top = 50.dp) - .align(Alignment.TopCenter), - expanded, - defaultSelectedCountry = countryList(LocalContext.current).single { it.code == "IN" }, - selectedCountry - ) { - expanded = !expanded - } - } - + ) { + CountryTextField( + sheetState = modalBottomSheetState, + label = stringResource(R.string.select_country_text), + modifier = Modifier + .padding(top = 50.dp) + .align(Alignment.TopCenter), + selectedCountry = selectedCountry, + defaultCountry = countryList(LocalContext.current).firstOrNull { it.code == "IN" } + ) } + } ``` # Demo diff --git a/app/build.gradle b/app/build.gradle index 02f051a..10b82e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,12 +4,12 @@ plugins { } android { - compileSdk 31 + compileSdk 33 defaultConfig { applicationId "com.canopas.campose.jetcountypicker" minSdk 21 - targetSdk 31 + targetSdk 33 versionCode 1 versionName "1.0" @@ -25,41 +25,44 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } + kotlinOptions { jvmTarget = '11' - useIR = true } + buildFeatures { compose true } - composeOptions { - kotlinCompilerExtensionVersion compose_version - } + packagingOptions { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' } } + composeOptions { + kotlinCompilerExtensionVersion compose_compiler_version + } } dependencies { implementation project(":countrypicker") - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.5.0' + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.9.0' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.material:material:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0' - implementation 'androidx.activity:activity-compose:1.4.0' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' + implementation 'androidx.activity:activity-compose:1.7.2' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" } \ No newline at end of file diff --git a/app/src/main/java/com/canopas/campose/jetcountypicker/MainActivity.kt b/app/src/main/java/com/canopas/campose/jetcountypicker/MainActivity.kt index d317aa3..51ec82b 100644 --- a/app/src/main/java/com/canopas/campose/jetcountypicker/MainActivity.kt +++ b/app/src/main/java/com/canopas/campose/jetcountypicker/MainActivity.kt @@ -6,9 +6,12 @@ import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.MaterialTheme +import androidx.compose.material.ModalBottomSheetValue import androidx.compose.material.Surface import androidx.compose.material.Text +import androidx.compose.material.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -17,7 +20,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign @@ -43,45 +45,41 @@ class MainActivity : ComponentActivity() { } } +@OptIn(ExperimentalMaterialApi::class) @Composable fun SampleCountryPicker() { Box { - var expanded by remember { mutableStateOf(false) } var selectedCountry by remember { mutableStateOf(null) } - val focusManager = LocalFocusManager.current + val modalBottomSheetState = rememberModalBottomSheetState( + initialValue = ModalBottomSheetValue.Hidden + ) CountryPickerBottomSheet( - title = { + sheetState = modalBottomSheetState, + bottomSheetTitle = { Text( modifier = Modifier .fillMaxWidth() .padding(16.dp), - text = stringResource(R.string.select_country_text), textAlign = TextAlign.Center, + text = stringResource(R.string.select_country_text), + textAlign = TextAlign.Center, fontWeight = FontWeight.Bold, fontSize = 20.sp ) }, - expanded, - onDismissRequest = { - expanded = false - }, onItemSelected = { selectedCountry = it - expanded = false - focusManager.clearFocus() } ) { CountryTextField( + sheetState = modalBottomSheetState, label = stringResource(R.string.select_country_text), modifier = Modifier .padding(top = 50.dp) .align(Alignment.TopCenter), - expanded = expanded, selectedCountry = selectedCountry, - defaultSelectedCountry = countryList(LocalContext.current).single { it.code == "IN" } - ) { - expanded = !expanded - } + defaultCountry = countryList(LocalContext.current).firstOrNull { it.code == "IN" } + ) } } } diff --git a/build.gradle b/build.gradle index 6649e12..2514740 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,15 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - compose_version = '1.1.0-beta04' + compose_version = '1.4.3' + kotlin_version = '1.8.10' + compose_compiler_version = "1.4.3" } } plugins { - id 'com.android.application' version '7.1.0' apply false - id 'com.android.library' version '7.1.0' apply false - id 'org.jetbrains.kotlin.android' version '1.6.0' apply false + id 'com.android.application' version '7.4.0' apply false + id 'com.android.library' version '7.4.0' apply false + id 'org.jetbrains.kotlin.android' version '1.8.10' apply false id 'io.github.gradle-nexus.publish-plugin' version "1.1.0" } apply from: "${rootDir}/scripts/publish-root.gradle" diff --git a/countrypicker/build.gradle b/countrypicker/build.gradle index ebbc804..c261ee4 100644 --- a/countrypicker/build.gradle +++ b/countrypicker/build.gradle @@ -11,11 +11,11 @@ ext { apply from: "${rootDir}/scripts/publish-module.gradle" android { - compileSdk 31 + compileSdk 33 defaultConfig { minSdk 21 - targetSdk 31 + targetSdk 33 versionCode 1 versionName "1.0" @@ -40,22 +40,22 @@ android { compose true } composeOptions { - kotlinCompilerExtensionVersion compose_version + kotlinCompilerExtensionVersion compose_compiler_version } } dependencies { - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.5.0' - testImplementation 'junit:junit:4.+' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation 'androidx.core:core-ktx:1.10.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.9.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.material:material:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation "androidx.compose.material:material-icons-extended:$compose_version" - implementation 'com.google.code.gson:gson:2.8.7' + implementation 'com.google.code.gson:gson:2.10.1' } diff --git a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt index 0d22122..48e5653 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt @@ -1,7 +1,6 @@ package com.canopas.campose.countrypicker import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding @@ -10,87 +9,86 @@ import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.* import androidx.compose.runtime.* +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import com.canopas.campose.countrypicker.model.Country +import kotlinx.coroutines.launch @OptIn(ExperimentalMaterialApi::class) @Composable fun CountryPickerBottomSheet( - title: @Composable () -> Unit, - show: Boolean, + sheetState: ModalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden), + bottomSheetTitle: @Composable () -> Unit, onItemSelected: (country: Country) -> Unit, - onDismissRequest: () -> Unit, content: @Composable () -> Unit ) { - val context = LocalContext.current - val countries = remember { countryList(context) } - var selectedCountry by remember { mutableStateOf(countries[0]) } - var searchValue by remember { mutableStateOf("") } - - val modalBottomSheetState = rememberModalBottomSheetState( - initialValue = ModalBottomSheetValue.Hidden - ) - - LaunchedEffect(key1 = show) { - if (show) modalBottomSheetState.show() - else modalBottomSheetState.hide() - } + var searchValue by rememberSaveable { mutableStateOf("") } + val scope = rememberCoroutineScope() - LaunchedEffect(key1 = modalBottomSheetState.currentValue) { - if (modalBottomSheetState.currentValue == ModalBottomSheetValue.Hidden) { - onDismissRequest() - } - } ModalBottomSheetLayout( - sheetState = modalBottomSheetState, + sheetState = sheetState, sheetShape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), sheetContent = { - title() + bottomSheetTitle() - Column { - searchValue = countrySearchView(modalBottomSheetState) - - LazyColumn( - contentPadding = PaddingValues(16.dp) - ) { - items( - if (searchValue.isEmpty()) { - countries - } else { - countries.searchCountryList(searchValue) - } - ) { country -> - Row(modifier = Modifier - .clickable { - selectedCountry = country - onItemSelected(selectedCountry) - } - .padding(12.dp)) { - Text(text = localeToEmoji(country.code)) - Text( - text = country.name, - modifier = Modifier - .padding(start = 8.dp) - .weight(2f) - ) - Text( - text = country.dial_code, - modifier = Modifier - .padding(start = 8.dp) - ) - } - Divider( - color = Color.LightGray, thickness = 0.5.dp - ) - } - } + CountrySearchView(searchValue) { + searchValue = it } + Countries(searchValue) { + scope.launch { sheetState.hide() } + onItemSelected(it) + } } ) { content() } -} \ No newline at end of file +} + +@Composable +fun Countries( + searchValue: String, + onItemSelected: (country: Country) -> Unit +) { + val context = LocalContext.current + val defaultCountries = remember { countryList(context) } + + val countries = remember(searchValue) { + if (searchValue.isEmpty()) { + defaultCountries + } else { + defaultCountries.searchCountryList(searchValue) + } + } + + LazyColumn( + contentPadding = PaddingValues(16.dp) + ) { + items(countries) { country -> + Row(modifier = Modifier + .clickable { onItemSelected(country) } + .padding(12.dp)) + { + Text(text = localeToEmoji(country.code)) + Text( + text = country.name, + modifier = Modifier + .padding(start = 8.dp) + .weight(2f) + ) + Text( + text = country.dial_code, + modifier = Modifier + .padding(start = 8.dp) + ) + } + Divider( + color = Color.LightGray, thickness = 0.5.dp + ) + } + } + +} diff --git a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt index 4fe5076..44b593f 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt @@ -1,8 +1,10 @@ package com.canopas.campose.countrypicker import androidx.compose.foundation.gestures.forEachGesture +import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme +import androidx.compose.material.ModalBottomSheetState import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text import androidx.compose.material.TextFieldColors @@ -10,37 +12,48 @@ import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowDropDown import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.rotate import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.input.pointer.PointerEvent import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.changedToUp import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.onClick import androidx.compose.ui.semantics.semantics import com.canopas.campose.countrypicker.model.Country import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +@OptIn(ExperimentalMaterialApi::class) @Composable fun CountryTextField( + sheetState: ModalBottomSheetState, label: String = "", isError: Boolean = false, modifier: Modifier, shape: Shape = MaterialTheme.shapes.small, - expanded: Boolean = false, selectedCountry: Country? = null, - defaultSelectedCountry: Country = countryList(LocalContext.current).first(), + defaultCountry: Country? = null, colors: TextFieldColors = TextFieldDefaults.outlinedTextFieldColors(), - onExpandedChange: () -> Unit, ) { + + val context = LocalContext.current + val defaultSelectedCountry = remember { + defaultCountry ?: countryList(context).first() + } + + val scope = rememberCoroutineScope() val countryValue = "${defaultSelectedCountry.dial_code} ${defaultSelectedCountry.name}" OutlinedTextField( modifier = modifier - .expandable(menuLabel = label, onExpandedChange = onExpandedChange), + .expandable(onExpandedChange = { + scope.launch { sheetState.show() } + }), readOnly = true, isError = isError, label = { Text(label) }, @@ -52,21 +65,16 @@ fun CountryTextField( Icon( Icons.Filled.ArrowDropDown, null, - Modifier.rotate( - if (expanded) - 180f - else - 0f - ) + Modifier.graphicsLayer { + rotationZ = if (sheetState.isVisible) 180f else 0f + } ) } ) } -@Composable fun Modifier.expandable( - onExpandedChange: () -> Unit, - menuLabel: String + onExpandedChange: () -> Unit ) = pointerInput(Unit) { forEachGesture { coroutineScope { @@ -82,7 +90,6 @@ fun Modifier.expandable( } } }.semantics { - contentDescription = menuLabel // this should be a localised string onClick { onExpandedChange() true diff --git a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt index aaae3cf..ca2d167 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt @@ -1,17 +1,25 @@ package com.canopas.campose.countrypicker import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.* +import androidx.compose.material.Icon +import androidx.compose.material.IconButton +import androidx.compose.material.LocalTextStyle +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.TextField +import androidx.compose.material.TextFieldDefaults import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.rounded.Cancel -import androidx.compose.runtime.* -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.ui.Alignment +import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalFocusManager @@ -22,52 +30,42 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -@OptIn(ExperimentalMaterialApi::class) @Composable -fun countrySearchView(state: ModalBottomSheetState): String { +fun CountrySearchView(searchValue: String, onSearch: (searchValue: String) -> Unit) { - var searchValue: String by rememberSaveable { mutableStateOf("") } - var showClearIcon by rememberSaveable { mutableStateOf(false) } val focusManager = LocalFocusManager.current - showClearIcon = searchValue.isNotEmpty() - - if (!state.isVisible) { - searchValue = "" - } - Row { Box( - modifier = Modifier - .padding(start = 20.dp, end = 20.dp) + modifier = Modifier.padding(start = 20.dp, end = 20.dp) ) { - TextField( - modifier = Modifier - .fillMaxWidth() - .height(52.dp) - .background( - Color.LightGray.copy(0.6f), - shape = RoundedCornerShape(10.dp) - ), - value = searchValue, - onValueChange = { - searchValue = it - }, - textStyle = LocalTextStyle.current.copy( - fontSize = 14.sp - ), - singleLine = true, + TextField(modifier = Modifier + .fillMaxWidth() + .height(52.dp) + .background( + Color.LightGray.copy(0.6f), shape = RoundedCornerShape(10.dp) + ), value = searchValue, onValueChange = { + onSearch(it) + }, textStyle = LocalTextStyle.current.copy( + fontSize = 14.sp + ), placeholder = { + Text( + text = stringResource(R.string.search_text), + style = MaterialTheme.typography.body1, + color = Color.Gray, + fontSize = 16.sp, + ) + }, singleLine = true, leadingIcon = { Icon( Icons.Default.Search, contentDescription = null, tint = Color.Black.copy(0.3f) ) - }, - trailingIcon = { - if (showClearIcon) { + }, trailingIcon = { + if (searchValue.isNotEmpty()) { IconButton(onClick = { - searchValue = "" + onSearch("") }) { Icon( imageVector = Icons.Rounded.Cancel, @@ -76,41 +74,24 @@ fun countrySearchView(state: ModalBottomSheetState): String { ) } } - }, - colors = TextFieldDefaults.textFieldColors( + }, colors = TextFieldDefaults.textFieldColors( backgroundColor = Color.Transparent, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent - ), - keyboardOptions = KeyboardOptions( + ), keyboardOptions = KeyboardOptions( keyboardType = KeyboardType.Text, - imeAction = ImeAction.Search - ), - keyboardActions = KeyboardActions(onSearch = { focusManager.clearFocus() }) + imeAction = ImeAction.Done + ), keyboardActions = KeyboardActions(onDone = { + focusManager.clearFocus() + }) ) - if (searchValue.isEmpty()) { - Text( - text = stringResource(R.string.search_text), - style = MaterialTheme.typography.body1, - color = Color.Gray, - fontSize = 16.sp, - modifier = Modifier - .align(Alignment.CenterStart) - .padding(start = 52.dp) - ) - } } } - return searchValue } - -@OptIn(ExperimentalMaterialApi::class) @Preview @Composable fun PreviewSearchView() { - countrySearchView( - rememberModalBottomSheetState(ModalBottomSheetValue.Expanded) - ) + CountrySearchView("search", {}) } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 77a3a48..69a8fde 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Jan 25 12:25:52 IST 2022 +#Thu Jun 01 18:49:37 IST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists