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

    agrosner

    09/30/2022, 3:41 PM
    we’re on compose 1.2.0-rc01
    s
    • 2
    • 12
  • s

    Shafayat Bin Mamun

    09/30/2022, 6:49 PM
    How to show a Row that is aligned bottom in a Box in Modal Bottom Sheet when sheetstate is half visible?
    c
    o
    j
    • 4
    • 5
  • d

    dewildte

    09/30/2022, 6:57 PM
    Is there a way to get an animation to run outside the bounds of the composable? So as to not have the animation clipped? Details in the thread.
    d
    c
    • 3
    • 15
  • w

    wiktor

    09/30/2022, 7:41 PM
    hey 👋 :android: question: I would like to test a compose version with a fix that is not released yet: https://issuetracker.google.com/issues/230168389#comment83, how can I do it?
    j
    • 2
    • 2
  • p

    Paul Woitaschek

    10/01/2022, 8:58 AM
    Does a function like this make sense? It’s quite often that I have the need to transform a suspend function to a state, so I wonder why there nothing like this built into the runtime 🤔
    @Composable
      private fun <T> suspendingGet(default: T, get: suspend () -> T): T {
        var value by remember { mutableStateOf(default) }
        LaunchedEffect(Unit) {
          value = get()
        }
        return value
      }
    o
    • 2
    • 1
  • a

    Ahmed Sellami

    10/01/2022, 11:38 AM
    Is it possible to create a state management library for compose to reduce the number of passed parameters to nested composables? Something like provider in flutter?
  • o

    Oleksandr Balan

    10/01/2022, 12:31 PM
    I would say you have to go with custom drawing of the path on the canvas for example with
    .drawWithContent()
    modifier. At the begining with the provided size you have to construct a list with all 6 hexagon points and then draw a path with lines starting from 1st point, to 2nd, then 3d and end in 4th. For animation purposes I would create a
    progress
    state with infinity repeated animation from 0f to 1f, which will represent a "shift" of the start and end of the path along their lines. Thus when a
    progress
    is set for example to 0.3f the starting point should be calculated on the line between 1st and 2nd point, end end point on the line between 4th and 5th point accordingly. When progress reaches 1f you should increment the starting index in the points array so that you will start with path: 2nd -> 3rd -> 4th -> 5th. Then you may style the path with rounded caps.
    r
    b
    • 3
    • 2
  • a

    adjpd

    10/01/2022, 12:35 PM
    Is there a vague timescale--ie. week, month, couple of months etc--as to when Compose will support kotlin 1.7.20? Cheers
    z
    • 2
    • 1
  • s

    Smorg

    10/01/2022, 2:30 PM
    Getting an IR Lowering error with this root cause
    Caused by: java.lang.IllegalStateException: couldn't find inline method Landroidx/lifecycle/viewmodel/compose/ViewModelKt;
    . Any suggestions on how to fix this?
    z
    • 2
    • 2
  • u

    肖志康

    10/01/2022, 2:31 PM
    Hello everyone, I'm using
    TextField
    in my app but got pomeblems. 1. Some
    annotations
    were assigned to the
    TextFieldValue
    , but in the
    onValueChange
    callback all the annotations are gone. 2. I also applied some
    SpanStyle
    to the text. But if using GBoard to type in this
    TextField
    , it can only have 1 character to be applied in the textfield, and kept calling
    onValueChange
    with same value. I tried
    1.2.1
    and
    1.3.0-beta03
    but got the same behavior, any fix plans or workaround suggestions?
    z
    • 2
    • 1
  • a

    Android75

    10/01/2022, 2:45 PM
    I don’ undestand why alpha doesn’t change. Ok i created 3 image and i/d like change alpha moving a bar/percentage. // data
    data class ImageTransitionData(
        var imageList: List<Image> = emptyList()
    )
    
    data class Image(var src: Bitmap?, var alpha: Float = 0f)
    // screen
    var pageState = viewModel.uiState.collectAsState().value
    pageState.imageList.forEach { image ->
        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.Center
        ) {
            BitmapImage2(
                image.src, image.alpha
            )
        }
    }
    
    @Composable
    fun BitmapImage2(image: Bitmap?, alpha:Float) {
    
    
        val imageBitmap = remember {
            mutableStateOf<ImageBitmap?>(null)
        }
    
        image?.apply {
            imageBitmap.value = this.asImageBitmap()
    
        }
        imageBitmap.value?.let {
            Image(
                modifier = Modifier.fillMaxSize(),
                bitmap = it,
                contentDescription = "",
                contentScale = ContentScale.Fit,
                alpha = alpha
            )
        }
    
        Log.d("touch", "TOUCH ${ alpha}")
    }
    Ok this works.. screen shows first image in alpha 1f i want change first image alpha… so…
    private fun setPercentage(percentage: Float) {
        if(percentage >=0){
    
           var image = uiState.value.imageList.toMutableList()
            image.get(0).alpha = percentage /100
    
            uiState.value = uiState.value.copy(
                imageList= image.toList()
            )
            Log.d("touch", "TOUCH ${image.map { "Alpha:${it.alpha} - " }}")
        }
    
    }
    it’s strange , i changed array but i dont’see recomposition
    z
    • 2
    • 3
  • r

    rkeazor

    10/01/2022, 3:24 PM
    Using Jetpack compose with Kotlin 1.7.20 is currently not possible correct?
    j
    • 2
    • 2
  • o

    orangy

    10/01/2022, 6:47 PM
    With the
    LazyListState
    how do I write a function to “bring item into view”? So that it would do minimal required scrolling to make an item entirely visible. I can’t find all the needed data, or just slow tonight 🙂
    c
    m
    +3
    • 6
    • 10
  • s

    Smorg

    10/01/2022, 10:55 PM
    Bumping this up. Any help would be appreciated. Being a pain in the ass for quite some time now.
  • m

    mgrazianodecastro

    10/01/2022, 10:59 PM
    Does compose use
    DisplayList
    to produce information to the RenderTread on the sync process?
  • m

    mgrazianodecastro

    10/01/2022, 11:13 PM
    Looking at some treads here, it seems like
    RenderNodes
    are like the
    DisplayList
    , but for the purpose to fulfill the compose pipline
    r
    z
    • 3
    • 12
  • s

    Shafayat Bin Mamun

    10/02/2022, 4:54 AM
    How to optimize recompose of google map markers with image downloaded?
    • 1
    • 3
  • a

    Android75

    10/02/2022, 8:15 AM
    hi, i didn’t find a way to check when mouse is over a Box.. i have to show an image when mouse is over an area..
    c
    m
    z
    • 4
    • 11
  • s

    Shafayat Bin Mamun

    10/02/2022, 4:34 PM
    Hello, anyway to get activity’s onResume and onPause state in a Compose Screen? Having issues with exoplayer.
    i
    • 2
    • 2
  • d

    Djaka Pradana Jaya Priambudi

    10/02/2022, 8:40 PM
    I'm trying out the
    molecule
    library and migrating my presenter code into
    composable
    function. But some function that have primitives parameter recomposed multiple times when it doesn't need to be. code in thread I expect
    presentCountryListState
    to be recomposed everytime either
    initialState
    is changed or
    query
    is changed. This is true, it will always recompose when query changed but when I look at the console everytime query changed this log shows:
    Recomposition for presentCountryListState
    Recomposition for present
    Recomposition for presentCountryListState
    Recomposition for present
    Notice that it run the function twice somehow Anyone know why this is happening?
    z
    • 2
    • 14
  • z

    zt

    10/02/2022, 10:07 PM
    How can I have a viewmodel that persists all throughout my app? Then one that persists only one screen? With them both supporting backstack. I'm using this small library https://github.com/X1nto/Taxi as opposed to compose destinations and androidx navigation cause its a lot simpler and animation is super easy. I'm just not sure how to get my viewmodels to behave how I want them to.
    Surface {
        Taxi(
            modifier = Modifier.fillMaxSize(),
            navigator = navigator,
            transitionSpec = { fadeIn() with fadeOut() }
        ) { destination ->
            when (destination) {
                is AppDestination.Root -> RootScreen(navigator)
                is AppDestination.Search -> SearchScreen(navigator = navigator)
                is AppDestination.Player -> PlayerScreen(
                    navigator = navigator,
                    videoId = destination.videoId
                )
                is AppDestination.Channel -> ChannelScreen(
                    navigator = navigator,
                    channelId = destination.channelId
                )
                is AppDestination.Settings -> SettingsScreen(onClickBack = navigator::pop)
            }
        }
    }
    Settings, Search, Player, Channel should all be scoped to the one screen. I'm using koin for injecting my viewmodels like this
    fun SearchScreen(
        viewModel: SearchViewModel = getViewModel(),
        navigator: BackstackNavigator<AppDestination>
    ) {
    i
    d
    • 3
    • 30
  • t

    Tim Malseed

    10/03/2022, 12:02 AM
    Hey friends, I wrote a post on compose navigation. This post details some of the common mistakes you can make when trying to implement jetpack navigation with compose, and how to avoid them https://programminghard.dev/compose-navigation/
    s
    • 2
    • 18
  • a

    Ali Khaleqi Yekta

    10/03/2022, 5:06 AM
    Hi. I'm trying to get the top offset of cursor in a
    BasicTextField
    . A solution I'm currently using is using the
    onTextLayout
    callback and from there, accessing
    textLayoutResult.getCursorRect(textFieldValue.selection.end).top
    . This works perfectly fine, but, It's only re-evaluated during a change in text layout and moving the cursor doesn't trigger that. So a solution I could think of is forcefully trigger
    onTextLayout
    on each change of cursor; but I don't know how and plus, it's probably inefficient and definitely hacky. Can anyone provide another solution or maybe an idea for triggering
    onTextLayout
    ?
    z
    • 2
    • 1
  • a

    Asad Mukhtar

    10/03/2022, 6:08 AM
    Hi Guys, anyone please let me know, how you guys handle the load more results in compose?
    private val _flightList = MutableLiveData<List<MultiCityFlightListingUiModel>>()
    val flightsList: LiveData<List<MultiCityFlightListingUiModel>> = _flightList
    For e.g I set the values on response of api, and observe that live data in the UI to show the appropriate results.
  • t

    Tower Guidev2

    10/03/2022, 10:04 AM
    Hi is there a better way to use
    produceState
    and
    collectAsState
    ?
    val stateFlow by produceState<Flow<Stateable>>(initialValue = flowOf(InitialState), true) {
    
        value = viewModel.reduce(ActivitySearch)
    
    }
    
    val state by stateFlow.collectAsState(initial = InitialState)
    in my composable? is there an approach where i can combine the
    produceState
    with the
    collectAsState
    ?
    z
    • 2
    • 3
  • v

    Vaios Tsitsonis

    10/03/2022, 12:16 PM
    Hello! I am trying to render a SVG like that
    Image(painter = painterResource(id = R.drawable.svg_name), contentDescription = "")
    and I get the following error:
    java.lang.IllegalArgumentException: Unknown command for: R
    Is there some sort of limitation? Is there any way to overcome this issue?
    s
    m
    e
    • 4
    • 12
  • q

    qlitzler

    10/03/2022, 12:27 PM
    Can a
    androidx.compose.ui.graphics.Path
    , and by extension an
    android.graphics.Path
    , be considered as
    @Stable
    or
    @Immutable
    ? I know the compose compiler doesn’t think so by default. I’m trying to assess if I could add the
    @Stable
    or
    @Immutable
    annotation myself.
    z
    • 2
    • 6
  • r

    rocketraman

    10/03/2022, 1:48 PM
    I've read through the very interesting thread https://kotlinlang.slack.com/archives/CJLTWPH7S/p1617664367220300. I'm using the experimental text UI and have implemented the suggestions of explicitly setting
    includeFontPadding = false
    and
    lineHeightStyle
    (the former does help a bit, the latter makes no difference, probably because my text is a single line), however I still get a lot of padding above and below my text. Is there a way to make that space smaller?
    s
    h
    • 3
    • 10
  • t

    themishkun

    10/03/2022, 2:36 PM
    Hi! Did anyone tried and failed to create a proper FlexBox implementation in Compose or is it just a niche layout waiting for its hero to implement it? The whole purpose of this question is to research any known compatability issues between flexbox and Compose single-pass layout model before trying to implement it myself
    f
    c
    +3
    • 6
    • 24
  • t

    Tower Guidev2

    10/03/2022, 4:02 PM
    I have a really strange issue
    m
    • 2
    • 3
Powered by Linen
Title
t

Tower Guidev2

10/03/2022, 4:02 PM
I have a really strange issue
my current android application only works as required on my device. when any of my colleagues build the same
github
branch the app builds and installs ok however the compose navigation does not work if i build an apk and distribute it to my team this works fine we have compared
gradle.properties
and
local.properties
for all team members and these are identical to mine. we are all using the same Android Studio version of
Android Studio Flamingo | 2022.2.1 Canary 2
Build #AI-222.4167.29.2221.9093980, built on September 22, 2022
Runtime version: 11.0.15+0-b2043.56-8887301 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 12
Metal Rendering is ON
Registry:
    external.system.auto.import.disabled=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    com.android.aas (3.5.1)
what could be causing this issue? what config are we missing? the part of the app that does not work for my colleagues is that the compose navigation does not work, the app employs a backdrop with menu items that allow the user to navigate to other sections of the application. clicking on these menu items only works for me
m

Mark T Gray

10/04/2022, 10:44 AM
My two cents worth are that some settings contained in files excluded by your .gitignore are effecting the compilations. But that is just a guess, and I have absolutely no idea what those settings might be
t

Tower Guidev2

10/04/2022, 3:38 PM
i fixed this by getting my colleagues to delete the
.idea
folder we tried lots of other approaches before finding this 😄
View count: 6