Skip to content

Commit

Permalink
increase version n arrange ccp
Browse files Browse the repository at this point in the history
  • Loading branch information
talhafaki committed Nov 23, 2023
1 parent 7c7ecd1 commit 95cf424
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
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.material3.Button
Expand Down Expand Up @@ -46,6 +48,12 @@ class MainActivity : ComponentActivity() {
.background(Color.White)
.fillMaxWidth()
.padding(horizontal = 16.dp, vertical = 8.dp),
searchModifier = Modifier
.background(Color.White)
.padding(16.dp)
.fillMaxWidth()
.height(235.dp)
.border(width = 1.dp, color = Color(0xFFDADADA), shape = RoundedCornerShape(8.dp)),
text = phoneNumber.value,
shape = RoundedCornerShape(8.dp),
showError = showError.value,
Expand Down
2 changes: 1 addition & 1 deletion countrycp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ afterEvaluate {
register<MavenPublication>("release") {
groupId = "com.github.tfaki"
artifactId = "countrycp"
version = "1.0.3"
version = "1.0.4"

from(components["release"])
}
Expand Down
18 changes: 7 additions & 11 deletions countrycp/src/main/java/com/loftymr/countrycp/CountryCP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -21,13 +19,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
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.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -81,6 +77,7 @@ private var fullNumberState: String by mutableStateOf(EMPTY_STRING)
@Composable
fun CountryCP(
modifier: Modifier = Modifier,
searchModifier: Modifier = Modifier,
text: String = EMPTY_STRING,
onValueChange: (String) -> Unit = {},
onFullNumberValue: (String) -> Unit = {},
Expand All @@ -90,6 +87,7 @@ fun CountryCP(
errorText: String? = null,
showClearIcon: Boolean = true,
focusField: Boolean = false,
initialCountryCode: String = "+90",
errorTextPaddings: PaddingValues = PaddingValues(horizontal = 16.dp),
phonePlaceholder: @Composable ((txtPlaceHolder: String?) -> Unit) = { txtPlaceHolder ->
Text(
Expand Down Expand Up @@ -118,7 +116,7 @@ fun CountryCP(

var textFieldValue by remember { mutableStateOf(EMPTY_STRING) }
val keyboardController = LocalSoftwareKeyboardController.current
var isPickCountry by remember { mutableStateOf(Country.countryList.first()) }
var isPickCountry by remember { mutableStateOf(Country.countryList.first { it.countryPhoneCode == initialCountryCode }) }
var phoneCode by remember { mutableStateOf(isPickCountry.countryPhoneCode) }
var expanded by remember { mutableStateOf(false) }
val rotationState by animateFloatAsState(targetValue = if (expanded) 180f else 0f, label = EMPTY_STRING)
Expand Down Expand Up @@ -265,11 +263,13 @@ fun CountryCP(
exit = fadeOut() + shrinkVertically()
) {
SearchCountry(
modifier = searchModifier,
searchFieldColors = searchFieldColors,
searchPlaceholder = searchPlaceholder,
onSelected = {
isPickCountry = it
phoneCode = it.countryPhoneCode
expanded = !expanded
}
)
}
Expand All @@ -281,6 +281,7 @@ fun CountryCP(
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun SearchCountry(
modifier: Modifier = Modifier,
searchFieldColors: TextFieldColors = TextFieldDefaults.colors(),
searchPlaceholder: @Composable ((txtPlaceHolder: String?) -> Unit) = { txtPlaceHolder ->
Text(
Expand All @@ -296,12 +297,7 @@ fun SearchCountry(
var searchValue by remember { mutableStateOf("") }

LazyColumn(
modifier = Modifier
.background(Color.White)
.padding(horizontal = 16.dp)
.fillMaxWidth()
.height(235.dp)
.border(width = 1.dp, color = Color(0xFFDADADA), shape = RoundedCornerShape(8.dp))
modifier = modifier
) {
stickyHeader {
SearchField(
Expand Down

0 comments on commit 95cf424

Please sign in to comment.