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
  • l

    Lilly

    05/11/2022, 1:12 AM
    I'm working with
    SnapshotStateMap<String, Any>
    and storing the value in a state object:
    // viewmodel content
    
    private val state: SnapshotStateMap<String, Any> = mutableStateMapOf()
    var myState by mutableStateOf(StateObject(state.getValue("key")))
    
    @Immutable
    data class StateObject(val value: Any)
    I'm changing the values by bubbling up a
    onValueChange
    event that accesses
    state
    like state["key"] = newValue. But when I use for example a
    Slider
    composable and
    onValueChange
    is triggered, the Slider does not reflect the change, although I can print the new values. I guess storing the value in a state object as intermediate step is the problem. Is this intended or do I miss something here?
    n
    • 2
    • 1
  • i

    Icyrockton

    05/11/2022, 2:21 AM
    Is there any tutorial or guide how to draw UML diagram for
    Composable
    component , which is helpful to visualize relationships between different UI elements
    j
    • 2
    • 2
  • c

    Colton Idle

    05/11/2022, 2:24 AM
    Can someone review this snippet of code to tell me whether or not a
    remember{}
    is needed? Code in thread
    n
    a
    j
    • 4
    • 19
  • m

    Marcin Wisniowski

    05/11/2022, 11:05 AM
    Compose previews. Top or bottom of the file? I can think of reasons for both ways.
    ⬇️ 27
    f
    f
    • 3
    • 4
  • t

    Todor Grudev

    05/11/2022, 12:55 PM
    Hello, Is there a way to handle the long press deletion of a text in a
    TextField
    - it feels like previously was the default behaviour, but I think with Compose it is not :?
    s
    • 2
    • 2
  • p

    Patrick Kellison

    05/11/2022, 1:36 PM
    Is there a clever way to do lazy initiation of variables within a composable scope?
    f
    a
    • 3
    • 3
  • l

    Lilly

    05/11/2022, 1:37 PM
    An android lint to make
    @Preview
    functions private to avoid polluting code completion might be useful?!
    s
    b
    • 3
    • 4
  • j

    Joseph Hawkes-Cates

    05/11/2022, 2:59 PM
    Good morning and Happy Google I/O day to everyone! I have a question about the Accompanist WebView. I think this may be an issue, but wanted to check before I logged it. Details in 🧵
    b
    • 2
    • 13
  • s

    Satyam G

    05/11/2022, 3:08 PM
    Hello, I have 2 options to consider for Image Loading In Compose 1. Glide 2. Coil (a new boy in Town) Almost both share common features like 1. Both has Request Options functionality 2. Both give placeholder, error, success callback for Image 3. Both has Transitions & Transformations Support 4. Coil has extra AsyncImage Can anyone share performance insights with their experience ?? Only Glide has big size as compare to Coil Can anyone share experience on which we should consider at first place for using with Jetpack Compose ??? It would be of great help.Thanks
    f
    a
    • 3
    • 5
  • m

    mertceyhan

    05/11/2022, 3:25 PM
    Hi all! I need to scroll on a component even screen has enough space, is that possible? I’ve tried the below code, it works well if the screen is small but it doesn’t work on if there is enough space to show all content. Please see the thread
    • 1
    • 1
  • p

    PHondogo

    05/11/2022, 3:58 PM
    Hello! Where can i get information for compose material icons and materialIconsExtended? Some kind of table with name and icon image?
    c
    • 2
    • 2
  • c

    Colton Idle

    05/11/2022, 7:16 PM
    "In Android Studio Electric Eel, you can use Live Edit to see the effect of updates to composables in real time. Live Edit updates Compose Preview and deploys code changes to an emulator or device. You don't have to wait for builds or deployments to be completed, so you can make faster progress in the creation of your app’s experience." https://developer.android.com/studio/preview/features#live_edit
    🙌 23
    🙌🏽 1
    🙌🏼 1
    b
    • 2
    • 1
  • s

    Sam

    05/11/2022, 8:40 PM
    patiently waits for
    accompanist v0.24.8-beta
    to drop
    🙃
    😂 3
    n
    • 2
    • 1
  • b

    Ben Trengrove [G]

    05/11/2022, 9:23 PM
    I'm right here waiting as well 😆
    🙌 1
    s
    • 2
    • 4
  • f

    Fudge

    05/11/2022, 9:27 PM

    https://youtu.be/qBkyU1TJKDg?t=2529▾

    https://youtu.be/qBkyU1TJKDg?t=1249▾

    Holy f***ing shit
    😮 1
    r
    r
    +5
    • 8
    • 41
  • a

    Alex

    05/12/2022, 7:59 AM
    What is the difference between nesting a
    Column
    inside of a
    Surface
    as opposed to adding the
    .background(color = MaterialTheme.colors.surface)
    modifier to the
    Column
    ? Which one would you consider better practice?
    f
    • 2
    • 1
  • i

    iamthevoid

    05/12/2022, 8:17 AM
    is it possible in compose redraw parent, but not redraw a child? For example i want single point for bottom sheet showing - and all app content must be placed inside BottomSheet content. But there can be different bottom sheets. And here i meet the need to change wrapping view (bottom sheet) without changing its content (the app) Can i do that somehow? I can just have single bottom sheet and change it layout, but it isnt looks good
    j
    a
    • 3
    • 5
  • t

    Tin Tran

    05/12/2022, 8:53 AM
    Has anyone has problem with the new live edit? I can’t seem to enable it even after upgrading to compose 1.2.0-beta01. After every change it shows out of date on the preview and I have to manually refresh it
    ➕ 1
    j
    f
    l
    • 4
    • 6
  • m

    Marcin Wisniowski

    05/12/2022, 11:11 AM
    I seem to be having a weird issue where compose preview shows wrong resources. The preview shows a different drawable or different string than what is referenced in the code. As if something was messing up resource IDs in previews.
    l
    • 2
    • 1
  • d

    dimsuz

    05/12/2022, 11:24 AM
    Why does this keeps recomposing
    Button
    slot's content and printing "recomposing"?
    MaterialTheme {
      val handler = { _: TextLayoutResult -> }
      MyButton(handler)
    }
    
    @Composable
    fun MyButton(handler: (TextLayoutResult) -> Unit) {
      val state by flowOf("two", "three").collectAsState("one")
      Button(onClick = {}, enabled = state == "two") {
        println("recomposing content")
        Text(text = "Button", onTextLayout = handler)
      }
    }
    If I remove "handler" parameter recomposition happens only once. Is there a way to somehow mark "handler" as stable?
    a
    h
    +2
    • 5
    • 15
  • l

    Lilly

    05/12/2022, 12:43 PM
    Lets say we have a main screen with a
    Scaffold
    .The Scaffold has a
    BottomNavigation
    and a
    TopAppBar
    . Navigating between the child screens means switching the content of the Scaffold. How can I have different TopBar actions on each screen? Do I have to drop the TopAppBar of the main screen and let the child screens have its own Scaffold with TopAppBar ? Another possibility I'm aware of would be to pass down the related TopBar composable and switch it on screen change like I do it with the screen content?
    m
    • 2
    • 4
  • m

    mattinger

    05/12/2022, 12:47 PM
    Hi all. So i’m using Kover with the IntelliJ coverage engine, but i’m still getting a lack of branch coverage despite actually covering all the branch conditions in my function. It seems pretty consistent that all the opening and closing braces on a Composable function are marked this way. As a result, i’m missing. a bunch of branches in my overall coverage number. I thought the intellij engine was supposed to handle this sort of stuff better than jacoco?
    r
    • 2
    • 1
  • t

    Tgo1014

    05/12/2022, 12:58 PM
    I’ve a
    LazyRow
    where the items can have different sizes, as it’s the last composable on the bottom of the screen, if when scrolling the user scrolls to a smaller item than the ones displayed first the screen moves up, which makes it seems weird. My question: is there a way to set the
    height
    of a
    LazyRow
    to be of its tallest item?
    a
    • 2
    • 3
  • s

    Slackbot

    05/12/2022, 2:31 PM
    This message was deleted.
    c
    j
    • 3
    • 3
  • i

    Ian Warwick

    05/12/2022, 4:17 PM
    Regarding hybrid testing. I could not find much information about testing espresso/compose mixed tests however did find some information relating to
    createEmptyComposeRule()
    however in practice using it with espresso tests with
    ActivityScenario
    based tests has issues with idling resource timeout. I found this repo that demonstrates the issue https://github.com/Maksim-Novikov/ComposeUiTestsBug (check the only
    andoridTest
    test there) I am not sure the source of this repo but a github community member posted it I guess however it demonstrates a workaround for my exact issue. My question is anyone using this approach and is there an official bug or something raised regarding this and the workaround? I can’t find anything 😞
    • 1
    • 2
  • r

    Rick Regan

    05/12/2022, 4:57 PM
    I’m trying to use Compose instrumented tests to check that moving a discrete slider (with integer values) causes its associated text node to display the current slider value. I make the movement using
    performTouchInput
    and check the text with
    hasText
    . The way I devised to move the slider doesn’t work for all ranges, so I’m looking for suggestions for the best (correct) way to move it. (See 🧵 for details.)
    k
    • 2
    • 6
  • t

    Tolriq

    05/12/2022, 7:26 PM
    Is there some nice documentation about animation as UI/UX like what animation spec convey what intent and things like that? Compose makes it easy to do many things, but as non designer there's so many options that I have no idea where to start.
    👀 1
    d
    • 2
    • 3
  • s

    Simon Stahl

    05/12/2022, 8:04 PM
    Is there a good way to measure time to UI in compose? Meaning, can I measure how long it takes to fully render a UI?
    b
    • 2
    • 10
  • f

    FunkyMuse

    05/12/2022, 10:41 PM
    Anyone? It's a critical issue, if on destroy isn't called: • Can't set result to previous screens • Can't clear resources properly if using that lifecycle callback • View models never call onCleared https://kotlinlang.slack.com/archives/CJLTWPH7S/p1652357807849139
    🤔 1
    • 1
    • 1
  • f

    fengdai

    05/13/2022, 1:43 AM
    In which scenario can a LifecycleOwner change?
    s
    i
    • 3
    • 2
Powered by Linen
Title
f

fengdai

05/13/2022, 1:43 AM
In which scenario can a LifecycleOwner change?
s

Stylianos Gakis

05/13/2022, 7:39 AM
I don’t know specifically when that might happen, but it’s good style to always pass the dependencies that are used inside there as keys no matter what. If it needs to be keyed for correctness, just do it. If you have to think about “oh this never changes, so I won’t do it” you will end up with possible false negatives where you don’t pass something that you should, and that leads to incorrect behavior. In contrast, if you do pass something that guaranteed will never change, it’s still gonna work as intended. tl;dr always pass the correct dependencies as keys there, you can’t go wrong by doing so.
i

Ian Lake

05/23/2022, 8:18 PM
If it exists within a
movableContentOf
, it could be reparented onto another tree that has a different LifecycleOwner (i..e., a different screen if you are using Navigation Compose)
👍🏻 1
View count: 2