```@Composable fun list( item: GymContents, ...
# android
f
Copy code
@Composable
fun list(
    item: GymContents,
    onEditClick: @Composable () -> Unit,
    onDeleteClick: () -> Unit,
    viewModel: GymViewModel
) {
    val isEditing by viewModel.isEditing.collectAsState()
    Row(
        modifier = Modifier
            .padding(8.dp)
            .fillMaxWidth()
            .border(
                border = BorderStroke(2.dp, Color.Black),
                shape = RoundedCornerShape(20)
            )
    ) {
        Text(text = item.name, modifier = Modifier.padding(8.dp))
        Text(
            text = "Sets: ${item.sets}",
            modifier = Modifier.padding(8.dp)
        )
        Text(text = "Reps: ${item.reps}")
        Text(text = "Lift: ${item.lift}")
        Row(modifier = Modifier.padding(8.dp)) {
            IconButton(onClick = onEditClick) {
                Icon(imageVector = Icons.Default.Edit, contentDescription = null)
            }

            IconButton(onClick = onDeleteClick) {
                Icon(imageVector = Icons.Default.Delete, contentDescription = null)
            }

        }
    }}
Type inference failed. Expected type mismatch: inferred type is @Composable () -> Unit but () -> Unit was expected
c
You defined
onEditClick
as a Composable function. But
onClick
expects a “normal” function.
f
mh
so what do u think i should go for?
Also you might get better infos of you ask questions about compose in #compose-android
f
okk
j
On edit click cannot be compostable. You need to manage showing/hiding the dialog via a state. To do that onEditClick should just change that state from false to true. Something like var isDialogVisible by rememberSaveable { mutableStateOf(false) } then onEditClick = { isDialogVisible = true } In your compose code, do if (isDialogVisible) { EditDialog() // that's the composable function }
f
done it, but in this way i think that the edit function is not called
c