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

    sashjakk

    11/29/2020, 11:26 AM
    Any ideas how to get item coordinates on screen within Lazy column? 🤔 Wanted to implement something like shared element transition... Or maybe something already available there and me just missed?
    a
    • 2
    • 2
  • s

    Spikey Sanju

    11/29/2020, 1:15 PM
    How to achieve Spannable string multi-text color in Compose?
    a
    • 2
    • 2
  • k

    Kshitij Patil

    11/29/2020, 2:26 PM
    Is there any way to integrate jetpack navigation with navigation compose? Like adding navigation compose as nested navigation in parent navigation or vice versa
    i
    • 2
    • 5
  • v

    Vivek Sharma

    11/29/2020, 2:48 PM
    Is there any library for date/time picker now ? or how can we use Date Time Picker like a dialog fragment?
    f
    • 2
    • 4
  • d

    Davide Bertola

    11/29/2020, 3:02 PM
    Hi, can anybody help me understand how does compose subscribe to state changes for knowing when to recompose ?
    b
    h
    a
    • 4
    • 30
  • h

    Hitanshu Dhawan

    11/29/2020, 8:52 PM
    Hey, what’s the counterpart of
    scrollToPosition(int position)
    in Compose?
    v
    • 2
    • 1
  • v

    Vivek Sharma

    11/30/2020, 9:42 AM
    Has anyone used
    Snackbar
    ? I found 2 methods on docs, 1 is taking
    boolean state
    and making it
    visible/hide
    on button click but here Snackbar doesn't get disappear after some interval (as we are controlling through state). 2 is when using
    Scaffold
    , it has
    snackbarHost
    where we customize our snackbar and display using a
    Coroutine Scope
    . So how can we make Snackbar hide after some time in 1 method? or should we use 2 method
    a
    • 2
    • 3
  • t

    Thiago

    11/30/2020, 12:53 PM
    Playing with recomposition to understand the optimistic scenario, I discovered that I can create a simple bouncing ball without any animation api. Just changing mutable state values. Is that a thing to avoid or is perfectly fine? About hardware resources can things like that consume a lot?
    bouncing_ball.kt
    z
    j
    a
    • 4
    • 10
  • t

    Tristan

    11/30/2020, 2:38 PM
    Hello, I have some difficulties understanding
    by state
    and
    remember
    differences. Could someone guide me towards some documentation about it?
    m
    a
    • 3
    • 11
  • s

    spierce7

    11/30/2020, 4:20 PM
    Has compose gone through performance optimization yet? I found someone who made a small compose benchmark vs standard Android views a while back. His results shows compose running more than 50% slower than Android Views. I updated his benchmark to the latest version of compose, and ran it. I haven’t seen any numbers, but compose is noticeably slower from a user perspective of loading the page. https://github.com/MustafaBasim/uiPerformanceTests
    r
    j
    d
    • 4
    • 6
  • m

    manueldidonna

    11/30/2020, 5:13 PM
    Unfortunately the app doesn't restore the state after a configuration change for a bug in the navigation library. I filed an issue in the tracker https://issuetracker.google.com/issues/174158395
    👍 1
    a
    • 2
    • 2
  • g

    grandstaish

    11/30/2020, 5:30 PM
    What’s the thinking behind making
    RoundedCornerShape
    take a percentage as an
    Int
    instead of a float between 0f-1f? I keep finding myself creating custom CornerSizes to work around this
    n
    • 2
    • 2
  • t

    tylerwilson

    11/30/2020, 5:32 PM
    I am starting to prototype a UI in Compose, and wonder if anybody has a sample or knows how to do something like so: something like a calendar, with a scrollable column of background cells (background), and with overlapping blocks of various sizes that scroll along with those cells. In SwiftUI I got it working with a scrollview inside a scrollview. Wonder if something similar is possible in Compose?? Thanks.
    m
    a
    • 3
    • 5
  • d

    Dominaezzz

    12/01/2020, 12:52 AM
    translate { scale { rotate { drawImage(...) } } }
    in what order are these transformations applied to the drawn image?
    n
    • 2
    • 5
  • n

    Nate Ridderman

    12/01/2020, 2:54 AM
    Anyone know why I can’t clone the source on my Mac? Getting a 400 error when I try
    repo init …
    • 1
    • 4
  • v

    Vincent tiensi

    12/01/2020, 5:19 AM
    I did a quick search on bazel in this chat but nothing showed up, can anyone share their experience working with jetpack compose in bazel?
    👍 2
    j
    a
    y
    • 4
    • 7
  • k

    Kshitij Patil

    12/01/2020, 7:24 AM
    Can we mutate the items list being passed in to the
    LazyColumnFor
    ? Like adding or removing items and expect the changes to be reflected in the
    LazyColumn
    ? Something like
    adapter.notifyDatasetChanged()
    we used to do with
    RecyclerView
    t
    d
    • 3
    • 4
  • g

    Geert

    12/01/2020, 11:31 AM
    I have been looking into SwiftUI lately, and fount this spacing property for rows and columns. I have been searching for it in Jetpack Compose but cannot find it? Is that correct? Do I have to add my own spacing between every item? for example
    Spacer(modifier = Modifier.width(4.dp))
    a
    l
    +2
    • 5
    • 9
  • d

    Daniele B

    12/01/2020, 3:13 PM
    Sharing a slide I am preparing for my next talk, putting KMP and JetpackCompose and SwiftUI on a timeline
    ❤️ 2
    t
    v
    • 3
    • 18
  • j

    Jordi Saumell

    12/01/2020, 8:10 PM
    For new compose apps that don’t rely on fragments I think it makes sense to manually handle config changes. Then, since android ViewModels are designed just to survive config changes, they are not necessary (in those apps). The navigation component is deeply tied to viewModels and I think it should also offer the possibility of working with plain kotlin viewModels (view controllers). It would be more lightweight, not require factories, and make more sense in general, I think. What do you think?
    c
    i
    • 3
    • 21
  • j

    JulianK

    12/02/2020, 11:05 AM
    As Android Studio 4.2-beta1 is out today, can we stay at 4.2 to use compose or is canary still recommended?
    j
    c
    • 3
    • 3
  • a

    Archie

    12/02/2020, 11:29 AM
    Hi @Ian Lake, Is it a bad idea to nest compose
    NavGraph
    ?
    NavHost(mainNavController, startDestination = STARTING) {
        composable(STARTING) {
            StartScreen(navController)
        }
        composable(NEXT) {
            Scaffold(
                topbar = { TopAppBar(...) }
            ) {
                val nestedNavController = ...
                NavHost(nestedNavController, startDestination = FLOW1) {
                    composable(FLOW1) {
                        Flow1Screen(navController)
                    }
                    composable(FLOW2) {
                        Flow1Screen(navController)
                    }
                    ...
                }
            }
        }
    }
    👀 1
    h
    • 2
    • 4
  • j

    Joseph D

    12/02/2020, 11:57 AM
    hi, is there a way to bind the viewmodel's lifecycle to composables'?
    a
    • 2
    • 1
  • v

    Val Salamakha

    12/02/2020, 12:14 PM
    Does Kotlin 1.4.20 support Compose in Android Studio Arctic Fox? Kotlin 1.4.10 works with Compose fine in it.
    j
    • 2
    • 1
  • k

    Kshitij Patil

    12/02/2020, 4:39 PM
    How to use flow with lazyColumn?
    collectAsState()
    or adding each element in a local
    MutableSnapshotList
    using something like
    onEach
    or
    collect { }
    g
    • 2
    • 3
  • t

    tcracknell

    12/02/2020, 6:31 PM
    Hello! The latest Jetpack Compose minor release, alpha08, is here! You can get it now from Google’s Maven Repository. Release notes are available at https://developer.android.com/jetpack/androidx/versions/all-channel. Please note that you will need to update your Kotlin compiler version to 1.4.20 for alpha08.
    😍 21
    🤖 1
    🎉 27
    :kotlin-intensifies: 3
    j
    n
    • 3
    • 4
  • b

    Bradleycorn

    12/02/2020, 6:34 PM
    Are there “gotcha’s” around using
    Flow
    with Composables and
    produceState
    ? For example, consider:
    @Composable 
    fun MyUi(viewModel: ViewModel) {
       val data by produceState(initialValue = "data", viewModel) {
            viewModel.getDataFlow().collect {
                value = it
            }
       }  
    }
    What if the
    viewModel.getDataFlow()
    method uses some flow operator(s)? For example:
    fun getDataFlow(): Flow<String> {
        return myRoomDb.getData().distinctUntilChanged().map { convertEntityToString(it) }
    }
    I think I remember reading awhile back that this can be a problem, because every time there is a recomposition, the operators (in this case map) have to get re-wired up. Which (I think) I understand. So if so, what’s the solution?
    z
    • 2
    • 11
  • k

    koufa

    12/02/2020, 6:46 PM
    Does Jetpack Compose work with Android Studio 4.2 beta or do we need to upgrade to the latest Canary ?
    👍 2
    s
    • 2
    • 1
  • k

    kobby

    12/02/2020, 7:22 PM
    Does the KMM framework support jetpack?
    z
    • 2
    • 1
  • c

    Colton Idle

    12/02/2020, 7:56 PM
    Trying to enable compose in my project (I'm not actually using it anywhere!) and I've been waiting for alpha08 because of kotlin 1.4.20 support and this is the error I get:
    androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0-alpha08) expects a minimum runtime version of 1.0.0-alpha08.
    Anyone else get this?
    j
    j
    • 3
    • 10
