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

    Utkarsh Tiwari

    01/26/2021, 3:31 AM
    Hi team, I am trying to create a custom Modal (half and full sized variant) by using
    ModalBottomSheetLayout
    , however, when I
    state.show()
    the modal, it expands to only cover half the screen height. I have to swipe-up to pull it to make it expand to cover the entire screen. What did I miss?
    v
    j
    • 3
    • 14
  • p

    Piotr Prus

    01/26/2021, 4:10 PM
    I am trying to make a bottomSheet that opens over mapView. Very similar to current behaviour of google maps. I have a problem with moving the map to the click location. Probably because BottomSheet opens over the map and not resize the mapview. When I move the map, it moves below. I am using
    BottomSheetScaffold
    . Is it a right component to use here? I put my detail data in
    sheetContent
    and mapView in
    bodyContent
    . Any idea how to deal with it? example behaviour: https://streamable.com/balbx
    j
    • 2
    • 6
  • d

    Dirk Hoffmann

    01/26/2021, 10:36 PM
    after upgrading lib versions I get weird compiler error on
    Icon(Icons.Filled...)
    kotlin 1.4.21-2 compose 0.3.0-build143
    import androidx.compose.material.Icon
    import androidx.compose.material.IconButton
    import androidx.compose.material.icons.Icons
    
    ...
    
            IconButton(onClick = { /* doSomething() */ }) {
                Icon(Icons.Filled.Lock)
            }
    None of the following functions can be called with the arguments supplied: 
    public fun Icon(bitmap: ImageBitmap, contentDescription: String?, modifier: Modifier = ..., tint: Color = ...): Unit defined in androidx.compose.material
    public fun Icon(painter: Painter, contentDescription: String?, modifier: Modifier = ..., tint: Color = ...): Unit defined in androidx.compose.material
    public fun Icon(imageVector: ImageVector, contentDescription: String?, modifier: Modifier = ..., tint: Color = ...): Unit defined in androidx.compose.material
    any ideas?
    k
    c
    • 3
    • 4
  • k

    Kshitij Patil

    01/27/2021, 4:44 AM
    Is there compose release today?
    j
    c
    • 3
    • 7
  • c

    Chethan

    01/27/2021, 4:56 AM
    Do we have some thing similar to switch map for mutable state flow . I want to trigger network calls only some values changes ?
    s
    • 2
    • 3
  • j

    Jason Ankers

    01/27/2021, 6:53 AM
    Is it possible to create animations based on scroll position in compose? I want a background to fade away while the list scrolls
    a
    • 2
    • 1
  • a

    allan.conda

    01/27/2021, 7:05 AM
    We’re getting crashes only for minified builds… Any idea how I could go about debugging this issue?
    Untitled
    c
    j
    c
    • 4
    • 8
  • j

    julioromano

    01/27/2021, 7:39 AM
    Does compose offer something similar to
    android:animateLayoutChanges="true"
    ?
    a
    m
    d
    • 4
    • 9
  • a

    allan.conda

    01/27/2021, 11:51 AM
    Anyone had to debounce onClick lambdas yet in Compose? Or immediately disable a button to prevent multiple clicks. We hoisted the state into the ViewModel and there’s a gap where the user can still click the button again before it gets disabled. Been trying to think of ways to handle this.
    k
    a
    • 3
    • 15
  • k

    Kshitij Patil

    01/27/2021, 12:30 PM
    Modifier.navigationBarsWithImePadding()
    or
    Modifier.imePadding()
    from
    accompanist-insets
    does not apply to
    ConstraintLayout
    . Is this a bug or am I doing something wrong? Compose:
    1.0.0-alpha10
    accompanist:
    0.4.2
    c
    m
    • 3
    • 5
  • f

    Francois Morvillier

    01/27/2021, 2:35 PM
    I have a @Composable I want to be called at regular intervals (for instance once a second) to display some debug info. What's the best way to achieve this?
    p
    • 2
    • 1
  • k

    Kshitij Patil

    01/27/2021, 2:51 PM
    Losing focus from a TextField and refocusing it triggers
    OnValueChange
    event even with no change in its Text. Is this expected behaviour?
    j
    • 2
    • 2
  • k

    Kshitij Patil

    01/27/2021, 4:24 PM
    I’ve observed one more issue which I didn’t discuss broadly here. When we change the Text of TextFieldValue from any external effect, say a button click sets some text value for TextField, this doesn’t change the cursor position. Ideally the cursor should be set to end of the set Text. Is there any way I can handle this programmatically? I’m aware of
    OffsetMapping
    for
    VisualTransformation
    but this isn’t available for the use-case I mentioned.
    s
    • 2
    • 6
  • m

    Marko Novakovic

    01/27/2021, 5:57 PM
    what does this error means?
    Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
    c
    c
    • 3
    • 7
  • g

    grandstaish

    01/27/2021, 6:55 PM
    Does anyone have an idea why
    detectTapGestures
    might not detect taps when there’s an ongoing animation on the screen? I have a separate
    pointerInput
    modifier that just logs input events, and both the down&up events are being logged. Once the animation completes, taps are detected fine again. I also added a log to check that my composable wasn’t being re-composed on every frame of the animation, but it doesn’t seem to be 🤔
    d
    • 2
    • 11
  • k

    krzysztof

    01/27/2021, 7:53 PM
    I have a problem getting
    Preview
    to show up - It worked previously (version
    alpha07
    ), now with
    alpha08
    from
    androidx.compose.ui:ui-tooling
    is giving me error:
    androidx.ui.tooling.preview.PreviewActivity is not an Activity subclass or alias
    • 1
    • 2
  • u

    Utkarsh Tiwari

    01/28/2021, 2:10 AM
    I am facing an issue when I am trying to show two different kinds of Modals in the same screen. I need to tap the button twice to show the dialog. Seems like I am not handling the states right. Any suggestions?
    t
    • 2
    • 5
  • k

    Kyant

    01/28/2021, 2:55 AM
    Are there any examples of transition v2? The new API changes a lot.
    d
    • 2
    • 3
  • c

    chris-horner

    01/28/2021, 4:16 AM
    Is there a neat way to animate the
    weight
    of an item in a
    Column
    down to 0? Seems a little tricky as weights must have a value greater than 0. Am I missing something?
    d
    • 2
    • 5
  • d

    darkmoon_uk

    01/28/2021, 4:18 AM
    I'm
    @Compose
    -ing views that are dependent on bundled resources at runtime; so these fail during preview. Is there a way I can check whether I'm running in
    @Preview
    mode
    in the composition, so that I can just put colored block instead of the asset?
    j
    m
    • 3
    • 7
  • l

    linus muema

    01/28/2021, 7:35 AM
    Hi, Is there a way to create a blur on the background of a
    Box
    like the "Log In" and "Sign Up" buttons below 🤔
    a
    • 2
    • 2
  • r

    rsktash

    01/28/2021, 7:57 AM
    Hi Is there a better way to prevent double click? disable logic not implemented yet
    t
    • 2
    • 2
  • j

    julioromano

    01/28/2021, 8:25 AM
    I can’t run a preview on a device anymore: the “Deploy preview” button is greyed out and the similar icons in the gutter are gone too. (Using Arctic Fox Canary 5) I don’t know if some setting is disabling this and which it may be.
    ✅ 1
    s
    j
    b
    • 4
    • 7
  • s

    Shakil Karim

    01/28/2021, 8:34 AM
    I have Multiple screens as Composable like HomeScreen, DashboardScreen, etc and all of them has it's own ViewModel e.g HomeViewModel and I'm using ViewModel as
    val viewModel: HomeViewModel = viewModel()
    in each screen, Do these ViewModels remain in memory all the time because I'm using a Single Activity? and I'm not using Navigation Component
    a
    • 2
    • 2
  • d

    Dejan Predovic

    01/28/2021, 9:55 AM
    I just updates AS and AGP to alpha05 and Compose compiler throws:
    j
    j
    • 3
    • 4
  • a

    Archie

    01/28/2021, 10:10 AM
    Is there a way to ensure that a composable would always be square? So that regardless what the size of its content, the Width or Height would always be equal? I tried:
    modifier.layout { measurable, constraints ->
        val placeable = measurable.measure(constraints)
    
        val wrapperWidth = placeable.width.coerceIn(constraints.minWidth, constraints.maxWidth)
        val wrapperHeight = placeable.height.coerceIn(constraints.minHeight, constraints.maxHeight)
        val size = wrapperWidth.coerceAtLeast(wrapperHeight)
        layout(size, size) {
            placeable.placeRelative(0, 0)
        }
    }
    But I am only altering the position here since I already measured the placeable. Any hints?
    a
    j
    t
    • 4
    • 15
  • p

    pawegio

    01/28/2021, 11:33 AM
    I’ve noticed that
    kotlinCompilerVersion
    in
    composeOptions
    got deprecated in recent android gradle api, but removing it generates
    IncompatibleComposeRuntimeVersionException
    .
    🤔 What’s the proper way to migrate?
    @Deprecated("")
    var kotlinCompilerVersion: String?
    • 1
    • 1
  • t

    Timo Drick

    01/28/2021, 1:13 PM
    I think i found a bug. Not sure. But i do have a modifier that swipes away an element in a list and than removes the item from the list. This modifier remembers the state that the element is removed. Than when i remove the element from the list it looks like that the next element gets the state of this modifier. When i use the key() {} code it works fine.
    LazyColumn {
        items(modelList) { item ->
            //key(item) { // with key it works fine
                Box(Modifier.swipeToRemove(onRemoved = {
                    modelList.remove(item)
                })) {
                    Item(item = item)
                }
            //}
        }
    }
    device-2021-01-28-140519.mp4
    m
    a
    • 3
    • 4
  • t

    Timo Drick

    01/28/2021, 3:04 PM
    I do want to filter a SnapshotStateList and than use the filtered list in a LazyColumn. How can i do it? Using this code does not work because it does not detect changes in the list and do not filter the list again:
    val list = remember(snapshotStateList) {
        snapshotStateList.filter { removed.contains(it).not() }
    }
    p
    a
    +2
    • 5
    • 15
  • z

    Zach Klippenstein (he/him) [MOD]

    01/28/2021, 4:59 PM
    I see that
    AbstractComposeView
    , when creating its composition, looks up the view tree for a
    CompositionReference
    using
    findViewTreeCompositionReference()
    . This seems really neat, since it could enable
    ComposeView -> AndroidView -> … -> ComposeView
    hierarchies to automatically link their compositions. However, as far as I can tell,
    AndroidView
    never actually sets the view tree
    CompositionReference
    from the calling composition on its
    View
    , and this whole mechanism seems to currently only be used to find the
    WindowRecomposer
    . Would it be feasible for every
    AndroidView
    call to get a
    CompositionReference
    and set it on its
    View
    to support this? Is this sort of automatic linking of compositions across android view subtrees even something that would make sense? If yes, is the
    AndroidView
    wiring planned? https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ComposeView.kt;drc=a32c0003449e3ca6141ef497f0ee2759b41943ba;l=176
    a
    l
    +2
    • 5
    • 10
