https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose
  • m

    miqbaldc

    12/29/2022, 5:49 AM
    Hi folks! Curious if anyone ever has this runtime crashed when using
    ModalBottomSheetState
    See error log in 🧵
    z
    j
    • 3
    • 5
  • m

    Mod

    12/29/2022, 6:26 AM
    Hi, I have a question please is it a good idea to create a view model for dialog? I have this case where I have a dialog and in the dialog I have to call an api on the confirm button and this dialog is used in multiple screens I asked this question here because the project in compose
    c
    • 2
    • 2
  • a

    AmrJyniat

    12/29/2022, 12:24 PM
    I'm using Google map in Compose, is there a wat to get the current zoom value from
    cameraPositionState
    or any other related state?
    y
    • 2
    • 2
  • z

    Zoltan Demant

    12/29/2022, 12:59 PM
    With a
    LazyColumn
    that spans the entire screen height, how can I add contentPadding such that the first item is centered on screen initially (without making it super-janky)? 🎅🏽 Some more details in 🧵!
    d
    j
    • 3
    • 3
  • d

    dorche

    12/29/2022, 1:05 PM
    Is there a “correct” way to return to where you were in a compose app, after a redirect back from a Chrome Custom Tab? The full flow is: • User uses app and navigates a few screens deep (using NavHost, pure Compose app) • After clicking a button, we open a Custom Tab. • User goes through the browser journey and at the end of it a redirect is issued (currently using an “app” scheme, not https but doubt this matters) From there we’d like to just be returned to the same composable that launched the Custom Tab, ideally with access to the data in the redirect url.
    • 1
    • 4
  • s

    shikasd

    12/29/2022, 3:26 PM
    Is this sampled or traced stack? Depending on how you measure it may introduce additional overhead making this trace bigger than it actually is Overall, looking into this trace, it seems like you have a heavy movable content lambda that composer is trying to relocate somewhere else. Movable content might introduce substantial overhead in this case, as moving part of composition is not quite simple, which might be what you see here.
    t
    • 2
    • 4
  • m

    mattinger

    12/29/2022, 3:58 PM
    Hey all, If i have a DropDownMenu, is there a way to have a sticky header content in it? I’m trying to put a search box so that the user doesn’t have to scroll through a large list of items to find what they want. However, when in put in the text field, it’s included in the scroll area:
    DropdownMenu(....) {
        TextField(...)
        items.forEach { 
            DropdownMenuItem(...)
        }
    }
    c
    • 2
    • 3
  • j

    Jaime

    12/29/2022, 9:26 PM
    Hello everyone, do you know if the keyboard bug in Column is already solved? I leave video in the thread
    c
    • 2
    • 4
  • c

    Cicero

    12/29/2022, 10:13 PM
    Hey, I wrote a function to draw custom borders, does anyone has any suggestion on how I can improve this? In 🧵
    • 1
    • 1
  • t

    Travis Griggs

    12/29/2022, 10:16 PM
    Is there a recommended convention on defining/passing the very ubiquituios modifier arguments? E.g. 1. Always define the modifier first or last? 2. Always pass the modifier argument first or last? 3. Do it wherever you want, just always use modifier =, so it's clear? 4. Something else?
    c
    c
    s
    • 4
    • 5
  • t

    Travis Griggs

    12/29/2022, 10:16 PM
    If BOM is the recommended way to go, why doesn't a new Compose Activity just put that in there?
    c
    m
    c
    • 4
    • 8
  • d

    Derrick Rocha

    12/29/2022, 11:24 PM
    Has anyone been able to get Compose Constraint Layout working in a multiple platform project? I'm able to add the dependency to the gradle file in my shared module, but Android studio fails to recognize the library. Thanks in advance.
  • r

    rkeazor

    12/30/2022, 2:42 AM
    Has anyone seen this issue when adding compose dependencies : "The consumer was configured to find a runtime component, preferable optimized for Android as well as com.android.build.api.attributes.BuildTypeAttr with value debug..." " none of the consumable configuration have attributes" ?
    l
    • 2
    • 16
  • a

    Arjan van Wieringen

    12/30/2022, 9:55 AM
    I have the following composable:
    @Composable fun EventDetail(
        selectedEvent: String,
        viewModel: EventDetailViewModel = viewModel(selectedEvent),
        modifier: Modifier = Modifier
    ) {
        val state by viewModel.state.collectAsState()
        EventDetail(
            state = state,
            onAmountToRecordChange = { raw -> viewModel.updateAmountToRecord(raw) },
            onRecordingOffsetChange = { raw -> viewModel.updateRecordingOffset(raw) },
            onRecordingStart = { viewModel.startRecording() },
            onRecordingStop = { viewModel.stopRecording() },
            onTrash = { viewModel.clearRecords() },
            modifier = modifier
        )
    }
    The state object is a simple data-class produced in the viewModel (which consists of some hot flows as well). The EventDetail composable gets triggered every frame even though the state doesn't change (the hashcode is consistently the same). Is this due to the
    collectAsState
    implementation? Does that trigger every frame?
  • a

    Abdul Hafeez Sajid

    12/30/2022, 10:48 AM
    Hi,
    onFocusChanged
    callback is triggered on the initial composition on TextField/BasicTextField in compose 1.3.2 without any focusRequest or clicking. Is this normal behaviour? if yes, how to avoid it. Any guide?
    a
    • 2
    • 3
  • y

    Yingding Wang

    12/30/2022, 12:13 PM
    Is there a debug function for compose modifier in AS? Currently, i have been using the compose preview with “try-and-error” approach to see the impact of modifiers in mein code. The Layout Inspector for compose shows way to many info and layers, and it also doesn’t show a trace of how the modifiers are applied in a chain.
  • t

    Travis Griggs

    12/30/2022, 8:39 PM
    It seems its common as editing composables, to wrap some existing composables in another. Is there some IDE magic that makes that flow easier? I looked in "refactor" menu options, but didn't see anything. I'
    l
    c
    • 3
    • 3
  • d

    Derrick Rocha

    12/30/2022, 9:21 PM
    I'm building a kotlin multiplatform mobile project and drawing Composables on iOS via Compose's Application method that returns an iOS View controller. This is working fine for my purposes, however, I'm running into issues with Compose's
    AnimatedVisibility()
    not changing visibility on iOS after the initial value is set. Has anyone doing Compose on iOS via the
    Application
    method run into this issue? Thanks.
    l
    • 2
    • 2
  • s

    sen

    12/31/2022, 4:54 AM
    I'm trying to make something like this

    image▾

    except the animation only animates the first index of change of a string to the end of the string. For example 42 -> 43 would animate the 2 -> 3 (and any other numbers after if applicable). The animation code I'm basing this off of The problem is, I don't know how exactly to remember the previous value. I tried doing something where I would simply remember it and update the previous value whenever
    DisposableEffect
    is invoked within the AnimatedContent, but for whatever reason it seems to be "delayed" by a value. Observing the value (the actual one, not the previous) I saw it cycles between the current and value it just was right before it incremented. I
    m
    • 2
    • 3
  • v

    v79

    12/31/2022, 10:25 AM
    Can someone explain to me the write way to write this function. I still really struggle with coroutines:
    fun getVehicle(vehicleId: Long): Vehicle? {
            val vehicle = viewModelScope.launch {
                repository.getVehicleById(vehicleId)
            }
            return vehicle
        }
    I know this is wrong. I just can't get my head around what is right.
    z
    c
    • 3
    • 13
  • m

    MR3Y

    12/31/2022, 6:13 PM
    java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
                                                                                                        	at androidx.compose.foundation.CheckScrollableContainerConstraintsKt.checkScrollableContainerConstraints-K40F9xA(CheckScrollableContainerConstraints.kt:36)
                                                                                                        	at androidx.compose.foundation.ScrollingLayoutModifier.measure-3p2s80s(Scroll.kt:336)
    • 1
    • 3
  • t

    Thomas

    01/01/2023, 6:12 AM
    Hi everyone, happy new year . I'm facing a logical problem in Jetapck compose, how can I create 2D Table with Row and Column headers and content Scrollable on Jetpakcompose, so far I'm facing a logical problem or compose limitation ?
  • t

    Thomas

    01/01/2023, 6:14 AM
    Thanks for your time and help
  • u

    Udi Oshi

    01/01/2023, 5:54 PM
    Hello Trying to create a simple ext for Shadow:
    @Composable
    fun Shadow.simpleDropShadow(color: Color? = null, offset: Offset?, blurRadius: Float?) = Shadow(
        color = color ?: colorResource(id = R.color.black_75),
        offset = offset ?: Offset(x = 2f, y = 4f),
        blurRadius = blurRadius ?: 0.1f
    )
    But no luck when trying to use in at all. Appreciate your assitance 🙏
    k
    a
    +3
    • 6
    • 13
  • c

    Colton Idle

    01/01/2023, 5:56 PM
    The amount of times something recomposes is technically out of your control and compose can decide to recompose something whenever it wants so you shouldn't really look into it too much IMO. compose does have debugging tools for compose count and compose perf though so you could look into those. Note: To clarify, I'm not saying that something might not be wrong with your code, but the fact that something recomposes multiple times is not necessarily an issue
    m
    • 2
    • 1
  • s

    Sagar yadav

    01/02/2023, 5:05 AM
    Hello Android Paging library for compose is still in alpha stage, (
    1.0.0-alpha17
    ) Is anyone using it in production ? I don’t see any issues reported on github https://developer.android.com/jetpack/androidx/releases/paging
    s
    • 2
    • 1
  • c

    chanjungskim

    01/02/2023, 8:29 AM
    I have a question, What's the difference between
    val interactionSource = remember { MutableInteractionSource() }
    and
    val interactionSource by remember { MutableInteractionSource() }
    and
    val interactionSource by rememberSavable { MutableInteractionSource() }
    ???
    j
    l
    +4
    • 7
    • 16
  • v

    vide

    01/02/2023, 9:12 AM
    I have a class that is marked
    @Immutable
    but compose metrics reports it as unstable. Am I doing something wrong here? I think this only started happening when I refactored the class to a shared package
    s
    • 2
    • 3
  • m

    myanmarking

    01/02/2023, 10:46 AM
    is there any built in behavior for LazyRow to be able to snap card by card, just like google play ?
    z
    c
    c
    • 4
    • 11
  • u

    Udi Oshi

    01/02/2023, 1:28 PM
    Trying to use Modal bottom sheet layout:
    val state = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded)
        val scope = rememberCoroutineScope()
    
        ModalBottomSheetLayout(
            modifier = Modifier.fillMaxSize(),
            sheetState = state,
            sheetContent = {
                Box(modifier = Modifier
                    .height(120.dp)
                    .background(color = Color.Red)) {
                    Text(text = "Half expanded")
                }
            }) {
            //  Full screen content
        }
    and keep getting:
    java.lang.IllegalArgumentException: The initial value must have an associated anchor.
    What am I doing wrong? 🙏
    c
    j
    • 3
    • 22
