https://kotlinlang.org logo
Join Slack
Powered by
# compose
  • o

    Orlando

    07/09/2025, 10:29 PM
    hi all, i am using this third party webview library in my Compose Multiplatform project: https://github.com/KevinnZou/compose-webview-multiplatform I can successfully use the
    navigator.evaluateJavaScript
    method to send a token and other information from the native app to the WebView on iOS, but it does not work on Android. Here's some sample code:
    Copy code
    @Composable
    fun MyWebViewScreen(webUrl: String) {
        val webViewState =
            rememberWebViewState("<https://www.mysite.com>")
        val webViewNavigator = rememberWebViewNavigator()
        val jsBridge = rememberWebViewJsBridge(webViewNavigator)
        val token by dataStore.getUserToken().collectAsState(initial = null)
    
        LaunchedEffect(Unit) {
            initWebView(webViewState)
            initJsBridge(jsBridge)
        }
    
        LaunchedEffect(
            webViewState.loadingState,
            token,
        ) {
            if (webViewState.loadingState == LoadingState.Finished && token != null) {
              val authMessage = {
                "options": "userAuth",
                "token": "$token",
              }
    
              webViewNavigator.evaluateJavaScript("window.postMessage($authMessage, '*');")
            }
        }
    
        Column(Modifier.fillMaxSize()) {
            WebView(
                state = webViewState,
                modifier = Modifier
                    .padding(WindowInsets.statusBars.asPaddingValues())
                    .fillMaxSize(),
                navigator = webViewNavigator,
                webViewJsBridge = jsBridge,
            )
        }
    }
    
    fun initWebView(webViewState: WebViewState) {
        webViewState.webSettings.apply {
            zoomLevel = 1.0
            isJavaScriptEnabled = true
            logSeverity = KLogSeverity.Debug
            allowFileAccessFromFileURLs = true
            allowUniversalAccessFromFileURLs = true
            androidWebSettings.apply {
                allowFileAccess = true
                isAlgorithmicDarkeningAllowed = true
                domStorageEnabled = true
            }
        }
    }
    
    fun initJsBridge(webViewJsBridge: WebViewJsBridge) {
        webViewJsBridge.register(GreetJsMessageHandler())
    }
    does anybody have any experience/workaround for Android? thanks!
  • u

    ursus

    07/10/2025, 6:15 PM
    what does it want? im using
    maxWidth
    which is from the box with constraints scope
    s
    s
    • 3
    • 8
  • c

    Christopher Mederos

    07/11/2025, 4:23 AM
    I'm using navigation-compose (nav2)... and still having trouble understanding how to manage save state with back nav Home Tab -> Post Screen (for post id #123) -> Home Tab -> Post Screen (for post id #123) Is there a way to back nav properly so that when returning to the same deeper / child destination again (post #123)... the state of that destination is restored?
  • z

    Zoltan Demant

    07/11/2025, 4:56 AM
    Copy code
    Box { Box { } }
    The inner box has a bunch of focusable, scrollable and clickable elements. I want to disable all of those, while still allowing the outer box to be clickable. How do I do that? More details in 🧵
    • 1
    • 2
  • a

    agrosner

    07/11/2025, 8:18 PM
    im using the material3
    ModalBottomSheetLayout
    component where I need to nest content with a
    LazyColumn
    . When i do that, the content refuses to scroll . I use a
    LazyVerticalGrid
    , like magic it scrolls. Anyone have a workaround that lets you use a lazycolumn? It has to somewhat do with the draggable anchors code but not entirely sure why one works, but not the other
  • j

    Jonathan

    07/11/2025, 8:41 PM
    Does translating and scaling using:
    Copy code
    .graphicsLayer {
        scaleX = scale
        scaleY = scale
        translationX = translation.value.x
        translationY = translation.value.y
    }
    change the size and location of the bounding box for click listeners?
    e
    • 2
    • 1
  • e

    enighma

    07/11/2025, 9:04 PM
    I'm building a solitaire game for fun in compose. Is it worth pursuing writing it using basic elements such as column etc. or is it better to have a custom layout for the entire game? The main challenge I see is dragging and dropping between columns, is that even possible?
    🤘 1
    b
    • 2
    • 3
  • t

    Thierry Kh

    07/12/2025, 5:53 PM
    Hi. I'm looking for a way to remove the padding around the navigation suite items of my navigation suite scaffold. I want to make it smaller so I set the items' height to 48dp. Is there a simple way to achieve what I want? I basically want to reproduce Instagram bottom nav bar but idk if it's possible to customize the nav bar of the nav suite scaffold.
  • n

    Nitesh Singh

    07/13/2025, 5:35 AM
    hey there bottom part background is blur with every image how i will do that UI in jetpack compose ?
    r
    • 2
    • 3
  • a

    Alex Styl

    07/14/2025, 3:27 AM
    I'm trying to figure which dependency brings in the scrollbars on desktop targets but im lost. In the IDE i see that the
    ScrollbarAdapter
    are contained within
    org.jetbrains.compose.foundation:foundation-desktop
    but when i check the sources of that artifact the code is different (and they dont contain the scrollbar stuff) Any ideas in which artifact are the sources of
    compose-multiplatform-core
    released? link on github is https://github.com/JetBrains/compose-multiplatform-core/blob/jb-main/compose/found[…]skikoMain/kotlin/androidx/compose/foundation/Scrollbar.skiko.kt
    s
    • 2
    • 7
  • k

    kecaroh

    07/14/2025, 10:31 AM
    Hi, i am working on grid reorder functionality based on this demo https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]/androidx/compose/foundation/demos/LazyGridDragAndDropDemo.kt. It works fine with this example, but I need to get this working with Compose 1.6.3 (because of some external dependencies). Issue is, there's no
    requestScrollToItem
    in that version of Compose, so I trying to use it with
    scrollToItem
    - it however behaves differently in some cases, reorder looks wonky etc. Is there a way for me to get
    requestScrollToItem
    in my older Compose version?
  • j

    Jonathan

    07/14/2025, 2:21 PM
    What is the difference between
    androidx.compose.material3:material3-window-size-class
    and
    androidx.compose.material3.adaptive:adaptive-
    ? They both seem to contain code for determining window size classes.
    l
    n
    • 3
    • 2
  • z

    Zoltan Demant

    07/14/2025, 4:31 PM
    During testing: in one of my composables I have
    val scope = rememberCoroutineScope()
    and If I log
    scope.coroutineContext[CoroutineDispatcher]
    I can see that its a ~_FlushingDispatcher_ But later on when I do
    scope.launch { .. }
    and check, suddenly the thread being used is: DefaultDispatcher-worker-5 @coroutine#238 Can anyone explain? The tests are being run on the JVM with
    runSkikoComposeUiTest
    .
  • a

    Andy Flisher

    07/14/2025, 7:24 PM
    A newly generated shared UI (Android, Desktop, iOS) project that started in the wizard is now throwing ā€œmodule not found composeAppā€ whilst trying to run iosApp on the simulator - nothing obvious has changed according to the commits, certainly nothing project or gradle related, but same on two different machines. I’ve tried cleaning, zapping gradle caches, restarts etc - I’m assuming it’s build process related but struggling to see what’s changed - just a couple of shared .kt files have been added 🤷
    • 1
    • 1
  • e

    enighma

    07/14/2025, 9:05 PM
    Text question Can I draw a unicode character without it's ascender and descenders? Let's say I want to fill a Box {} with the letter
    A
    but I don't want any of the white space that is there for other letters. In my real example I'm using unicode characters, all of which is of the same size, but I don't want the whitespace I'm getting I.e. can I draw the glyph itself somehow.
    y
    b
    • 3
    • 6
  • u

    ursus

    07/15/2025, 8:11 PM
    I'm working on chat UI. I'm looking at
    Jetchat
    sample I want to keep scroll at 0 (if it was at 0) when new messages are inserted
    Copy code
    val listState = rememberLazyListState()
    SideEffect {
        if (!listState.canScrollBackward) {
            listState.requestScrollToItem(index = 0) <------------------
        }
    }
    LazyColumn(
        ...
        state = listState,
        ...
    ) {
        ...
    }
    this seems to do the trick. However, I also have a next screen (image message detail). If I navigate there, and then back, the chat screen composable is "instantiated" again, therefore triggering
    SideEffect
    lambda, and resetting the scroll -- which is not what I want -- the scroll offset should be kept (which it does by default, but then I don't get that "keep scroll at 0" behavior) Any clean way around this other than hacks?
    b
    a
    • 3
    • 19
  • j

    Jonathan

    07/15/2025, 8:22 PM
    Has anyone attempted to pause an infinite animation? The
    InfiniteTransition
    doesn’t have a pause/stop function. In the past I achieved it by using a
    while
    loop inside of a
    LaunchedEffect
    and manually updating an
    Animatable
    instance. This feels a little clunky and I wonder if there is a proper API I should be using.
    šŸ‘€ 3
  • u

    ursus

    07/15/2025, 8:24 PM
    Sorry to necromance this y'all. But using
    SideEffect
    has a quirk that the lambda gets triggered when there was navigation (backstack.push), and than back again to the list screen; and user expects the scroll to be kept as was -- but here,
    SideEffect
    fires again, thuss resetting the scroll.. any idea what to do about it?
  • u

    ursus

    07/15/2025, 11:46 PM
    Why does
    LazyColumn
    do a ā€œdouble stepā€ scroll when calling
    animateScrollToItem (0)
    ? I would expect one smooth scroll like recycler used to do.
    s
    • 2
    • 3
  • z

    Zoltan Demant

    07/16/2025, 4:26 PM
    Since I dont know when, ModalBottomSheets drag handle shows a square ripple when you touch it. Is this intentional or a bug? I just stumbled upon it in my app, and honestly a bit baffled by it even though I get the rationale behind it..
  • e

    eygraber

    07/16/2025, 9:10 PM
    Does this mean that with 1.9 Jetpack Compose will be the sole implementation of Compose across all targets, with Desktop, Web, etc... specific code being provided by Jetbrains?
    e
    i
    • 3
    • 8
  • r

    ribesg

    07/17/2025, 7:35 AM
    Why is
    androidx.compose.material3.windowsizeclass.calculateWindowSizeClass()
    in
    skikoMain
    and not
    commonMain
    in
    material3-window-size-class
    1.9.0-alpha03
    ? I had to duplicate the function in my app's
    commonMain
  • u

    ursus

    07/17/2025, 2:09 PM
    If I have a
    TextField
    and I enter a screen, it doesn't have focus, no keyboard is opened. If I tap it, it gets focused, keyboard opens. If I close the screen, and then come back to it again, focus is somehow preserved, and keyboard opens automatically I don't want that (for a chat ui).
    I want the keyboard to never auto-open when I enter the screen.
    Any way to fix this? I'm trying the
    keyboardOptions.showKeyboardOnFocus = false
    but doesn't seem to have an effect I think it's that the focus is preserved somehow across screen boundaries. Is there a way to scope it?
  • a

    Arne Vanstraeseele

    07/17/2025, 3:17 PM
    Hi, We are using Jetpack Navigation dialogs. The dialogs has a viewmodel with his state. But when I close my app an reopens it, my state is gone (Dialog just reopens with a clean state). How should I fix that?
  • o

    Orlando

    07/17/2025, 7:50 PM
    hi all, does anyone know how i can remove the padding above the keyboard (see image) in a WebView text input. here's the code i have:
    Copy code
    Column(Modifier.fillMaxSize()) {
            WebView(
                state = webViewState,
                modifier = Modifier.windowInsetsPadding(WindowInsets.safeDrawing).fillMaxSize()
            )
        }
    if i use the following modifier, the keyboard covers the webview's text input:
    Copy code
    modifier = Modifier.padding(WindowInsets.statusBars.asPaddingValues()).fillMaxSize()
    w
    • 2
    • 2
  • n

    Nish

    07/17/2025, 8:31 PM
    Hi everyone, I'm familiar with swiftui and learn compose however at present I face a difficulty in updating UI since i don't know how the rendering works!! Im currently trying to show user's location on map with icons using stateflow<list<Person>> however nothing shows up on UI? can someone here tell me the right approach when using this?
    p
    w
    • 3
    • 3
  • v

    Vishal Sheoran

    07/18/2025, 3:29 AM
    Hi Everyone, do anyone have any idea how to use webviews in Compose Multiplatform. I am looking for any solution that works on both ios and Android.
    c
    • 2
    • 2
  • t

    Thomas Hormes

    07/18/2025, 5:55 AM
    Is it a known issue that the M3 Datepicker on Landscape mode is buggy? Or am I doing something wrong? šŸ˜… This is using CMP 1.9.0-alpha03 on Android
  • k

    Kyant

    07/18/2025, 9:28 AM
    How to get pan, zoom and rotation velocity with custom
    detectTransformGestures
    ? I tried to use
    Copy code
    val zoomVelocityTracker = VelocityTracker()
    zoomVelocityTracker.addPosition(elapsedTimeMillis, Offset(totalZoom, 0f))
    but got wrong velocity which is very small
    s
    • 2
    • 1
  • p

    Pablichjenkov

    07/18/2025, 8:11 PM
    Is it possible that applying
    Copy code
    val colorModifier = Modifier.background(CustomColor)
    in a Surface
    Copy code
    Surface(modifier = colorModifier) {...}
    Show a different color than in a Box
    Copy code
    Box(modifier = colorModifier) {...}
    Not sure what could be the reason behind it but I am having this behavior where the color on the surface looks a bit more whitish. For a bit more context. It is a Composable very deep in the Composable tree, a leaf in the tree basically.
    s
    • 2
    • 2