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

    Manuel Lorenzo

    08/24/2022, 1:59 PM
    I’m having some issues with Accompanist permissions and Compose: I grant the permissions to my app, but if I close it and open it again, I see that the permissions are denied (like they’re never saved or persisted). Here’s the code 🧵
    • 1
    • 1
  • a

    andrew

    08/24/2022, 2:34 PM
    I know order matters and such, but borders are still drawn inside of the box
    c
    n
    • 3
    • 8
  • j

    Jasmin Fajkic

    08/24/2022, 7:04 PM
    me once again with navigation 😄 😅. Is it better in navhost to create one function navigate and just where we need pass string as route where to go (check thread):
    i
    • 2
    • 2
  • s

    Simona Stojanovic

    08/24/2022, 8:02 PM
    Hi everyone 👋! With today’s
    1.3.0-beta01
    Compose release, we are introducing some major changes to the way the Compose Modifier API works under the hood (⚠️ no public APIs have changed and it’s backwards compatible). If you notice any issues with modifiers or have any feedback when upgrading to
    1.3.0-beta01
    , please let us know here or by creating an issue. For more details around this change, check out the release notes. Thanks all! 🤙
    c
    m
    • 3
    • 5
  • w

    Wojciech Rozwadowski

    08/24/2022, 8:49 PM
    I want to use
    value class
    with
    String
    as
    key
    for
    LazyColumn
    item. Unfortunately I received
    Type of the key testString is not supported. On Android you can only use types which can be stored inside the Bundle
    Is there any chance to add custom
    Saver
    to
    LazyColumn
    or to add support for
    value class
    ?
    f
    • 2
    • 6
  • a

    Aaron Waller

    08/24/2022, 11:03 PM
    I need some recommendations on how to solve the following problem: Currenlty building a Social media application with a lot of Screens, each Screen contains a List<Post>. I fetch the data from my GraphQL Backend and I do NOT save it into a Room/SQLite database (No Single Source of Truth). If for example Post with ID 1 in the List of Screen A gets updated by the user, it should also update the Post with ID 1 in List of Screen B. Happens sometimes that the same Post is contained in multiple Lists all around the app. How can I reflect the changes I made on Screen A in Screen B? Screen B doesn’t reload everytime because I have
    saveState = true
    . When I restart the application it of course fetches the up to date data from my graphql endpoint. Is a SSOT system the only way to solve it? Is it even possible in my case due to the constantly changing and user generated content? P.S I’m using GraphQL Apollo + MVVM + Clean Architecture.
    i
    l
    s
    • 4
    • 4
  • m

    mattinger

    08/25/2022, 4:55 AM
    So, i’m trying to test a wrapper i’m writing around ModalBottomSheetLayout, and the testing strategy i have to use seems very odd to me. I can’t seem to call the
    show
    or
    animateTo
    functions of the ModalBottomSheetState outside of a composition, or i get this error:
    A MonotonicFrameClock is not available in this CoroutineContext. Callers should supply an appropriate MonotonicFrameClock using withContext
    . I’ve boiled this down to a pretty simple example, which i will put in the thread. But the basic strategy i seem to have to resort to is to keep mutableState object, and then in the
    setContent
    block, i can create a LaunchedEffect and collect that value and call the animateTo method instead.
    j
    • 2
    • 3
  • s

    Shafayat Bin Mamun

    08/25/2022, 5:19 AM
    Any news on when we can create our own composable as markers in google maps compose?
  • k

    K Merle

    08/25/2022, 5:35 AM
    Does it make a difference if, in a composable function, you declare lambda first, and pass it as an argument, or directly pass it as an argument?
    @Composable
    fun Parent() {
        val argument = {
            // Do something
        }
        Child(param = argument)
    }
    
    fun Child(param: () -> Unit) {}
    vs
    @Composable
    fun Parent() {
        Child(param = {
            // Do something
        })
    }
    
    fun Child(param: () -> Unit) {}
    m
    l
    • 3
    • 6
  • p

    Philip S

    08/25/2022, 7:43 AM
    How do you make it so the content of a
    LazyColumn
    is not hidden by soft keyboard and
    TextInput
    when scrolled to bottom? Basically I want "This is message 5" to still be visible when opening keyboard. The activity uses
    android:windowSoftInputMode="adjustResize"
    and I tried using some padding values from https://google.github.io/accompanist/insets/ without effect.
    n
    s
    • 3
    • 3
  • k

    KotlinLeaner

    08/25/2022, 8:45 AM
    Hi, Is there any better approach in compose to solve last item padding in column? Please have a look my approach.. Thanks
    Column {
        items.forEachIndexed { index, item ->
            if (index != items.lastIndex) {
                Column(
                    Modifier.padding(0.dp, 0.dp, 0.dp, dimensionResource(R.dimen.item_view_padding))
                ) { }
            }
        }
    }
    a
    • 2
    • 2
  • c

    Can Korkmaz

    08/25/2022, 9:12 AM
    Hello, in Androidview does setting a layout parameter in previous recompositions with update block stay intact even if the update block changes, or does it default to factory settings. Also assuming I insert an animation inside update block,
    imageView.animateByResource(R.anim.shrink_animation) {
        imageView.setScaleBoth(0f)
    }
    would that default to initial value at every compositon. Like adding a lifecycleEventObserver in update state, it would be added many times since it is added every recomposition. I pass update block as lambda parameter by the way. If the way I understand the update block mechanics is correct, then I should wrap updates that I want to execute only once in an Event, and use with getIfNotHandled(). Or with additional control blocks.
    • 1
    • 2
  • n

    nuhkoca

    08/25/2022, 11:57 AM
    Hello! Even though I use a very unique identifier, I am sometimes getting below and app is crashing.
    If you are using LazyColumn/Row please make sure you provide a unique key for each item.
    Did anybody face a similar problem with
    LazyList
    ?
    s
    c
    • 3
    • 7
  • z

    Zoltan Demant

    08/25/2022, 2:08 PM
    Compose
    1.3.0-beta01
    had a huuuge impact on performance with debug builds (in a good way). What changed? Did the modifier refactor have this big of an impact? Its almost on-par with a release build now 🙌🏽
    l
    • 2
    • 3
  • s

    Slackbot

    08/25/2022, 2:18 PM
    This message was deleted.
  • j

    José González D'Amico

    08/25/2022, 3:09 PM

    https://youtu.be/-ZExs9Gncic▾

    o
    • 2
    • 1
  • g

    gsala

    08/25/2022, 4:17 PM
    Hey. Why is it that there’s no easy way to combine or modify
    PaddingValues
    . Sometimes I would like to combine padding values like
    WindowInsets.ime.asPaddingValues - PaddingValues(bottom = 30.dp)
    . Other times I would just like to override some default padding values like
    BottomSheetDefaults.ContentPadding.copy(bottom = 0.dp)
    . Shouldn’t this be easier in the compose APIs ? Or am I missing the right way to do this?
    z
    q
    +2
    • 5
    • 16
  • m

    Marco Pierucci

    08/25/2022, 4:20 PM
    Hello hello, do I have to explicitly call
    focusManager.clearFocus()
    If I expect text field to clear its focus upon button clicks?
  • i

    Igor Stevanovic

    08/25/2022, 5:01 PM
    Hello! Does anybody have a project example that showcases recording a video in Jetpack Compose?
    c
    l
    • 3
    • 4
  • d

    dimsuz

    08/25/2022, 5:13 PM
    Is it ok to do this
    fun MyComposable(
      value: Boolean,
      slot1: @Composable () -> Unit = if (value) { Content1() } else { Content2() },
      slot2: @Composable (() -> Unit)? = if (value) { Content1() } else null,
    )
    I recall having some state-related problems with one of those (or both), but can't recall exactly which ones. Maybe one of the slots is ok and another is not? Or both ok/not ok?
  • l

    Leland Richardson [G]

    08/25/2022, 5:21 PM
    assuming
    Content1()
    returns a
    @Composable () -> Unit
    it should work fine. i think there used to be a bug related to this type of thing but shouldn’t be any more. please file one if it doesn’t work
    d
    • 2
    • 4
  • g

    Garrett Coughlin

    08/25/2022, 7:52 PM
    Hey Everyone! I am dealing with some strange behavior with a LazyRow. Based on a boolean property, I am highlighting a UI element. The problem is when the Boolean Property changes, the UI only updates when the element is no longer visible on the screen
    f
    • 2
    • 11
  • a

    allan.conda

    08/25/2022, 11:45 PM
    I got feedback that lazycolumn is more sensitive to scroll than recyclerview. Is it deliberate and is there a way to reduce this?
    s
    i
    a
    • 4
    • 5
  • a

    AmrJyniat

    08/26/2022, 9:45 AM
    I noticed that
    LaunchEffect()
    has natural behavior like
    distinctUntilChanged()
    ? I have an event for showing toast but it seems that show the toast only once. Code in 🧵
    c
    s
    • 3
    • 17
  • u

    uli

    08/26/2022, 12:11 PM
    Is there any good reading on compose. By compose I explicitly do not mean Jetpack Compose UI but the compose base concepts.
    s
    • 2
    • 2
  • s

    Stylianos Gakis

    08/26/2022, 2:40 PM
    Reading through the per-app language documentation, there’s a part which says “Note that calling
    setApplicationLocales()
    recreates your
    Activity
    , unless your app handles locale configuration changes by itself.” Now I remember reading some discussions here, like this one where @Adam Powell suggests that compose handles those itself anyway. Shouldn’t that mean that the documentation should reflect this behavior if it’s also the case for this config change too? It’d be great to know that directly from there without needing to be part of this slack channel.
    m
    a
    +2
    • 5
    • 19
  • c

    Colton Idle

    08/26/2022, 2:44 PM
    I want to add a "modal" bottom sheet. I would like it to turn the rest of the page dark, (like showing an actual modal dialog does). What are the ways to accomplish this? Seems like it's only possible if using a bottom sheet navigation destination?
    s
    o
    +2
    • 5
    • 15
  • g

    Guilherme Almeida

    08/26/2022, 4:10 PM
    Hello 👋 I am trying to draw a waveform and a progress line on top of it in compose using Canvas. A naive implementation could look like this:
    @Composable
    public fun NaiveWaveform(
      waveform: Waveform,
      progress: Float,
    ) {
      Box(
        modifier = Modifier
          .width(256.dp)
          .height(64.dp)
      ) {
        Canvas(modifier = Modifier.fillMaxSize()) {
          drawWaveform(waveform) // heavy drawing, rarely changes
          drawProgress(progress) // changes every 500ms
        }
      }
    }
    The waveform is basically a wrapper for a FloatArray and progress is a float that goes from 0..1. The problem here is that the waveform can have thousands of points to be drawn which makes it hard to be drawn alongside the progress line that updates every 500 ms. Therefore I thought of creating two different Composables, one for each component. By doing that I should be able to leverage smart recomposition (Waveform is @Immutable) and only draw the waveform when it changes, keeping it independent from the progress line. Something like:
    @Composable
    public fun StackedWaveform(
      waveform: Waveform,
      progress: Float,
    ) {
      Box(
        Modifier
          .width(256.dp)
          .height(64.dp)
      ) {
        WaveformCanvas(waveform = waveform)
        ProgressCanvas(progress = progress)
      }
    }
    
    @Composable
    public fun ProgressCanvas(
      progress: Float,
    ) {
      println("ProgressCanvas")
      Canvas(
        modifier = Modifier.fillMaxSize(),
      ) {
        println("Drawing Progress")
        drawProgress(progress)
      }
    }
    
    @Composable
    public fun WaveformCanvas(
      waveform: Waveform,
    ) {
      println("WaveformCanvas")
      Canvas(
        modifier = Modifier.fillMaxSize(),
        onDraw = {
          println("Drawing waveform")
          drawWaveform(waveform)
        },
      )
    }
    And now comes the bit I can’t understand quite well, the logs for these (with the progress animating):
    I/System.out: WaveformCanvas
    I/System.out: ProgressCanvas
    I/System.out: Drawing waveform
    I/System.out: Drawing Progress
    
    -- this initial setup makes sense 👆, compose goes through each composable and draws on each Canvas, but then:
    
    I/System.out: ProgressCanvas
    I/System.out: Drawing waveform
    I/System.out: Drawing Progress
    I/System.out: ProgressCanvas
    I/System.out: Drawing waveform
    I/System.out: Drawing Progress
    ...
    (repeats while progress is increasing)
    Ideally, that second section in the logs should only have “ProgressCanvas” and “Drawing Progress” logs, but somehow it is also redrawing the waveform! Looking at the logs, Compose seems to be skipping
    WaveformCanvas
    (it only calls it once in the beggining, as intended), but moving forward the canvas inside still redraws the waveform everytime the progress changes 🤔 If anyone knows a better way to approach this please let know, thanks in advance!
    l
    m
    • 3
    • 16
  • j

    Jeremiah Jordan

    08/26/2022, 7:29 PM
    Hi, not sure if this is the right channel, but I'm struggling to figure out how to use the GoogleMap's MapEffect composable. My android studio doesn't know what it is when I load these libraries:
    implementation "com.google.android.gms:play-services-maps:$play_maps_version"
        implementation "com.google.maps.android:android-maps-utils:$maps_compose_version"
        implementation "com.google.maps.android:maps-compose:$maps_compose_version"
    And after googling a bit, it looks like it belongs to this package:
    implementation "com.google.maps.android.compose:$maps_compose_version"
    Although it doesn't seem to actually load when I use it, even though I don't have any gradle errors. I'm assuming that if it loaded correctly, I'd be able to use the experimental maps annotation
    @MapsComposeExperimentalApi
    , but so far I haven't figured out the gradle-kung fu to get that to happen.
    • 1
    • 1
  • m

    mattinger

    08/26/2022, 7:30 PM
    So i found an odd thing today. Turns out that “enabled” on a BasicText field does not change the color of the text value in the field. I would have expected it to have muted the text color based on the enabled parameter. I’ve verified that the text style passed in is using a color value of Color.Unspecified. What’s even more surprising is that it’s not paying any attention to LocalContentAlpha either, which i would have expected. I tried surrounding it with that, but it didn’t change anything. THe only way i’ve gotten it to change is to explicitly copy the text style and alter the alpha of it’s color. Has anyone else had this issue?
    s
    s
    z
    • 4
    • 3
Powered by Linen
Title
m

mattinger

08/26/2022, 7:30 PM
So i found an odd thing today. Turns out that “enabled” on a BasicText field does not change the color of the text value in the field. I would have expected it to have muted the text color based on the enabled parameter. I’ve verified that the text style passed in is using a color value of Color.Unspecified. What’s even more surprising is that it’s not paying any attention to LocalContentAlpha either, which i would have expected. I tried surrounding it with that, but it didn’t change anything. THe only way i’ve gotten it to change is to explicitly copy the text style and alter the alpha of it’s color. Has anyone else had this issue?
s

Stylianos Gakis

08/26/2022, 7:34 PM
Sounds reasonable for the
BasicText
as it's the one you're falling back to if you want the barebones text which you have full control over. It'd be surprising if the material one functioned that way I'd say, not this one.
s

Siyamed

08/26/2022, 7:43 PM
There is no theming in BasicText and BasicTextField. They are as minimal as possible.
z

zsperske

08/27/2022, 12:13 AM
Yeah its literally called “BasicText”, if you use it you need to make the decisions on how to handle these things yourself
View count: 2