8000 [MBL-1254] Add the confirm pledge screen and views by mtgriego · Pull Request #1968 · kickstarter/android-oss · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[MBL-1254] Add the confirm pledge screen and views #1968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from 8000
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ fun AddOnsScreen(
onItemAddedOrRemoved: (Map<Reward, Int>) -> Unit,
onContinueClicked: () -> Unit
) {

var countryInput by remember {
mutableStateOf(initialCountryInput ?: "United States")
}
var countryListExpanded by remember {
mutableStateOf(false)
}
val interactionSource = remember {
MutableInteractionSource()
}
Expand Down Expand Up @@ -190,81 +183,12 @@ fun AddOnsScreen(

Spacer(modifier = Modifier.height(dimensions.paddingSmall))

Column(
modifier = Modifier
.fillMaxWidth()
.clickable(
interactionSource = interactionSource,
indication = null,
countryListExpanded = false }
),
) {
TextField(
modifier = Modifier
.height(dimensions.minButtonHeight)
.width(dimensions.countryInputWidth),
value = countryInput,
>
countryInput = it
countryListExpanded = true
},
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done
),
shape = shapes.medium,
colors = TextFieldDefaults.textFieldColors(
backgroundColor = colors.kds_white,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
textStyle = typography.subheadlineMedium.copy(color = colors.textAccentGreenBold),
)

AnimatedVisibility(visible = countryListExpanded) {
Card(shape = shapes.medium) {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.background(color = colors.kds_white)
) {
if (countryInput.isNotEmpty()) {
items(
items = countryList.filter {
it.location()?.displayableName()?.lowercase()
?.contains(countryInput.lowercase()) ?: false
}
) {
CountryListItems(
item = it,
title = it.location()?.displayableName() ?: "",
country ->
countryInput =
country.location()?.displayableName() ?: ""
countryListExpanded = false
onShippingRuleSelected(country)
}
)
}
} else {
items(countryList) {
CountryListItems(
item = it,
title = it.location()?.displayableName() ?: "",
country ->
countryInput =
country.location()?.displayableName() ?: ""
countryListExpanded = false
onShippingRuleSelected(country)
}
)
}
}
}
}
}
}
CountryInputWithDropdown(
interactionSource = interactionSource,
initialCountryInput = initialCountryInput,
countryList = countryList,
>
)
}

items(
Expand Down Expand Up @@ -318,3 +242,94 @@ fun CountryListItems(
Text(text = title)
}
}

@Composable
fun CountryInputWithDropdown(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niceeee

interactionSource: MutableInteractionSource,
initialCountryInput: String? = null,
countryList: List<ShippingRule>,
onShippingRuleSelected: (ShippingRule) -> Unit
) {
var countryListExpanded by remember {
mutableStateOf(false)
}

var countryInput by remember {
mutableStateOf(initialCountryInput ?: "United States")
}

Column(
modifier = Modifier
.clickable(
interactionSource = interactionSource,
indication = null,
countryListExpanded = false }
),
) {
TextField(
modifier = Modifier
.height(dimensions.minButtonHeight)
.width(dimensions.countryInputWidth),
value = countryInput,
>
countryInput = it
countryListExpanded = true
},
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done
),
shape = shapes.medium,
colors = TextFieldDefaults.textFieldColors(
backgroundColor = colors.kds_white,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent
),
textStyle = typography.subheadlineMedium.copy(color = colors.textAccentGreenBold),
)

AnimatedVisibility(visible = countryListExpanded) {
Card(shape = shapes.medium) {
LazyColumn(
modifier = Modifier
.fillMaxWidth()
.background(color = colors.kds_white)
) {
if (countryInput.isNotEmpty()) {
items(
items = countryList.filter {
it.location()?.displayableName()?.lowercase()
?.contains(countryInput.lowercase()) ?: false
}
) {
CountryListItems(
item = it,
title = it.location()?.displayableName() ?: "",
country ->
countryInput =
country.location()?.displayableName() ?: ""
countryListExpanded = false
onShippingRuleSelected(country)
}
)
}
} else {
items(countryList) {
CountryListItems(
item = it,
title = it.location()?.displayableName() ?: "",
country ->
countryInput =
country.location()?.displayableName() ?: ""
countryListExpanded = false
onShippingRuleSelected(country)
}
)
}
}
}
}
}
}
}
Loading
0