composablehorizons / compose-unstyled

Unstyled, fully accessible Compose Multiplatform UI components that you can customize to your heart's content.
https://composeunstyled.com
MIT License
344 stars 11 forks source link

Exception on iOS + Wasm/browser for ModalBottomSheet #13

Closed dozy-programmer closed 1 month ago

dozy-programmer commented 1 month ago

Hello,

Thank you for creating this library, it is exactly what I need. I am facing an issue on iOS. I implemented the following from the example code:

@Composable
fun ModalBottomSheetDemo() {
    BoxWithConstraints(
        modifier = Modifier
            .fillMaxSize()
            .background(Brush.linearGradient(listOf(Color(0xFF800080), Color(0xFFDA70D6))))
    ) {
        val modalSheetState = rememberModalBottomSheetState(
            initialDetent = Hidden,
            detents = listOf(Hidden, Peek, FullyExpanded)
        )

        Box(
            modifier = Modifier
                .align(Alignment.Center)
                .padding(
                    WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal).asPaddingValues()
                )
                .clip(RoundedCornerShape(6.dp))
                .clickable { modalSheetState.currentDetent = Peek }
                .background(Color.White)
                .padding(horizontal = 14.dp, vertical = 10.dp)
        ) {
            BasicText("Show Sheet", style = TextStyle.Default.copy(fontWeight = FontWeight(500)))
        }

        val isCompact = maxWidth < 600.dp

        ModalBottomSheet(state = modalSheetState) {
            Scrim(scrimColor = Color.Black.copy(0.3f), enter = fadeIn(), exit = fadeOut())

            Sheet(
                modifier = Modifier
                    .padding(top = 12.dp)
                    .let { if (isCompact) it else it.padding(horizontal = 56.dp) }
                    .statusBarsPadding()
                    .padding(
                        WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal)
                            .asPaddingValues()
                    )
                    .shadow(4.dp, RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp))
                    .clip(RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp))
                    .background(Color.White)
                    .widthIn(max = 640.dp)
                    .fillMaxWidth()
                    .imePadding(),
            ) {
                Box(
                    Modifier.fillMaxWidth().height(600.dp),
                    contentAlignment = Alignment.TopCenter
                ) {
                    DragIndication(
                        modifier = Modifier.padding(top = 22.dp)
                            .background(Color.Black.copy(0.4f), RoundedCornerShape(100))
                            .width(32.dp)
                            .height(4.dp)
                    )
                }
            }
        }
    }
}

The issue I am facing is when running this code on iOS (running compose-multiplatform v 1.7.0-alpha02), I am getting the following error:

Uncaught Kotlin exception: kotlin.native.internal.IrLinkageError: Function 'clickable' can not be called: No function found for symbol 'androidx.compose.foundation/clickable|clickable@androidx.compose.ui.Modifier(androidx.compose.foundation.interaction.MutableInteractionSource;androidx.compose.foundation.Indication?;kotlin.Boolean;kotlin.String?;androidx.compose.ui.semantics.Role?;kotlin.Function0<kotlin.Unit>){}[0]'

I was able to pinpoint the issue to:

 DragIndication(
    modifier = Modifier.padding(top = 22.dp)
        .background(Color.Black.copy(0.4f), RoundedCornerShape(100))
        .width(32.dp)
        .height(4.dp)
)

If you can take a look and try on compose-multiplatform 1.7.0-alpha02 to see if you can reproduce, I would appreciate it!

alexstyl commented 1 month ago

thanks for using the library and for opening this issue.

I will have a look asap. Can you confirm that if you don't use the DragIndication() for the time being, there are no crashes?

dozy-programmer commented 1 month ago

Hello Alex,

Thank for responding promptly, much appreciated. You are correct, not using DragIndication() will result in no crashes.

If you need any more info from my side, just let me know.

dozy-programmer commented 1 month ago

I tested on the following platforms:

Android - no issue Desktop - no issue wasm/browser - crashes iOS - crashes

Here is the error message I am getting for wasm/browser Screenshot 2024-08-28 at 9 28 33 AM

alexstyl commented 1 month ago

you are making my life much much easier. thank you :)

it's just that im in the middle of house hunting right now, so i'm a bit slower with reviews.

Aiming to sort this out in the weekend

alexstyl commented 1 month ago

Fixed in 1.11.1 https://github.com/composablehorizons/composables-core/releases/tag/1.11.1