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

    Slackbot

    09/09/2022, 4:32 AM
    This message was deleted.
  • z

    Zoltan Demant

    09/09/2022, 9:36 AM
    Ive been doing
    LaunchedEffect(list.size){ scrollToTop() }
    in order to scroll my
    LazyColumn
    to the top whenever the list size changes. This works great, but it also scrolls the list to the top whenever I navigate back to it since the LaunchedEffect is restarted. I could work around this with
    rememberSaveable
    , but that doesnt seem ideal. Is there another better approach?
    a
    • 2
    • 6
  • a

    AmrJyniat

    09/09/2022, 10:47 AM
    Does
    AnimatedVisibility
    disable/ignore the padding of its children?
    AnimatedVisibility(visible = isExpanded) {
        Divider(
           modifier = Modifier.padding(bottom = 12.dp).fillMaxWidth(),
           color = Gray200,
           thickness = 2.dp
        )
    
        OutlinedButton(
            modifier = Modifier.padding(top = 12.dp),
            onClick = {}
        ){}
    }
    The padding of both divider and button has no effect when wrapping them within AV, but when I comment AV out the padding works well, am I missing anything?
    l
    • 2
    • 2
  • c

    Colton Idle

    09/09/2022, 12:46 PM
    Does this look wrong to anyone?
    LaunchedEffect(viewModel.screenState.something != null)
    Should it instead be
    LaunchedEffect(viewModel.screenState.something
    and then do the null check inside (or outside of) the LE?
    z
    c
    +2
    • 5
    • 5
  • s

    Stylianos Gakis

    09/09/2022, 2:46 PM
    Try turning the item into smth like
    Spacer(Modifier)
    and see if it still recomposes. If not, then the problem is in the item itself. From guessing I’d say it should not recompose unless you’re inside the item reading something related to the scroll-state or some other state which changes while scrolling
    a
    s
    • 3
    • 7
  • u

    Ugnius N.

    09/09/2022, 3:17 PM
    Hey guys! Is there any way to control two horizontal pagers with a single pager state? I want to control them bidirectional, but for now I only found a solution to use different states and write some logic to control oneeachother
    c
    • 2
    • 2
  • c

    Chris Fillmore

    09/09/2022, 5:16 PM
    If I try to run a composable
    @Preview
    on a device, I get an error of the sort: https://stackoverflow.com/q/68554294
    i
    • 2
    • 10
  • a

    Aaron Waller

    09/09/2022, 6:51 PM
    Does someone know how to setup a Instagram-Like BottomNavBar? Example: The “Home” Icon in the BottomNavBar stays selected even when the user clicks on a profile or the comments of a post. Also when the user clicks the “Home” icon again it goes back to the feed but only if he already selected the Home tab. When the user is on the Explore tab and clicks back to Home he continues right where he left off. I tried it with Nested Navigation but couldn’t get it right, am I on the right path?
    i
    s
    • 3
    • 22
  • y

    yogaboy

    09/10/2022, 6:14 PM
    Hey guys! Is there any implementation in Material3 swipe to dismiss on LazyColumn?
    rememberDismissState
    is missing in M3. Pls. any example or tutorial? I read the documentation for compose and material3 and I can’t find anything even on github. Thanks a lot 🙏🏻
    j
    c
    g
    • 4
    • 21
  • t

    Tariyel Islami

    09/10/2022, 7:57 PM
    Hi guys, I’m doing the Instagram clone. I’m stuck in the User section. There has to be a current user and other users. Do I need to do all the operations in a single UserViewmodel or do I need to separate them as CurrentUserViewModel and otherUserViewModel? Or How should be best practice?
    y
    m
    • 3
    • 5
  • a

    andrew

    09/11/2022, 4:40 AM
    Well, compose officially won me over fully. Getting back into AOSP fw dev and the view system is such a drag to work with 😆
    r
    • 2
    • 3
  • c

    Chachako

    09/11/2022, 6:12 AM
    Here is a paging problem: the data of items in
    LazyColumn
    comes from two different APIs. “A-API” is the basis of “B-API” so paging requests complete item data is very slow. The data of the “B-API” is not urgently needed. I hope it can be loaded lazily. Is there any way?
    m
    • 2
    • 3
  • y

    yogaboy

    09/11/2022, 6:07 PM
    Well, does anyone here understand M3 design tokens please? Why Material Theme Builder generates System token and not reference token?
  • m

    mgrazianodecastro

    09/12/2022, 12:50 AM
    How to change the pressed color of a clickable box? I don't mean the box's color, but the click's color 🤔
    t
    • 2
    • 4
  • m

    mgrazianodecastro

    09/12/2022, 4:09 AM
    btw, is anyone besides me having some issues with blend mode on draw modifiers within the components of a lazy column? When the scroll reaches the top or bottom of the page the components get the usual stretch, and when that happens the blend overlay effect just dies until the stretch finishes.
    r
    • 2
    • 7
  • z

    Zoltan Demant

    09/12/2022, 9:55 AM
    (Animations 🌠*):* Ive managed to fine tune my app to some extreme smoothness, but I cant really seem to acheive the same smoothness when using
    AnimatedContent
    . Theres almost always a slight stutter when using it to transition to a new screen; and its almost always exclusive to the first time the screen is shown - from there and on the transition is smooth for as long as the app is running. Using R8, baseline profiles, etc. Is this a known issue; or am I simply doing something wrong? Ill attach a simple code example in the thread. 🧵
    • 1
    • 1
  • z

    Zoltan Demant

    09/12/2022, 10:12 AM
    Heres a discussion about it! https://kotlinlang.slack.com/archives/CJLTWPH7S/p1662557589916869
    t
    • 2
    • 3
  • t

    Tgo1014

    09/12/2022, 10:33 AM
    Are you going to make some app that does this? 👀
    z
    a
    • 3
    • 3
  • a

    Asad Mukhtar

    09/12/2022, 10:39 AM
    Hi, how i use the api response from viewModel to Composable function? Like i have a this code, how i observe the flightsList and show the data in Composable function?
    private val _flightList = MutableLiveData<List<FlightListingUiModel>>()
    val flightsList: LiveData<List<FlightListingUiModel>> = _flightList
    m
    • 2
    • 1
  • i

    Isaac Udy

    09/12/2022, 10:59 AM
    Does anyone know if there is a way to keep
    remember
    state alive between calls to
    movableContentOf
    ? I currently have a situation where I am doing something like this:
    val moveable = remember { moveableState { DrawAnItem() } }
    if(visible) moveable.invoke()
    The problem is that when “visible” gets toggled, all `remember`ed state inside
    DrawAnItem
    is reset. However, if I do this:
    val moveable = remember { moveableState { DrawAnItem() } }
    if(visible) moveable.invoke()
    else {
        Box(modifier = Modifier.alpha(0f)) {
            moveable.invoke()
        }
    }
    the `remember`ed items are properly remembered in between calls to “visible”. This obviously isn’t a very good solution, but I’m trying to figure out how to keep a composable “alive” when I know that I’m going to render it again in the not-too-distant future.
    f
    z
    • 3
    • 5
  • a

    Asad Mukhtar

    09/12/2022, 12:25 PM
    Hi, how i show compose skeleton while making api call and on the response show UI instead of skeleton?
    a
    • 2
    • 1
  • a

    Adrian Landborn

    09/12/2022, 1:29 PM
    Just to make it clear. The screenshot is on a Left and Right variant of a button.
    r
    m
    d
    • 4
    • 5
  • u

    Uli Bubenheimer

    09/12/2022, 7:35 PM
    Is the calculation of
    currentCompositeKeyHash
    aka
    currentComposer.compoundKeyHash
    well-defined?
    rememberSaveable()
    uses it for save keys, but if I add something like
    key(objectWithDefaultHashKey)
    to my Compose hierarchy then I assume the save key will be different before and after process death, and whatever I saved would not be restored, right? My particular use case has
    key(enumValue)
    , which I assume would also have different hash values before and after process death, based on what
    Enum.hashCode()
    does. Would I be in the clear then, as far as
    rememberSaveable()
    goes, if I used something like
    key(enumValue.myStringLabel)
    instead? The reason for my question is this comment from a Googler: https://issuetracker.google.com/issues/152014032#comment4
    a
    • 2
    • 1
  • c

    Chris Fillmore

    09/12/2022, 7:49 PM
    I’m trying to get
    @Preview
    working in a multi module project. Has anyone had trouble doing this?
    a
    • 2
    • 13
  • k

    KoskiA

    09/12/2022, 8:18 PM
    Does anyone have advice on how to keep a
    LazyColumn
    at a specific scroll amount, instead keeping an item/key visible, when inserting items? (i.e. sticking to the top of the list when inserting at zero)
    a
    • 2
    • 5
  • l

    Lilly

    09/12/2022, 11:02 PM
    What is the right way to provide state for a specific item of a
    LazyColumn
    ? Currently the state is applied to all items. Example code:
    @Composable
    private fun ScannerList(
        items: List<DiscoveredBluetoothDevice>,
        connectionState: ConnectionState, // StateFlow in view model
    ) { ...
    
    private fun ScannerListItem(
        connectionState: ConnectionState,
        ...
    ) {
        ListItem(
           trailing = {
               Button(onClick = {  // trigger change of connectionState in view model })
               val iconColor: Color = when (connectionState) { ConnectionState.Connected -> Green600 ... }
           }
        ) 
    }
    Do I have to narrow down
    List<DiscoveredBluetoothDevice>
    so I get sth like
    List<DiscoveredBluetoothDeviceItem>
    ?
  • t

    Tariyel Islami

    09/13/2022, 12:28 AM
    hi guys, The viewmodel is cleared when popbackstack is called or when I press the back button . But when I come back to the screen it doesn’t start again. Is there a proper solution to this?
    i
    o
    s
    • 4
    • 16
  • c

    Colton Idle

    09/13/2022, 3:16 AM
    Anyone from accompanist here? I'm only seeing 0.26.2-beta but according to ben-manes version plugin, I'm out of date? https://github.com/google/accompanist/releases
    j
    b
    • 3
    • 2
  • o

    Oliver.O

    09/13/2022, 10:48 AM
    During some lab exercises targeting Compose usage on big screens with lots of Composables, I discovered a scenario where excessive slot table operations were rendering the UI unresponsive for tens of seconds. Maybe of interest to the Compose team? (It's a Desktop/Web/WASM lab application but the slot table is part of Compose runtime, so this applies to other platforms, too.) Details in 🧵.
    o
    c
    • 3
    • 5
  • s

    steelahhh

    09/13/2022, 1:39 PM
    Started seeing this exception on some modules
    e: Multiple values are not allowed for plugin option androidx.compose.compiler.plugins.kotlin:metricsDestination
    when I try to run composable metrics Don't see any other obvious source where this value would come from aside from my own code. Any ways to debug this properly?
    e
    • 2
    • 5
Powered by Linen
Title
s

steelahhh

09/13/2022, 1:39 PM
Started seeing this exception on some modules
e: Multiple values are not allowed for plugin option androidx.compose.compiler.plugins.kotlin:metricsDestination
when I try to run composable metrics Don't see any other obvious source where this value would come from aside from my own code. Any ways to debug this properly?
e

ephemient

09/13/2022, 1:46 PM
first guess: are you on Windows? that snippet won't work (and I don't have Windows to figure out an equivalent)
s

steelahhh

09/13/2022, 1:53 PM
I'm running this on Mac OS, so sadly that's not it
e

ephemient

09/13/2022, 2:04 PM
hmm. does your path have a
:
or any other special characters in it? or are you somehow applying other command-line arg additions in some modules?
s

steelahhh

09/13/2022, 2:08 PM
I am adding other command line args in common module config, but nothing Compose-related Might be somehow caused by kapt + molecule (at least this is the diff from modules where metrics work) 🤔
That was exactly the reason Removing either
kapt
or molecule plugin solves the issue and metrics run just fine Time to give anvil a go, I guess 😛arrot-upside-down:
View count: 161