Powered by Linen
Title
c

Colton Idle

12/02/2020, 7:56 PM
Trying to enable compose in my project (I'm not actually using it anywhere!) and I've been waiting for alpha08 because of kotlin 1.4.20 support and this is the error I get:
androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0-alpha08) expects a minimum runtime version of 1.0.0-alpha08.
Anyone else get this?
This is all I'm adding to my app level build.gradle
kotlinOptions {
    jvmTarget = '1.8'
    useIR = true
}
buildFeatures {
    compose true
    viewBinding true
}
composeOptions {
    kotlinCompilerVersion '1.4.20'
    kotlinCompilerExtensionVersion '1.0.0-alpha08'
}
root level build.gradle was changed to this:
classpath 'com.android.tools.build:gradle:7.0.0-alpha01'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20"
and gradle was updated to 6.7.1 I've tried cleaning, building, etc. Any other debugging steps I can take here?
j

jaqxues

12/02/2020, 9:56 PM
Did you not update the actual
implementation
clauses?
c

Colton Idle

12/03/2020, 3:11 AM
@jaqxues I'm not actually using anything compose related yet. I'm just trying to enable it in general. So I have no deps with
implementation
yet. @jim or @Leland Richardson [G] any ideas?
j

jim

12/03/2020, 3:30 AM
Do you have anything else in your build files that mentions 
alpha07
?  In particular, what is your 
androidx.compose.runtime:runtime
 dependency version?
