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

    fengdai

    05/07/2022, 9:49 AM
    Question about State . Why does’t the second way work? 1. Work:
    var refreshing by remember { mutableStateOf(false) }
    LaunchedEffect(refreshing) {
        if (refreshing) {
            delay(2000)
            refreshing = false
        }
    }
    
    SwipeRefresh(
        state = rememberSwipeRefreshState(isRefreshing = refreshing),
        onRefresh = { refreshing = true },
    ) { ... }
    2. Can’t enter refreshing state:
    val state = rememberSwipeRefreshState(isRefreshing = false)
    
    LaunchedEffect(state.isRefreshing) {
        if (state.isRefreshing) {
            delay(2000)
            state.isRefreshing = false
        }
    }
    
    SwipeRefresh(
        state = state,
        onRefresh = { state.isRefreshing = true },
    ) { ... }
    • 1
    • 1
  • o

    oday

    05/07/2022, 3:17 PM
    I get an exception here about FocusRequester not being initialized
    val passwordRequester = remember { FocusRequester() }
    
            Card(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(horizontal = 32.dp),
                elevation = 4.dp
            ) {
                Column(
                    modifier = Modifier.padding(16.dp),
                    horizontalAlignment = Alignment.CenterHorizontally
                ) {
                    EmailInput(
                        modifier = Modifier.fillMaxWidth(),
                        email = email,
                        onEmailChanged = onEmailChanged
                    ) {
                         // HERE
                        passwordRequester.requestFocus()
                    }
    
                    Spacer(modifier = Modifier.height(16.dp))
    
                    PasswordInput(
                        modifier = Modifier.focusRequester(passwordRequester),
                        password = password,
                        onPasswordChanged = onPasswordChanged,
                        onDoneClicked = onAuthenticate
                    )
                }
            }
    o
    • 2
    • 1
  • c

    CLOVIS

    05/08/2022, 6:58 PM
    Is there a tutorial somewhere on out-of-flow positioning? E.g. how to implement things like CSS'
    position: absolute
    . What's the correct way to do something like display a shape that is above the rest of the contents?
    r
    • 2
    • 2
  • e

    eygraber

    05/09/2022, 12:00 AM
    If I have a project where I don't want to have a dependency on Compose, and I define a
    androidx.compose.runtime.Immutable
    annotation class locally, will the compiler plugin pick it up if I use that project as a dependency in another project?
    k
    e
    a
    • 4
    • 3
  • d

    Dazai

    05/09/2022, 3:14 AM
    how can I use collections functions inside of a composable function? Like i need to pass the @composable context to the map function on a flow. Example :
    val windowSize: State<DpSize> = windowSize().map {
                    with(LocalDensity.current) {
                        DpSize(it.first.toDp(), it.second.toDp())
                    }
                }.collectAsState(DpSize(800.dp, 600.dp))
    e
    • 2
    • 3
  • d

    Dazai

    05/09/2022, 3:14 AM
    is there a clean way to do this?
    l
    • 2
    • 2
  • h

    hfhbd

    05/09/2022, 8:17 AM
    Is is possible to get a CompositionLocalValue for a specific keyed group? • key(root) -- CompositionLocalProvider provides 1 --- key(foo) --- same CompositionLocalProvider provides 42 I would like to the value 1 from a Composable inside the key foo.
    z
    • 2
    • 2
  • t

    theapache64

    05/09/2022, 8:24 AM
    Why changing snapshot state from background thread during composition causing a crash? 🧵
    f
    a
    +2
    • 5
    • 40
  • a

    Abhinav Sharma

    05/09/2022, 8:25 AM
    Question: Can Coil ignore the subsequent calls with same url until first call is success? Scenario:
    @Composable
    fun Foo() {
      // call to load image from coil
    }
    Foo makes image call when on its first composition and due to any reason if Foo is recomposed before first call could be a success Coil makes another image load call Is there a way to avoid this? cc @Colin White
    m
    c
    • 3
    • 4
  • m

    mertceyhan

    05/09/2022, 10:13 AM
    Hi all! I’m trying to implement DotsIndicator for HorizontalPager on Compose but I am stuck with the implementation. Does anyone have an idea?

    https://user-images.githubusercontent.com/15737675/38328329-e7008c06-384a-11e8-8449-9f2e396d2bc5.gif▾

    t
    c
    • 3
    • 6
  • t

    theapache64

    05/09/2022, 10:26 AM
    I got this crash in my crashlytics today and it doesn’t have the triggering point (where it triggered from).
    Fatal Exception: java.lang.IllegalArgumentException
    Cannot round NaN value.
    kotlin.math.MathKt__MathJVMKt.roundToInt (MathKt__MathJVMKt.java:1132)
    androidx.compose.animation.core.VectorConvertersKt$IntOffsetToVector$2.invoke-Bjo55l4 (VectorConverters.kt:172)
    It looks like its thrown from the animation framework . Full stacktrace in 🧵
    t
    d
    • 3
    • 6
  • a

    Akram Bensalem

    05/09/2022, 11:37 AM
    How can I make this blur effect with Jetpack compose ?
    f
    • 2
    • 1
  • d

    dead.fish

    05/09/2022, 11:55 AM
    I had the assumption that chaining Modifiers with
    .then()
    would replace the configuration of earlier modifiers. Now I stand corrected that an application of the
    .padding(...)
    modifier and an additional
    Modifier.padding(...)
    applied via
    .then()
    is actually additive. Is this really so or did I hit a weird bug here? I looked into the implementation of padding and this just measures / places the contents, I guess the culprit might be somewhere in
    CombinedModifier
    which I haven’t fully understood how it works (and if there is special code somewhere that folds “padding” modifiers by adding their values together).
    f
    a
    • 3
    • 12
  • c

    Chris Fillmore

    05/09/2022, 1:30 PM
    Are there any API’s or libs to help with notifications?
    a
    t
    • 3
    • 4
  • m

    Mehdi Haghgoo

    05/09/2022, 1:44 PM
    Hey @Doris Liu I tried to create a custom VectorConverter for animating image scales. It didn't work out. I think I have to do more low-level or subclass the parent ContentScale interface. More in thread.
    d
    • 2
    • 5
  • a

    Aaron Waller

    05/09/2022, 1:56 PM
    I’m building my app in Jetpack Compose and use one ViewModel for every feature/screen. Now I need to access the login state from everywhere inside the app, I also have a coin system where I need access to from every screen. How do I accomplish this? My first idea was to put the login state and coin state inside a “MainViewModel” and then use this in every Screen for example in my “SettingsScreen” composable use “SettingsViewModel” and “MainViewModel”. But I’m not sure if this is a good practice to use two viewModels in one screen. How can I have access to the Login state and the Coins in every screen?
    r
    c
    • 3
    • 13
  • r

    rook

    05/09/2022, 7:29 PM
    I’m not sure if this is a bug or I’m missing something, just looking for validation. The following renders nothing in either preview or at application runtime:
    val someFun: (@Composable () -> Unit)? = null
    someFun?.invoke() ?: BasicText(text = "Foo")
    Edit: Found the issue in the bug tracker: https://issuetracker.google.com/issues/198511576. Unfortunately, it’s still not fixed.
    t
    • 2
    • 3
  • x

    xxfast

    05/10/2022, 1:35 AM
    Whats the best way to pull this off? I want to be able to
    .clip()
    with an inverted shape, so to say. A coloured circle shape wouldn't work here because the surface colours are all transparent.
    ➕ 1
    n
    • 2
    • 1
  • a

    aoriani

    05/10/2022, 3:01 AM
    Does anyone know if there's an Android Studio plugin or something similar that could export the images for every preview? It would be helpful to share preview with designers.
    ➕ 2
    x
    f
    +2
    • 5
    • 8
  • m

    Manideep Polireddi

    05/10/2022, 5:52 AM
    We are getting a crash due to illegal state read.
    java.lang.IllegalStateException: Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied
    But we are not able to figure out which part of our source is causing this problem since all of the stacktrace points to android framework, compose runtime and animation library. Full stacktrace in the 🧵 Note: the crash is intermittent and we are able to reproduce it a few times, when the app is changing orientation from landscape back to portrait. Can anyone help us figure out how we can get to the root cause for this crash?
    :plus-one: 3
    z
    t
    a
    • 4
    • 23
  • a

    Alexander Maryanovsky

    05/10/2022, 7:13 AM
    Getting a
    ClassCastException
    here. Seems like a Compose compiler/runtime bug.
    ✅ 1
    • 1
    • 4
  • m

    Michał Diner

    05/10/2022, 7:44 AM
    Is there any smart way to prevent overlapping range values on a rangeSlider?
    m
    • 2
    • 2
  • s

    Satyam G

    05/10/2022, 9:04 AM
    Can we give Animation to a Card which will display and give a visual like SnackBar is displayed. How to achieve this SnackBar kind of Animation ??
    f
    r
    • 3
    • 26
  • s

    scana

    05/10/2022, 12:26 PM
    Hey guys, pretty broad question - assuming that I create my own CustomTheme (https://developer.android.com/jetpack/compose/themes/custom), how can I share it efficiently between screens, given that I migrate existing XML Fragment-based app to Compose? E.g. I migrate two separate screens to Compose, and they both are built like this:
    CustomTheme {
       // screen A content
    }
    
    CustomTheme {
      // screen B content
    }
    Won't this recreate my fonts/colors all over again? What would be the best approach here?
    f
    f
    c
    • 4
    • 10
  • k

    Kevin Del Castillo

    05/10/2022, 1:30 PM
    Hey everyone 👋 how do you usually handle your higher composables (let's say a whole screen content) when that composable has a lot of parameters?
    r
    l
    • 3
    • 4
  • c

    Chris Fillmore

    05/10/2022, 5:37 PM
    I have a composable which triggers a notification. Is there a best practice in Compose for how to obtain the
    Intent
    for the notification’s
    setContentIntent()
    ? I’m trying to avoid having the composable know about its host Activity. Clicking the notification will launch that Activity. I can think of a few things I could do: • Pass in a lambda like
    intent: () -> Intent
    to invoke anytime I need an intent • Pass in the Activity
    Class<?>
    • CompositionLocal? (bad idea?)
    i
    • 2
    • 2
  • j

    Jorge Domínguez

    05/10/2022, 7:51 PM
    Is it possible to animate changes between two inputs of a
    LazyColumn
    ?
    LazyColumn {
        tasksList.forEach { task ->
            item {
                TaskItem(
                    taskName = task.name,
                    onStartTask = { onStartTask(task) }
                )
            }
        }
    }
    I'd like to animate a
    TaskItem
    if the corresponding
    Task
    object is not present in the next
    tasksList
    passed to
    LazyColumn
    o
    • 2
    • 8
  • r

    Rohil Chodankar

    05/10/2022, 8:13 PM
    Hey everyone, We have some of our compose test execute as instrumentation as well as unit test via robolectric. On compose version
    1.0.5
    all tests are executed successfully. But now we are trying to upgrade the compose version to
    1.1.0
    but some of the test fail when executed as unit test. But the same test work when executed as an instrumentation test. We have tried to update robolectric version to the latest
    4.8.1
    but that didn't work. After debugging a bit, it looks like the following step doesn't complete execution.
    rule.onNodeWithText("some text").assertExists()
    Internally it ends up in a loop in
    RobolectricIdlingStrategy.runUntilIdle()
    . Anyone who has faced similar issue?
    a
    • 2
    • 3
  • g

    goku

    05/10/2022, 9:05 PM
    Is there a way to test
    Modifier.padding
    ?
    m
    • 2
    • 3
  • c

    Chris Fillmore

    05/10/2022, 9:10 PM
    Is there any guidance on using
    ModalBottomSheetLayout
    with insets? The sheet goes up to the top of the screen, under the status bar. Is this just something we should avoid doing (for now?)
    m
    • 2
    • 2
Powered by Linen
Title
c

Chris Fillmore

05/10/2022, 9:10 PM
Is there any guidance on using
ModalBottomSheetLayout
with insets? The sheet goes up to the top of the screen, under the status bar. Is this just something we should avoid doing (for now?)
m

MR3Y

05/10/2022, 9:22 PM
https://issuetracker.google.com/issues/192478844
c

Chris Fillmore

05/10/2022, 9:22 PM
Thanks
View count: 3