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

    Zach Klippenstein (he/him) [MOD]

    01/05/2023, 12:24 AM
    are you using emojicompat?
    • 1
    • 1
  • y

    Yariv Ziporin

    01/05/2023, 4:53 AM
    Hi guys, does anyone knows a library called formbuilder on github? It's great and it works for validating fields. However there's a function called getdata that creates a data class according to the data field in the form and it crashes even with a simple form of one string text field.
    k
    m
    • 3
    • 2
  • j

    Johannes Prüller

    01/05/2023, 8:04 AM
    Hello everyone, I have a question regarding
    ModalBottomSheetLayout
    with a nested
    LazyColumn
    . I followed the docs how to implement this, but as it turns out there is a strange behaviour randomly happening, which causes that the list cannot be scrolled down further and also the end of list animation is shown. Does anyone know what’s causing this?
  • k

    KotlinLeaner

    01/05/2023, 9:21 AM
    Hi guys, Can someone help me on to autoscroll the column item. I have
    Column
    inside that there are few items. Some of the item are hidden and visible on some condition. There is one
    Nested Column
    which is adding item and auto scrolling which is done with the help of this post. Item adding will done through
    Add Me
    CTA. Main problem comes here, when I was added more than 10 item and then we click on
    Show Banner
    CTA,
    AnimatedVisibility
    condition will true and display the view and
    Nested Column
    will shifted the few items downward. I don't won't like this, instead I wan't to calculate the whole column height and always show the last item. Same as done through in the answer gif.
    • 1
    • 2
  • o

    oday

    01/05/2023, 10:04 AM
    ok so I am using/modifying
    .value
    stuff inside a
    when
    , which yes is technically not inside a Composable, and I’m being allowed to do so, but there is a big warning about it of course how do I avoid that?
    LazyRow(
        contentPadding = PaddingValues(16.dp)
    ) {
        items(
            items = listItems.value,
            key = { it.type },
            itemContent = { item ->
                val label = when (item) {
                    is BrowseEventsFilter.PeriodFilter -> {
                        when {
                            item.period.value != Period.Any -> {
                                item.enabled.value = ChipStatus.ENABLED
                                stringResource(id = item.period.value.label())
                            }
    
    
    ...............etc
    s
    • 2
    • 9
  • s

    svenjacobs

    01/05/2023, 10:15 AM
    Hello everybody and a Happy New Year! Let’s say I have a multi-module / multi-feature Android application in Compose. In one of the features I want to place a composable above all other composables (full screen), but of course this composable is not the top most composable in the hierarchy. I could put this composable at the very beginning in my
    main
    module, but then I would have a tight coupling of main and the feature. Is this even possible, a composable some layers down in the hierarchy rendering above all other composables?
    a
    z
    • 3
    • 9
  • c

    chanjungskim

    01/05/2023, 12:52 PM
    Is there any way to seperate Glance import and Compose import? I always need to select one of them when I code... I also make Widget so I use both of them.
    k
    m
    • 3
    • 26
  • c

    chanjungskim

    01/05/2023, 3:31 PM
    I have another question... Today I applied detekt with Twitter compose rules. And It says Composable function that is content should have modifier param from Top Level. I don't get it. Why is that? The function is like
    @Composable
    fun MyView(){
        // fixed content.
    }
    k
    • 2
    • 1
  • n

    Nebil

    01/05/2023, 5:34 PM
    Hello everyone, I was trying trying to group list of events by day and sort the events within that day and I ran into a problem when I try to group the events for a given day by event type and still sort the whole events for that given day by start time regardless of the game type. Open to any suggestions. Thanks.
    l
    • 2
    • 4
  • j

    Justin Yue

    01/06/2023, 12:08 AM
    I'm writing a custom view to be used inside
    AndroidView
    , but when I run my app, my custom view does not appear. I was thinking perhaps passing in null for the
    root
    paramater might be problematic for
    LayoutInflater.from(context).finflate(R.layout.view_visualization, null, false)
    . Normally, I would call
    rootView
    instead, but that just returns my custom view. Is there a way to instead have the root be the composable that calls this custom view?
    m
    i
    • 3
    • 17
  • y

    Yingding Wang

    01/06/2023, 1:31 AM
    How can I use vector drawable with the original
    android:fillColor
    in compose? `painterResource`seems to override these fillColor with Theme Colors.
    a
    • 2
    • 2
  • m

    mattinger

    01/06/2023, 1:55 AM
    Just a quick question on the @Immutable annotation. How should we treat things with immutable lists?
    data class Foo(values: List<String>)
    b
    • 2
    • 3
  • a

    AmrJyniat

    01/06/2023, 8:51 AM
    I have a
    TextField
    with validations, I want to show error(make
    isError
    property equals to true) only after losing the TextField's focus, not on the initial composition, how I can accomplish that?
    z
    a
    • 3
    • 8
  • e

    Elio Maroun

    01/06/2023, 9:13 AM
    https://github.com/kizitonwose/Calendar/issues/437
    k
    • 2
    • 1
  • h

    Hasan Nagizade

    01/06/2023, 9:13 AM
    Hi when I open my app from recents screen network calls work but I don't see updates on the screen. What could be the reason for that?
    f
    • 2
    • 1
  • o

    oday

    01/06/2023, 11:19 AM
    I would like to test for whether a lazycolumn (or any list) contains X items, not that X items are visible right now on the screen, but whether the list in general has this many items
    e
    • 2
    • 2
  • t

    Tgo1014

    01/06/2023, 12:54 PM
    This used to work but the
    clickable
    is not being applied anymore. What's the proper way to handle dynamic modifiers?
    val localModifier = Modifier
        .fillMaxWidth()
        .height(IntrinsicSize.Max)
        .apply {
            if (!disableClick) {
                this.clickable {
                    Timber.w("Music CLicked")
                    onMusicClick.invoke(music)
                }
            }
        }
        .padding(8.dp)
    g
    e
    m
    • 4
    • 10
  • n

    Nat Strangerweather

    01/06/2023, 2:12 PM
    I have a problem with
    PullRefreshIndicator
    ; it stays stuck half-way down the screen and does not refresh anything. Here is my code: 🧵
    • 1
    • 2
  • u

    ursus

    01/06/2023, 2:28 PM
    Why does it matter if I call a composable from within a
    when
    in every branch, vs. producing a value with the
    when
    and calling the composable with the result? Former seems to lag the scrolling, while latter doesn’t
    Code in thread`
    f
    z
    a
    • 4
    • 13
  • n

    Nat Strangerweather

    01/06/2023, 2:37 PM
    I have a problem with the
    PullRefreshIndicator
    which stays stuck halfway down the screen and does not execute the function. Please see code in thread.
    a
    • 2
    • 4
  • l

    Landry Norris

    01/06/2023, 2:39 PM
    I’m trying to test a two finger gesture with the following code:
    private fun SemanticsNodeInteraction
                .twoFingerGesture(offset1, offset2) {
            performTouchInput {
                down(0, offset1)
                down(1, offset2)
    
                up(0)
                up(1)
            }
        }
    When I put logs in forEachGesture, it seems like the pointer id is set to 2 for all 4 events, and the event.changes size is always 1, instead of (1, 2, 2, 1) like when I do the same gesture manually. Is there something I’m doing wrong in my code?
    a
    • 2
    • 4
  • t

    Tariyel Islami

    01/06/2023, 4:33 PM
    Hello guys, There should be multiple screens in one screen. For example: in screen X, there will be screens A, B, C, D. But they all belong to X. Do I need to keep these screens as content or should I add them as navigation?
    z
    d
    i
    • 4
    • 8
  • a

    Akash Khatkale

    01/06/2023, 6:59 PM
    Hey there, Is there any way to pass on drag/touch event from one composable to another ? I have a button in my layout, so once i long press that button i show a popup....so if i long press a button and then drag my finger to the popup, the popup should continue handling the drag event. Is there any way to do this ?
  • n

    Nicolai

    01/06/2023, 8:27 PM
    Hi guys! Is there a way in Compose where I can detect if a text can actually fit and if not change the text to an abbreviation to make it fit?
  • v

    vide

    01/07/2023, 6:54 PM
    I have a weird issue with recompositions. I have a function with the following metrics, but the function is never skipped even when the parameters don't change:
    restartable skippable scheme("[androidx.compose.ui.UiComposable]") fun MenuButton(
      stable menuOpen: Boolean = @dynamic LiveLiterals$NavBarKt.Boolean$param-menuOpen$fun-MenuButton()
      stable setMenuOpen: Function1<Boolean, Unit>
      defaultFocusRequester: FocusRequester
      stable onWidthChange: Function1<Dp, Unit>
    )
    The problem goes away from defaultFocusRequested is removed from the parameters, so it's definitely related to that. The object that is passed is the same on every recomposition, but it never skips. Is there a bug in compose metrics reporting the function as skippable? 🤔
    r
    z
    • 3
    • 10
  • m

    mgrazianodecastro

    01/07/2023, 9:48 PM
    Does google have plans to publish a jetpack compose style CameraX implementation?
    a
    • 2
    • 2
  • m

    Miguel Kano

    01/07/2023, 10:39 PM
    In the fragment world, we could have a shared top bar where each fragment could specify what gets displayed for the action items and receive the click events. In compose, the recommended approach seems to be to define the top bar outside the NavHost and use APIs such as
    NavController.currentBackStackEntryAsState()
    to mutate the top bar based on the current screen. This means the root Scaffold owns the declaration of the top bar. It works fine for simple cases like just toggling the visibility of the top bar or controlling the bottom bar, but I find it not very practical in the following aspects. I've searched around on this slack, but couldn't find an answer that feels satisfying.
    Scaffolder(
        topBar = {
            if (current screen is "xyz") show this else that...
        },
        ...
    ) {
        NavHost {...}
    }
    1: How would the currently displayed composable screen receive the click event on the action items? Pushing the event down is discouraged. I found this post from Ian, but I don't get it 2: If which action items should display depends on the logic/data fetched from the current screen, how should that be communicated to the root Scaffold? 3: In reality with large apps, I would want to define/encapsulate such logic and click event handling closer to the actual feature rather than defining all variations of them at the root level.
    • 1
    • 1
  • p

    Puskal

    01/08/2023, 5:31 PM
    I am using stateflow. One of the ui state is ErrorState. If api return error, it will emit ErrorState and as per it error message will display in ui. After error display, if i naviagate to other pages and navigate back ErrorState will again collect and error msg display. (Expected behavior as i am using stateflow). But i dont need to show error msg after naviagate back. I am thinking about certain solution like using another sharedflow for error state. Or if possible scoping viewmodel to composable so that new viewmodel instance created on naviagate back. Is there any other best recommend way to handle such type of issue.
    z
    p
    d
    • 4
    • 4
  • f

    Francesc

    01/08/2023, 8:35 PM
    As long as the screen for this composable is in the backstack the viewmodel will be kept alive. Once you pop the screen the viewmodel will be destroyed
    z
    • 2
    • 1
  • n

    Nat Strangerweather

    01/08/2023, 9:38 PM
    I have this in a lazyColumn:
    items(state.newsFeedItems) { item ->
                            ResultsChip(item, navController)
                        }
    The
    newsFeedItems
    come from a room database. When I click on a
    ResultsChip
    I get the corresponding items in my next screen. When I navigate back and click on another
    ResultsChip
    for some reason I get the items of the first chip in my next screen. Is there something when navigating back that
    remembers
    the previous items? Why does clicking on a second chip not yield the second chip items but the first ones?
    z
    • 2
    • 2
Powered by Linen
Title
n

Nat Strangerweather

01/08/2023, 9:38 PM
I have this in a lazyColumn:
items(state.newsFeedItems) { item ->
                        ResultsChip(item, navController)
                    }
The
newsFeedItems
come from a room database. When I click on a
ResultsChip
I get the corresponding items in my next screen. When I navigate back and click on another
ResultsChip
for some reason I get the items of the first chip in my next screen. Is there something when navigating back that
remembers
the previous items? Why does clicking on a second chip not yield the second chip items but the first ones?
z

zt

01/09/2023, 6:15 AM
I believe if you pass a lambda that produces a unique value for every item in the key param then it should behave as expected. This explains it more in detail: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/package-summary#(androidx.compose.foundation.lazy.LazyListScope).items(kotlin.collections.List,kotlin.Function1,kotlin.Function1,kotlin.Function2)
n

Nat Strangerweather

01/09/2023, 9:12 AM
Thank you for this! 😊
View count: 8