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

    Colton Idle

    11/04/2021, 6:34 AM
    How would you go about building this composable? To me, It's two distinct piece (the blue background card) and then the "bottomCard" composable. The tricky thing about the bottom card composable (that I keep iterating on) is that the icons (soccer balls) are supposed to be aligned with their respective score, but they also have to be offset so that they are 40% on the card, but 60% is hanging off the top to create this cool affect.
    s
    r
    +2
    • 5
    • 11
  • s

    Sololo

    11/04/2021, 6:54 AM
    where can I found the compose compiled files ?
    z
    • 2
    • 1
  • s

    Steffen Funke

    11/04/2021, 6:56 AM
    I don’t seem to get
    @Immutable
    to work correctly for me - why do my list items recompose, when changing only a
    isLoading
    flag of my UI-State? 👉 Code in 🧵
    a
    o
    z
    • 4
    • 17
  • e

    elect

    11/04/2021, 10:32 AM
    is the code for the toolbox (which is based on Compose now) available anywhere?
    👀 3
    c
    • 2
    • 2
  • e

    elect

    11/04/2021, 12:32 PM
    what are these collapsable elements in the Toolbox? Toolbars?
    c
    • 2
    • 3
  • a

    allan.conda

    11/04/2021, 1:16 PM
    What is the right way to deep link into a destination in which its graph’s start destination has arguments. Should I pass those arguments to my deep link? Please see example in thread. I’m having an issue where I’m not able to navigate to the destination because of the missing parameters for the start destination.
    i
    • 2
    • 4
  • b

    Bradleycorn

    11/04/2021, 2:03 PM
    Custom Layout Question (some sample code in the 🧵)… I’m writing a basic Grid composable that takes a number of columns and a content composable. To do the measuring of the child measurables, setting the width contraints is pretty straight forward. But I’m curious about the height constraints for each measurable. It seems like I should take into account the heights of previously measured items (well, rows), and calculate the max available remaining height (based on the overall maxHeight constraints passed into the layout) and then pass height constraints into the measure function for the current item to ensure that it fits within the overall space. Does that seem right or do I not need to worry about
    z
    • 2
    • 9
  • j

    julioromano

    11/04/2021, 3:33 PM
    Hello @jim, Regarding this tweet of yours: whilst I generally share the sentiment of not tying up code to the platform, I’m sometimes struggling when it comes to practice. 1) When using Hilt,
    hiltViewModel()
    is the only “easy” way to get dagger-managed objects from within a
    @Composable
    function. Are there any alternatives? 2) In a non 100% compose app (where we can’t just disable all configuration changes in the manifest) any operation running inside a
    rememberCoroutineScope()
    will be interrupted during a configuration change. In these cases we need to resort to the `ViewModel`’s
    viewModelScope
    . Are there any alternatives? Any insight on the topic is very much appreciated!
    👀 1
    j
    z
    +3
    • 6
    • 16
  • a

    Alex

    11/04/2021, 3:40 PM
    I am trying to observe the total scrollY of a nested scroll connection, but the results are wrong for fast scrolls, code in 🧵
    s
    • 2
    • 6
  • r

    rsktash

    11/04/2021, 3:59 PM
    Do we have an option of manual storing and restoring component state like focus, list current index? There is problem when component is rendered conditionally
    if(state.loading) {
    ShowLoading()
    } else {
    LazyColumn{}
    }
    l
    • 2
    • 1
  • j

    Jaime

    11/04/2021, 4:09 PM
    Hi everybody how are you ? I have a problem with a mutableStateFlow, when opening another composable it is always being invoked many times this is my code in case you can help me I have been researching for a long time ViewModel
    private val _marketStatusIsClosed = MutableStateFlow(MarketStatusUiState())
    val marketStatusClosed: StateFlow<MarketStatusUiState> get() = _marketStatusIsClosed
    Composable
    val marketStatusState by rememberFlowWithLifecycle(tickerDetailViewModel.marketStatusClosed)
        .collectAsState(MarketStatusUiState())
    this is the code that is always running even though it is not visible to the user
    if (!marketStatusState.isLoading) {
        Log.e("BuyInSharesScreen", "$marketStatusState")
        if (marketStatusState.isMarketClose) {
    
        } else {
            open another composable
        }
    }
    the new composable (screen) is being opened many times, and it is already closing so I do the navigation
    currentBackStackEntry?.arguments?.putParcelable(CREATE_ORDER_INFO, operation)
    navigate(Screens.BuyStockConfirmationScreen.route)
    c
    z
    i
    • 4
    • 28
  • t

    Tash

    11/04/2021, 4:43 PM
    Hi all, what’s a good upper limit for # of parameters for a Composable (incl ones with default values)?
    z
    k
    +3
    • 6
    • 12
  • m

    Matti MK

    11/04/2021, 5:41 PM
    Would anyone happen to know of a sample that implements Scaffold and a collapsible TopBar? Can't seem to find an example of it, and I'd prefer to keep my TopBar in the scaffolding similarly as done in the compose samples
    ➕ 1
    s
    s
    o
    • 4
    • 13
  • a

    Arpit Shukla

    11/04/2021, 6:45 PM
    Can someone please help me with this keyboard flickering issue? https://stackoverflow.com/questions/69844103/how-to-remove-keyboard-flicker-when-switching-between-textfields
    z
    • 2
    • 2
  • c

    Colton Idle

    11/04/2021, 7:35 PM
    Is this the gist on how to make a Checkbox with a Text label in compose?
    var theValue by remember { mutableStateOf(false) }
    val doSomething = { theValue = !theValue }
    Row(modifier = Modifier.clickable { doSomething() }, verticalAlignment = CenterVertically) {
        Text(text = "Show this: ")
        Checkbox(checked = theValue, onCheckedChange = { doSomething() })
    }
    or is there something else to have the touch ripples not be independent depending if you click on the row vs the checkbox.
    b
    a
    • 3
    • 5
  • c

    Colton Idle

    11/04/2021, 11:09 PM
    I'm using a Card, and have a composable inside the card that I'm offsetting on the y-axis (basically trying to draw outside of the card), but the card seems to clip it's children. Is it possible to opt out of that behavior for a card? Edit: I converted the Card to a Box and I still get the same clipped output. 🤔
    g
    • 2
    • 9
  • c

    Colton Idle

    11/04/2021, 11:48 PM
    I can't find EqualWeight as shown off by Doris on twitter. Has the api changed? I tried looking for EqualWeight on cs.android.com with only 1 hit (and its a python file?)
    g
    d
    • 3
    • 4
  • s

    Steffen Funke

    11/05/2021, 7:23 AM
    Given a Fragment with a
    LazyColumn
    inside a
    ComposeView
    , both wrapped in a View based
    BottomNavigation
    container hierarchy. Goal: I need to pass outside View based events, e.g.
    onTabItemReselected
    , from containing
    BottomNavigationView
    to the compose hierarchy, to let my
    LazyList
    scroll up, as the current tab is reselected. My cumbersome, but working approach now looks like this, I am wondering if there are better ways, to avoid those ViewModel round turns, only to dispatch the
    scrollToTop
    - Event Thanks - 👉 Code in thread🧵
    a
    • 2
    • 13
  • v

    Vsevolod Kaganovych

    11/05/2021, 9:25 AM
    Hey. Does anyone know how to implement this kind of sticky headers in Compose? Or advise from where I should start looking?
    c
    t
    s
    • 4
    • 4
  • f

    fabio.carballo

    11/05/2021, 10:16 AM
    Hey - Any ideas on why the deploy preview and live literals wouldn't be working? Not sure if is a compose version problem / configuration. The Preview works, but the deploy/interactive/live litterals just dont show.
    y
    c
    +2
    • 5
    • 20
  • a

    Adrian Tappe

    11/05/2021, 10:20 AM
    Having a formatter class that is expensive to instantiate but the function
    fun format(number: Int): String
    it uses then is side-effect free. Where would you use it with Compose? In the ViewModel and expose the State as String or in Compose? I intuitively would expose the number as state - and see the formatting as part of transforming the state to UI - so put it into the Compose part. How would you then get this class in Compose - if for performance reasons I’d usually inject it as
    @Singleton
    or
    @Reusable
    via dagger?
    b
    • 2
    • 1
  • i

    Ink

    11/05/2021, 11:43 AM
    Is it possible to achieve view in background like in the attachment?
    c
    b
    +2
    • 5
    • 9
  • r

    Ruben Quadros

    11/05/2021, 2:04 PM
    Hi guys, I keep getting
    java.lang.IllegalArgumentException: Key was already used. If you are using LazyColumn/Row please make sure you provide a unique key for each item
    . I am sure all the keys are unique and I even logged them to be sure. Also this happens when items are rapidly added to lazy column. Please find the sample code in the thread
    :thread-please: 1
    c
    j
    • 3
    • 7
  • z

    Zoltan Demant

    11/05/2021, 2:41 PM
    Will editing 2 mutableState values "at the same time" result in 2 recompositions?
    y
    e
    +2
    • 5
    • 6
  • f

    fabio.carballo

    11/05/2021, 3:18 PM
    How does the merging mechanism in the testing works? Imagining I have a list of :
    Row {
       Text()
       Checkbox(selected)
    }
    How can I guarantee that the
    Row
    gets the correct
    semantics
    of
    selected
    that inside the
    material.Checkbox
    ? Is there a way it can inherit that status from the "children" ?
    a
    z
    • 3
    • 3
  • r

    rsktash

    11/05/2021, 3:51 PM
    message has been deleted
    b
    z
    r
    • 4
    • 10
  • a

    Archie

    11/05/2021, 3:58 PM
    Is it a bad idea to define a class contianing Composable functions to impose a type dependency?
    :thread-please: 2
    j
    • 2
    • 10
  • s

    saket

    11/06/2021, 6:38 AM
    Is anyone using compose on android with kotlin 1.6.0-RC and not running into this error?
    java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions.setUseIR(boolean)'
    👀 1
    y
    b
    t
    • 4
    • 6
  • a

    AmrJyniat

    11/06/2021, 9:08 AM
    How to get padding values(top, end..etc) from
    PaddingValues
    class? there is no
    <http://paddingValues.top|paddingValues.top>
    getter!
    f
    • 2
    • 3
  • z

    Zoltan Demant

    11/06/2021, 10:21 AM
    How can I perform an action & then run an animation, and run an animation & then perform an action in compose?
    c
    • 2
    • 5
