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

    Sergey Y.

    03/14/2021, 11:58 PM
    Hi. Interested in the question regarding the support of different platform APIs. For instance, will it be possible in the future to support (have a modifier) native Acrylic Material on Windows 10 or analogs on MacOS/KDE-based linux? https://docs.microsoft.com/en-us/windows/uwp/design/style/acrylic I've found how to do it on JFrame, but it looks verbose https://stackoverflow.com/a/28821423 Thanks.
    i
    j
    • 3
    • 5
  • g

    gbaldeck

    03/15/2021, 3:19 AM
    is there any reason that a mutable state flow wouldnt cause a composable function to reload its state when the value of the state flow has changed? I'm running into an issue where I'm changing the value of a mutable state flow but the composable function that collects it as state is not receiving the update or doing a rerender
    t
    v
    • 3
    • 7
  • a

    albertosh

    03/15/2021, 1:52 PM
    Hi everyone Is DropdownMenu available in compose desktop? I tried to import (
    androidx.compose.material.DropdownMenu
    ) it but the IDE can’t find it. I’m using version
    0.3.2
    of compose
    j
    j
    • 3
    • 8
  • t

    theapache64

    03/15/2021, 3:07 PM
    Apart from the
    dirChooser
    flag, is there any way to define default installation directory? I read it's possible via `jpackage`'s
    --install-dir
    option, but how can I pass that param from
    build.gradle.kts
    ? 🤔
    o
    a
    • 3
    • 6
  • y

    Yan Pujante

    03/15/2021, 4:43 PM
    I am trying to wrap my head around flow/coroutines all at the same time as learning compose-desktop so clearly I am struggling 😉. I have the following piece of code:
    private val _pendingIOs = MutableStateFlow(0)
        val pendingIOs: StateFlow<Int>
            get() = _pendingIOs
        
        fun createPart(): Flow<Part> = flow {
            val e = coroutineScope {
                withContext(Dispatchers.Main) {
                    <http://logger.info|logger.info>("executing in Main")
                    _pendingIOs.value++
                    try {
                        async(<http://Dispatchers.IO|Dispatchers.IO>) {
                            delay(100) // simulate io delay
                            Part(_nextPartId++, "xxx")
                        }.await()
                    } finally {
                        <http://logger.info|logger.info>("executing in Main")
                        _pendingIOs.value--
                    }
                }
            }
            emit(e)
        }
    The idea being that I am updating a pendingIO state variable prior to executing any IO. The UI can then simply display a CircularProgressIndicator when said stateflow variable is > 0. Is this an acceptable way of doing things? Is there a better way? Is my flow code correct or could be simplified?
    j
    a
    • 3
    • 10
  • c

    Casey Brooks

    03/15/2021, 7:41 PM
    Is there any documentation for properly setting up JPMS with Compose for Desktop apps? My project runs fine with
    run
    task, but I get `NoClassDefFoundError`s when running with
    runDistributable
    that I believe are because of how jlink/jpackage is packaging it with some of my Java dependencies. I’ve never done anything with JPMS, so it would be nice to have a guide for getting that configured properly with the Gradle plugin,
    module-info.java
    , and anything else that’s needed
    j
    s
    • 3
    • 5
  • s

    samuel

    03/15/2021, 11:13 PM
    While receiving
    TextFieldValue
    input, is there a way to specify the type that is expected or is it always expected to be a
    string
    (
    TextFieldValue.text
    ) For example could i have an arbitrary
    KotlinType
    that i could use for validation directly?
    j
    • 2
    • 5
  • v

    Vahalaru

    03/16/2021, 3:24 AM
    I was looking at Jetpack Compose Playground in the crossfade animation. Would somebody educate me if I'm wrong but, couldn't this concept be used in a fashion similar to Androids Fragment Containers? Or even a makeshift navigation? Hear me out you make your parent containers "fragments/fragment activities" and the main window contains a container composable "Activity". In your "Activity" you have a enumerated variable that is remembered containing your "fragments" or containers. Using this one would be able to trigger changing the state by changing the composable container in the variable, thus triggering a state change which refreshes the window. Could I be onto something here? Link is here Playground
    t
    z
    • 3
    • 8
  • t

    Trevor Merritt

    03/16/2021, 12:46 PM
    is there a way to preview compose views with IDEA? I am not targeting android, so android studio seems like overkill to get a preview.
    t
    a
    o
    • 4
    • 6
  • p

    PHondogo

    03/16/2021, 1:28 PM
    Hello! Is it possible to debug rendering from IDE? Now breakpoints are not triggered.
    o
    • 2
    • 1
  • p

    PHondogo

    03/16/2021, 2:36 PM
    I was trying to compile gradle multimodule project with desctop-compose artifact in each module. If I compile only one module it is ok. But when I add another gradle module with dependency on first module I got an error:
    androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: You are using an outdated version of Compose Runtime that is not compatible with the version of the Compose Compiler plugin you have installed. The compose compiler plugin you are using (version 1.0.0-alpha13) expects a minimum runtime version of 1.0.0-alpha13.
    v
    • 2
    • 2
  • a

    albertosh

    03/16/2021, 5:34 PM
    Hi! Noob question here 😅 I’m currently learning compose directly in desktop (maybe not the most clever idea…). I’m able to code simple UIs, but when it’s time to code “real” apps I’m struggling with suspend functions How should I bridge my suspended code and Compose? My code in the thread
    s
    z
    • 3
    • 6
  • n

    Nikky

    03/16/2021, 11:07 PM
    i am new to compose.. is there any library or component for updating UI from a
    Store<T>
    or
    Store<List<T>>
    type? i have only used something similar in fritz2 but.. if i want to build a desktop UI,might as well check if i can do it "right" or in other words.. can i render a
    StateFlow<T>
    and have the UI rebuild as as the value changes ?
    z
    • 2
    • 1
  • h

    homchom

    03/17/2021, 3:02 AM
    Hello! I've been looking into Compose recently; I've never used it before (and I'm relatively new to Kotlin in general), but I am wondering the scope to which it is intended to be used. I was going to use LWJGL for a project (and by extension, OpenGL); can Compose be used to create UIs for this? Or do you have to make your UI either entirely with Compose or not at all? If the latter, should I be using it, or is Compose meant more for UI-only applications? Thanks in advance.
    j
    • 2
    • 2
  • t

    Timo Drick

    03/17/2021, 4:04 AM
    During porting my entries for the ComposeDevChallenge i noticed a glitch in the Canvas drawArc function. It looks like i have to substract the offset of each axis from the size. Otherwise the arc is distorted.
    • 1
    • 2
  • p

    PHondogo

    03/17/2021, 8:04 AM
    Hello! I have kotlin multiplatform gradle project. When I applying compose plugin, its applyed for all targets. How can i filter some targets that should not be proceessed by compose compiler plugin?
    o
    • 2
    • 1
  • t

    Timo Drick

    03/17/2021, 2:35 PM
    I ported my submissions to the AndroidDevChallenge to CfD https://github.com/timo-drick/compose_desktop_dev_challenge
    video.mp4
    🎉 13
    o
    t
    • 3
    • 3
  • s

    Shabinder Singh

    03/17/2021, 8:16 PM
    Compile Error: java.lang.IllegalStateException: 2. expected value parameter count to be higher IDE editor doesnt give any error , actual expect are defined with same number of paramenters , still following error and in error function doesnt show
    placeholder
    parameter. is this a compiler bug?
    c
    j
    d
    • 4
    • 4
  • s

    Shabinder Singh

    03/18/2021, 1:22 AM
    I am not able to build Distributable Packages..... Error: --module-path is not specified and this runtime image does not contain jmods directory. Usage: jlink <options> --module-path <modulepath> --add-modules <module>[,<module>...] Use --help for a list of possible options Commands Tried:
    ./gradlew :desktop:packageDeb
    ./gradlew :desktop:runDistributable
    ./gradlew :desktop:createDistributable
    Running Locally using
    ./gradlew :desktop:run
    works fine!
    g
    d
    • 3
    • 13
  • v

    Vahalaru

    03/18/2021, 6:28 AM
    I am new to making contributions on github. I would love to be a part of compose desktop and to work towards making it better. That said where would be a good place to start? I would love to hear some suggestions.
    j
    t
    d
    • 4
    • 4
  • y

    Yan Pujante

    03/18/2021, 2:57 PM
    I captured what is happening with the
    OutlinedTextField
    when it gets resized My original code (which I was having issue with):
    OutlinedTextField(searchFilter.value,
                        onValueChange = { searchFilter.value = it },
                        trailingIcon = {
                            Icon(
                                Icons.Outlined.Search,
                                contentDescription = "filter",
                            )
                        },
                        modifier = Modifier.height(40.dp)
                    )
    It this a bug or the intended behavior? Is there anything I can do to change the behavior (I would like to use
    40.dp
    )?
    k
    j
    • 3
    • 6
  • n

    Nikky

    03/18/2021, 7:18 PM
    when i have a
    State<List<MyData>>
    how would i use a layout compontn like Rowm Column or smth else to render each element in the list ? essentially, can i do a renderEach ?
    z
    t
    a
    • 4
    • 13
  • s

    Slackbot

    03/18/2021, 7:26 PM
    This message was deleted.
    🎉 1
    a
    s
    • 3
    • 2
  • d

    Dirk Hoffmann

    03/19/2021, 9:59 AM
    how can I close a
    Popup
    on hitting Escape key? (as the following does not work):
    Popup(alignment, IntOffset(0, verticalOffset), isFocusable = true) {
            Card(
                Modifier.border(5.dp, Color.LightGray).size(350.dp, 200.dp)
                    .onPreviewKeyEvent { when (it.key) {
                        Key.Escape -> {
                            onDismissRequest()
                            true
                        }
                        else -> false
                    }}
            ) {
                ...
    onPreviewKeyEvent
    is never executed
    i
    • 2
    • 1
  • d

    Dirk Hoffmann

    03/19/2021, 1:39 PM
    Also: on any component I have
    Modifier.clickable { }
    and/or
    Modifier.pointerInput(Unit) {
        detectTapGestures(
            onPress = {/* Called when the gesture starts */ },
            onDoubleTap = { /* Called on Double Tap */ },
            onLongPress = { /* Called on Long Press */ },
            onTap = { /* Called on Tap */ }
        )
    }
    how could I detect a Mouse right button click ??
    i
    s
    • 3
    • 3
  • o

    Olivier Patry

    03/19/2021, 2:03 PM
    I try using
    vectorXmlResource
    but it fails with a NPE, form
    openResourceStream
    . I guess my problem comes from my Gradle configuration not packaging my assets in the final Jar file but I don't know how to fix that. Any clue?
    desktop-app/src/main/kotlin
    for the source code,
    desktop-app/src/main/resources
    for the assets. I put an
    icons/
    dir within
    resources/
    which contains my Android Vector drawables and then I use
    vectorXmlResource("icons/ic_settings.xml")
    .
    i
    • 2
    • 18
  • s

    smallshen

    03/20/2021, 2:40 PM
    how to enable window transparency?
    l
    • 2
    • 2
  • y

    Yan Pujante

    03/20/2021, 2:57 PM
    Tip: I am not sure it is the best way to accomplish this, but using unweighted and weighted items in a
    Row
    lets you define which one occupies all the space available.. For example, I wanted to display some text, and on the right side (=end) of the row, I want an icon, and I was able to achieve it like this:
    @Composable
    fun TestLayout() {
        val border = Modifier.border(1.dp, color = Color.Red)
        Row(modifier = Modifier.fillMaxWidth().padding(10.dp)) {
            Text("Text", modifier = border.weight(1f)) // weighted
            Icon(Icons.Outlined.Refresh, contentDescription = "refresh", modifier = border) // unweighted
        }
    }
    👍 1
    v
    t
    • 3
    • 5
  • y

    Yan Pujante

    03/20/2021, 5:03 PM
    I have the following code:
    class Model {
        var value1 by mutableStateOf(0)
            private set
    
        var value2 = 0
            private set
    
        fun onClick1() { value1++ }
        fun onClick2() { value2++ }
    }
    
    val model = Model()
    
    @Composable
    fun TestModel() {
        val m = Modifier.padding(10.dp)
        Column {
            Row { Text(model.value1.toString(), modifier = m); Button(onClick = {model.onClick1()}) { Text("Val1++")} }
            Row { Text(model.value2.toString(), modifier = m); Button(onClick = {model.onClick2()}) { Text("Val2++")} }
        }
    }
    which produces the result in the attached screenshot. I have a few questions: 1) Is it valid to have the state in an external object (like) Model (as opposed to have it directly inside the composable function)? Are there caveats? 2) I don't understand how Compose recognizes that value1 has changed since its underlying representation is a
    State
    but it is exposed as a simple value. How does compose know this? How is value2 different from value1 from a user point of view (IntelliJ tells me that value1 is
    public final var value1: Int
    when using Ctrl-Q)? 3) if I understand correctly (some of) the magic of compose comes from the compiler. Is there a way to "see" this magic in action? Like a flag? (something like compiling
    .cpp
    to
    .s
    to "see" the assembly code)
    a
    c
    • 3
    • 21
  • t

    theapache64

    03/20/2021, 7:57 PM
    🐛 Bug : Animation Issue 🧵
    d
    • 2
    • 15
