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

    Denis Ismailaj

    02/26/2021, 10:49 AM
    Hello! I found a todo comment on androidx.compose.material that I would like to subscribe to as an issue, but the number that’s in there doesn’t seem to show up in search results anywhere and I couldn’t find anything in the Issue Tracker. Does this mean I don’t have permission to view the issue or is it not documented in the tracker?
    // TODO(b/158077409) support shape in OutlinedTextField
    :yes: 1
    a
    a
    • 3
    • 3
  • o

    Orhan Tozan

    02/26/2021, 11:10 AM
    What is the recommended way to declare computed state? Is it with
    remember(a, b) { a + b}
    or
    derivedStateOf { a + b }
    ?
    l
    d
    +2
    • 5
    • 43
  • p

    Peter Parker

    02/26/2021, 11:29 AM
    Today we updated our project from compose alpha version to beta. Now we got this strange exception (ava.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/AndroidAmbientsKt;) when using the Insets class from Chris Banes for edge-to-edge. Does someone know this exception and has a solution for this problem?
    l
    • 2
    • 2
  • k

    Kensuke Sano

    02/26/2021, 12:12 PM
    Is there any way to show placehoder while loading text or image like redacted in SwiftUI? https://swiftwithmajid.com/2020/10/22/the-magic-of-redacted-modifier-in-swiftui/
    ➕ 1
    j
    d
    e
    • 4
    • 5
  • a

    Archie

    02/26/2021, 12:30 PM
    Hi @Adam Powell, Any reason why,
    @Composable
    fun TopAppBar(
        title: @Composable () -> Unit,
        modifier: Modifier = Modifier,
        navigationIcon: @Composable (() -> Unit)? = null,
        actions: @Composable RowScope.() -> Unit = {},
        backgroundColor: Color = MaterialTheme.colors.primarySurface,
        contentColor: Color = contentColorFor(backgroundColor),
        elevation: Dp = AppBarDefaults.TopAppBarElevation
    ) {
    ...
    }
    Doesn't expose
    contentPadding
    ? Is it possible to request exposing the content padding to adding addition padding for
    WindowInsets
    would be easier?
    a
    v
    a
    • 4
    • 12
  • l

    Lukas K-G

    02/26/2021, 1:00 PM
    I would like to align some text in different `Row`s by the longest text before it. I.e.
    Auto
    Normal
    and
    Auto
    should start at the same offset depending on the longest text in the previous “column” (visualized in green). Any ideas how I achieve do that? 🤔
    d
    b
    • 3
    • 9
  • e

    escodro

    02/26/2021, 1:20 PM
    Hello, everyone! 😊 I have a
    Flow
    inside a
    ViewModel
    that is notified in every time a change is made in my database and reflect the state via
    sealed class
    to my composable. This
    Flow
    is attached to the
    viewModelScope
    . Basically I’m facing two problems: 1. Every time the screen is recomposed, the function to load the data is called and a new flow is registered and listening to changes. 2. When I’m navigating in another composables that handles the same data, the
    Flow
    keeps emitting data changes for the composable that is no longer visible. Is there a better way to implement it? Should I use my own scope instead the one from
    ViewModel
    ? If so, how can I “dispose” the scope when the Composable is no longer visible?
    @Composable
    private fun TaskListLoader(viewModel: TaskListViewModel = viewModel()) {
        viewModel.loadTasks()
        val viewState by viewModel.state.collectAsState()
        TaskScaffold(...)
    }
    fun loadTasks() = viewModelScope.launch {
        loadAllTasksUseCase().collect { tasks ->
            // emit via StateFlow
        }
    }
    Thanks a lot in advance! ❤️
    a
    b
    +5
    • 8
    • 76
  • s

    Samir Basnet

    02/26/2021, 2:30 PM
    Do we have an animation so that we set a delay and from the point of composition after the delay the Animation starts ?
    j
    • 2
    • 1
  • d

    Deepak Gahlot

    02/26/2021, 3:00 PM
    @Preview
    @Composable
    fun AttachmentComponent() {
    
        var fileName = remember { mutableStateOf(ArrayList<String>()) }
        var array = arrayOf("application/pdf")
        var files = ArrayList<String>()
        var fileAttached = remember { mutableStateOf(false) }
    
    
        Column {
    
            val registerTakeFile = registerForActivityResult(
                ActivityResultContracts.OpenMultipleDocuments()
            ) {
                for (i in 0 until it.size) {
                    var uri = it.get(i)
                    files.add(uri.path!!)
                }
                fileName.value = files
            }
    
            Text(
                text = "Attachment",
                color = colorResource(id = R.color.gray1)
            )
            if (fileAttached.value) {
                FileAttached(item = fileName.value)
            }
            OutlinedButton(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(16.dp),
                colors = ButtonDefaults.outlinedButtonColors(
                    contentColor = colorResource(id = R.color.blue1)
                ),
                onClick = {
                    registerTakeFile.launch(array)
                    fileAttached.value = true
                }
            ) {
                Icon(painterResource(id = R.drawable.ico_attach), contentDescription = "attach")
                Text(
                    fontSize = 14.sp,
                    text = "Add Files",
                    )
            }
        }
    }
    
    @Composable
    fun FileAttached(item: ArrayList<String>) {
        Column {
            item.forEach {
                Row {
                    Text(
                        text = it,
                        color = colorResource(id = R.color.black)
                    )
                }
            }
        }
    }
    i
    • 2
    • 4
  • s

    Shakil Karim

    02/26/2021, 3:27 PM
    I found Bottom Sheet API very weird to use, for example when I have show more than 1 bottom sheet on screen, I have to do something like that.
    ModalBottomSheet(
        sheetState = clubsSheetState,
        sheetContent = {
              ---------Sheet 1 content
        },
        content = {
            ---- Sheet 1 body
              ModalBottomSheet(
                   sheetState = clubsSheetState,
                   sheetContent = {
                         ---------Sheet 2 content
                   },
                   content = {
                       ---- Sheet 2 body
                   })
    
        })
    Isn't it will be better to use it like Dialog if(show) { BottomSheet() }
    h
    • 2
    • 2
  • n

    Neal Sanche

    02/26/2021, 3:36 PM
    So, yesterday, I was tracking down what I am referring to as unexpected recomposition issues in an app I'm working on that deals with images from the CameraX API. Content Redacted for brevity, see thread.
    j
    r
    c
    • 4
    • 10
  • a

    Adam Powell

    02/26/2021, 3:59 PM
    Hey folks! We're glad that so many of you are as excited about the Compose beta as we are! So many of you, in fact, that this channel is getting a lot of traffic. If you are going to post a code snippet longer than 4-6 lines, please post a brief topic comment and then post your code snippet in a thread replying to that comment. This makes sure that everyone can have their message seen and large code snippets don't flood out other discussion topics. Thanks, everyone!
    👍🏾 3
    ☝️ 3
    👏 3
    👍 16
    👍🏼 39
    s
    n
    • 3
    • 3
  • r

    rsktash

    02/26/2021, 4:08 PM
    Hi. I’m trying to play mp3 in desktop compose app. Is there any working audio java library ? For android I’m using
    android.media.MediaPlayer
    😴 1
    👀 1
    🙌 1
    m
    • 2
    • 2
  • g

    grandstaish

    02/26/2021, 4:09 PM
    ❔ Is there a function to transform an html string into an
    AnnotatedString
    ?
    a
    l
    +3
    • 6
    • 13
  • l

    Lucien Guimaraes

    02/26/2021, 4:11 PM
    I have a weird behaviour right now with TopAppBar only when darkMode is enable. If
    elevation = 0.dp
    the background is correctly applied. If the elevation is by default, the background color is different (more bright). Is this an intended behaviour or a bug with beta01 ? Also it's only with the black color from Compose (
    Color.Black
    ), I tried with other colors and it's working fine 🤷
    ✅ 1
    a
    a
    • 3
    • 7
  • t

    timmy

    02/26/2021, 4:19 PM
    hello everyone how can i use constraint layout in this compose beta version?
    z
    • 2
    • 4
  • s

    Stylianos Gakis

    02/26/2021, 4:28 PM
    Why do I sometimes get something like "there is no getValue() method to serve as a delegate when I simply have a
    var someVariable by remember { mutableStateOf(false) }
    . I had to manually import
    import androidx.compose.runtime.getValue
    myself for it to work. Is there something I am doing wrong, or an IDE bug?
    l
    j
    c
    • 4
    • 6
  • t

    Tony Kazanjian

    02/26/2021, 5:29 PM
    Is there anything like
    viewPager
    in compose beta, or should we still go for interoperability for something like that for now?
    s
    s
    • 3
    • 3
  • r

    rsktash

    02/26/2021, 7:33 PM
    Hi why Slider onValueChanged is being triggered on every state change? I think onValueChange must be called when user interacts with the slider isn’t it?
    a
    j
    +2
    • 5
    • 26
  • v

    Vitor Prado

    02/26/2021, 7:45 PM
    How to prevent
    BottomDrawerLayout
    intercept my content scroll?
    j
    • 2
    • 1
  • c

    Colton Idle

    02/26/2021, 7:50 PM
    Kotlin 1.4.31 is now available with fixes for several bugs, including some that appeared in IntelliJ IDEA and Android Studio with Kotlin 1.4.30.
    Safe to update, or will that blow something up with compose? https://twitter.com/kotlin/status/1365237672231452675
    j
    t
    • 3
    • 12
  • v

    vanpra

    02/26/2021, 8:10 PM
    Hey, I'm using a Dialog composable and am offsetting it's content by some amount. Previously this would result in any portion of the offset content which is not in the dialog area to not be shown. However after this update it seem like this the content is still shown outside the dialog. I was just wondering if this is a bug or intended behaviour?
    j
    l
    • 3
    • 3
  • a

    Arkadii Ivanov

    02/26/2021, 8:46 PM
    Caught the following random crash, happened only once, can't reproduce anymore. Posting here just in case.
    Untitled
    l
    l
    • 3
    • 4
  • c

    Chris Grigg

    02/26/2021, 8:50 PM
    hey guys, i’m migrating an
    animatedFloat
    to
    remember { Animatable(initialValue = 0f) }
    . Changing this involves replacing an
    onEnd
    callback and I’m using async/await for it, I was wondering if this is a good way of approaching it? Complete code snippets are below in the reply thread.
    d
    d
    • 3
    • 8
  • c

    Colton Idle

    02/26/2021, 9:34 PM
    Can't get left/right shadow on my card to show up in a simple Surface + Column. I'm missing something simple I assume? Short code snippet in 🧵
    a
    • 2
    • 12
  • g

    Gabriel

    02/26/2021, 9:57 PM
    Random observation, when I was using requiredHeight(intrinsicsize.max) and fillmaxwidth() on a row inside a column, it was not in fact filling the max width, it instead seemed to do the width as intrinsic.min, when I set an exact hieght on the row, the row then filled the width to it's max
    t
    • 2
    • 1
  • c

    Chris Grigg

    02/26/2021, 10:34 PM
    Is anyone seeing a lot of IR compiler errors related to the use of
    viewModel()
    within composables since upgrading to beta 1?
    • 1
    • 1
  • i

    itnoles

    02/27/2021, 3:19 AM
    is this is very odd that
    DropdownMenu(expanded = false)
    is like disappear?
    d
    • 2
    • 3
  • s

    sen kumar

    02/27/2021, 5:05 AM
    How to use TextWatcher - methods -
    override fun afterTextChanged(editable: Editable?)
    in a TextField component in Compose?
    d
    • 2
    • 12
  • s

    sen kumar

    02/27/2021, 5:09 AM
    How to implement addTextChangedListener(TextWatcher watcher) in a TextField compose
    c
    • 2
    • 2
Powered by Linen
Title
s

sen kumar

02/27/2021, 5:09 AM
How to implement addTextChangedListener(TextWatcher watcher) in a TextField compose
c

Colton Idle

02/27/2021, 6:22 PM
I don't believe you're supposed to have these sort of "listeners" in compose. You hold the data and so you know when it changes.
s

sen kumar

02/27/2021, 7:08 PM
Thanks Colton - This is for a real time validation as the user types each char - I am not sure without listeners there is an option to do such a validation.
View count: 2