https://kotlinlang.org logo
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
  • j

    Joseph Hawkes-Cates

    06/10/2022, 9:22 PM
    Is there a way to set the modifier on an Image so it is full size unless it’s bigger than X% of the bounds at which point we scale it to fit within that percentage of the layout?
    🤔 1
    b
    z
    • 3
    • 5
  • c

    Chris Fillmore

    06/10/2022, 11:34 PM
    Under what circumstances should I use
    Modifier.composed()
    ? I have a custom modifier that is fairly general purpose (like
    transformable()
    but with slightly different behaviour). I see
    transformable()
    uses
    composed()
    . Is this just an optimization? Thanks for any tips!
    a
    z
    • 3
    • 2
  • c

    Colton Idle

    06/11/2022, 12:31 AM
    Is it bad in compose if I have a
    mutableStateListOf<Item>
    and then just
    list.clear()
    and
    list.addAll()
    when I get a new list that's mostly the same? My use case: I am using Firestore where you can listen to a query via a Flow. So if I listen to a query of top20Books(), and I show that in my list, but one of the ratings on the books changes, my listener will get invoked again, which will cause me to throw away the old list and add the new list. But the only item that change was the top item, where the rating changed from a 4.82 to a 4.83. Or should I take a different route on this. Like should I try to do the diffing myself?
    s
    f
    +2
    • 5
    • 8
  • o

    orangy

    06/11/2022, 10:52 AM
    I have a weird effect with
    animateColor
    involving alpha. It goes from
    Color.White
    to
    Color.Blue.copy(0.1f)
    with a
    tween()
    spec. Instead of linear transition from one appearance to another, it goes first to less transparent
    Color.Blue
    pretty fast and then alpha catches up, resulting in the unexpected effect of a “hump” transition. Any ideas how to fix it? E.g. in browser similar transition effect between same colors works as expected. (Compose for Desktop, if it is important)
    c
    • 2
    • 5
  • l

    lilypuchi

    06/11/2022, 12:37 PM
    I was reading Jorge’s Compose Internals (which if someone hasn’t read yet, I highly recommend to) I came across this (Pg 88 in the latest edition),
    In SubcomposeLayout for example, whenever a layout occurs, the parameters passed to its lambda might vary, and in that case it will trigger a recomposition. In the other hand, if a state that is read from a subcomposition changes, a recomposition will be scheduled for the parent Composition once the initial composition is performed.
    How does one read read a state from a subcomposition 🤔 ? Is it same as reading state ‘in’ a subcomposition or am I reading it wrong?
    s
    • 2
    • 3
  • s

    Saiedmomen

    06/11/2022, 6:43 PM
    In the io22 talk Performance best practices for Jetpack Compose, there is a

    section▾

    about Deferred reads and skipping compose phases. In particular there is a sample about animated background color and it is suggested to read color only inside
    drawBehind
    so that composition and layout phases can be skipped. I don't understand if composition is skipped, how snapshot subscription works and
    drawBehind
    is notified of color change. Is the draw phase executed on each frame? Is it related to nested use of composition for canvas?
    @Composable
    fun SkipPhases() {
        val transition = rememberInfiniteTransition()
        val color by transition.animateColor(
            initialValue = Color.Cyan,
            targetValue = Color.Magenta,
            animationSpec = InfiniteRepeatableSpec(tween())
        )
    
        Box(modifier = Modifier.fillMaxSize().drawBehind { drawRect(color) }) {
            Text(text = "SkipPhases")
        }
    }
    j
    y
    z
    • 4
    • 7
  • m

    Marcin Wisniowski

    06/11/2022, 7:52 PM
    I think I found a bug in Android Studio regarding overriding Composable methods, not sure if this is known? If not where to report it? Info in 🧵
    j
    • 2
    • 5
  • m

    Mehdi Haghgoo

    06/12/2022, 6:19 AM
    Is it guaranteed that every frame takes 16 ms in Android?
    🇳🇴 2
    r
    • 2
    • 7
  • k

    kotlinforandroid

    06/12/2022, 9:42 AM
    Is it possible to someone draw into the bounding of of a neighboring composable? For example I want to draw something centered on top of box 2. But using a column doesn't work since it would use the largest width, which is the one of the top content. There would be a empty space left and right of box 2.
    j
    • 2
    • 3
  • o

    orangy

    06/12/2022, 12:04 PM
    Is there some kind of pattern in Compose to execute actions inside nested components without exposing too much details outside? In my specific example I have a LazyColumn somewhere deep into a more complex component, and I want to expose an action like “scroll to top” to the outside world. Obviously, I don’t want
    LazyListState
    to be exposed, because composition of this bigger component can change, but semantic would remain. How do you do this?
    a
    • 2
    • 3
  • o

    orangy

    06/12/2022, 1:03 PM
    I have a
    LazyColumn
    and I want it to retain scroll position relative to the item key when I update the content. E.g. if I have items from the
    listOf(1,2,3)
    and I scroll to top, and then update data and repopulate items from
    listOf(0,1,2,3)
    I want scroll position to be still at item
    1
    with the same offset, and to see item
    0
    user would need to scroll up. Any hints on how to implement this effectively?
    ✅ 1
    m
    z
    • 3
    • 4
  • s

    Siddarth R Iyer

    06/12/2022, 2:43 PM
    Does anyone have any idea when the next stable version of Compose is set to be released? I'd like to upgrade to Kotlin v1.7.0 but this issue is blocking it.
    j
    t
    +2
    • 5
    • 11
  • c

    Colton Idle

    06/12/2022, 3:50 PM
    I have a cool animation that runs but it gets clipped. I couldn't figure out why, but I did trace it down to this modifier I added
    .blur(Dp(bottomSheetProgress * 4))
    even if I make it
    .blur(Dp(0F))
    it will still clip. Is there anyway to opt out of this behavior?
    s
    • 2
    • 5
  • c

    Chuck Stein

    06/12/2022, 5:02 PM
    The
    SnackbarDuration.Indefinite
    javadoc says "_Show the Snackbar indefinitely until explicitly dismissed or action is clicked_", however so far I haven't figured out any way for the user to manually dismiss a snackbar other than clicking the action. How can this be done?
    ➕ 2
    a
    • 2
    • 6
  • a

    Alexandre Brown

    06/12/2022, 8:07 PM
    Hello, is it possible create a compose project for Desktop & Web ? I tried the multiplatform setup but it created desktop & android directories. In my case I don't want android. Thanks
    m
    • 2
    • 1
  • a

    Alexandre Brown

    06/13/2022, 1:33 AM
    Hello, can someone point me to some tutorial about desktop compose UI ? My new app looks terrible 😄
    c
    • 2
    • 3
  • c

    Colton Idle

    06/13/2022, 2:02 AM
    Has anyone figured out how to have a
    Row(Modifier.horizontalScroll())
    but have the current item "snap" in place. I've looked at Chris Banes' snapper lib, but it only works with LazyRows. And HorizontalPager in accompanist is built on LazyRow so that's also a no-go. I need a non-lazy row/carousel impl with "snapping", but really can't find anything but I'm sort of finding it tough to believe no one has solved for this problem yet.
    r
    f
    • 3
    • 4
  • e

    eygraber

    06/13/2022, 2:12 AM
    Is there a way to take screenshots using
    ComposeTestRule
    with Robolectric. Currently getting
    androidx.compose.ui.test.ComposeTimeoutException: Condition still not satisfied after 2000 ms
    errors on
    captureToImage
    when calling
    rule.onRoot().captureToImage().asAndroidBitmap().compress(Bitmap.CompressFormat.PNG, 100, FileOutputStream(File("test.png")))
    e
    • 2
    • 3
  • o

    orangy

    06/13/2022, 8:26 AM
    Is it possible to change content of the sticky header in the LazyColumn when it is “hanging” over the content vs when it is rendered as a normal item?
    m
    a
    • 3
    • 5
  • t

    Tash

    06/13/2022, 5:22 PM
    Hi all, there is some hesitancy on my team to depend on https://github.com/google/accompanist given this:
    Any of the features available in this group of libraries may become obsolete in the future, at which point they will (probably) become deprecated.
    We will aim to provide a migration path (where possible), to whatever supersedes the functionality.
    Citing that these migrations/deprecations could become problematic to maintain. Did anyone run into similar concerns and go with some alternative?
    a
    c
    +2
    • 5
    • 11
  • c

    Colton Idle

    06/13/2022, 8:26 PM
    I have this weird requirement where I have to give a Box the same height that is equal to the total height of the 1st and 2nd item of a LazyCol on top of the box.. The 1st and 2nd item in the list can change at any time or else I would just try to take the easy route and use some hardcoded height. How can I properly set a variable of
    totalHeightOfFirstAndSecondItemInLazyCol
    .
    Box {
    Box(fillMaxWidth().height(totalHeightOfFirstAndSecondItemInLazyCol)
    LazyColumn() { //all items are different sizes }
    }
    s
    • 2
    • 2
  • z

    zsperske

    06/13/2022, 9:06 PM
    If I have an
    android:letterSpacing
    value like the following, how do I use it in Compose?
    <!-- Letter Spacing -->
    <dimen name="largeTitleLetterSpacing">0.00625</dimen>
    j
    • 2
    • 1
  • l

    Landry Norris

    06/13/2022, 9:17 PM
    I was reading through the androidx google source repository, and I noticed in the documentation that ‘Compose is still experimental and should not be used in a production application’. Is this still the case, or is the compose compiler README out of date?
    j
    l
    • 3
    • 5
  • g

    Grégory Lureau

    06/13/2022, 9:48 PM
    Trying to run molecule with CfD (copied the runtime methods as there is no build yet for JVM), looks like it's always recomposing and remember call the `calculation`on each composition. Any advice?
    j
    j
    • 3
    • 4
  • a

    andrew

    06/14/2022, 2:00 AM
    Is it alright for an applier node to have access to the applier via callbacks?
    🤔 1
    a
    • 2
    • 8
  • r

    raghunandan

    06/14/2022, 6:05 AM
    [Solved] I am unable to preview compose ui. Unable to figure out the issue. Any one with similar issue can help?? This is in a multi module project. Says need to build for the preview to be shown but once i do that the same msg is shown in design editor. Tried clean and build multiple times.
    c
    • 2
    • 5
  • n

    nuhkoca

    06/14/2022, 10:58 AM
    Hello, is it possible to limit width of
    placeables
    using custom layout? In my case, button overlaps other items but I would expect other components to get smaller as much as button gets wider. Code in the 🧵
    f
    • 2
    • 15
  • f

    fengdai

    06/14/2022, 11:57 AM
    Hey guys. I have a question about Compose testing. My test has a
    LaunchedEffect
    which will change a state after a delay and trigger a recomposition. I want to wait for the end of the consequent recomposition and then do some assertions. How can I achieve the waiting?
    waitForIdle
    doesn’t work.
    a
    • 2
    • 3
  • s

    Slackbot

    06/14/2022, 2:54 PM
    This message was deleted.
    :not-kotlin: 1
    ❓ 1
    c
    c
    • 3
    • 2
  • c

    Colton Idle

    06/14/2022, 4:17 PM
    I've been stuck on this for entirely way too long. How do you get the height of the status bar using accompanist? I know there's
    Modifier.statusBarsHeight()
    , but I don't need the Modifier, I just need to add a few values together (including the status bar height).
    :thank-you: 1
    a
    a
    • 3
    • 5
Powered by Linen
Title
c

Colton Idle

06/14/2022, 4:17 PM
I've been stuck on this for entirely way too long. How do you get the height of the status bar using accompanist? I know there's
Modifier.statusBarsHeight()
, but I don't need the Modifier, I just need to add a few values together (including the status bar height).
:thank-you: 1
a

Alex Vanyo

06/14/2022, 5:07 PM
There’s
WindowInsets.statusBars.getTop
! Although I’m curious if you could share your use case a bit for adding some together?
a

Albert Chang

06/15/2022, 12:46 AM
In accompanist, it’s
<http://LocalWindowInsets.current.statusBars.top|LocalWindowInsets.current.statusBars.top>
.
☝️ 2
a

Alex Vanyo

06/15/2022, 12:47 AM
Whoops, I entirely missed “using accompanist”, sorry 😅
c

Colton Idle

06/15/2022, 1:13 AM
Thank you both. Haven't migrated yet. @Alex Vanyo My use case right now generally is the fact that I need to download a hero image from my back end and I need it to be the size of one of my list items but the size kept looking off and I finally figured that it's because my app is laid out edge to edge. So I need to have the status bar height to give to my back end along with the item cell height so that combined it knows the exact height image to give me.
That worked great though. My app looks awesome with a correctly sized hero image now. Thank you both again
👍 2
👍🏽 2
View count: 5