Powered by Linen
Title
t

theapache64

03/20/2021, 7:57 PM
🐛 Bug : Animation Issue 🧵
Why new animDuration not getting reflected? 🤔 What am I missing ? Code: https://gist.github.com/theapache64/96671be7b7ca459981180492dcff6c94
tgb-2021-03-21_01.25.18.mp4
dynamic animDuration not supported? 🤔
d

Doris Liu

03/20/2021, 8:16 PM
animate*AsState
is designed to only apply new
animationSpec
when
targetValue
changes. I'm curious what's your use case?
t

theapache64

03/20/2021, 8:19 PM
@Doris Liu I want the animDuration to be dynamic. my
targetValue
changes on button click, but new
animationSpec
not getting applied.
animateFloatAsState
takes initial
animationSpec
. Can u pls check the above attached code ? I think i miss something.. am new to compose animations
d

Doris Liu

03/20/2021, 9:30 PM
@theapache64 which compose version are you using? It's working just fine when I tried it with beta02 on Android - the animation is updated to whatever time I entered in the TextField
t

theapache64

03/20/2021, 9:31 PM
@Doris Liu am on Compose for Desktop ->
0.4.0-build174
d

Doris Liu

03/20/2021, 9:33 PM
Seems like a compose desktop specific issue. The code looks correct btw. 🙂 Could you file a bug please?
t

theapache64

03/20/2021, 9:33 PM
Sure. thanks for checking
d

Doris Liu

03/20/2021, 9:35 PM
Actually, let me check on beta03 (not yet released), maybe desktop release is ahead of beta02.
t

theapache64

03/20/2021, 9:35 PM
Okay
d

Doris Liu

03/20/2021, 9:39 PM
yea, looks like it's an issue introduced recently (i.e. in beta03). 😅 Thanks for letting me know
t

theapache64

03/20/2021, 9:40 PM
Ohh i see. alright. 🙇 do i need to file it in jb-compose repo ?
d

Doris Liu

03/20/2021, 9:41 PM
No. Please file it here: https://issuetracker.google.com/issues?q=componentid:612128
t

theapache64

03/20/2021, 9:46 PM
Filed : https://issuetracker.google.com/issues/183220315
👍 1
d

Doris Liu

03/20/2021, 9:46 PM
Thank you! 🙏
👍 1
View count: 2