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

    pourpre

    11/04/2020, 5:44 PM
    Does anyone know of any samples using navigation-compose specifically the passing and receiving of arguments? The current samples don't use arguments.
    i
    • 2
    • 7
  • v

    Vivek Sharma

    11/04/2020, 6:58 PM
    Box and Stack are same? , I dont get the difference between them
    a
    • 2
    • 4
  • t

    Tash

    11/04/2020, 7:58 PM
    Frequently seeing the following build error on
    AS 4.2 Canary 15
    &
    1.0.0-alpha04
    :
    e: java.lang.IllegalArgumentException: Unbound type parameters are forbidden: [Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@4decb5a, Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@45aa5e3d]
    Haven't had success with isolating it to anything in particular. Anyone know what might be causing this?
    l
    • 2
    • 22
  • g

    Gabriel

    11/04/2020, 7:59 PM
    mutableStateOf
    is something that was introduced as part of compose right?
    l
    • 2
    • 2
  • g

    Gabriel

    11/04/2020, 8:01 PM
    Hey folks, I'm using mockito to mock a viewmodel and then return certain values, my view model contains this where imageItems is
    var imageItems: List<ImageItem> by mutableStateOf(listOf())
    	private set
    and then my mock looks like this
    @Mock
    lateinit var viewModel: ImageListViewModel
    ...
    
    `when`(viewModel.imageItems).thenReturn(listOf())
    but doing this gives me an error:
    java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object androidx.compose.runtime.State.getValue()' on a null object reference
    would anyone know what I'm doing wrong?
    z
    • 2
    • 13
  • m

    Manuel Lorenzo

    11/04/2020, 11:07 PM
    hi everybody! I don’t know if this has already been asked around here, but here’s my question: I have a composable which is the one inside my main content, that has a scaffold with a top bar, a content and a bottom navigation bar. I’m creating more composables in the content part, and in this case I have a
    LazyColumnFor
    , and I’m also using the navigation for compose. My question is that when I click on an item from the composable that has the
    LazyColumnFor
    I’m navigating to the detail composable of that item (let’s call it
    ItemDetail
    ) and here, I see that the content is between the top bar and the bottom nav bar of the scaffold of the parent component. Is it possible to have a reference to the top bar and the bottom nav bar? For example I want to add the back arrow to the top bar for the up navigation. Thanks in advance!
    z
    i
    a
    • 4
    • 20
  • c

    Colton Idle

    11/05/2020, 12:43 AM
    Anyone using gson or moshi (reflection based) with Compose? Simply enabling compose (I'm not even using an compose code) in a project with reflection causes kotlin reflect to crash at runtime. https://youtrack.jetbrains.com/issue/KT-42322 Just curious if someone has figured out some kind of workaround yet.
    a
    • 2
    • 3
  • a

    Archie

    11/05/2020, 5:40 AM
    Hi @Ian Lake, Is there a way to set a Destination's arguments to take it from a
    stringResource(...)
    ? Since
    navArgument(...)
    isn't a
    @Composable
    function, its not possible to do:
    composable(
        route = Screen.route + ...,
        arguments = listOf(
            navArgument("NAME") {
                defaultValue = stringResource(id = R.string.placeholder)
            },
        ),
    ) {
        ...
    }
    i
    • 2
    • 3
  • k

    Kshitij Patil

    11/05/2020, 6:14 AM
    Do we have support for compose to be diagonally draggable? https://stackoverflow.com/questions/64379464/how-to-create-a-drag-gesture-in-any-direction-in-android-jetpack-compose
    a
    • 2
    • 3
  • k

    Karthick

    11/05/2020, 10:38 AM
    I have Idea 2020.2.3 Community Edition, but unable to see compose in new project wizard for compose desktop
    j
    • 2
    • 3
  • d

    David Wadge

    11/05/2020, 11:31 AM
    Anyone else having an issue with the
    OutlinedTextField
    not displaying the keyboard on focus?
    • 1
    • 1
  • g

    Grigorii Yurkov

    11/05/2020, 12:12 PM
    Is it possible to rotate an
    Image
    ?
    s
    • 2
    • 2
  • l

    Lilly

    11/05/2020, 12:56 PM
    Hey guys, I wasn't active in compose for a while. What are the current best practise samples/howTo's/playgrounds I should be aware of? Thanks in advance!
    h
    s
    t
    • 4
    • 5
  • a

    Arun

    11/05/2020, 2:29 PM
    Hi, there's a
    Divider
    composable for horizontal dividers. Will there be a counterpart for vertical?
    j
    • 2
    • 3
  • a

    alorma

    11/05/2020, 2:33 PM
    if you set the
    prefredHeight
    won't it work?
    a
    • 2
    • 1
  • g

    Grigorii Yurkov

    11/05/2020, 3:54 PM
    Can we replace
    ValueAnimator
    with some function from compose, or we still have to use it? In my case I need to show
    CircularProgressIndicator
    animation from 0% to 100% with 500ms duration triggered by button click
    m
    l
    • 3
    • 3
  • d

    David Attias

    11/05/2020, 4:23 PM
    Hey guys, is it possible to use Text to display a clickable link inside a text string ? I can't find a way using AnnotatedString... ?
    j
    a
    • 3
    • 4
  • v

    Vivek Sharma

    11/05/2020, 6:09 PM
    Is there a way to make a circular checkbox?
    • 1
    • 1
  • t

    Tash

    11/05/2020, 6:20 PM
    Hi all. Looking to do a fadeIn -> wait -> fadeOut animation. Would also like to get a listener for when the whole animation is complete. Looking into using
    transitionDefinition
    to build out the flow. Is that the best way to accomplish something like this?
    d
    • 2
    • 2
  • g

    grandstaish

    11/05/2020, 7:54 PM
    Is it somehow possible to pass a value from a parent composable draw scope to a child’s draw scope? I’d like to create (and cache) a
    LinearGradient
    brush in a parent draw modifier, and have a child composable’s draw modifier later use that same
    LinearGradient
    . (This would ensure that I have the same colours and size when the child uses it.) Follow up q: is there anything that I can use within a draw scope that would allow me to know the current composable’s coordinate offset relative to another parent? I.e. the compose equivalent of
    offsetDescendantRect
    a
    • 2
    • 2
  • r

    redrield

    11/05/2020, 8:12 PM
    Is there a way to disable a
    FloatingActionButton
    that I'm missing? cause the only solution i can seem to find is just copying the declaration from compose and adding a new parameter
    r
    s
    a
    • 4
    • 5
  • g

    gpaligot

    11/05/2020, 8:16 PM
    Hi all, I’m trying to use compose navigation but when I want to use
    navController.navigate("my_route")
    , I got an error because it doesn’t find any signature with just a string as first parameter. Someone have any idea why? My full source code:
    @Composable
    fun Screen() {
      val navController = rememberNavController()
      NavHost(navController, startDestination = "movies") {
        composable("movies") {
          MovieHome(navController = navController, movies = movies) {
            navController.navigate("movies_detail")
          }
        }
        composable("movies_detail") {
          MovieDetails(movie = joker)
        }
      }
    }
    s
    i
    • 3
    • 4
  • v

    Vincent tiensi

    11/05/2020, 9:26 PM
    Regarding the Compose Pagination library, I know it’s a little early to ask this since it literally just dropped (Thanks everyone for your hard work!), but is there a cleaner way to save scroll state and pagination data when using
    LazyColumn
    with
    pager.flow.collectAsLazyPagingItems
    ? Right now in order to save both state and items I’ve been lifting out the
    collectAsLazyPagingItems
    output and storing it directly in the fragment since I can only call this method in a @composable and the queried list item data is nested into the PagePresenter.
    a
    j
    a
    • 4
    • 8
  • p

    Patrick Yin

    11/05/2020, 11:03 PM
    Just wondering if Compose has the equivalent method of
    View.announceForAccessibility(String)
    ?
    a
    • 2
    • 3
  • r

    redrield

    11/06/2020, 1:07 AM
    Is there a way to inform the composer that data has been written to a list that doesn't involve duplicating said list each time I need to update it? I'm updating said list at 50Hz which feels like undue strain to put on the GC if im leaking that much memory
    a
    z
    • 3
    • 9
  • z

    ziv kesten

    11/06/2020, 8:44 AM
    Trying to explore compose desktop, separating my android dependencies, dagger would probably work since it's decoupled from android but what about networking? Is retrofit android dependant?
    a
    g
    l
    • 4
    • 12
  • k

    Kshitij Patil

    11/06/2020, 9:00 AM
    How to pass styled attributes to
    AndroidView
    ?
    m
    • 2
    • 2
  • a

    Ashwani Singh

    11/06/2020, 2:07 PM
    Want to render 2 Text lablel on image and image will be download from server using CoiI Image. The problem is when render the image after getting from server text label is hide or went in background. Is there any way to render the text after image dowloaded?
    c
    • 2
    • 1
  • k

    KamilH

    11/06/2020, 2:18 PM
    Is it possible to position UI element in relation to root? I’m gathering element position with `onGloballyPositioned`’s
    positionInRoot
    after that I would like to show another composable which would be full screen (would have the same size as root) and then position some composable in a position I gathered before. Is something like that possible? Maybe there is a method that will let me put (or try to put if it’s in bounds)
    placable
    position relative to root?
    a
    c
    • 3
    • 4
  • j

    James Ward

    11/06/2020, 3:23 PM
    Can anyone point me to an example where a component event handler function calls a suspend fun? I'm trying:
    @Composable
    fun MyButton() {
        Button(onClick = {
            launchInComposition {
                delay(10)
            }
        }) {
            Text("hello, world")
        }
    }
    And getting:
    @Composable invocations can only happen from the context of a @Composable function
    👋 1
    g
    • 2
    • 2
Powered by Linen
Title
j

James Ward

11/06/2020, 3:23 PM
Can anyone point me to an example where a component event handler function calls a suspend fun? I'm trying:
@Composable
fun MyButton() {
    Button(onClick = {
        launchInComposition {
            delay(10)
        }
    }) {
        Text("hello, world")
    }
}
And getting:
@Composable invocations can only happen from the context of a @Composable function
👋 1
Don't know if this is correct, but it seems to work:
@Composable
fun MyButton() {
    val scope = remember { CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate) }

    onActive { onDispose { scope.cancel() } }

    Button(onClick = {
        scope.launch {
            delay(1000)
            println("asdf")
        }
    }) {
        Text("hello, world")
    }
}
g

Grigorii Yurkov

11/06/2020, 4:08 PM
rememberCoroutineScope()
☝️ 1
View count: 2