Powered by Linen
Title
z

Zoltan Demant

11/06/2021, 10:21 AM
How can I perform an action & then run an animation, and run an animation & then perform an action in compose?
In the regular view days of Android I would just create an animation in place and attach start/end listeners to it.
fun removeFromWindow() {
    manager.removeView(this)
}
e.g. Removing the view from the window should happen after the animation finishes. Similar but reverse story when adding the view. My code thus far has a mutableState<Boolean> which indicates whether the view should be attached, but there are no start/end listeners so I dont know where to go from there.
c

Csaba Kozák

11/06/2021, 10:51 AM
Compose uses suspending functions for animations. So you can call
animatable.animateTo(…)
then it will suspend until the animation is done. In the next line, you can set the state to remove the view.
z

Zoltan Demant

11/06/2021, 11:00 AM
Thank you! Would that be something like this?
var wasVisible by remember {
    mutableStateOf(false)
}

LaunchedEffect(visible) {
    if (!wasVisible) {
        // addToWindow
    }

    val animatable = Animatable(
        initialValue = if (wasVisible) 1f else 0f
    )

    animatable.animateTo(
        targetValue = if (visible) 1f else 0f
    )

    if (!visible) {
        // removeFromWindow 
    }

    wasVisible = visible
}
c

Csaba Kozák

11/06/2021, 11:08 AM
You should move animatable out of the effect, and remember it. See here.
z

Zoltan Demant

11/06/2021, 11:20 AM
Ouch, I just realized a couple of things that will make this much harder to implement (probably). For one, none of the compose code runs until after addToWindow has been called - the composable never gets called before the view is rendered, obviously, but totally missed on my part.. And since Im running this inside a foreground service, removeFromWindow is called when the service is being destroyed, and theres no time to run the animation at all. The latter of which is the most important, you can clearly see it just disappearing. SInce this isnt related to compose Ill continue digging to find a workaround, thanks for the advice on Animatable, it helped!
👍 1
View count: 3