Powered by Linen
Title
z

Zach Klippenstein (he/him) [MOD]

01/28/2021, 4:59 PM
I see that
AbstractComposeView
, when creating its composition, looks up the view tree for a
CompositionReference
using
findViewTreeCompositionReference()
. This seems really neat, since it could enable
ComposeView -> AndroidView -> … -> ComposeView
hierarchies to automatically link their compositions. However, as far as I can tell,
AndroidView
never actually sets the view tree
CompositionReference
from the calling composition on its
View
, and this whole mechanism seems to currently only be used to find the
WindowRecomposer
. Would it be feasible for every
AndroidView
call to get a
CompositionReference
and set it on its
View
to support this? Is this sort of automatic linking of compositions across android view subtrees even something that would make sense? If yes, is the
AndroidView
wiring planned? https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/ComposeView.kt;drc=a32c0003449e3ca6141ef497f0ee2759b41943ba;l=176
IIRC, at least a couple releases ago, for subcomposition to work the subcomposition had to be manually composed every time the
CompositionReference
was composed, and so if that’s still the case then this simple view tree mechanism lacks the ability to push those recompose events down and this wouldn’t work.
I’m asking because I work on a navigation library where we currently manually implement this sort of nested composition linking through our own, non-view-tag-based mechanism, and it works but it only works if the boundary between compose and android views is controlled by the library. This is a restriction I think we’re ok living with, but if this were something that Compose just supported automatically, it would be great for two reasons: we could delete a bunch of code, and it would work across any Compose/Android view boundaries, not just the ones we control.
a

