Created
August 26, 2024 06:20
-
-
Save kaiyrzhanDE/8626112bb6c83f72f0d699c98fa3bf04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ExposedDropdownMenuBox( | |
| expanded = isExpanded.value, | |
| onExpandedChange = { isExpanded.value = it }, | |
| ) { | |
| FilterContainer( | |
| title = R.string.input_customer_name, | |
| ) { | |
| OutlinedTextField( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .menuAnchor() | |
| .padding(horizontal = 20.dp), | |
| placeholder = { | |
| Text( | |
| text = stringResource(id = R.string.search), | |
| color = GreyChateau, | |
| fontSize = 17.sp | |
| ) | |
| }, | |
| singleLine = true, | |
| leadingIcon = { | |
| Icon( | |
| painter = painterResource(id = R.drawable.ic_search), | |
| contentDescription = null, | |
| tint = Color.Unspecified, | |
| ) | |
| }, | |
| trailingIcon = { | |
| if (isLoadingCustomers) { | |
| Box(modifier = Modifier.size(24.dp)) { | |
| CircularProgressIndicator() | |
| } | |
| } | |
| }, | |
| colors = OutlinedTextFieldDefaults.colors( | |
| cursorColor = Geraldine, | |
| unfocusedBorderColor = GreyChateau, | |
| focusedBorderColor = GreyChateau | |
| ), | |
| value = state.customerName, | |
| onValueChange = { | |
| isExpanded.value = true | |
| onEvent(FilterEvent.ChangeCustomerName(it)) | |
| }, | |
| shape = RoundedCornerShape(10.dp), | |
| textStyle = TextStyle.Default.copy(fontSize = 17.sp, color = Zeus), | |
| ) | |
| } | |
| DropdownMenu( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .imePadding() | |
| .heightIn(min = 200.dp, max = 300.dp) | |
| .padding(horizontal = 20.dp), | |
| border = BorderStroke(1.dp, color = SoftPeach), | |
| scrollState = scrollState, | |
| shape = RoundedCornerShape(10.dp), | |
| containerColor = Color.White, | |
| expanded = isExpanded.value && customers.isNotEmpty(), | |
| onDismissRequest = { isExpanded.value = false }, | |
| shadowElevation = 5.dp, | |
| properties = PopupProperties(focusable = false) | |
| ) { | |
| customers.forEach { customer -> | |
| DropdownMenuItem( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .clickable { onEvent(FilterEvent.SelectCustomer(customer)) } | |
| .clip(RoundedCornerShape(5.dp)), | |
| onClick = { onEvent(FilterEvent.SelectCustomer(customer)) }, | |
| text = { | |
| Column( | |
| modifier = Modifier | |
| .fillMaxWidth() | |
| .padding(vertical = 10.dp) | |
| ) { | |
| Text( | |
| text = customer.name, | |
| fontSize = 15.sp, | |
| fontWeight = FontWeight.Normal, | |
| color = Zeus, | |
| ) | |
| Text( | |
| text = buildAnnotatedString { | |
| append(stringResource(id = R.string.bin_placeholder)) | |
| append(SPACE_STRING) | |
| append(customer.code) | |
| }, | |
| fontSize = 13.sp, | |
| fontWeight = FontWeight.Normal, | |
| color = MediumGray, | |
| ) | |
| } | |
| HorizontalDivider(color = SoftPeach) | |
| }, | |
| trailingIcon = { | |
| Icon( | |
| modifier = Modifier.size(24.dp), | |
| painter = painterResource(id = R.drawable.ic_check), | |
| contentDescription = null, | |
| tint = Color.Unspecified, | |
| ) | |
| } | |
| ) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment