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

    AmrJyniat

    11/25/2021, 5:04 PM
    I have a full Expanded 
    ModalBottomSheetLayout
    , when swipe it to the bottom to collapse it, it stops on Half Expand state and I need to swipe it again to collapse it totally, any idea?
    • 1
    • 1
  • m

    mcpiroman

    11/25/2021, 5:13 PM
    I want to display a tree view (using standard
    LazyColumn
    ), but because the tree itself is very complicated and reactive, I would also like to use compose-runtime to manage its nodes. I.e. I want to use the compose with custom `NodeApplier`to generate nodes of the tree that I then take and display with the standard (in my case desktop)-compose. Can it be somewhat easily achievable? There is something called
    sub-composition
    , the `Composition`function also takes a parent `CompositionContext`but I don't quite know how to glue that together. I have looked at https://github.com/JakeWharton/mosaic/ but it uses the compose-runtime standalone, while I want it kind of 'nested'.
    z
    t
    • 3
    • 12
  • d

    Daniele Segato

    11/25/2021, 6:43 PM
    I'm trying compose material3, I've read here that we are supposed to keep both Material2 and Material3 libraries together right now. I'd rather not, but I need an
    OutlinedTextField
    do you know of any library or snipped of code that port material 2 textfield to material 3? Thanks
    a
    • 2
    • 1
  • s

    Steffen Funke

    11/25/2021, 6:54 PM
    Is it a known bug that on Samsung / Android 9 devices, when Talkback enabled, any Scrollable (
    LazyColumn
    ,
    scrollable
    modifier) does not react to 2 finger scroll gestures at all? Easy reproducible with the very simplest
    LazyColumn
    demo (in Thread). I don’t experience this with other devices so far. Actually a dealbreaker for converting an existing App (which relies on accessibility) to compose, as I planned to 😞 Should I file a bug?
    • 1
    • 1
  • k

    Kulwinder Singh

    11/26/2021, 2:06 AM
    var readMore by remember { mutableStateOf(false) }
    var clickText by remember { mutableStateOf("Read More") }
    var showClickButton by remember { mutableStateOf(false) }
    val annotatedText = buildAnnotatedString {
        withStyle(style = SpanStyle(color = MaterialTheme.colors.OnSurface800)) {
            append(text + " ")
        }
        
        if (showClickButton) {
            pushStringAnnotation("click", "click")
            withStyle(style = SpanStyle(color = MaterialTheme.colors.Interactive500)) {
                append(clickText)
            }
            pop()
        }
    }
    
    ClickableText(
            text = annotatedText,
            style = MaterialTheme.typography.smallBody,
            overflow = TextOverflow.Ellipsis,
            maxLines = if (readMore) Int.MAX_VALUE else 2,
            onTextLayout = { showClickButton = it.hasVisualOverflow }
        )
    I am trying to “Read More” button at the end of text view but looks like
    buildAnnotatedString
    does not recompose when
    showClickButton
    or state change, so here how can i achieve this ?
    a
    z
    • 3
    • 10
  • m

    Mehdi Haghgoo

    11/26/2021, 5:02 AM
    Anytime the Compose UI
    View
    is used as part of a transition, it will be detached from its window when the transition starts instead of when the transition ends, thus causing your composable to dispose of its state while it is still on screen.
    What does this mean? why is Compose UI view detached from its window when the transition starts?
    i
    • 2
    • 1
  • s

    sindrenm

    11/26/2021, 8:33 AM
    Has anyone here experienced
    View.measure
    crashes in Accompanist (probably accompanist-pager) starting on v0.19.0? Suspect it comes from the refactor to using a
    LazyList
    introduced in that version, and we're seeing it across multiple devices in production, but we're unable to reproduce it locally, and we're a little lost on how to debug this. 😅 GitHub issue: https://github.com/google/accompanist/issues/847
    👍🏼 1
    👍 3
    a
    z
    +2
    • 5
    • 9
  • a

    allan.conda

    11/26/2021, 9:40 AM
    I'm writing E2E test with Compose. It works fine generally, however I'm testing deep links and the composeTestRule.activity keeps the old destroyed activity causing a crash if I try to access it after the deep linking action. Compose test APIs that don't use the activity work fine though. Should I file a bug?
    k
    a
    • 3
    • 4
  • r

    rsktash

    11/26/2021, 10:57 AM
    Hi I’ve experimented with
    Modifier.animateItemPlacement()
    function of lazy list. There is a bug when we add an item to the first index of a lazy list which is full and scrollable at this moment. When it is not full added item is animated but when it is full it is not animating. As a workaround I added extra item to the top of lazy list via
    item("hint") { }
    a
    • 2
    • 14
  • m

    Michael Paus

    11/26/2021, 11:51 AM
    I would like to be able to pan my canvas content with some inertia effect. Does compose have any concept or tools to achieve that? Searching for “inertia” in the context of compose did not reveal anything useful. (E.g., JavaFX has this built into gesture handling by default. https://openjfx.io/javadoc/17/javafx.graphics/javafx/scene/input/GestureEvent.html)
    a
    • 2
    • 2
  • d

    Daniele Segato

    11/26/2021, 1:06 PM
    Can we exchange ideas about how to make `ViewModel`s independent of compose? I'm thinking specifically of
    TextFieldValue
    for forms. Say you need to control both the text and the selected state from the ViewModel. How do you handle this scenario?
    a
    a
    • 3
    • 11
  • a

    Arpit Shukla

    11/26/2021, 1:18 PM
    I just marked the following class with
    @Immutable
    and now the app started crashing.
    @Immutable
    data class EqualSplit(
        val name: String,
        val image: String,
        val number: String,
        val selected: Boolean
    )
    The error log says:
    java.lang.NoSuchFieldError: No static field $stable of type I in class EqualSplit; or its superclasses
    What does this mean?
    j
    • 2
    • 2
  • a

    Arpit Shukla

    11/26/2021, 3:23 PM
    I have a list of data classes that I am displaying using a LazyColumn. But even when a single item in the list changes, all the items inside LazyColumn are recomposed. I thought marking the data class as
    @Immutable
    might fix the issue but it didn't. How can I prevent these unnecessary recompositions? Code in 🧵
    j
    • 2
    • 3
  • i

    iamthevoid

    11/26/2021, 4:08 PM
    I want to add spaces in text field. I’d did all what i can for achieve this, but looks like some kind of visual artifacts exists even after i ensure that offsets in
    OffsetMapping
    mapping correctly. I’ll add scratch in thread. Logic next When price entering then
    filter
    of
    VisualTransformation
    calls and i creating
    Price
    object. It contains three values integer(string, with spaces), fractional(string) and boolean describes is there comma or no. This object stores in my class, implements
    VisualTransformation
    and
    OffsetMapper
    . mapping of offset happens based on this object. It stores price (with spaces) and price payload. For example if
    price
    is
    8 994,34
    payload
    should be
    8994,34
    (witout spaces). Based on this values i am calculating offset. I even simulate this in scratch file [screenshot] and all looks good. But in dynamic, when i interact with input - i see artifacts! i For example: when i try to backspace number then backspaced not the number, that i want to backspace, but backspace previous, but not always And then i understood. The problem is that offsets that i calculate is dynamic. That changes when integer length changes. Example
    9 999
    offset at position 2, and when i enter another digit whenever
    99 989
    offset now at position 3. So when i backspace digit offset positions also changes during editing. This situation can be solved?
    t
    c
    m
    • 4
    • 10
  • m

    Marko Novakovic

    11/26/2021, 8:25 PM
    using
    Map
    like:
    mutableStateOf(map)
    and reassigning that
    Map
    doesn’t trigger recomposition? how can I approach this?
    t
    j
    +2
    • 5
    • 14
  • s

    Stylianos Gakis

    11/26/2021, 10:52 PM
    Is there any sort of equivalent mechanism to
    @DisallowComposableCalls
    that I can apply to my own functions to not allow them to be called from inside composable functions? Or if not, any ideas on how to improve the developer experience regarding this: I have a function that looks like this:
    inline val Int.dp: Int
        get() = (this * Resources.getSystem().displayMetrics.density).toInt()
    That is used from normal non-composable functions, but is simply annoying as it always comes as a code completion suggestion when I’m inside composable functions, but in there I always want the
    androidx.compose.ui.unit.dp
    import instead.
    t
    • 2
    • 3
  • u

    ursus

    11/27/2021, 5:03 AM
    Could one say Compose ui is more equivalent to flutter ui, than os native?
    :yes: 1
    k
    a
    +5
    • 8
    • 23
  • m

    Mjahangiry75

    11/27/2021, 9:26 AM
    how to draw a vertical dotted line in
    compose
    ?
    s
    • 2
    • 1
  • z

    Zoltan Demant

    11/28/2021, 10:27 AM
    If I have a
    LazyList
    with a column that contains several sub-items (e.g. inside a card). How can I optimize it such that the nested items arent recomposed all the time? Im seeing 3 recompositions each time the list is recomposed, taking up about 15 ms each; since Im also using a pager, the same process is repeated for pages to the left/right of the current one, effectively taking up 135 ms everytime the list recomposes.
    c
    t
    • 3
    • 5
  • a

    Alexander Suraphel

    11/28/2021, 1:35 PM
    Trying to run the
    todoapp
    inside
    compose-jb
    and getting the following error:
    The minCompileSdk (31) specified in a
    dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
    is greater than this module's compileSdkVersion (android-30).
    Dependency: androidx.compose.material:material:1.1.0-beta01.
    AAR metadata file: /Users/alexander/.gradle/caches/transforms-3/137251a10d2c5151ea1d3a5bd29928e0/transformed/jetified-material-1.1.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.
    How do if fix this? I’ve tried
    clean
    ->
    build
    and “Invalidate cache and restart”
    m
    c
    • 3
    • 5
  • a

    Archie

    11/28/2021, 6:25 PM
    Hi @Ian Lake, Any guide on how to provide Navigation Animation with Accompanist for Nested Navigation? I tried doing:
    navigation(
       route = "routeName",
       startDestination = "startDestination"
    ) {
       // transitions defined in this composable never seem to run
       composable(
            route =  "someDestination",
            enterTransition = { slideIntoContainer(AnimatedContentScope.SlideDirection.End) },      
            exitTransition = { slideOutContainer(AnimatedContentScope.SlideDirection.Start) },      
            popEnterTransition = { slideIntoContainer(AnimatedContentScope.SlideDirection.End) },   
            popExitTransition = { slideOutContainer(AnimatedContentScope.SlideDirection.End) },
       ) {
          ...
       }
       ...
    }
    i
    • 2
    • 5
  • r

    Rudolf Tammekivi

    11/28/2021, 8:41 PM
    Is Play Store automatic robo testing still clicking around and navigating the app randomly? My app shows an AlertDialog with two buttons when first launched and for the past few releases the robo testing only starts the app and idles around for a minute. Wondering if it's something on my end or has anyone had similar experience.
    :not-kotlin: 1
    a
    • 2
    • 2
  • k

    Kiprop Victor

    11/29/2021, 10:15 AM
    What is the road map for compose to support Kotlin 1.6.0?
    👀 1
    n
    j
    h
    • 4
    • 5
  • m

    Michal

    11/29/2021, 12:24 PM
    Compose 1.1.0-beta03 freezes on ComposeView. I don't see any logs, but the issue seems to be same as https://kotlinlang.slack.com/archives/CJLTWPH7S/p1620052815345200 it happens very randomly, but quite often. I will see if downgrading or changing some other dependencies will work. Do you have any idea how to debug? The UI thread isn't busy, just doesn't accept any inputs and if I use a navigation drawer which can switch between compose view fragments, it starts working again.
    l
    h
    d
    • 4
    • 13
  • j

    Javier

    11/29/2021, 2:30 PM
    Is it possible to modify
    animateContentSize
    to expand the component from the center instead of from the left to right?
    d
    • 2
    • 6
  • j

    John Aoussou

    11/29/2021, 3:17 PM
    Is there a way to call a specific composable from a notification? I know how the open an activity, but I'm trying to access a specific screen (the same way you would do it with a navhost)
    l
    i
    • 3
    • 9
  • a

    AmrJyniat

    11/29/2021, 5:24 PM
    What are the diffs between
    coordinates.positionInRoot()
    and
    coordinates.positionInParent()
    ?
    b
    d
    k
    • 4
    • 5
  • d

    Dan Peluso

    11/29/2021, 6:56 PM
    Has anyone updated their project to Kotlin 1.6 with compose successfully? Trying to update now and getting this error from one of our modules:
    e: This version (1.0.5) of the Compose Compiler requires Kotlin version 1.5.31 but you appear to be using Kotlin version 1.6.0 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
    i
    t
    h
    • 4
    • 7
  • m

    mcpiroman

    11/29/2021, 7:37 PM
    How do I get proper
    fillMaxWidth
    inside sth with `horizontalScroll`(by default it is ignored)? I simply want the background to span all available width.
    z
    c
    • 3
    • 8
  • j

    jeff

    11/29/2021, 8:38 PM
    What's the easiest way to animate between alignments? Say,
    Alignment.TopStart
    ->
    Alignment.BottomStart
    within a
    Box
    ? Possibly-related: can ConstraintLayout animate between constraints (via movement not just crossfade or something)?
    b
    a
    +2
    • 5
    • 15
Powered by Linen
Title
j

jeff

11/29/2021, 8:38 PM
What's the easiest way to animate between alignments? Say,
Alignment.TopStart
->
Alignment.BottomStart
within a
Box
? Possibly-related: can ConstraintLayout animate between constraints (via movement not just crossfade or something)?
b

bohregard

11/29/2021, 8:39 PM
I actually just did something like this
If you checkout the BiasAlignment class, you’ll see that for the most part it’s just a pair of float values that describe where it’s at on the screen
So you can do something like this:
BiasAlignment(
    -1f,
    placeholderAlignment
)
val placeholderAlignment by animateFloatAsState(targetValue = if (isFocused || text.isNotEmpty()) -1f else 0f)
j

jeff

11/29/2021, 8:40 PM
Oooh nice. Thanks!
b

bohregard

11/29/2021, 8:40 PM
No problem 🙂
There is probably a better way to do it, but honestly this worked really well for me so I just stuck with it
j

jeff

11/29/2021, 8:41 PM
Haha based on your blurb you are solving a very similar problem as I am 😄
😂 1
a

Adam Powell

11/29/2021, 8:48 PM
the only thing I might change about this is to avoid recomposition as it animates by having an Alignment implementation that reads and returns the animated value when requested, so that only the layout invalidates during the animation. Otherwise, 👍
d

Doris Liu

11/29/2021, 8:58 PM
I'd recommend checking out this thread with animations using the new
onPlaced
modifier: https://twitter.com/TashaRamesh/status/1461289694616907777
You should be able to use the
animatePlacement
in the sample code here (https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/package-summary#(androidx.compose.ui.Modifier).onPlaced(kotlin.Function1) ) to animate movement for when constraints change in a ConstraintLayout. Alternatively, ConstraintLayout has an API for animating between constraints: https://github.com/androidx/constraintlayout/blob/main/constraintlayout/compose/sr[…]main/java/androidx/constraintlayout/compose/ConstraintLayout.kt
j

jeff

11/29/2021, 9:04 PM
@Doris Liu Nice! I'll check that out, thank you! @Adam Powell would you mind elaborating a bit? I'm still wrapping my head around what causes recomposition. Do you mean something like
remember { SomeCustomAnimatedAlignment(...) }
?
a

Adam Powell

11/29/2021, 10:41 PM
Yes, though you don't necessarily need the remember either depending on how often the function would otherwise recompose. The idea being that the values returned by the Alignment change over the animation, not the Alignment object itself
👍 1
p

Pulak

11/30/2021, 4:39 PM
Is it possible in compose to animate say from center of screen to a certain (x, y) coordinate yet?
d

Doris Liu

11/30/2021, 7:26 PM
@Pulak
onPlaced
is designed to make that change (from center of screen to somewhere else) animatable. Check out the sample code
animatePlacement
linked above. If you add
animatePlacement
modifier to your element that you intend to move, you can expect the position change to be animated. We do plan on having official support for the
animatePlacement
concept in the near future. But because of
onPlaced
being experimental, we can't build animation APIs on top of it just yet.
👍 1
View count: 8