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

    Adam Brown

    07/30/2022, 7:57 AM
    I'm looking to display a tree structure, but I also need to be able to drag to reorder, and expand/collapse nodes in the tree. I've done some looking and can't seem to find any existing libraries that tick all those boxes. But thought I might poll the channel here to see if there is one I might be missing. If not, anyone have any tips on where to start making my own implementation? Maybe building it on top of LazyColumn?
    o
    a
    8 replies · 3 participants
  • z

    Zoltan Demant

    07/30/2022, 12:55 PM
    This is what Im used to! Notice the added ',' after the
    modifier = {}
    block.
    o
    1 reply · 2 participants
  • r

    ryan.fonzi

    07/30/2022, 2:30 PM
    Dialog
    seems to ignore the density values in
    LocalDensity
    for its content. 🧵
    d
    13 replies · 2 participants
  • o

    oianmol

    07/30/2022, 4:58 PM
    Learnt and wrote about
    Indication
    and
    Interaction
    Interface today in compose https://medium.com/@anmol.verma4/jetpack-compose-interaction-and-indication-8cfed0e82bcb
  • d

    dimsuz

    07/30/2022, 5:32 PM
    I know that Compose team is planning to address the issue with
    @Stable
    and
    @Immutable
    stuck inside the
    compose.runtime
    artifact, but is there some workaround until then? Especially when I cannot use
    .aar
    because I'm building a small library which I want to be a
    .jar
    and so no option of simply adding a dependency on
    compose.runtime
    ...
    j
    2 replies · 2 participants
  • a

    andrew

    07/31/2022, 2:20 AM
    Do we have a way to tell when a sticky header as “stuck” in a LazyLayout?
    d
    2 replies · 2 participants
  • r

    raghunandan

    07/31/2022, 5:12 AM
    [Solved] https://link.medium.com/UQzK9RJr6rb. In the linked blog post how do i get the centered item index as soon as an item is centered??. I was looking at pager code and its based on current page offset the index is incremented or decremented.
    1 reply · 1 participant
  • j

    Jasmin Fajkic

    07/31/2022, 11:27 AM
    Few question about bottom sheet. How do you actually use bottom sheet in combination with bottom tab bar? I have multiple bottom sheets that should be presented on different screens where tab bar is visible. Only solution that worked for me so far is this lib https://github.com/oleksandrbalan/modalsheet. I would be happy to see how other solve this issue. Second question is: did someone tried to implement for example that sheet is initially hidden, when press button open it at 65% and then drag to 90 %. I know that it is possible to use half expanded but is there any option like to add snap points to open at 65%? Thx in advance
  • z

    Zoltan Demant

    07/31/2022, 12:24 PM
    If I have a
    ContentTransform
    with
    fadeIn()
    and `slideOutVertically()`; is it expected that the slideOutVertically should fade out as well? This doesnt make sense to me, is it a bug?
    s
    2 replies · 2 participants
  • s

    samuel

    07/31/2022, 1:10 PM
    I would like to get the index of the last visible line in case the text in my
    Text
    composable overflows. I came across
    TextLayoutResult.getLineEnd
    that seems like it could help me in this case. However, i need to supply the
    lineIndex
    . How would i go about getting the
    lineIndex
    of the line that is overflowing?
    s
    4 replies · 2 participants
  • o

    oianmol

    07/31/2022, 1:58 PM
    [FIXED] I am working on a custom Indication in Compose, and listening to Focus changes from my InteractionSource, End result is to have the TextField glowing when in focus(Focus == Assuming the keyboard is open ?) and normal when not in focus. For some reasons my TextField never emits a value of true when keyboard opens for that TextField when clicked.
    4 replies · 1 participant
  • o

    oianmol

    07/31/2022, 3:16 PM
    Androidx Repo is a 💎 and has a lot of android tests and Demos for jetpackcompose Checkout Foundation demo's here https://github.com/androidx/androidx/tree/androidx-main/compose/foundation/foundation/integration-tests/foundation-demos + Foundation Tests https://github.com/androidx/androidx/blob/androidx-main/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/DraggableTest.kt + Material Tests https://github.com/androidx/androidx/blob/androidx-main/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
  • g

    Greg Steckman

    08/01/2022, 3:21 AM
    I hope it's ok to post this here - I published a Compose Multiplatform-based plotting library that, so far, targets Android, Desktop, and web-canvas. I call it Koala Plot and you can try out the web version of the samples served from GitHub pages here. I'm interested to receive any feedback, and in collaborating with others on it going forward.
  • l

    Lilly

    08/01/2022, 5:35 AM
    I face a strange behavior when navigating to another screen (not using any navigation libraries). When I navigate from screen A -> B, it takes 2-4 seconds until B is displayed. In this time screen A is still displayed although the screen has already been disposed according to my logs:
    DisposableEffect(Unit) {
            onDispose { Log.e("ScreenA", "Leaving...") } // is logged immediately after call to navigate to screen B but screen A still visible
        }
    I would at least expect an empty screen B immediately after this log. Any ideas? EDIT: logs in thread.
    z
    11 replies · 2 participants
  • l

    Loney Chou

    08/01/2022, 11:16 AM
    Hello, I'm inspecting animation mechanism, but is confused by this invocation. Is this by design? Inside
    VectorizedInfiniteRepeatableSpec
    , `repetitionStartVelocity`calls `getVelocityFromNanos`with `targetValue = startVelocity`and
    initialVelocity = end
    . I can't get the meaning out of it. Compose version 1.1.1.
    d
    1 reply · 2 participants
  • i

    IsaacMart

    08/01/2022, 12:49 PM
    hello guys. I am retrieving a signed-in user from room database with the intention of updating views in compose. how should i store the user? I have tried remember{} but am getting the error:
    Required:
    MutableState<User.Companion>
    Found:
    User
    var user by  rememberSaveable { mutableStateOf(User) }
    
    val systemUiController = rememberSystemUiController()
    SideEffect {
        systemUiController.setStatusBarColor(
            color = PrimaryColor
        )
    }
    
    LaunchedEffect(key1 = context){
        viewModel.userResults.collect{ event ->
            when(event){
                is Resource.Success ->{
                      event.data?.let {// user from room database
                         user = it // It throws an error here
                     }
                }
                is Resource.Error ->{
                    Toast.makeText(context, event.message, Toast.LENGTH_SHORT).show()
                }
            }
    
        }
    s
    2 replies · 2 participants
  • c

    Cyril Kym

    08/01/2022, 1:51 PM
    Hi everybody, I'm currently trying to implement a Barcode Scanner for my compose app. I'm using CameraX and Google ML Kit for this use case. Scanning the Codes and getting the values behind it is already working. Now I'd like to mark the position of the currently scanned Barcode within the camera View. I' having trouble implementing this. The barcode has a property with a bounding Box and I think I'd just have to add this as a overlay to the Preview, but I don't know how to do it. Any Ideas?
    1 reply · 1 participant
  • j

    Joel Anderson

    08/01/2022, 2:58 PM
    Hey folks, I am trying to create a collapsible section in a lazy column that can contain (potentially) hundreds of list items. I'd like this section to be expandable and collapsible with change animations. I've seen Google recommend to use
    AnimatedVisibility
    for hiding list items, but this has a negative potential side effect when that list of hidden items is very large: when you scroll past the collapsed section, the LazyColumn tries to recompose all the hidden items at once and drops frames or potentially freezes. I've filed the issue here: https://issuetracker.google.com/issues/240599812 but am not sure if anyone has any alternatives? For now we've settled on just removing the items from the lazy list when they are not visible, but that breaks our change animations.
  • a

    agrosner

    08/01/2022, 4:06 PM
    issue related to https://kotlinlang.slack.com/archives/CJLTWPH7S/p1659115703829819
  • b

    Bradleycorn

    08/01/2022, 6:55 PM
    👋 Hi Everyone! I have updated my app to target
    API level 33
    , and as soon as I did that, all of my instrumented tests that use
    createComposeRule
    no longer work, and fail with an
    ActivityNotFoundException
    (it’s looking for androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity). Has anyone else run into this problem? I can reproduce the issue using the latest stable Android Studio (Chipmunk 2021.2.1 Patch 1), following these steps: 1. Create a New project using the “Empty Compose Activity” template. 2. Add a compose rule to the included
    ExampleIntrumentedTest
    , like this:
    @get:Rule var composerule = createComposeRule()
    3. Run the example
    useAppContext
    test, and note that it passes. 4. Now, in the app module’s build.gradle, update the
    compileSdk
    and
    targetSdk
    to use
    33
    . 5. Run the example
    useAppContext
    test again, and see that it fails with
    ActivityNotFoundException
    … Has anyone else found this? How can we fix it? Thanks!
    a
    3 replies · 2 participants
  • c

    Chris Johnson

    08/01/2022, 9:18 PM
    Is there a way to change statusBar/navigationBar colors in a launcherActivity via something in compose? Or is this just something that needs to be done on the Activity level via styles. Currently if I use accompanist when setting up my themes to try and switch the colors you notice initially they default to the MaterialTheme. (which makes sense. My composable theme hasn't been invoked yet) Guess I was wondering if there's a way to apply your compose themes and set those as the source of truth before the activity default theme comes into play? For instance I'd like to set the status/nav bar to transparent on my launcher activity
    a
    3 replies · 2 participants
  • j

    Jorge Domínguez

    08/01/2022, 8:01 PM
    I have a form UI written in Compose, the user can click a Create button that triggers an object creation that will be stored in a DB. Initially I was constructing the object in the Compose callback for the Create button, but I believe that's something the UI shouldn't be doing, so I moved the logic to the ViewModel, but then I ended up with a function with a lot of parameters, is there a better way to do this? I was thinking of using a state holder that's updated whenever the fields in the form are updated, so when the Create button is clicked I take the data from the state holder and I don't need to pass several parameters to the ViewModel function, but that would require hoisting the state of the TextFields, which I'm not sure if it's desired
    b
    3 replies · 2 participants
  • j

    julian

    08/01/2022, 6:26 PM
    I'm repeatedly finding Jetpack Compose-related code documentation to be unclearly written. Here's an example for `SnapshotMutableState`:
    A mutable value holder where reads to the value property during the execution of a Composable function, the current RecomposeScope will be subscribed to changes of that value.
    e
    2 replies · 2 participants
  • p

    prat

    07/25/2022, 3:50 PM
    This function should ***not*** be used to (re-)launch ongoing tasks in response to callback
    events by way of storing callback data in [MutableState] passed to [key1].
    Can someone please give an example of this bad use case for
    LaunchedEffect
    ? I want to make sure that I understand this correctly.
    z
    2 replies · 2 participants
  • b

    Billy Newman

    08/01/2022, 6:35 PM
    Hello all, looking for some help drawing text along an arc drawn in Canvas. Code in replies.
    s
    t
    6 replies · 3 participants
  • r

    raghunandan

    07/18/2022, 11:04 AM
    I used view pager to achieve the below ui. I had to hardcode the padding to 142.dp. Is there any other way to achieve this using pager lib.
    9 replies · 1 participant
  • t

    Tash

    08/01/2022, 9:42 PM
    Does
    currentLines
    ever get updated from the
    onTextLayout
    block? Like if you removed everything else.
    p
    c
    +1
    8 replies · 4 participants
  • p

    Paul Woitaschek

    08/02/2022, 7:13 AM
    With accompanist 0.25.0, the permission flow has changed. https://google.github.io/accompanist/permissions/ https://github.com/google/accompanist/commit/a9506584939ed9c79890adaaeb58de01ed0bb823 Now the
    permissionRequested
    is missing with the goal for a better UX. But doesn’t this take away the possibility to ask for the permission right away? For example in our flow the user clicks on a camera icon. In this case I don’t want to show her a dialog where I explain that I’m now going to ask her for her permission.
    a
    2 replies · 2 participants
  • j

    Joe Altidore

    08/01/2022, 10:27 PM
    Hello guys, I am new in compose and I got the error below when i tried to run my compose project the first time. Please, how do I resolve the error?
    Execution failed for task ':app:compileDebugKotlin'.
    > Could not resolve all files for configuration ':app:kotlin-extension'.
       > Could not find androidx.compose.compiler:compiler:1.3.0-alpha02.
    i
    2 replies · 2 participants
  • f

    fengdai

    08/02/2022, 8:51 AM
    Hi guys. I’m playing with Snapshot System. I tried to modify a mutable state in global snapshot, but the apply listener doesn’t get called back. Code in🧵
    z
    8 replies · 2 participants
Powered by Linen
Title
f

fengdai

08/02/2022, 8:51 AM
Hi guys. I’m playing with Snapshot System. I tried to modify a mutable state in global snapshot, but the apply listener doesn’t get called back. Code in🧵
Here is my code:
val globalWriteObserverHandler = Snapshot.registerGlobalWriteObserver {
  println("on global written")
  Snapshot.sendApplyNotifications()
}
val applyObserverHandler = Snapshot.registerApplyObserver { set, _ ->
  println("on applied - $set")
}
val count = mutableStateOf(0)
count.value = 1
globalWriteObserverHandler.dispose()
applyObserverHandler.dispose()
If I take a snapshot before the modification and dispose the snapshot immediately, then the apply listener can get called back when state is modified:
...
val count = mutableStateOf(0)
// added this line
Snapshot.takeSnapshot().dispose()
count.value = 1
...
Dose anyone know the reason?
I found it’s due to the logic in
fun <T : StateRecord> T.overwritableRecord
.
internal fun <T : StateRecord> T.overwritableRecord(
    state: StateObject,
    snapshot: Snapshot,
    candidate: T
): T {
    ...

    if (candidate.snapshotId == id) return candidate

    ...

    snapshot.recordModified(state)

    return newData
}
When candidate record is found, it returns, without calling
recordModified
. Is this expected? If yes, what the reason?
z

Zach Klippenstein (he/him) [MOD]

08/03/2022, 7:08 PM
I’m guessing yea, because the snapshot system is designed only to let observers know if an object has been modified, not how many times it’s been modified, in a given snapshot. If an object is modified many times in a snapshot, there are probably major performance wins to this approach.
f

fengdai

08/04/2022, 12:59 PM
I see. It makes sense. But I still feel that the behavior is a little bit buggy in my first code snippet. I expect there would be at least one apply notification.
z

Zach Klippenstein (he/him) [MOD]

08/04/2022, 4:54 PM
Look at the kdoc for initializeObjects and sendApplyNotifications in Snapshot.kt. Changes aren't recorded for brand new state objects until the snapshot is applied or initializeObjects is called.
f

fengdai

08/05/2022, 12:07 AM
initializeObjects
? I’m guessing you mean
notifyObjectsInitialized
. And it works. Thanks very much!
z

Zach Klippenstein (he/him) [MOD]

08/05/2022, 6:10 PM
Yep, sorry
View count: 3