c

Colton Idle

12/03/2020, 5:45 AM
@jim I don't have any reference to androidx.compose.runtime. I literally took my existing project, and followed the docs to add compose, so all I added was really this
kotlinOptions {
    jvmTarget = '1.8'
    useIR = true
}
buildFeatures {
    compose true
    viewBinding true
}
composeOptions {
    kotlinCompilerVersion '1.4.20'
    kotlinCompilerExtensionVersion '1.0.0-alpha08'
}
and that's enough to not allow me to compile.
@jim that was the issue. 😭 I simply added
implementation "androidx.compose.runtime:runtime:1.0.0-alpha08"
and it worked. Someone should really clarify in the "Add Jetpack Compose to an existing project" what is mandatory and what's not 😄 https://developer.android.com/jetpack/compose/setup#add-compose It tells you have to configure kotlin, and gradle, but the toolkit dependencies seem optional. tooling previews, material, etc. No mention of
androidx.compose.runtime:runtime:
So close! My issue of simply enabling compose causing kotlin reflect to break still exists in 1.4.20 and alpha-08. 😭 https://issuetracker.google.com/issues/174692120
@jim you fixed it!!! Thank you thank you thank you. We've been wanting to add compose to our project for what feels like months... but could never even simply enable it. Now we'll be able to. Can't wait to try the snapshot/alpha09!!! ❤️
@jim just used a snapshot that became available. Compose works. finally. and it's beautiful 😭
🎉 2
j

jim

12/03/2020, 10:02 PM
🎉 Glad to hear it!
View count: 2