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

    Ayfri

    07/18/2021, 9:15 PM
    Hi, why can't we create Composable with lambda references I mean
    ::MyComponent
    , I tried to use it in
    myArray.forEach(::MyComponent)
    but it throws an error 🤔
    a
    • 2
    • 1
  • n

    Nathan Castlehow

    07/19/2021, 3:32 AM
    Bit of an architecture question if anybody has a sec? I have some temporary state which should be shared between (and updated by) two distinct screens. It’s not a repository level thing as its just some temporary state. Trying to find the best way to get this state into the relevant screen view model. Explored options in thread
    s
    k
    +2
    • 5
    • 22
  • k

    Kefas

    07/19/2021, 4:08 AM
    If Compose is not able to infer the stability of a type, annotate the type with
    @Stable
    to allow Compose to favor smart recompositions.
    How do we know that compose is able (or not able) to infer the stability of a type?
    👀 4
    m
    • 2
    • 1
  • m

    ms

    07/19/2021, 6:21 AM
    Is there any manager or LocalProvider to control ModalBottomSheet? I have a
    HorizontalPager
    which has 3 pages, if I use a ModalBottomSheet in 3rd page & show it, I can still scroll to other pages even though the BottomSheet is visible, which is not the behaviour when using layouts
    a
    • 2
    • 5
  • m

    Md. Nazmun Sadat Khan

    07/19/2021, 7:05 AM
    Hello! I am a hobbyist trying to learn Android programming with Kotlin. I am trying to learn Jetpack Compose by making toy projects. I am currently working on an app that displays XKCD comics complete with double-tap to zoom, pinch, pan and fling gestures. To achieve this, I am currently using two pointerInput with different keys, one to detect double taps using detectTapGestures, and another to detect pans/drags using detectDragGestures. Finally, I am using transformable to detect multi-finger gestures like pinch-zoom. This setup works, but I am not sure that if this is the best way to go about it. I have a number of questions on this: Is it okay to use multiple pointerInput on the same widget? Does it impact performance in any way? What exactly is the role of key1 argument of pointerInput? Should they be different for different pointerInput? It seems that I can't use more than one gesture detectors within the same pointerInput scope, as the first one seems to "consume" the event. Is there any way to prevent this, or is this by design? I can't find many resources on Google where multiple gestures are implemented on the same object.
    a
    • 2
    • 4
  • a

    Adib Faramarzi

    07/19/2021, 8:27 AM
    does
    TextField
    expose anything related to focus? In other words, how can one be notified of something like
    isFocused
    ?
    f
    m
    d
    • 4
    • 26
  • t

    Tiago Nunes

    07/19/2021, 12:32 PM
    Hey everyone, how do I send a one-time event from the viewmodel to the composable? I want to navigate after a long operation
    👍 1
    t
    n
    +5
    • 8
    • 50
  • a

    Adib Faramarzi

    07/19/2021, 1:16 PM
    Is there any reason that I’m not seeing the Compose’s toolbar? There used to be multiple buttons for changing themes and deploying a certain preview, but currently there are only 3 buttons: Refresh, Switch Layout and Select Design Surface
    i
    • 2
    • 4
  • c

    Colton Idle

    07/19/2021, 2:13 PM
    When building a purely compose application, where do I out the logic for "if user is logged out, go to LoggedOutScreenComposable". Currently I'm passing shared prefs into my main App composable and doing the check there but that seems wrong, although it works.
    m
    • 2
    • 1
  • m

    Mehdi Haghgoo

    07/19/2021, 2:39 PM
    Hey Composers! Is it possible to have 3d rotations in Compose animations? The typical roll-type one-dimensional rotation does not seem to be enough in creating some animations. Does Compose support rotation around X, and Z axes in addition to the Y axis which is already in place?
    :yes: 1
    d
    • 2
    • 2
  • y

    Yuri Drigin

    07/19/2021, 2:49 PM
    Hi folks! I need to set priority (content resistance) to item in
    Row
    but cannot figure out how to do it. For sample I have few texts in Row, but I need truncate the first one for sample, not the last
    weight
    isn’t correct way to do it Thanks
    Untitled.kt
    a
    • 2
    • 11
  • a

    alorma

    07/19/2021, 3:29 PM
    Hi! Is it possible u sing
    LazyColumn
    to have
    stickyHeader
    that overlaps the first item of
    items
    ?
    d
    • 2
    • 2
  • e

    emmanuelvinas

    07/19/2021, 4:44 PM
    Hi, is there a way to paint an ImageVector into a canvas or more generally a Painter? Or maybe a way to convert an ImageVector to an ImageBitmap ?
    a
    • 2
    • 1
  • o

    orangy

    07/19/2021, 5:09 PM
    I don’t know much about accessibility, screen readers and related matter, but I wonder what is the proper way to make a checkbox with text accessible? Material component has
    Checkbox
    but it doesn’t have a label. Of course, I can make a
    Row
    with checkbox and text, but they won’t be semantically connected (and I need special handling for label tap to toggle checkbox). What is the proper way of making labeled checkbox with accessibility in mind?
    j
    b
    a
    • 4
    • 7
  • t

    TheDukerChip

    07/19/2021, 6:59 PM
    I have been using LazyColumn to load list of items with paging-compose library Here is the code
    @Composable
    fun ListOfItems(pagedItems: Flow<PagingData<Item>>) {
        val items: LazyPagingItems<Item> = pagedItems.collectAsLazyPagingItems()
    
        LazyColumn {
            items(items) { item ->
                ItemCard(item)
            }
        }
    }
    Problem is scrolled state is not retained when the screen is rotated Tried with the following
    val listState: LazyListState = rememberSaveable(saver = LazyListState.Saver) { LazyListState() }
    val scrollState: ScrollState = rememberSaveable(saver = ScrollState.Saver) { ScrollState(0) }
    
    LazyColumn(
        modifier = Modifier
            .scrollable(scrollState, Orientation.Vertical),
        state = listState,
    ) {}
    Still got no luck
    d
    • 2
    • 2
  • b

    brandonmcansh

    07/19/2021, 7:23 PM
    Randomly hitting this today:
    IllegalStateException: Couldn't obtain compiled function body for IrBasedSimpleFunctionDescriptor: FUN FUNCTION_FOR_DEFAULT_PARAMETER name:Column$default visibility:public modality:FINAL <> (modifier:androidx.compose.ui.Modifier?, verticalArrangement:androidx.compose.foundation.layout.Arrangement.Vertical?, horizontalAlignment:androidx.compose.ui.Alignment.Horizontal?, content:@[Composable] @[ExtensionFunctionType] kotlin.Function1<androidx.compose.foundation.layout.ColumnScope, kotlin.Unit>, $mask0:<http://kotlin.Int|kotlin.Int>, $handler:kotlin.Any?) returnType:kotlin.Unit [inline]
    • 1
    • 2
  • n

    Nat Strangerweather

    07/19/2021, 7:36 PM
    is anyone aware of some sample code for the button animation featured here: https://material.io/blog/jetpack-compose-beta. I am talking about the top left one.
    d
    • 2
    • 6
  • c

    Colton Idle

    07/19/2021, 8:01 PM
    Getting this error:
    java.lang.IllegalArgumentException: navigation destination -2074115716 is not a direct child of this NavGraph
    Simple repro code in thread
    • 1
    • 2
  • d

    Daniel Burnhan

    07/19/2021, 8:36 PM
    Hey guys. Have a few more questions on compose navigation. Im using the navigation component. How are you guys handling global states like logged in and logged out? Before I was handling like the following
    class MyAppModel: ViewModel{
        val loggedInState: Flow<Boolean>
    }
    
    class MainActivity : ComponentActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            "SETUP APP MODEL HERE"
            val myAppModel= MyAppModel()
            setContent {
                MyUI(myAppModel)
            }
        }
    }
    
    @Composable
    fun MyUI(vm: MyAppModel){
        val loggedIn = vm.loggedInState.asLiveData().observeAsState()
        when (loggedIn.value){
            is true -> DasboardUI()
            is false -> AuthUI()
        }
    }
    Now that I have a navgraph. It seems like Ill have to have to observe this state in every path in the navgraph to be able to react to it? Otherwise I could create two separate navigation hosts and have them separate for Authentication workflow and the rest of the app?
    ➕ 1
    i
    c
    • 3
    • 11
  • j

    Jason Inbody

    07/19/2021, 11:44 PM
    What does the error
    java.lang.IllegalStateException: pending composition has not been applied
    imply? I recently copy and pasted some google map code and now I'm getting this error
    • 1
    • 4
  • p

    Philip Dukhov

    07/20/2021, 6:31 AM
    Hello! I had a discussion about text field focus on issue tracker, but probably slack is a better place to continue it. I can’t understand, why would text field need focus after keyboard is dismissed? Google engineer says: “It allows the user to dismiss the keyboard, but still continue typing on the keyboard without the user having to hit tab multiple times to re-focus on the TextField that was previously focused.“. What means “hit tab multiple times to re-focus” here? User needs one click on text field to start editing, no matter focused it or not, am I missing something? Is there another way to show keyboard for a focused text field?
    a
    • 2
    • 3
  • a

    Abhishek Dewan

    07/20/2021, 7:44 AM
    Could someone please advise as to why during recomposition the scaffold state seems to be working as intended by the isTopBarEditing state is always reset to false. This is SearchTab is part of a bottom navigation bar and anytime I navigate away and come back to it, the scaffold state seem to hold the position of the SearchResults composable without a problem but isTopBarEditing is always reset to false (added snippet in thread)
    a
    • 2
    • 3
  • m

    Michal Jezierski

    07/20/2021, 8:56 AM
    Hello, is it possible to focus BasicTextField by calling requestFocus on FocusRequester (or other way) BUT WITHOUT triggering keyboard ?
    a
    r
    • 3
    • 3
  • a

    allan.conda

    07/20/2021, 10:32 AM
    We have a requirement to have a row with two boxes, and the width of each box is same as the widest box. Any idea how to achieve this optimally in Compose? I have a working solution but it requires multiple passes and flickers in the process.
    👀 2
    d
    m
    d
    • 4
    • 4
  • t

    Todor Grudev

    07/20/2021, 10:47 AM
    Hello 🙂 what’s the best way to access a string resource inside a coroutine scope? Code in a :thread-please:
    a
    a
    • 3
    • 4
  • d

    dimsuz

    07/20/2021, 11:43 AM
    I am getting some weird kotlin compiler internal error exception while compiling specific
    rc02
    -based composable. It says it can't inline
    Box$default
    . Is this some known bug or should I report it? Exception: https://gist.github.com/dimsuz/99c94126807cfa6ca1dc515228a8913a
    • 1
    • 1
  • c

    Colton Idle

    07/20/2021, 1:18 PM
    Looking at compose navigation docs. They say
    Testing
    We strongly recommended that you decouple the Navigation code from your composable destinations to enable testing each composable in isolation, separate from the NavHost composable.
    What does that last bit mean? Decouple nav code from composables EXCEPT the navHost composable (since there's no real way to decouple that, right?). Just checking because I'm not familiar with the "separate from" terminology.
    i
    • 2
    • 1
  • m

    Mehdi Haghgoo

    07/20/2021, 1:49 PM
    I see Missing classes error for all previews.
    ➕ 1
    b
    g
    d
    • 4
    • 3
  • j

    Joey

    07/20/2021, 2:22 PM
    I'm currently using the vanpra compose date/time pickers which is pretty good, but I was wondering if any official implementations are also planned?
    a
    • 2
    • 2
  • s

    Simon Hardt

    07/20/2021, 2:58 PM
    I'm having trouble getting compose previews in android studio when using compose
    1.0.0-rc02
    (or rc1). it used to with
    1.0.0-beta09
    . I've tried AGP
    7.0.0-beta05
    (current studio beta) and
    7.1.0-alpha03
    (current studio canary). I'm getting the following error. any ideas?
    a
    • 2
    • 1
Powered by Linen
Title
s

Simon Hardt

07/20/2021, 2:58 PM
I'm having trouble getting compose previews in android studio when using compose
1.0.0-rc02
(or rc1). it used to with
1.0.0-beta09
. I've tried AGP
7.0.0-beta05
(current studio beta) and
7.1.0-alpha03
(current studio canary). I'm getting the following error. any ideas?
a

Abhishek Dewan

07/20/2021, 3:01 PM
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1626788987082600
👍 2
View count: 2