From 89b55d3c97d22e25785cc5bc467f49e8ab87bf61 Mon Sep 17 00:00:00 2001 From: Radhika canopas <74301808+cp-radhika-s@users.noreply.github.com> Date: Wed, 16 Aug 2023 12:29:59 +0530 Subject: [PATCH] Upgrade to AGP 8.1.0 (#16) * Upgrade agp 8 * Migrate to material3 --- .github/workflows/app-build.yml | 4 +- .github/workflows/publish.yml | 5 +- README.md | 61 +++++++++-------- app/build.gradle | 13 ++-- app/src/main/AndroidManifest.xml | 5 +- .../campose/jetcountypicker/MainActivity.kt | 53 ++++++++------- .../campose/jetcountypicker/ui/theme/Shape.kt | 11 --- .../campose/jetcountypicker/ui/theme/Theme.kt | 51 ++++++++++---- .../campose/jetcountypicker/ui/theme/Type.kt | 24 ++++--- build.gradle | 15 ++-- countrypicker/build.gradle | 24 ++++--- countrypicker/src/main/AndroidManifest.xml | 2 +- .../countrypicker/CountryPickerBottomSheet.kt | 68 ++++++++++++------- .../countrypicker/CountryPickerTextField.kt | 54 +++++++-------- .../countrypicker/CountrySearchView.kt | 23 ++++--- gradle/wrapper/gradle-wrapper.properties | 6 +- scripts/publish-module.gradle | 15 ++-- 17 files changed, 240 insertions(+), 194 deletions(-) delete mode 100644 app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Shape.kt diff --git a/.github/workflows/app-build.yml b/.github/workflows/app-build.yml index c2c4fe5..e38a221 100644 --- a/.github/workflows/app-build.yml +++ b/.github/workflows/app-build.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v2 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Build with Gradle run: ./gradlew build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 30de2bf..1ff19ad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,5 @@ name: Publish + on: push: tags: @@ -11,11 +12,11 @@ jobs: steps: - name: Check out code uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: adopt - java-version: 11 + java-version: 17 - name: Publish to MavenCentral run: ./gradlew countrypicker:publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository diff --git a/README.md b/README.md index 7d8a3be..e18b3ad 100644 --- a/README.md +++ b/README.md @@ -10,46 +10,51 @@ Available on [Maven Central](https://repo1.maven.org/maven2/com/canopas/jetcount Add the dependency ```gradle - implementation 'com.canopas.jetcountrypicker:jetcountrypicker:1.0.5' + implementation 'com.canopas.jetcountrypicker:jetcountrypicker:1.0.9' ``` ## How to use ? ```kotlin - Box { + var openBottomSheet by rememberSaveable { mutableStateOf(false) } var selectedCountry by remember { mutableStateOf(null) } - val modalBottomSheetState = rememberModalBottomSheetState( - initialValue = ModalBottomSheetValue.Hidden - ) - - CountryPickerBottomSheet( - sheetState = modalBottomSheetState, - bottomSheetTitle = { - Text( - modifier = Modifier - .fillMaxWidth() - .padding(16.dp), - text = stringResource(R.string.select_country_text), - textAlign = TextAlign.Center, - fontWeight = FontWeight.Bold, - fontSize = 20.sp - ) - }, - onItemSelected = { - selectedCountry = it - } - ) { + + Box { CountryTextField( - sheetState = modalBottomSheetState, label = stringResource(R.string.select_country_text), modifier = Modifier - .padding(top = 50.dp) - .align(Alignment.TopCenter), + .fillMaxWidth() + .padding(top = 50.dp, start = 40.dp, end = 40.dp), selectedCountry = selectedCountry, - defaultCountry = countryList(LocalContext.current).firstOrNull { it.code == "IN" } + defaultCountry = countryList(LocalContext.current).firstOrNull { it.code == "IN" }, + onShowCountryPicker = { + openBottomSheet = true + }, isPickerVisible = openBottomSheet + ) + } + + if (openBottomSheet) { + CountryPickerBottomSheet( + bottomSheetTitle = { + Text( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + text = stringResource(R.string.select_country_text), + textAlign = TextAlign.Center, + fontWeight = FontWeight.Bold, + fontSize = 20.sp + ) + }, + containerColor = Color.White, + onItemSelected = { + selectedCountry = it + openBottomSheet = false + }, onDismissRequest = { + openBottomSheet = false + } ) } - } ``` # Demo diff --git a/app/build.gradle b/app/build.gradle index 10b82e1..c1d7c6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,9 +5,10 @@ plugins { android { compileSdk 33 + namespace 'com.canopas.campose.countypickerdemo' defaultConfig { - applicationId "com.canopas.campose.jetcountypicker" + applicationId "com.canopas.campose.countypickerdemo" minSdk 21 targetSdk 33 versionCode 1 @@ -54,15 +55,15 @@ dependencies { 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 platform("androidx.compose:compose-bom:$compose_bom_version") + implementation "androidx.compose.ui:ui" + implementation "androidx.compose.material3:material3" + implementation "androidx.compose.ui:ui-tooling-preview" 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/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 324ccaa..5dca29d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + (null) } + Box { - var selectedCountry by remember { mutableStateOf(null) } - val modalBottomSheetState = rememberModalBottomSheetState( - initialValue = ModalBottomSheetValue.Hidden + CountryTextField( + label = stringResource(R.string.select_country_text), + modifier = Modifier + .fillMaxWidth() + .padding(top = 50.dp, start = 40.dp, end = 40.dp), + selectedCountry = selectedCountry, + defaultCountry = countryList(LocalContext.current).firstOrNull { it.code == "IN" }, + onShowCountryPicker = { + openBottomSheet = true + }, isPickerVisible = openBottomSheet ) + } + if (openBottomSheet) { CountryPickerBottomSheet( - sheetState = modalBottomSheetState, bottomSheetTitle = { Text( modifier = Modifier @@ -67,20 +78,14 @@ fun SampleCountryPicker() { fontSize = 20.sp ) }, + containerColor = Color.White, onItemSelected = { selectedCountry = it + openBottomSheet = false + }, onDismissRequest = { + openBottomSheet = false } - ) { - 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" } - ) - } + ) } } diff --git a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Shape.kt b/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Shape.kt deleted file mode 100644 index 94e3794..0000000 --- a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Shape.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.canopas.campose.jetcountypicker.ui.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes -import androidx.compose.ui.unit.dp - -val Shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) -) \ No newline at end of file diff --git a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Theme.kt b/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Theme.kt index 2fc8fa7..eb5f01c 100644 --- a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Theme.kt +++ b/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Theme.kt @@ -1,21 +1,30 @@ package com.canopas.campose.jetcountypicker.ui.theme +import android.app.Activity +import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme import androidx.compose.runtime.Composable +import androidx.compose.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat -private val DarkColorPalette = darkColors( +private val DarkColorScheme = darkColorScheme().copy( primary = Purple200, - primaryVariant = Purple700, - secondary = Teal200 + secondary = Purple700, + tertiary = Teal200 ) -private val LightColorPalette = lightColors( +private val LightColorScheme = lightColorScheme().copy( primary = Purple500, - primaryVariant = Purple700, - secondary = Teal200 + secondary = Purple700, + tertiary = Teal200 /* Other default colors to override background = Color.White, @@ -30,18 +39,30 @@ private val LightColorPalette = lightColors( @Composable fun JetCountyPickerTheme( darkTheme: Boolean = isSystemInDarkTheme(), + dynamicColor: Boolean = true, content: @Composable() () -> Unit ) { - val colors = if (darkTheme) { - DarkColorPalette - } else { - LightColorPalette + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } } MaterialTheme( - colors = colors, + colorScheme = colorScheme, typography = Typography, - shapes = Shapes, content = content ) } \ No newline at end of file diff --git a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Type.kt b/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Type.kt index fa1b39e..d5a1b48 100644 --- a/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Type.kt +++ b/app/src/main/java/com/canopas/campose/jetcountypicker/ui/theme/Type.kt @@ -1,6 +1,6 @@ package com.canopas.campose.jetcountypicker.ui.theme -import androidx.compose.material.Typography +import androidx.compose.material3.Typography import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight @@ -8,21 +8,27 @@ import androidx.compose.ui.unit.sp // Set of Material typography styles to start with val Typography = Typography( - body1 = TextStyle( + bodyLarge = TextStyle( fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, - fontSize = 16.sp + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp ) /* Other default text styles to override - button = TextStyle( + titleLarge = TextStyle( fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp ), - caption = TextStyle( + labelSmall = TextStyle( fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp ) */ ) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2514740..89abfe8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,18 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { - compose_version = '1.4.3' - kotlin_version = '1.8.10' - compose_compiler_version = "1.4.3" + compose_compiler_version = "1.5.0" + compose_bom_version = "2023.06.01" } } plugins { - 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" + id 'com.android.application' version '8.1.0' apply false + id 'com.android.library' version '8.1.0' apply false + id 'org.jetbrains.kotlin.android' version '1.9.0' apply false + id 'io.github.gradle-nexus.publish-plugin' version "1.3.0" } apply from: "${rootDir}/scripts/publish-root.gradle" -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/countrypicker/build.gradle b/countrypicker/build.gradle index 4076e75..d2fcc64 100644 --- a/countrypicker/build.gradle +++ b/countrypicker/build.gradle @@ -5,19 +5,18 @@ plugins { ext { PUBLISH_GROUP_ID = 'com.canopas.jetcountrypicker' - PUBLISH_VERSION = '1.0.8' + PUBLISH_VERSION = '1.0.9' PUBLISH_ARTIFACT_ID = 'jetcountrypicker' } apply from: "${rootDir}/scripts/publish-module.gradle" android { compileSdk 33 + namespace 'com.canopas.campose.countrypicker' defaultConfig { minSdk 21 targetSdk 33 - versionCode 1 - versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -25,7 +24,7 @@ android { buildTypes { release { - minifyEnabled true + minifyEnabled false consumerProguardFiles 'proguard-rules.pro' } } @@ -42,7 +41,11 @@ android { composeOptions { kotlinCompilerExtensionVersion compose_compiler_version } - + publishing { + singleVariant("release") { + withSourcesJar() + } + } } dependencies { @@ -53,9 +56,12 @@ dependencies { 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 platform("androidx.compose:compose-bom:$compose_bom_version") + implementation "androidx.compose.ui:ui" + implementation "androidx.compose.material3:material3" + implementation "androidx.compose.ui:ui-tooling-preview" + implementation "androidx.compose.material:material-icons-extended" + implementation "com.squareup.moshi:moshi-kotlin:1.15.0" } diff --git a/countrypicker/src/main/AndroidManifest.xml b/countrypicker/src/main/AndroidManifest.xml index e1fa088..44008a4 100644 --- a/countrypicker/src/main/AndroidManifest.xml +++ b/countrypicker/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file 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 48e5653..fa7300a 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerBottomSheet.kt @@ -6,45 +6,67 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.runtime.* +import androidx.compose.material3.BottomSheetDefaults +import androidx.compose.material3.Divider +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.SheetState +import androidx.compose.material3.Text +import androidx.compose.material3.contentColorFor +import androidx.compose.material3.rememberModalBottomSheetState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.canopas.campose.countrypicker.model.Country import kotlinx.coroutines.launch -@OptIn(ExperimentalMaterialApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun CountryPickerBottomSheet( - sheetState: ModalBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden), + sheetState: SheetState = rememberModalBottomSheetState(skipPartiallyExpanded = false), + shape: Shape = BottomSheetDefaults.ExpandedShape, + containerColor: Color = BottomSheetDefaults.ContainerColor, + contentColor: Color = contentColorFor(containerColor), + tonalElevation: Dp = BottomSheetDefaults.Elevation, + scrimColor: Color = BottomSheetDefaults.ScrimColor, bottomSheetTitle: @Composable () -> Unit, onItemSelected: (country: Country) -> Unit, - content: @Composable () -> Unit + onDismissRequest: () -> Unit ) { var searchValue by rememberSaveable { mutableStateOf("") } val scope = rememberCoroutineScope() - ModalBottomSheetLayout( + ModalBottomSheet( + onDismissRequest = onDismissRequest, sheetState = sheetState, - sheetShape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp), - sheetContent = { - bottomSheetTitle() + shape = shape, + containerColor = containerColor, + contentColor = contentColor, + tonalElevation = tonalElevation, + scrimColor = scrimColor + ) { + bottomSheetTitle() - CountrySearchView(searchValue) { - searchValue = it - } + CountrySearchView(searchValue) { + searchValue = it + } - Countries(searchValue) { - scope.launch { sheetState.hide() } + Countries(searchValue) { + scope.launch { + sheetState.hide() onItemSelected(it) } } - ) { - content() } } @@ -64,14 +86,12 @@ fun Countries( } } - LazyColumn( - contentPadding = PaddingValues(16.dp) - ) { + LazyColumn(contentPadding = PaddingValues(16.dp)) { items(countries) { country -> Row(modifier = Modifier .clickable { onItemSelected(country) } - .padding(12.dp)) - { + .padding(12.dp) + ) { Text(text = localeToEmoji(country.code)) Text( text = country.name, @@ -85,9 +105,7 @@ fun Countries( .padding(start = 8.dp) ) } - Divider( - color = Color.LightGray, thickness = 0.5.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 44b593f..d7a83e0 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountryPickerTextField.kt @@ -1,19 +1,17 @@ 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 -import androidx.compose.material.TextFieldDefaults +import androidx.compose.foundation.gestures.awaitEachGesture import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowDropDown +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults +import androidx.compose.material3.Text +import androidx.compose.material3.TextFieldColors import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.graphicsLayer @@ -25,20 +23,20 @@ import androidx.compose.ui.platform.LocalContext 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) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun CountryTextField( - sheetState: ModalBottomSheetState, label: String = "", isError: Boolean = false, modifier: Modifier, shape: Shape = MaterialTheme.shapes.small, selectedCountry: Country? = null, defaultCountry: Country? = null, - colors: TextFieldColors = TextFieldDefaults.outlinedTextFieldColors(), + colors: TextFieldColors = OutlinedTextFieldDefaults.colors( + ), + isPickerVisible: Boolean = false, + onShowCountryPicker: () -> Unit ) { val context = LocalContext.current @@ -46,13 +44,13 @@ fun CountryTextField( defaultCountry ?: countryList(context).first() } - val scope = rememberCoroutineScope() + val countryValue = "${defaultSelectedCountry.dial_code} ${defaultSelectedCountry.name}" OutlinedTextField( modifier = modifier .expandable(onExpandedChange = { - scope.launch { sheetState.show() } + onShowCountryPicker() }), readOnly = true, isError = isError, @@ -66,7 +64,7 @@ fun CountryTextField( Icons.Filled.ArrowDropDown, null, Modifier.graphicsLayer { - rotationZ = if (sheetState.isVisible) 180f else 0f + rotationZ = if (isPickerVisible) 180f else 0f } ) } @@ -76,18 +74,14 @@ fun CountryTextField( fun Modifier.expandable( onExpandedChange: () -> Unit ) = pointerInput(Unit) { - forEachGesture { - coroutineScope { - awaitPointerEventScope { - var event: PointerEvent - do { - event = awaitPointerEvent(PointerEventPass.Initial) - } while ( - !event.changes.all { it.changedToUp() } - ) - onExpandedChange.invoke() - } - } + awaitEachGesture { + var event: PointerEvent + do { + event = awaitPointerEvent(PointerEventPass.Initial) + } while ( + !event.changes.all { it.changedToUp() } + ) + onExpandedChange.invoke() } }.semantics { onClick { 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 ca2d167..7e8ba57 100644 --- a/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt +++ b/countrypicker/src/main/java/com/canopas/campose/countrypicker/CountrySearchView.kt @@ -9,16 +9,17 @@ 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.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.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalTextStyle +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -30,6 +31,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +@OptIn(ExperimentalMaterial3Api::class) @Composable fun CountrySearchView(searchValue: String, onSearch: (searchValue: String) -> Unit) { @@ -51,7 +53,7 @@ fun CountrySearchView(searchValue: String, onSearch: (searchValue: String) -> Un ), placeholder = { Text( text = stringResource(R.string.search_text), - style = MaterialTheme.typography.body1, + style = MaterialTheme.typography.labelMedium, color = Color.Gray, fontSize = 16.sp, ) @@ -74,8 +76,9 @@ fun CountrySearchView(searchValue: String, onSearch: (searchValue: String) -> Un ) } } - }, colors = TextFieldDefaults.textFieldColors( - backgroundColor = Color.Transparent, + }, colors = TextFieldDefaults.colors( + focusedContainerColor = Color.Transparent, + unfocusedContainerColor = Color.Transparent, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent, disabledIndicatorColor = Color.Transparent diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2639cdf..0638b3f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jun 01 18:49:37 IST 2023 +#Fri Aug 11 12:20:35 IST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists \ No newline at end of file +zipStorePath=wrapper/dists diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 5e7a782..9f72264 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -1,7 +1,10 @@ apply plugin: 'maven-publish' apply plugin: 'signing' -task androidSourcesJar(type: Jar) { +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + +tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { from android.sourceSets.main.java.srcDirs @@ -13,28 +16,24 @@ task androidSourcesJar(type: Jar) { artifacts { archives androidSourcesJar } -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION afterEvaluate { publishing { publications { release(MavenPublication) { - // The coordinates of the library, being set from variables that - // we'll set up later + tasks.named("generateMetadataFileForReleasePublication").configure { dependsOn("androidSourcesJar") } + groupId PUBLISH_GROUP_ID artifactId PUBLISH_ARTIFACT_ID version PUBLISH_VERSION - /// Two artifacts, the `aar` (or `jar`) and the sources if (project.plugins.findPlugin("com.android.library")) { from components.release } else { artifact("$buildDir/libs/${project.getName()}-${version}.jar") } - artifact androidSourcesJar - + // artifact androidSourcesJar // Mostly self-explanatory metadata pom { name = PUBLISH_ARTIFACT_ID