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

    rajesh

    06/29/2021, 6:31 PM
    I want to run the code coming from onClick parameter as well as some local code as shown below. How should I do that?
    fun doSomething(onClick: ()->Unit) {
      //doing something
      Text("some text", modifier =     Modifier.clickable(onClick = onClick + //something that I want to execute here which can't be sent in onClick param)
    }
    j
    • 2
    • 2
  • p

    Peter Mandeljc

    06/30/2021, 7:10 AM
    Is it possible to have like a Surface with border, that fades outwards. Smth like this:
    c
    a
    +2
    • 5
    • 16
  • j

    julioyg

    06/30/2021, 7:47 AM
    Hi everyone! is it normal than when navigating between composables, say have a list/detail model, when i click back the list composable recomposes? as in I click an item on the list, go to the detail, I click the back arrow and the list recomposes. The reason i think this is happening is because the List compose fetches the items using the
    produceState
    delegate from the network and it's called every time I go back, is that the expected behavior or something I'm doing wrong?
    r
    j
    • 3
    • 5
  • r

    rajesh

    06/30/2021, 8:56 AM
    How do I implement exo player in LazyColumn that only play currently visible video element? My current implementation play all videos simultaneously.
    c
    s
    • 3
    • 4
  • m

    martinsumera

    06/30/2021, 9:21 AM
    showLayoutBounds
    is supported within compose but it is integrated deep inside the UI core. I wonder if it is possible to create something like this on my own without tampering with the core. For example, by some modifier which adds some behavior to all subsequent composables.
    a
    • 2
    • 8
  • t

    Tin Tran

    06/30/2021, 9:24 AM
    Hi! How do I stretch image to fill parent bound with accompanist coil? I’ve tried
    scale(Scale.FILL)
    but it didn’t work
    c
    • 2
    • 4
  • o

    Orhan Tozan

    06/30/2021, 9:28 AM
    Will the Compose release of today support KT 1.5.20?
    n
    f
    • 3
    • 3
  • b

    Berkeli Alashov

    06/30/2021, 10:31 AM
    (Code in the thread) What would be the best way to avoid re-composition in this case? or rather avoid pager restarts
    c
    a
    • 3
    • 14
  • d

    Daniele Segato

    06/30/2021, 10:46 AM
    val scale by animateFloatAsState(
        targetValue = when {
            badgeText.isNullOrBlank() -> 0f
            else -> 1f
        },
            animationSpec = spring(
            dampingRatio = Spring.DampingRatioMediumBouncy
        )
    )
    This makes my badge jump a bit with an animation when a new badge is shown on my icon. I also want to make it bounce a bit when it changes value (ex. badgeText "1" -> "2"), say bounce to 1.2f scale and than back to 1f. What's the best way to cause this nudge? I suppose I have to use a
    LaunchEffect
    but than I do not know how to nudge the scale value in an efficient way, thanks in advance for any answer
    a
    d
    • 3
    • 7
  • s

    StefMa

    06/30/2021, 11:07 AM
    Hi guys, is there some commitment, when compose supports new Kotlin releases "by default"? At least on new patch- or even minor-level Kotlin releases? Currently the build fails because of those "we may do not support this Kotlin version. Fix it with the
    suppress
    compiler argument". Is there something in the pipeline? Or is compose, unfortunately, now 100% coupled to an specific Kotlin release and we have to wait for a new release of compose each time a new Kotlin version comes out?
    e
    a
    c
    • 4
    • 6
  • m

    Marko Novakovic

    06/30/2021, 11:11 AM
    can you help to get rid of this jitter? code in thread
    jitter.webm
    m
    • 2
    • 5
  • p

    Piotr Prus

    06/30/2021, 11:15 AM
    Hi everyone! I am struggling with GoogleMaps and its snapshot functionality. In order to prepare a google map snapshot we should use the
    liteMode
    and SnapshotReadyCallback. With this code(code in thread), I am getting crash with error: Bitmap size needs to be more than 0. How can I set the initial size of the googleMap?
    • 1
    • 2
  • n

    Nick

    06/30/2021, 1:13 PM
    I want to load this chart into an
    AppWidget
    on Android. Compose doesn’t work in
    AppWidgets
    . I believe I saw someone on here mention being able to convert a
    Composable
    to an
    ImageView
    ? Is that possible?
    🇳🇴 1
    m
    • 2
    • 5
  • c

    Colton Idle

    06/30/2021, 1:57 PM
    I want to show an error on a text field on AFTER a user has focussed on it and then left it. e.g. I click first name text input, and then click on last name text input, then first name text input should show red "First name required" The samples show how to have an error state, but it's based on validation of the input, not losing focus.
    a
    • 2
    • 2
  • j

    julioromano

    06/30/2021, 2:37 PM
    I noticed ,when writing in a
    BasicTextField
    , that pressing the Android back button triggers a “de-focus” of the textfield. This results in the user having to press back twice for backwards navigation: the first press is to de-focus the text field and the second is to actually navigate to the previous screen. Has anyone experienced this too? I assume this is by design, how to work around this (i.e. navigate back immediately without the de-focus first)?
    ➕ 5
    d
    i
    • 3
    • 5
  • a

    alorma

    06/30/2021, 3:11 PM
    Hi, Is there a way to show an
    AlertDialog
    with custom content? like I want to show a list of itms to select one (like old android AlertDialog.singleChoice())
    ➕ 1
    a
    i
    • 3
    • 6
  • k

    KoskiA

    06/30/2021, 3:37 PM
    Has anyone else noticed an their saved states increasing after converting to Compose? We recently started integrating Compose into our app, and the converted Fragment started triggering our checks preventing large saved state bundles (we used to have a problem with
    TransactionTooLargeException
    ). Compose inflated our saved state by 3x for the Fragment! Kind of surprising given the functional, state-hoisting nature of Compose. I've done some investigating, and there is no smoking-gun culprit, just some inefficiencies (assuming their not required) that add up on complex screens. Findings in 🧵
    👀 2
    :yes: 2
    ➕ 2
    l
    d
    a
    • 4
    • 7
  • d

    Daniele Segato

    06/30/2021, 4:27 PM
    question: Is it possible to avoid the soft keyboard (IME) covering an input
    TextField
    when opening? I've a big form with TextFields. When i click on one close to the bottom of the screen the IME open up and cover it is there a way to make the view scroll up just enough so that the TextField is visible? Is this supposed to happen or am I doing something wrong?
    ➕ 6
    r
    c
    +6
    • 9
    • 35
  • h

    Hardeep Singh

    06/30/2021, 5:02 PM
    How can we integrate Youtube Data API in #compose? I have just integrated Google-Sign-In in my app, and now want to integrate YouTube-Data-API, I tried to follow this guide https://developers.google.com/youtube/v3/quickstart/android, but I don't know how to implement that into Compose.
    c
    • 2
    • 1
  • s

    saket

    06/30/2021, 5:31 PM
    👋 Compose beta09 thinks that my project is using kotlin 1.4.31 instead of 1.5.10. I suspect that this is because some dependencies are pulling in stdlib 1.4.31. Explicitly adding stdlib 1.5.10 as a dependency fixes this error. Is there a better way of solving this?
    error: this version (1.0.0-beta09) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.4.31 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
    I’ve already tried declaring
    kotlinCompilerVersion
    and
    kotlinCompilerExtensionVersion
    under
    composeOptions
    .
    ➕ 1
    e
    a
    • 3
    • 7
  • d

    David Edwards

    06/30/2021, 8:12 PM
    I have been really enjoying trying out Mosaic. I have been slowly introducing it into a bot I am making for a game. Super enjoyable so far. I would encourage anyone making a CLI / Bot to give it a go.
    🎮 3
    :party-parrot: 6
    c
    t
    e
    • 4
    • 9
  • o

    Orhan Tozan

    06/30/2021, 9:30 PM
    Any reason why there was no new Compose release today?
    :yes: 1
    ➕ 3
    j
    e
    a
    • 4
    • 3
  • c

    Colton Idle

    06/30/2021, 10:22 PM
    Feel like I'm missing something basic. Anyone know why this doesn't compile?
    var myCount by remember { mutableStateOf(0) }
    val shouldDisplay = remember { derivedStateOf { (myCount > 1) } }
    m
    t
    h
    • 4
    • 14
  • m

    mattinger

    06/30/2021, 10:31 PM
    Anyone know if there’s a decent equivalent of NumberPicker for compose? The normal android view is way out of date in terms of it’s support for theming, so using an AndroidView wouldn’t really help me. I don’t see any existing Composable that would implement this. I saw some gists on the web for one that scrolls through the numbers, but the non selected numbers are only visible while scrolling, and disappear when a number is actually selected. I’m looking for the style in the system NumberPicker (which also is used in DatePicker and TimePicker)
    d
    • 2
    • 7
  • b

    Ben Abramovitch

    06/30/2021, 10:59 PM
    Hey, if anyone has a moment to take a look at this issue I’m having that would be wonderful. https://stackoverflow.com/questions/68187240/custom-layout-draws-position-0-off-screen-when-content-is-larger-than-screen Essentially when I try to place a placeable off screen, instead of position 0 drawing at position 0, it’s drawing as if the total content was centered, so the further i am off screen, the further x=0 gets drawn, such as -300 I feel like there is maybe a way to handle this with AlignmentLines but i can’t figure it out if so. Also, dividing the difference by two and tacking that on seemed to work for width, but it’s not working for height even if i try to account for the statusbar/toolbars etc, and it. seems pretty hacky anyway
    t
    a
    • 3
    • 47
  • c

    Colton Idle

    07/01/2021, 3:28 AM
    Does this look super terrible and not idiomatic compose? All I want to do is create my own composable called
    OutlinedTextFieldWithFocusLostError
    I have this
    var focusLostCount by remember { mutableStateOf(0) }
    val shouldDisplayError by remember { derivedStateOf { (focusLostCount > 1) } }
    OutlinedTextField( modifier = Modifier.fillMaxWidth(1f)
                      .onFocusChanged { focusState -> if (!focusState.isFocused) { focusLostCount++ } },
    So basically I just want a quick solution on a user clicking on a text field, and then clicking away onto another text field, hence triggering shouldDisplayError which itself runs some validation to check if the input is empty. Having a counter seems a little fishy though, hence the question.
    d
    z
    r
    • 4
    • 14
  • b

    Bagadeshkumar R

    07/01/2021, 5:18 AM
    Hi guys, Is anyone done Flexbox layout in compose?
    a
    • 2
    • 1
  • l

    lhwdev

    07/01/2021, 7:38 AM
    I found that Compose UI swallows error log(but still freezes) inside some places(which seems to be called from ui nodes?) for example inside
    graphicsLayer { /* this lambda */ }
    so far harder to debug. Why does this happen?
    a
    • 2
    • 5
  • m

    Marcin Środa

    07/01/2021, 7:48 AM
    Does Paging 3 no longer returns the
    null
    value during loading data from network? version: 3.0.0, compose: 1.0.0-beta08
    • 1
    • 2
  • l

    Law Gimenez

    07/01/2021, 8:07 AM
    Hi friends, tried migrating to DataStore from SharedPreferences but
    createDataStore
    method not found. I already added the library on Gradle. I’m following Google’s documentation by the way
    p
    • 2
    • 8
Powered by Linen
Title
l

Law Gimenez

07/01/2021, 8:07 AM
Hi friends, tried migrating to DataStore from SharedPreferences but
createDataStore
method not found. I already added the library on Gradle. I’m following Google’s documentation by the way
p

patrick

07/01/2021, 8:13 AM
Not sure which version you are using, but there's something about this in the Release Notes of DataStore for the `alpha07`: https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0-alpha07
l

Law Gimenez

07/01/2021, 8:20 AM
Thanks I’m checking this one https://android-developers.googleblog.com/2020/09/prefer-storing-data-with-jetpack.html. Do you have any idea how to migrate from SharedPreferences using this latest syntax?
p

patrick

07/01/2021, 8:28 AM
Does this work:
val Context.myDataStore by preferencesDataStore(
    name = "settings",
    produceMigrations = { context ->
        listOf(
            SharedPreferencesMigration(context, "settings")
        )
    }
)
?
l

Law Gimenez

07/01/2021, 8:30 AM
@patrick no it doesn’t work I’m sorry
p

patrick

07/01/2021, 8:33 AM
In your context it could look somewhat like this:
val Context.myDataStore by preferencesDataStore(
    name = "filename",
    produceMigrations = { context ->
        listOf(
            SharedPreferencesMigration(context, "settings")
        )
    }
)

object OnlineJobPreferences{

    fun save(context: Context, jobPreferences: String){
        val dataStore = context.myDataStore
        dataStore.updateData { ... }
    }
}
You can access the datastore anywhere in your codebase by calling
myDataStore
on a context and the migration should happen automatically
l

Law Gimenez

07/01/2021, 8:36 AM
@patrick thanks your syntax worked already. Does it migrate all the stored values from my old SharedPreferences, or should do it manually?
p

patrick

07/01/2021, 8:37 AM
It should work automatically you just need to use the datastore (reading or writing) as I understood it from the docs
l

Law Gimenez

07/01/2021, 8:37 AM
@patrick appreciate the help. Thank you so much!
View count: 1