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

    Marcin Środa

    05/31/2021, 7:23 AM
    Does anyone have a problem with LazyColumn after latest update?
    a
    • 2
    • 7
  • t

    Tolriq

    05/31/2021, 7:28 AM
    Is overdraw still something to try to optimize in Compose world?
    ➕ 1
    z
    r
    • 3
    • 5
  • t

    taponidhi

    05/31/2021, 8:09 AM
    I'm relatively new to android development. Started learning in december'20 with xml/view based layouts through udacity. Soon switched to compose as declarative UI seemed easier to me having done web development in react. I have practiced everything (animations, i/o, custom layouts, theming) in isolated manner through preview composables. Now I am trying to create a full fledged app with firebase. I have some queries and it would really help if you can clear even some of those. 1. For showing images, I am using accompanist. I wanted to know is there a codelab like those for jetpack compose to learn accompanist? 2. How do i cache images? Like if I fetch some image by url once and close the app. Then next time can i show old image without fetching it again. Does accompanist do that? 3. During Layouts codelab for compose there was a lazy column scroll handling to scroll to top/bottom by button. When i used to scroll to top then only 4/5 items were visible rest disappeared. But as soon as i touched the window again everything came back up. Was it a compose compiler problem or just debug app/my mobile problem? 4. Is there a preferred way to map firestore model to local model? I was thinking to create extension functions. Any tutorial for mvvm/repository pattern with compose will be helpful. Everywhere i see these but the basics are still a bit hazy. Any answers will be informative for me. Thanks all.
    :thread-please: 2
    a
    c
    • 3
    • 3
  • u

    ubu

    05/31/2021, 9:34 AM
    Hi everyone. Any idea when to expect beta08?
    a
    • 2
    • 1
  • i

    iamthevoid

    05/31/2021, 9:37 AM
    I am working with accompanist pager. Would to create own pager indicator. Also i would to indicator change color smoothly when page changing from active to inactive. I have pager state
    currentPage
    and
    currentPageOffset
    values. What is the best way in compose to blend colors one with another for current case? It is not an animation, colors must change on drag (recompose), so somehow i must change color based on
    currentPage
    and
    currentPageOffset
    . Would be the good solution is changing the alpha? Or i can somehow blend colors?
    c
    • 2
    • 4
  • a

    Adrian Landborn

    05/31/2021, 10:50 AM
    Anyone using the latest Lottie lib for compose? com.airbnb.android:lottie-compose:1.0.0-beta07-1 I get build issues when trying to fetch dependencies.
    a
    • 2
    • 2
  • s

    Spikey Sanju

    05/31/2021, 11:21 AM
    [✅ Resolved]. Hello all, When I pass these unit functions for
    TapGestures
    I really see a
    performance issue
    . Why is it happening? Is there any way optimise performance? For ex - When I tap
    LazyColumn Item
    it will goto
    details screen
    . But now it takes
    1s to navigate to details screen
    . When remove those functions & use clickable to goto details screen it’s working fine!
    z
    • 2
    • 4
  • s

    Se7eN

    05/31/2021, 11:31 AM
    How do I make something like this but wrap the height to get rid of the extra space? I understand it's because of the
    aspectRatio(1f)
    but whatever height I use, the arc only fills half of it. Code in thread.
    👍 1
    a
    • 2
    • 3
  • f

    Felipe Passos

    05/31/2021, 11:36 AM
    Hello, how do i make this idea work : api.stream is reading a websocket, the idea is to update a variable every time it receives a websocket message.
    Sem título.kt
    s
    d
    • 3
    • 24
  • i

    iamthevoid

    05/31/2021, 12:53 PM
    I want to collect
    navController.currentBackStackEntryFlow
    and must to do it in CoroutineScope. I have few questions 1. Where can I read about relation of coroutines and composables 2. Where better to collect this flow? Looks like there are mechanisms in compose to handle coroutines, but i am not sure that good practice to do as i did. 3. Even if it is good practice - what is better to use as key for
    LaunchedEffect
    ? I select activity, but it seems meaningless
    d
    a
    +2
    • 5
    • 7
  • d

    Daniele Segato

    05/31/2021, 12:58 PM
    I'm trying to use
    Layout
    for the first time I've set myself to build a fairly straight forward widget, but with a small circular dependency 2 components (the name is to help imagining but they can be whatever): • field • button the
    button
    can decide its own width but must match
    field
    height the
    field
    can decide its own height but must leave room for the
    button
    in it's width (
    maxWidth - button.width
    ) the idea is the component will show the field and the button side by side filling width and wrapping height using the field. As far as I understood I can measure all components only once. If I measure
    field
    first I can adjust
    button
    width accordingly but I cannot make its height match
    field
    If I measure
    button
    first I can know it's width but I cannot tell it to take as much height as the
    field
    Can someone enlighten me on how to overcome a situation like this with Layout? thanks
    z
    • 2
    • 2
  • d

    dimsuz

    05/31/2021, 12:58 PM
    Hi! Two questions: 1. Does
    @Stable
    imply
    @Immutable
    or vice versa? 2. If I have a
    data class
    which contains only vals (which are either other data classes or privitives or non-mutable collection types), does it mean that Compose compiler plugin will be able to infer `@Stable`/`@Immutable` automatically? I found an earlier thread that seemed to suggest that. 3. It would be great if both of these points were somehow covered in documentation (or did I miss that?)
    ➕ 2
    a
    e
    • 3
    • 8
  • b

    Bradleycorn

    05/31/2021, 2:16 PM
    Is there an (out of the box) way to create an Expanding BottomSheet, as defined in the Material Specs? https://material.io/components/sheets-bottom#expanding-bottom-sheet
    e
    k
    • 3
    • 6
  • n

    nglauber

    05/31/2021, 2:32 PM
    I’m trying to change the status bar color using accompanist library, but no success… 😕
    val systemUiController = rememberSystemUiController()
    val useDarkIcons = MaterialTheme.colors.isLight
    
    SideEffect {
        systemUiController.setStatusBarColor(
            color = Color.Red,
            darkIcons = useDarkIcons
        )
    }
    MyComposable()
    c
    c
    • 3
    • 14
  • r

    Rooparsh

    05/31/2021, 2:54 PM
    Hi all, I have been trying my hands on Compose recently and stumbled upon
    TextField
    API. I noticed some issue in the one of the API approach. The cursor doesn't move forward as the value gets updated. Attaching a video as reference. Its the one which accepts TextFieldValue Am I missing here something ??
    :thread-please: 1
    🧵 1
    c
    • 2
    • 11
  • s

    Shakil Karim

    05/31/2021, 4:27 PM
    Finally https://android-review.googlesource.com/c/platform/frameworks/support/+/1704159 AnimatedContent 😍
    m
    d
    +2
    • 5
    • 8
  • s

    spierce7

    05/31/2021, 6:30 PM
    Something I’ve kind of wondered several times over the past few months, and haven’t been able to get an answer for - if Compose doesn’t use a shadow dom, how is it working under the hood? I’ve tried to understand it, and I know it creates a tree structure under the hood. How does it stay efficient and function under the hood if the tree structure it maintains is not a virtual dom?
    a
    z
    c
    • 4
    • 9
  • c

    Colton Idle

    05/31/2021, 7:04 PM
    I'm trying to create a video player (exoPlayer) as a composable and I'm following along with this article https://itnext.io/playing-a-video-with-jetpack-compose-10a453ff956 It gets me to the point where I'm playing a video which is nice, but I have 3 questions if anyone can chime in. 1. Is the
    remember
    method appropriate to make sure the composable doesn't reload the video on every compostion? 2. LaunchedEffect (I haven't used it before) seems like an interesting use case to use to update the fact that the video url has changed. Maybe the fact that it's called "Effect" is throwing me off, but would there be any other way to do this? 3. How does one properly dispose of this video playback. Does the composable clean up the androidView inside of it when I don't show it on screen anymore?
    s
    h
    • 3
    • 5
  • r

    robnik

    05/31/2021, 7:35 PM
    How do you ask questions of, or send requests to, nested Composables? Here’s a simplified example in thread.
    k
    z
    • 3
    • 6
  • c

    Chris Fillmore

    05/31/2021, 7:58 PM
    Hi everyone, happy Monday. Question: I understand that a ViewModel should not reference an Activity, or Context, or View, lest they be retained across configuration changes. Does this restriction apply to Composables as well? Or can I have a ViewModel that references something which has a @Composable method? e.g:
    class MyViewModel : ViewModel() {
      val plugin: Plugin
      ...
    }
    
    interface Plugin {
      @Composable
      fun Content()
    }
    My use case is, in my app we can dynamically load plugins depending on user requirements. These plugins themselves have composable methods to draw UI, and their own ViewModels in turn. Thanks for any help!
    a
    • 2
    • 4
  • d

    dimsuz

    05/31/2021, 8:03 PM
    Still trying to get the understanding of basics right. If I change a remembered mutable state outside of the composition, will it trigger recompose? I have a
    ComposeView
    in an ordinary view hierarchy. See the snippet in the thread.
    a
    • 2
    • 16
  • c

    Colton Idle

    05/31/2021, 9:07 PM
    How would I do something like this to satisfy my designers requirements? Basically the bottom of the image should be inline with the bottom of the first piece of text AND if the text starts to get too long, it should elipsis instead of drawing on top of (or below) the image. I tried using negative padding (as I would do in web dev) but that's not allowed in compose apparently?
    a
    • 2
    • 1
  • t

    tylerwilson

    05/31/2021, 10:40 PM
    I am trying to define a Dialog in Compose and display it from older toolkit ui. Anybody have any examples I could work from in this case? Optimally also callable via a class Navigation.navigate() call.
    a
    • 2
    • 2
  • n

    nglauber

    05/31/2021, 11:18 PM
    Is this a bug, or I’m doing something wrong? 🤔 After delete one char, and type another character, the TextField is cleared 😕
    c
    j
    +3
    • 6
    • 15
  • t

    tad

    06/01/2021, 12:12 AM
    Question about layout constraints: I'm trying to constrain one layout in a Column between a min and max size, but let it expand and contract with the available space in the parent.
    a
    • 2
    • 4
  • m

    ms

    06/01/2021, 5:05 AM
    How can I achieve this? The blue box needs to fill remaining space after placing those 3 boxes I tried with Column and ConstraintLayout as well Code in 🧵
    a
    • 2
    • 2
  • h

    Hardeep Singh

    06/01/2021, 6:24 AM
    How can we integrate Google sign-in in Jetpack Compose?
    a
    j
    • 3
    • 5
  • n

    Nana Vong

    06/01/2021, 6:36 AM
    Hi, why i can't receive any notification when state changed like this:
    data class Question(var add: Boolean = true)
    val testState = MutableLiveData<List<Question>>()
    testState.value = listOf(Question(false))
    val state = testState.observeAsState()
    RedButton(
        text = state.value?.get(0)?.add?.toString() ?: "?",
        btnColor = Color.Red,
        modifier = Modifier.clickable {
            testState.value = testState.value.apply {
                this?.get(0)?.add = true
            }
        })
    l
    a
    • 3
    • 4
  • a

    aipok

    06/01/2021, 7:24 AM
    Does anyone know how fake/pass navController to make a preview for BottomNavigation?
    k
    i
    • 3
    • 2
  • m

    Marcin Środa

    06/01/2021, 8:17 AM
    Hey, got a question about TextField with placeholder test. How can I check is editable text empty?
    • 1
    • 2
Powered by Linen
Title
m

Marcin Środa

06/01/2021, 8:17 AM
Hey, got a question about TextField with placeholder test. How can I check is editable text empty?
composeTestRule.onNodeWithContentDescription(inputDescription).assertTextEquals("")
returns
java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [])
Semantics of the node:
Node #130 at (l=0.0, t=273.0, r=1080.0, b=420.0)px
ContentDescription = '[message_input_text]'
ImeAction = 'Send'
EditableText = ''
TextSelectionRange = 'TextRange(0, 0)'
Focused = 'false'
Text = '[Type Message]'
Actions = [GetTextLayoutResult, SetText, SetSelection, OnClick, OnLongClick, PasteText]
MergeDescendants = 'true'
Has 1 child
Selector used: (ContentDescription = 'message_input_text' (ignoreCase: false))
Well, weird. The fix is quite simple- useUnmergedTree:
composeTestRule.onNodeWithContentDescription(inputDescription, useUnmergedTree = true).assertTextEquals("")
View count: 5