Adam Powell

01/28/2021, 5:33 PM
hmm, yeah we could do that
🎉 2
l

Leland Richardson [G]

01/28/2021, 5:42 PM
thanks for the idea zach!
🙏 1
➕ 1
z

Zach Klippenstein (he/him) [MOD]

01/28/2021, 7:01 PM
I think it should be pretty straightforward, i can try to get a CL up probably next week
a

Adam Powell

01/28/2021, 7:31 PM
oh I'm halfway through it now, I'm just writing a test for it
🎉 3
https://android-review.googlesource.com/c/platform/frameworks/support/+/1564002
🙏 1
v

Vinay Gaba

01/28/2021, 9:27 PM
I only read Zach’s comments once (and maybe I should read it a few times) but if I understood this correctly, does this change enable the possibility of introducing a mechanism to propagate recompositions through AndroidView such that ComposeView -> AndroidView -> ComposeView hierarchies have “interlinked” compositions. Does this also come with any performance wins?
z

Zach Klippenstein (he/him) [MOD]

01/28/2021, 9:29 PM
It doesn’t just enable the possibility of introducing such a mechanism, it is the mechanism.
😄 2
☝️ 1
z

zsperske

02/01/2021, 1:01 AM
great stuff! it's so cool to see such an interactive dev team/community relationship
View count: 12