feat: refs#6659 defaultComponents

This commit is contained in:
Sergio De la torre 2025-03-24 12:39:01 +01:00
parent 028d0b85aa
commit 3ec49358ad
1 changed files with 23 additions and 12 deletions

View File

@ -7,8 +7,11 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -18,6 +21,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
@ -36,9 +40,10 @@ fun CustomDialogListComposable(
buttonOkText: String = "",
onOkClick: () -> Unit = {},
showRecyclerView: Boolean = true,
recyclerViewItems: List<Number> = listOf(),
onItemSelected: (Number) -> Unit = {},
recyclerViewItems: List<Any> = listOf(),
onItemSelected: (Any) -> Unit = {},
hintOne: String = "",
showTextInput: Boolean = true,
onEnterPressed: (String) -> Unit = {}
) {
var valueOne by remember { mutableStateOf(TextFieldValue()) }
@ -64,28 +69,34 @@ fun CustomDialogListComposable(
DescriptionTextCustomDialog(description)
}
ScanTextCustomDialog(
value = valueOne,
onValueChange = { valueOne = it },
hint = hintOne,
onEnterPressed = onEnterPressed,
focusRequester = focusRequester
)
if (showTextInput)
ScanTextCustomDialog(
value = valueOne,
onValueChange = { valueOne = it },
hint = hintOne,
onEnterPressed = onEnterPressed,
focusRequester = focusRequester
)
Spacer(modifier = Modifier.height(8.dp))
if (showRecyclerView && recyclerViewItems.isNotEmpty()) {
LazyColumn(modifier = Modifier.fillMaxWidth()) {
LazyColumn(
modifier = Modifier.wrapContentWidth(align = Alignment.CenterHorizontally)
) {
items(recyclerViewItems) { item ->
HorizontalDivider(thickness = 1.dp, color = Color.DarkGray)
Text(
text = item.toString(),
style = MaterialTheme.typography.bodyLarge,
color = VerdnaturaColors.White,
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
.padding(16.dp)
.clickable {
onItemSelected(item)
onItemSelected(item.toString())
}
.align(Alignment.CenterHorizontally)
)
}
}