Hi, i am kinda new to all of this and have a probl...
# multiplatform
i
Hi, i am kinda new to all of this and have a problem with one of my Kotlin multiplatform Projects. In order to share resources between Android and Desktop i updated my compose-plugin from 1.5.12 to 1.6.0 and used this new generated class (https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#resource-usage) Weirdly that broke one of my custom Composables, it worked fine on both android and Desktop before updating and it still works fine on android, but it does not work on desktop. there are no Compile errors or anything, it just does not pop up when i click on it (its a drop-down-menu) I don't know if i am doing something wrong or its a problem with some versions that don't work together properly. But its very confusing for me since it still works on android. Edit: I assume the TextField
Modifier.clickable{expanded = !expanded}
lambda never gets called in the desktop version, i tried setting a breakpoint there in the debugger and didn't get any breaks when clicking on it, why that is and why it worked before and still works on android i don't know. Edit2: if i copy paste the
Modifier.clickable{expanded = !expanded}
to the trailingIcon (Image) inside the TextField i can click on that and that expands the drop-down-menu, but only if i click the icon itself, i also tried to give the surrounding box the
Modifier.clickable{expanded = !expanded}
but that did not work either
Copy code
@OptIn(ExperimentalMaterialApi::class, ExperimentalResourceApi::class)
@Composable
fun DropdownMenuCustom(
    modifier: Modifier = Modifier,
    value:String,
    label:String,
    onItemClick: (String)->Unit
){
    var expanded by remember { mutableStateOf(false) }

    var icon:ImageVector
    var labelColor: Color
    var bottomLineColor:Color
    var bottomLineThickness: Dp

    if(expanded){
        icon = Icons.Filled.KeyboardArrowUp
        labelColor = MaterialTheme.colors.primary.copy(ContentAlpha.high)
        bottomLineColor  = MaterialTheme.colors.primary
        bottomLineThickness = 2.dp
    }else{
        icon = Icons.Filled.KeyboardArrowDown
        labelColor = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium)
        bottomLineColor = MaterialTheme.colors.onSurface.copy(ContentAlpha.medium)
        bottomLineThickness = 1.dp
    }


    Box(modifier = modifier){
        TextField(
            enabled = false,
            colors = TextFieldDefaults.textFieldColors(
                disabledTextColor = MaterialTheme.colors.onSurface,
                disabledLabelColor = labelColor

            ),
            modifier = Modifier
                .focusable(enabled = true)
                .clickable {expanded = !expanded}
                .indicatorLine(
                    enabled = true,
                    isError = false,
                    interactionSource = remember { MutableInteractionSource() },
                    colors = TextFieldDefaults.textFieldColors(
                        disabledIndicatorColor = bottomLineColor,
                        unfocusedIndicatorColor = bottomLineColor,
                    ),
                    unfocusedIndicatorLineThickness = bottomLineThickness
                )
                .pointerHoverIcon(
                    icon = PointerIcon.Hand,
                    overrideDescendants = true
                ),
            readOnly = true,
            value =  value,
            singleLine = true,
            onValueChange = {},
            trailingIcon = { Image(
                imageVector = icon,
                contentDescription = null,
                modifier = Modifier.fillMaxHeight()
            )},
            label = { Text(text = label)},
        )

        DropdownMenu(
            modifier = Modifier.pointerHoverIcon(
                icon = PointerIcon.Hand,
                overrideDescendants = true),
            expanded = expanded,
            onDismissRequest = {expanded = false},
        ){
            Currency.values.forEach{
                entry ->
                DropdownMenuItem(
                    onClick = {
                        onItemClick(entry.key)
                        expanded = false
                    }
                ){
                    Row (
                        modifier = Modifier.fillMaxWidth(),
                        horizontalArrangement = Arrangement.SpaceBetween
                    ){
                        Text(text = entry.key)
                        if(entry.value.drawableResource !=null){
                            Image(
                                modifier = Modifier
                                    .width(30.dp)
                                    .aspectRatio(4f/3f)
                                    .border(
                                        width = 1.dp,
                                        color = Color(0.1f,0.1f,0.1f,0.15f))
                                ,
                                painter = painterResource(entry.value.drawableResource!!),
                                contentDescription = "",
                                contentScale = ContentScale.Crop)
                        }
                    }
                }
            }
        }

    }
}
🧵 3
c
Please don’t post long code snippets in the stream.
i
ok, i will try to remember that for next time, i was just not sure how i could ask the question without sharing the relevant code btw, I got it running again by updating the plugin version even further to
1.6.10-dev1496
first i didn't want to do that because i thought the dev version might be unstable and cause more problems
c
You can post snippets here in the thread.