https://kotlinlang.org logo
Docs
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
  • b

    Brian G

    05/24/2021, 2:10 PM
    Does Compose provide a way to measure intrinsic text width/height, synchronously, offscreen OUTSIDE of @Composable function? I'm integrating with a legacy system and it requires measuring certain things ahead of time, with View's you can simply do:
    val view = MyView(context)
    view.measure(widthMeasureSpec, heightMeasureSpec)
    return Pair(textView.measuredWidth, view.measuredHeight)
    I guess I could use
    ComposeView
    for this but I'm wondering if there is something more directly available in Compose API.
    a
    • 2
    • 8
  • z

    Zhelyazko Atanasov

    05/24/2021, 2:41 PM
    I'm looking at the animation API and either I'm missing something (most likely) or it's harder to implement this using Compose. I want to implement a shake/wiggle animation. Imagine a
    TextField
    and a button. When the user clicks the button, if the value in the
    TextField
    is not correct or empty, I'd like to move the
    TextField
    to the left/right a few times to draw the user's attention. In a
    View
    world I can do something like this:
    ObjectAnimator
      .ofFloat(myTextInput, "translationX", 0, 25, -25, 25, -25,15, -15, 6, -6, 0)
      .setDuration(duration)
      .start();
    But with Compose I can't figure out a way to have the current and target value be the same. The direction I went into is to use
    animateDpAsState
    together with
    keyframes
    animation spec to animate the
    offset
    of my
    TextField
    and it does the job. My issue is how to trigger the animation.
    ✅ 1
    z
    • 2
    • 8
  • t

    Tin Tran

    05/24/2021, 2:43 PM
    Hi guys! I think that I'm having a race condition here with
    ModalBottomSheetLayout
    . Code in 🧵
    r
    • 2
    • 13
  • a

    Archie

    05/24/2021, 3:32 PM
    Anyone lost Android Studio’s
    Interactive Mode
    on 4.2 Beta? I can’t seem find out why its missing?
    ☝️ 2
    t
    p
    c
    • 4
    • 5
  • v

    Vitaliy Zarubin

    05/24/2021, 3:42 PM
    Is this normal behavior? Why is refresh random? (Swipe Refresh & Paging)
    c
    a
    m
    • 4
    • 9
  • i

    iamthevoid

    05/24/2021, 3:58 PM
    Does anybody met next exception [thread] ? Why can it be? I have code with finite loops just for represent button styles from design system [thread]
    a
    • 2
    • 7
  • c

    Ciprian Grigor

    05/24/2021, 4:50 PM
    Is kotlin.serialization compatible with compose? I get this: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during code generation
    v
    • 2
    • 3
  • z

    Zach Klippenstein (he/him) [MOD]

    05/24/2021, 5:17 PM
    I just published another post in (what is turning out to be) a series on Compose’s state management model. Feedback welcome! A historical introduction to the Compose reactive state model
    🎉 29
    👏🏼 3
    👏 8
    🙂 2
    👍 9
    👍🏼 4
    a
    m
    q
    • 4
    • 6
  • b

    Benny Özcetin

    05/24/2021, 6:38 PM
    Hi everyone, I was playing with the AnimatedVisibility() today, and wonder if there is a way to figure out when the animation end. Does anyone know something about this?
    d
    • 2
    • 2
  • n

    nglauber

    05/24/2021, 6:51 PM
    I saw this question here and makes me think: How’s
    match_parent
    in Compose? 🤔 https://stackoverflow.com/questions/67677125/fill-height-for-child-in-row
    • 1
    • 1
  • s

    Spiral123

    05/24/2021, 9:03 PM
    has anyone had experience of enabling list scrolling in compose using a rotary encoder (e.g. twisting a watch crown)? I’m starting to suspect it may not be supported.
    z
    a
    • 3
    • 8
  • a

    Arkadii Ivanov

    05/24/2021, 10:57 PM
    A question: shouldn't the
    State
    interface have
    out T
    and not just
    T
    ? Like
    State<out T> { ... }
    👍 4
    👍🏼 1
    l
    z
    a
    • 4
    • 31
  • c

    Clément Jean

    05/25/2021, 2:06 AM
    Hi guys, I'm trying to put the following jetpack-compose code in a separate gradle module called
    ui_components
    (android library)
    /**
     * Display a vertical list of [OutlinedTextField]
     */
    @Composable
    fun Form(fields: List<FormField>) {
        LazyColumn(content = {
            items(fields) { item ->
                OutlinedTextField(
                    value = item.mutableState.value,
                    onValueChange = { item.mutableState.value = it },
                    label = { Text(text = stringResource(id = item.label)) },
                    isError = item.isError(item.mutableState.value)
                )
            }
        })
    }
    However, when I compile the logs show me the following error:
    e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call 'items' into
    local final fun androidx.compose.foundation.lazy.LazyListScope.<anonymous>(): kotlin.Unit defined in com.xxx.xxx.ui_components.Form
    {
            items(fields) { item ->
                OutlinedTextField(
                    value = item.mutableState.value,
                    onValueChange = { item.mutableState.value = it },
                    label = { Text(text = stringResource(id = item.label)) },
                    isError = item.isError(item.mutableState.value)
                )
            }
        }
    Am I doing something wrong here? Because individually the module compile (so no dependency missing, I guess) and without the dependency to
    ui_components
    the app compiles. Would be great if you can explain me, thanks in advance! 🙏
    z
    a
    • 3
    • 3
  • r

    Ryan Simon

    05/25/2021, 5:50 AM
    Hey guys, question about handling one-off events in Compose. I normally would deal with this by using a
    SingleLiveEvent
    and observing changes in my
    Fragment
    . Now that I’m in Compose world, it seems that using a
    SingleLiveEvent
    isn’t something that’s supported. What are your recommendations for handling one-off events coming from the ViewModel like showing a Snackbar, navigation, etc? Sample code in the thread of what I’m doing now.
    ➕ 1
    a
    a
    +3
    • 6
    • 54
  • v

    Vitaliy Zarubin

    05/25/2021, 6:07 AM
    Please tell me what's wrong? Why not "People". Material+Icons
    c
    • 2
    • 4
  • n

    natario1

    05/25/2021, 10:02 AM
    What's the point of remembering the graph in
    NavHost
    here? As far as I understand it makes it ignore any graph update. https://github.com/androidx/androidx/blob/androidx-main/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt#L98
    a
    • 2
    • 2
  • i

    iamthevoid

    05/25/2021, 12:07 PM
    Can not launch test for Composable elements, that launches before. I don’t notice when this test became broken, maybe after compose version update (current is beta07)
    • 1
    • 1
  • t

    Tolriq

    05/25/2021, 2:25 PM
    Is there some documentation about the "cost" of adding wrappers to composable? For example in a Column I want to have a Text in the middle with weight to fit all the remaining space. Seems it's impossible to directly center vertically the text, and the simple solution is to wrap the Text in a Row. But since before Compose the rule was always to avoid adding nesting for things likes that, it sounds like bad when maybe it just have 0 impact and is actually the perfect solution.
    f
    a
    +6
    • 9
    • 19
  • c

    Chris Grigg

    05/25/2021, 2:38 PM
    Can someone help clarify the best practices on using hot flows within Compose? Almost everything I’ve found seems to specify recommendations for cold flows explicitly. This article describes the use of
    flowWithLifecycle
    , which looks like it was introduced in a newer version of lifecycle than I have installed. Is
    flowWithLifecycle
    the best way or can/should one still use
    shareIn
    or
    stateIn
    with a hot flow to control the collection behavior in a lifecycle-aware way?
    a
    • 2
    • 69
  • j

    julioromano

    05/25/2021, 2:57 PM
    Is there a way to get an overview of the CLs that are being merged to the compose repo? I’m a gerrit noob so I don’t really have a clue how to dig in from https://android-review.googlesource.com/
    a
    z
    • 3
    • 2
  • b

    Billy Newman

    05/25/2021, 4:11 PM
    Anyone know ho to use a unicode character in Text field? Getting an illegal escape error using this:
    Text(text = "\u202")
    d
    e
    • 3
    • 2
  • n

    Nthily

    05/25/2021, 4:12 PM
    hi, im using 
    Hilt
     , but when I use navigation to jump to another page, the 
    viewModel
     I get from that page is not the same as the 
    viewModel
     I get here
    m
    c
    • 3
    • 4
  • d

    Daniel

    05/25/2021, 4:32 PM
    Anyone know how to convert a
    Color
    to a native color int?
    v
    c
    • 3
    • 3
  • c

    chao

    05/25/2021, 5:26 PM
    Is it reasonable to have a
    @Composable
    function with return type? I am trying to evaluate the feasibility to write JVM unit tests for them:
    @Composable
    fun spanStyleRange(textAttribute: TextAttribute): AnnotatedString.Range<SpanStyle> {
        val spanStyle: SpanStyle = when (textAttribute.type) {
            TextAttributeType.HASHTAG ->
                SpanStyle(color = MaterialTheme.colors.primary, fontWeight = FontWeight.Bold)
            else -> SpanStyle()
        }
        return AnnotatedString.Range(
            item = spanStyle,
            start = textAttribute.start,
            end = textAttribute.start + textAttribute.length
        )
    }
    In thie example,
    spanStyleRange
    need to be annotated with
    @Composable
    because it is using
    MaterialTheme.colors
    d
    a
    • 3
    • 11
  • d

    Daniel

    05/25/2021, 5:40 PM
    I'm trying to figure out how to architecture some state. I have a screen that shows a book reader with a book, a current position, and a style. The problem is that I want to store (essentially) an integer page number in the db, but have a floating point page number to represent in-progress page terms in the view model. To do this I think I need to have the source of truth be the view model, which simultaneously updates the repo. In contrast, I want a standard flow for the style where I update it in the repo and then the change flows back down to the view model and then the view. I currently combine these pieces of state into a single flow in the view model, but the different sources of updates led me to some bugs. Is there a cleaner way to do this?
    t
    • 2
    • 15
  • m

    Marko Novakovic

    05/25/2021, 8:15 PM
    I have trouble grasping how recomposition works in example I currently have. Code and more info in thread.
    z
    • 2
    • 13
  • s

    Saiedmomen

    05/25/2021, 10:10 PM
    Is there any plan for targeting Fuchsia? https://www.theverge.com/2021/5/25/22452620/google-fuchsia-os-nest-hub-smart-display-update-operating-system-linux-kernal
    a
    a
    • 3
    • 2
  • n

    Noop

    05/25/2021, 11:52 PM
    Are there any HTML renderers available in Compose?
    j
    a
    • 3
    • 4
  • y

    YASAN

    05/26/2021, 2:07 AM
    Anyone else having issues with LazyColumn on Beta07? My items become invisible in a weird way after I updated to beta07. Based on my Git log it doesnt look like I have changed anything else that can have such effect.
    a
    • 2
    • 5
  • j

    Jason Ankers

    05/26/2021, 5:05 AM
    When using multiple back stacks with bottom nav bar, how can we clear all the tab back stacks at once? (i.e. when the user logs out)
    ➕ 2
    i
    n
    • 3
    • 3
Powered by Linen
Title
j

Jason Ankers

05/26/2021, 5:05 AM
When using multiple back stacks with bottom nav bar, how can we clear all the tab back stacks at once? (i.e. when the user logs out)
➕ 2
i

Ian Lake

06/03/2021, 1:25 PM
There's no good way to do this. Do you mind filing an issue against Navigation for this? https://issuetracker.google.com/issues/new?component=409828&amp;template=1093757
j

Jason Ankers

06/03/2021, 1:33 PM
Sure, done: https://issuetracker.google.com/issues/189979430
👍 1
n

Nabeel

06/03/2021, 3:10 PM
In my previous project I've just restarted activity after logout completed. It would be a better way if you are using Single activity architecture
View count: 1