Powered by Linen
Title
u

Udi Oshi

01/02/2023, 1:28 PM
Trying to use Modal bottom sheet layout:
val state = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded)
    val scope = rememberCoroutineScope()

    ModalBottomSheetLayout(
        modifier = Modifier.fillMaxSize(),
        sheetState = state,
        sheetContent = {
            Box(modifier = Modifier
                .height(120.dp)
                .background(color = Color.Red)) {
                Text(text = "Half expanded")
            }
        }) {
        //  Full screen content
    }
and keep getting:
java.lang.IllegalArgumentException: The initial value must have an associated anchor.
What am I doing wrong? 🙏
c

Csaba Szugyiczki

01/02/2023, 1:32 PM
Make sure your content has size https://stackoverflow.com/a/68624825
u

Udi Oshi

01/02/2023, 1:33 PM
content is ConstraintLayout where its modifier set as fillMaxSize, isn’t that enough?
c

Csaba Szugyiczki

01/02/2023, 1:34 PM
should be
u

Udi Oshi

01/02/2023, 1:38 PM
Tried adding default height of 1.dp to it with not luck, tried also to wrap the content with box with min height of 1.dp, nothing works.
val state = rememberModalBottomSheetState(ModalBottomSheetValue.HalfExpanded)
    val scope = rememberCoroutineScope()

    ModalBottomSheetLayout(
        modifier = Modifier.fillMaxSize(),
        sheetState = state,
        sheetContent = {
            Box(
                modifier = Modifier
                    .height(120.dp)
                    .defaultMinSize(minHeight = 1.dp)
                    .background(color = Color.Red)
            ) {
                Text(text = "Half expanded")
            }
        }) {
        //  Full screen content
        Box(
            modifier = Modifier
                .defaultMinSize(minHeight = 1.dp)
                .fillMaxSize()
        ) {
            Text(text = "Hello content")
        }
Cleanest and still crashes
c

Csaba Szugyiczki

01/02/2023, 1:45 PM
is it crashing if you start from Hidden state?
u

Udi Oshi

01/02/2023, 1:46 PM
Don’t know but I hidden is not option for my UX behavior
c

Csaba Szugyiczki

01/02/2023, 1:47 PM
I understand. Just to try narrowing down the problem. I can see no issues with your code 🤷
u

Udi Oshi

01/02/2023, 1:49 PM
Not crashing, but doesn’t show the content, even after removing .defaultMinSize(minHeight = 1.dp). Text (hello content) isn’t showing
I understand why text is not showing (black over black color) but the state is really shi**y workaround, will need to change state in some launched effects
Another weird thing:
LaunchedEffect(key1 = state, block = {
        if (state.currentValue == ModalBottomSheetValue.Hidden) {
            state.animateTo(ModalBottomSheetValue.HalfExpanded)
        }
    })
crashes it with same exception 🙅
c

Csaba Szugyiczki

01/02/2023, 1:57 PM
what if you set the width of your sheetContent to .fillMaxWidth?
u

Udi Oshi

01/02/2023, 1:58 PM
Still crashing
Thought maybe device to render some stuff so I’ve added delay:
LaunchedEffect(key1 = state, block = {
        if (state.currentValue == ModalBottomSheetValue.Hidden) {
            scope.launch {
                delay(2500)
                state.animateTo(ModalBottomSheetValue.HalfExpanded)
            }
        }
    })
same result. How many workarounds we need to use in order to show this component? 😂
c

Csaba Szugyiczki

01/02/2023, 2:07 PM
something must be wrong with the content then
u

Udi Oshi

01/02/2023, 2:17 PM
I’ll continue investiagte later, and update here. thanks anyway for your time and effort @Csaba Szugyiczki
j

jossiwolf

01/03/2023, 7:38 AM
ModalBottomSheetLayout/ModalBottomSheetState can have three states/values: Hidden, HalfExpanded, Expanded. HalfExpanded is only included if the sheet content is taller than 50% of the ModalBottomSheetLayout. At 120dp, given that your layout fills the entire screen, you will only have a Hidden and Expanded state as the sheet content is smaller than 50% of the container. This means you are essentially telling ModalBottomSheetState to move to a value it doesn't know, hence the exception.
c

Csaba Szugyiczki

01/03/2023, 8:05 AM
The exception message could be more specific in this case. Is there a way to tell in advance if the HalfExpanded state exists?
j

jossiwolf

01/03/2023, 8:28 AM
Yes, we've recently made some changes that will allow us to specify a better message here. There's no way to know "in advance" (except if your container/sheet content bright ratio is static) as the ModalBottomSheetState gets created before the data used to calculate the anchors is available. We have an open issue about this but have other higher priority work items in the backlog.
c

Csaba Szugyiczki

01/03/2023, 8:29 AM
Thank you for the update!
j

jossiwolf

01/03/2023, 8:36 AM
Star https://issuetracker.google.com/191884670 for updates :)
u

Udi Oshi

01/03/2023, 8:52 AM
Thank you very much for this detailed explanation Jossi.
View count: 3