# multiplatform

Ivo Heberle

03/08/2024, 8:08 AM
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 ( 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)
fun DropdownMenuCustom(
    modifier: Modifier = Modifier,
    onItemClick: (String)->Unit
    var expanded by remember { mutableStateOf(false) }

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

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

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

            modifier = Modifier
                .focusable(enabled = true)
                .clickable {expanded = !expanded}
                    enabled = true,
                    isError = false,
                    interactionSource = remember { MutableInteractionSource() },
                    colors = TextFieldDefaults.textFieldColors(
                        disabledIndicatorColor = bottomLineColor,
                        unfocusedIndicatorColor = bottomLineColor,
                    unfocusedIndicatorLineThickness = bottomLineThickness
                    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)},

            modifier = Modifier.pointerHoverIcon(
                icon = PointerIcon.Hand,
                overrideDescendants = true),
            expanded = expanded,
            onDismissRequest = {expanded = false},
                entry ->
                    onClick = {
                        expanded = false
                    Row (
                        modifier = Modifier.fillMaxWidth(),
                        horizontalArrangement = Arrangement.SpaceBetween
                        Text(text = entry.key)
                        if(entry.value.drawableResource !=null){
                                modifier = Modifier
                                        width = 1.dp,
                                        color = Color(0.1f,0.1f,0.1f,0.15f))
                                painter = painterResource(entry.value.drawableResource!!),
                                contentDescription = "",
                                contentScale = ContentScale.Crop)

🧵 3


03/08/2024, 9:52 AM
Please don’t post long code snippets in the stream.

Ivo Heberle

03/08/2024, 11:14 AM
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
first i didn't want to do that because i thought the dev version might be unstable and cause more problems


03/08/2024, 12:02 PM
You can post snippets here in the thread.