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

    Slackbot

    08/22/2022, 2:29 PM
    This message was deleted.
    k
    h
    +3
    • 6
    • 8
  • e

    Erfannj En

    08/22/2022, 5:13 PM
    Hello, I want the composables inside the column to have a height min, in addition to using weight for scrollable in small size screen, but when chaining them in the modifier, the height min does not work and is not applied. Do you have a solution for this problem?
    c
    • 2
    • 2
  • m

    mattinger

    08/22/2022, 5:40 PM
    So, I know there is the intent that the compose compiler will no longer need to directly line up with the version of compose you are using in your code. Does anyone know of the 1.3.0 compiler makes that possible or not? We’re in the process of getting ready to update our kotlin to 1.7 and compose to 1.2, and i want to be able to decide if we should be using kotlin 1.7.0 (compose compiler 1.2.0) or kotlin 1.7.10 (compose compiler 1.3.0)
    j
    • 2
    • 3
  • e

    enighma

    08/22/2022, 6:15 PM
    I have a vague memory that it used to be possible to have a composable as an extension function, but now I get a warning that it's not(might've never worked). Here's a sample situation of what I naively want:
    @Composable LazyGridScope.myFun() = ...
    Is there a workaround or suggested solution for this? I guess I can pass it as a param and run
    scope.apply{}
    .
    a
    s
    • 3
    • 8
  • r

    rook

    08/22/2022, 6:26 PM
    Weird thing I noticed: I can’t import both
    LazyListScope.items
    and
    LazyGridScope.items
    . I’m not sure if that’s intentional or if I’m meant to alias them somehow.
    i
    • 2
    • 10
  • t

    Travis Griggs

    08/22/2022, 11:39 PM
    I'm trying to put together a calendar header that scrolls like shown. I can get static versions working, but haven't been able to figure out the magic for doing it with animation. i tried to do a 3 row column with up arrow, weekday row, and down arrow, and then message with the Modifier.offset(y) values, but that doesn't seem to create this effect. Any pointers on how I should go about this?
  • a

    Alan Lee

    08/23/2022, 2:16 AM
    Does anyone have a good example of using BottomNav with mix of different tabs that wrap native Fragment (that has network calls before showing data) or WebView that allow caching of the tabs so when you transition to a different tab and return the content is shown without reloading?
  • c

    Colton Idle

    08/23/2022, 8:12 AM
    Is there a less verbose way of writing this?
    val lifecycle = LocalLifecycleOwner.current.lifecycle
    DisposableEffect(lifecycle) {
      val observer = LifecycleEventObserver { _, event ->
        if (event == Lifecycle.Event.ON_RESUME) {
          vm.doThing()
        }
      }
      lifecycle.addObserver(observer)
      onDispose { lifecycle.removeObserver(observer) }
    }
    t
    f
    i
    • 4
    • 6
  • d

    dave08

    08/23/2022, 9:11 AM
    Hi! I just added
    androidx.compose.runtime
    (with NO other changes to the code base and NO extra added dependencies) to my app and enabled the compose compiler and suddenly pressing the back button from one fragment doesn't allow the fragment it's going back to to load properly... is this a known bug?
    g
    i
    • 3
    • 15
  • d

    dave08

    08/23/2022, 9:11 AM
    (I've updated all my dependencies to the most recent stable version -- including the navigation component)
  • a

    Aaron Waller

    08/23/2022, 9:13 AM
    One of the biggest downsides of Compose for me is the performance. Eventhough I have R8 enabled and I’m running in release build (which is also a downside cause it takes hours to build and heats up my laptop) it is still a poor experience. HorizontalPager + LazyVerticalGrid with 3 columns = 10 FPS Same setup on XML = extremely fast.
    z
    s
    +4
    • 7
    • 38
  • a

    AmrJyniat

    08/23/2022, 9:36 AM
    How I can pass the click event from child composable to its parent? e.g:
    Card(
      Modifier.clickable { doSomething() }
    ){
       CheckBox(
         .....,
         onCheckedChange = {  } // leave it empty and pass its event to parent
       )
       Text("Some label")
    }
    m
    o
    j
    • 4
    • 5
  • y

    Yashwant Gowla

    08/23/2022, 1:07 PM
    Hello folks, A Collection of major Jetpack compose UI components which are commonly used. Hope this will help for the learning. Kindly hit a star if you liked it too: https://github.com/SimformSolutionsPvtLtd/SSComposeCookBook/
  • m

    Manuel Lorenzo

    08/23/2022, 1:41 PM
    hi everybody, I’ve got a problem with a LazyColumn of elements that have a favourite button: basically when I tap the favourite button, the item that is being favourited (a document in my case) is changed in the underlying data structure in the VM, but the view isn’t updated, so I never see any change in the button state 🧵
    c
    o
    a
    • 4
    • 18
  • a

    Arpit Shukla

    08/23/2022, 2:37 PM
    Hi everyone, I was going through the Jetpack Now In Android official sample. Really great sample but I couldn't find any example of navigation triggered by ViewModel there. In my apps I use Channels to send navigation events from ViewModel but Google seems to be recommending against this approach. I have gone through a lot of official samples but haven't found one which demonstrates how to handle navigation triggered by ViewModel. Does anyone know of any such sample (official or unofficial)? Maybe @Manuel Vivo
    c
    p
    • 3
    • 8
  • a

    Andrew Hughes

    08/23/2022, 4:54 PM
    I noticed that the M3
    ColorScheme
    is annotated with
    @Stable
    , however, it does not override
    equals
    . The
    @Stable
    annotation mentions that the following must be true:
    1. The result of
    equals
    will always return the same result for the same two instances.
    I assume this means that two instances of a class with the same internal values should evaluate to
    true
    using
    equals
    . However, this is not the case for
    ColorScheme
    . Am I misunderstanding what this means?
    m
    g
    • 3
    • 24
  • j

    Jasmin Fajkic

    08/23/2022, 5:48 PM
    Would it be possible to define different screen transition for same route? For example with deeplink i want to have bottom sheet behaviour and if going from screen A to B i want to have push stack behaviour?
    i
    • 2
    • 2
  • m

    Micko Cabacungan

    08/23/2022, 7:15 PM
    Hey yall, has anyone used AndroidView to inflate a PlayerView and use exoplayer to play a video, but backgrounding the app and foregrounding the app seems to make that view disappear. I’ve tried to observe the lifecycle to make sure to only release exoplayer when the lifecycle is destroyed, but this doesnt work, I have logs in the
    update
    parameter and
    factory
    parameter and they dont show up when i background the app and then foreground it
  • a

    Aaron Waller

    08/23/2022, 8:07 PM
    I display a non dismissable dialog when the user lost connection. Somehow it’s not working correctly, sometimes the dialog shows up eventhough I’m connected to internet and doesnt want to diassapear. The setup is super easy but still not working. Code in thread
    l
    d
    • 3
    • 4
  • w

    wintersoldier

    08/24/2022, 5:13 AM
    Hey all , Can anyone help how to draw a curved dashed line with arrow in compose. (Similar to the below attached image)
    r
    y
    • 3
    • 10
  • e

    Erfannj En

    08/24/2022, 5:17 AM
    Does anyone have a solution for this problem?
  • d

    dawidhyzy

    08/24/2022, 6:58 AM
    In the project, I just joined I found strange
    @Composable
    usage
    class SomeViewModel(
        repository: SomeRepository,
    ) : ViewModel() {
    
        val something: State<String?>
            @Composable
            get() = repository.something.collectAsState()
    }
    what could be the implication of including
    ViewModel
    in composition?
    j
    s
    • 3
    • 11
  • a

    allan.conda

    08/24/2022, 7:40 AM
    How can the parent composable communicate events to the child composable? For example, I want to scroll-to-top the start destination when the bottom bar is tapped.
    y
    f
    b
    • 4
    • 6
  • s

    Stylianos Gakis

    08/24/2022, 8:51 AM
    Are there any APIs in compose text to change a text which spans let’s say two lines to look more “balanced” by making the lines take roughly the equal amount of space? I’m betting on “no”, but doesn’t hurt to ask 😄 Like instead of: Lorem ipsum dolor sit amet consectetur adipiscing elit Do: Lorem ipsum dolor sit amet consectetur adipiscing elit
    z
    s
    +2
    • 5
    • 12
  • o

    Oleksandr Balan

    08/24/2022, 10:12 AM
    AnimatedContent
    This is the way :mandalorian: https://developer.android.com/jetpack/compose/animation#animatedcontent You could start with default:
    AnimatedContent(targetState = loginUiState) { state ->
       when (state) {
         is LoginEmailUiState ->
            LoginEmailPassContainer(state)
         is ResetPasswordUiState ->
            ResetPasswordContainer(state)
       }
    }
    And then tweak
    transitionSpec
    as needed, see docs above ☝️
    y
    • 2
    • 1
  • l

    Lucien Guimaraes

    08/24/2022, 10:26 AM
    Is there any way to add a Floating context menu with Compose?
    y
    f
    • 3
    • 4
  • t

    Tariyel Islami

    08/24/2022, 11:39 AM
    Hi guys, Jetpack compose is very easy but not very satisfying in terms of performance. Especially lazylayout so laggy. I tried the suggested methods. I activated R8, got build in release mode. But it still hangs. I wonder if I should switch to xml? What do you recommend ?
    f
    • 2
    • 1
  • y

    Yann Badoual

    08/24/2022, 12:00 PM
    Any way to have a
    lineSpacing
    in
    TextField
    except using
    TextStyle.ineHeight
    (lineHeight also changes the cursor size)
    s
    • 2
    • 1
  • m

    Michal Klimczak

    08/24/2022, 12:31 PM
    I have a weird issue with manual scroll invoking.
    LazyListState.animateScrollToItem(0)
    suspends indefinitely whenever I intercept the scroll animation by touching the list. Thus blocking the collection for any consecutive animations. Tried working around with
    withTimeout
    , but it seems like the
    animateScrollToItem
    animation loop has no way of supporting cancellation (no
    yield
    in the
    while
    loop).
    f
    • 2
    • 7
  • l

    Landry Norris

    08/24/2022, 1:25 PM
    [Solved] Can a composable be skipped even if a parameter to a modifier has changed? Example in 🧵
    • 1
    • 4
Powered by Linen
Title
l

Landry Norris

08/24/2022, 1:25 PM
[Solved] Can a composable be skipped even if a parameter to a modifier has changed? Example in 🧵
I have an interface that handles touch events for a Canvas composable called DrawHandler. I have the following method
@Composable
fun Drawing(drawObjects: List<DrawObject>, drawHandler: TouchHandler) {
    println("Draw handler is $drawHandler in drawing")
    Canvas(modifier = Modifier.fillMaxSize().handleDraw(drawHandler).clipToBounds()) {
        ... draw stuff based on drawObjects
    }
}
I need to be able to swap out my draw handler, and the new one should receive touch events.
I see that the value printed by the log changes from DrawImpl@49051c9 to DrawImpl@add3299, but my log inside handleDraw only says it gets called with DrawImpl@49051c9
Just realized my mistake. If it helps anyone, my handleDraw method used pointerInput(Unit) instead of pointerInput(drawHandler)
Changing it to pointerInput(drawHandler) caused changes to drawHandler to force recomposition of Canvas.
View count: 2