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

    Michal Klimczak

    09/15/2021, 7:28 AM
    I'm trying to pinpoint performance issues (laggy LazyColumn). I'm testing that on release+R8 (on Huawei P20 lite Android 9), but it's still not good. I don't really understand what kind of difference should I expect between release+R8 on development machine and google play version and wanted to try to simulate that. Found:
    adb shell cmd package compile -r bg-dexopt my.app.id
    But it only shows me
    Failure: package my.app.id could not be compiled
    My second question is - can I somehow test the final experience, e.g. should deploying to Firebase App Distribution work as fine as Google Play or not really?
    👀 1
    s
    w
    • 3
    • 8
  • a

    Alexander Sitnikov

    09/15/2021, 9:35 AM
    I have a problem with
    Flow.collectAsState()
    where collection of the flow starts one frame after initial composition. Usually my
    Flow
    emits its first value immediately upon subscription, and in that case I don’t want to see
    initialValue
    . But because collect starts only after first frame, there’s visible fast “blink” when you first open a screen. As I understand it’s because
    LaunchedEffect
    executes it’s lambda in
    AndroidUiDispatcher
    , and it dispatches `LaunchedEffect`’s job only after first frame has been drawn. I found a solution, where if I launch a coroutine that collects the
    Flow
    with
    start = CoroutineStart.UNDISPATCHED
    , value is produced immediately after first composition (so I can read it inside
    SubcomposeLayout
    of some sort, and screen does not “blink”). Is there any pitfalls of doing so?
    a
    • 2
    • 27
  • z

    Zoltan Demant

    09/15/2021, 10:04 AM
    Where should I start digging when looking to optimize a large/complex screen that stutters? 🧵👀
    b
    s
    +3
    • 6
    • 11
  • s

    Stylianos Gakis

    09/15/2021, 11:01 AM
    Is there a way to not strip out @Preview composables for a build that has
    isMinifyEnabled = true
    ? Couldn’t find how to edit my proguard to make that happen My use case is that I want a different build type, that is not production, but is used to test the production experience (minified) but also be able to browse the previews rendered by Showkase
    c
    e
    j
    • 4
    • 11
  • p

    Peter Mandeljc

    09/15/2021, 11:01 AM
    would it be a bad idea, to have a CompositionLocalProvider for a callback, to communicate with root composable, like post msg on a msg bus?
    c
    k
    • 3
    • 3
  • t

    Tim Malseed

    09/15/2021, 12:04 PM
    Hey all, I've got a
    BottomSheet
    that sits above the
    BottomAppBar
    . As the sheet is expanded, I'd like the
    BottomAppBar
    to scroll off screen. I've managed to sort of achieve this by tying the `BottomAppBar's`y offset to the bottom sheet's offset amount (derived from
    BottomSheetState
    direction & progress:
    val bottomSheetScaffoldState = rememberBottomSheetScaffoldState()
    
    Scaffold (
        bottomBar = {
            BottomAppBar(Modifier.offset(y = 56.dp * (1f - bottomSheetState.offsetFraction()))
        }
    ) { padding ->
        BottomSheetScaffold(Modifier.padding(bottom = 56.dp * bottomSheetState.offsetFraction()))
    }
    The problem is that the bottom sheet scroll/fling events now seem to be sort of interrupted. I guess having the padding change out from underneath it while it's scrolling causes issues with the size calculations or something along those lines. Just wondering if anyone can recommend an approach for this?
    z
    c
    • 3
    • 10
  • n

    Napa Ram

    09/15/2021, 12:11 PM
    how to listen to onbackpressed in jetpack compose
    d
    • 2
    • 1
  • v

    Vinícius Santos

    09/15/2021, 2:39 PM
    Hi, I've just switched to acompanist navigation animation, and iam having the folowing error when I try to add the args to the
    composable()
    , removing the arguments makes evething works fine.
    Navigation destination that matches request NavDeepLinkRequest{ uri=<android-app://androidx.navigation/character> } cannot be found in the navigation graph NavGraph(0x0) startDestination={NavGraph(0x78da56c6) route=main startDestination={Destination(0x78d845ec) route=home}}
    This is the code thats braking
    composable(
                route = MainRoutes.CharacterDetail.routeName,
               arguments = MainRoutes.CharacterDetail.navArgs, /*Comenting this line get things working again*/
                enterTransition = {initial, target -> null },
                exitTransition = {initial, target -> null },
                popEnterTransition = {initial, target -> null },
                popExitTransition = {initial, target -> null }
    
            ) { backStackEntry ->
                val character = MainRoutes.CharacterDetail.getNavArgs(backStackEntry)
                character?.let {
                    CharacterScreen(
                        character = character,
                        onBack = { navController.popBackStack() })
                }
            }
    i
    • 2
    • 6
  • m

    miqbaldc

    09/15/2021, 3:15 PM
    Would anyone giving me a hint about this snippet code in 🧵 Context:
    mutableStateOf(<with initial/default value>)
    but the recomposition unable to use the default value
    z
    • 2
    • 10
  • l

    Luke

    09/15/2021, 3:32 PM
    Considering:
    Column(modifier = Modifier.height(128.dp)) {
        Text("Super long text...", overflow = TextOverflow.Ellipsis)
    }
    Is there a way to constraint the Text to ellipsize as soon as the next line would be outside the column? Since the column has a predefined height, different font scales would require different max lines. I know I can check
    LocalDensity.current.fontScale
    but I'm looking for something more generic
    c
    • 2
    • 2
  • r

    Rak

    09/15/2021, 3:48 PM
    HI, just had a presentation on compose in my company and the QAs asked will compose still work with their automation frameworks. Anyone have any comments?
    z
    s
    s
    • 4
    • 5
  • v

    Vinay Gaba

    09/15/2021, 4:53 PM
    Just noticed that the alpha version of Compose enforces a minCompileSdk of 31. Do we know if the stable version of Compose is also going to enforce this soon (my guess is that it probably will). The main reason we were trying to use alpha was because we wanted to leverage Kotlin 1.5.30.
    z
    h
    +2
    • 5
    • 8
  • d

    divid3d

    09/15/2021, 9:07 PM
    Matrix code created in Compose
    matrix_code.mp4
    👏🏼 1
    😀 2
    💯 8
    🤯 1
    👏 22
    👏🏻 1
    c
    • 2
    • 1
  • o

    Orhan Tozan

    09/15/2021, 10:12 PM
    ETA of a stable Compose release with KT 1.5.30?
    a
    c
    • 3
    • 4
  • c

    Colton Idle

    09/16/2021, 5:41 AM
    When I'm hooking up the
    up
    button, I know that both
    navController.navigateUp()
    and
    navController.popBackStack()
    do the same thing, but which one should be used for the up action specifically.
    navigateUp
    right?
    :yes: 3
    a
    o
    +5
    • 8
    • 40
  • s

    Stefan Oltmann

    09/16/2021, 8:40 AM
    I was asked if I could display photos in the gallery of my app in the way Lightroom CC or Mylio do with their "fluid grid style". I don't see any support for that in Compose. Does someone know a library that has this kind of grid style already?
    ➕ 1
    ✅ 1
    a
    a
    • 3
    • 3
  • k

    K Merle

    09/16/2021, 9:59 AM
    I need to popBackStack() to a specific screen that contains Scaffold bottom navigation. Depending on the situation, sometimes it takes two popBackStack's sometimes one to get to the screen. Is there any better way to handle returning to the bottom navigation screen and still keep the bottom navigation state in a situation where I am not sure how many popBackStacks are required?
    s
    w
    • 3
    • 2
  • r

    Rafiul Islam

    09/16/2021, 10:08 AM
    Is it possible to make a similar layout as below using LazyColumn in jetpack compose? Inner List is not scrollable.
    c
    c
    • 3
    • 9
  • n

    Nicholas Doglio

    09/16/2021, 12:52 PM
    What’s the best way to handling an infinite paging list without using the jetpack paging library? (Trying to keep my paging solution JVM only for easier testing and hopefully KMP at some point) I’m currently using
    SnapshotStateList
    and it’s working fine but still new to Compose so was wondering if anyone had a better implementation.
    r
    • 2
    • 2
  • s

    Stefan Oltmann

    09/16/2021, 2:23 PM
    I want to scroll a
    LazyRow
    so that the element is centered.
    LazyListState.animateScrollToItem()
    takes an
    index
    and a
    scrollOffset
    as arguments. Per default it scrolls the list so that the item is the first one. If a positive
    scrollOffset
    is given it scrolls further, making the item go off scren. So I tried to give a negative
    scrollOffset
    and calculate what I need so that the element is in center position. The problem is: Negative Offsets are not allowed. 😞 How can I scroll to an index that it's at the center of the list?
    👀 3
    j
    • 2
    • 5
  • t

    theapache64

    09/16/2021, 4:34 PM
    🧪 How do I see the
    println
    or
    Log
    output in androidTest? Details in thread 🧵
    • 1
    • 1
  • n

    Nikhil

    09/16/2021, 5:58 PM
    How can I get the center of any composable element? I was trying using
    onGloballyPositioned{..}
    (I also have some other code and I want to avoid adding it this modifier since it’s called a lot.) Is there any method/modifier where I can get any alternative of `Rect`/
    bounds
    ?
    d
    z
    w
    • 4
    • 8
  • b

    brabo-hi

    09/16/2021, 6:10 PM
    Hi all, is there a performance issue when we embed Scaffold? For example the first Scaffold has a bottom bar and each page has a Scaffold Content. Which means, instead of defining TopAppBar from the parent and change depending on the route, each child will have it’s one Scaffold therefore it own TopAppbar
    s
    • 2
    • 2
  • k

    K Merle

    09/16/2021, 7:09 PM
    Is it possible to turn off default fade transition animation?
    i
    f
    • 3
    • 15
  • g

    gpaligot

    09/16/2021, 8:34 PM
    Hello here! I'm playing with
    Text
    composable, the callback
    onTextLayout
    to get information about text measurements and the modifier
    drawBehind
    .
    Text(
        text = "My text here\n Multi line",
        modifier = Modifier.drawBehind {
            // Draw something here
        },
        onTextLayout = { textLayoutResult ->
            // Get value of textLayoutResult.multiParagraph.lineCount 
            // Get values of textLayoutResult.multiParagraph.getLineHeight(index)
        }
    )
    If I'm using this snippet with two states, it works well but my composable is draw 2 times. First time to measure the text and the second time when my states are updated inside the
    onTextLayout
    callback which force a new recomposition. I would like to know if it is possible to avoid to draw 2 times my text when there are no changes between my first and second composition? If anyone have an idea, I'm very interested! Thanks!
    a
    • 2
    • 3
  • m

    Marko Novakovic

    09/16/2021, 8:55 PM
    am introducing
    compose
    into new project but I can’t run it. error:
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
    I have fragment with
    ComposeView
    and am just calling
    setContent
    on it any help? compose version 1.0.2 compose build feature is enabled
    composeOptions {
        kotlinCompilerExtensionVersion = "1.0.2"
        kotlinCompilerVersion = "1.5.21"
    }
    z
    w
    • 3
    • 41
  • c

    Colton Idle

    09/16/2021, 11:11 PM
    I have a horizontal pager with two images that isn't working how I expect it would. Anyone have any ideas? Code in thread.
    fail.mp4
    a
    • 2
    • 3
  • a

    adjpd

    09/16/2021, 11:13 PM
    When I click on a bottom
    BasicTextField
    , the keyboard covers the input. Is this expected behavior (even with
    adjustResize
    )?
    LazyColumn {
      items((1..100).toList()) { BasicTextField("$it", {}) }
    }
    👍 1
    w
    b
    • 3
    • 6
  • b

    bohregard

    09/16/2021, 11:54 PM
    Has anyone had any issues with the Paging 3.0 Library duplicating data? Every time a new page is requested, it loads the new data but then overwrites all of the previous data with the new data. See code in thread:
    i
    d
    d
    • 4
    • 33
  • z

    Zoltan Demant

    09/17/2021, 7:06 AM
    When using enums in compose, would you recommend using
    remember
    on
    Enum.values()
    such that a new array isnt created on each recomposition, or am I over-optimizing?
    f
    • 2
    • 1
Powered by Linen
Title
z

Zoltan Demant

09/17/2021, 7:06 AM
When using enums in compose, would you recommend using
remember
on
Enum.values()
such that a new array isnt created on each recomposition, or am I over-optimizing?
f

Felix Schütz

09/17/2021, 7:21 AM
I would not worry about it before profiling shows it to be a problem.
👍 1
👍🏽 1
☝️🏻 1
View count: 4