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

    Anders Søe

    05/30/2021, 6:29 PM
    I have an existing Spring Boot desktop application i consider migrating to compose-desktop. Can i inject my existing spring components into compose some way ? And if yes.. any examples/documentation i could look at ?
    a
    • 2
    • 3
  • a

    Ardian

    05/30/2021, 6:36 PM
    👋 Hello everyone! Is there a way to make
    SwingPanel
    rendered behind another composable? I've tried using the
    Box
    layout to wrap
    SwingPanel
    with the other composable but it seems like it always displays
    SwingPanel
    on top of the other.
    Box {
      SwingPanel { //logic here }
      Image { //logic here }
    }
    k
    e
    +2
    • 5
    • 6
  • m

    Mitchell Syer

    05/30/2021, 11:36 PM
    Hello I am having trouble with MacOS signing in CI. I have everything I need to create a pkg inside the CI, the keychain, the certs, and everything else. It seems to get stuck on the PackagePkg task, I believe its because of the issue mentioned in this article https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions. About how its asking the computer for input on allowing the keychain to be accessed. Here is the relevant github action yml, I am not sure how to fix it myself, as you need to sign the pkg during the build, and not after, and compose doesnt seem to have a way to force it like the article does like this
    /usr/bin/codesign --force -s <identity-id> ./path/to/you/app -v
    - name: Build MacOS Package
          if: ${{ matrix.runtime == 'osx-x64' }}
          run: |
            echo ${{ secrets.APPLE_CERT }} | base64 --decode > certificate.p12
            security create-keychain -p ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} build.keychain 
            security default-keychain -s build.keychain
            security unlock-keychain -p ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} build.keychain
            security import certificate.p12 -k build.keychain -P ${{ secrets.APPLE_CERT_PASSWORD }} -T /usr/bin/codesign
            security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.APPLE_KEYCHAIN_PASSWORD }} build.keychain
    
            ./gradlew packagePkg notarizePkg \
            -Pcompose.desktop.mac.sign=true \
            -Pcompose.desktop.mac.signing.identity=${{ secrets.APPLE_IDENTITY }} \
            -Pcompose.desktop.mac.notarization.appleID=${{ secrets.APPLE_ID }} \
            -Pcompose.desktop.mac.notarization.password=${{ secrets.APPLE_PASSWORD }}
    o
    a
    • 3
    • 4
  • s

    smallshen

    05/31/2021, 5:44 AM
    how can we implement our own ComposeLayer, it is internal
    k
    i
    s
    • 4
    • 8
  • j

    Javier

    05/31/2021, 3:41 PM
    Where are release notes for 0.4.0?
    o
    • 2
    • 3
  • g

    gbaldeck

    05/31/2021, 9:30 PM
    There seems to be an issue with the
    items
    function in LazyListScope. The item content is not re-rendering despite state change. Or perhaps I'm doing something wrong? here is the code https://github.com/recursivelftr/Grim-Locations/blob/master/src/main/kotlin/io/grimlocations/ui/view/component/LocationListComponent.kt#L52
    j
    z
    • 3
    • 12
  • t

    Tristan B.

    06/01/2021, 8:00 AM
    I tried to migrate from 0.3.2 to 0.4.0 and it seems that the SwingPanel doesn't have the same behavior anymore. In the 0.4.0, the JPanel doesn't follow the modifier rules anymore. When the JFrame is big, the JPanel is too small, when the JFrame is small, the JPanel is too big and it overlaps Compose components. Is this a bug ?
    i
    • 2
    • 12
  • o

    olonho

    06/01/2021, 9:55 AM
    We finally released M4, please read https://blog.jetbrains.com/kotlin/2021/06/compose-for-desktop-milestone-4-released/
    :kotlin-intensifies: 22
    👏 25
    👏🏼 1
    d
    c
    c
    • 4
    • 13
  • t

    theapache64

    06/01/2021, 9:56 AM
    I think someone should update the project description to something like "Jetpack Compose for Desktop and Web..." 😉 , by the way is it true that the project old only 8 months? 🤔
    💯 1
    ✅ 1
    o
    • 2
    • 1
  • v

    Vadim Kapustin

    06/01/2021, 12:22 PM
    How to react to the Enter key being pressed while editing in TextField? (with singleLine == true)
    i
    a
    t
    • 4
    • 6
  • c

    Colton Idle

    06/01/2021, 1:00 PM
    Should the multiplatform template be opened from Android studio or from IJ?
    o
    • 2
    • 2
  • g

    gbaldeck

    06/01/2021, 1:19 PM
    I need to file a bug for the LazyColumn rendering issue I discovered. The composable function passed to the
    items
    function is not re-rendering during state changes. This seems to be an issue introduced in a recent build as everything worked fine until recently and I have not changed my code in about a month. Should bugs currently be filed on github or youtrack?
    o
    a
    a
    • 4
    • 8
  • k

    Kirill Grouchnikov

    06/01/2021, 1:42 PM
    Filed tiny little bugs...
    😄 4
    c
    • 2
    • 1
  • k

    Kirill Grouchnikov

    06/01/2021, 1:55 PM
    Work in progress on Aurora (desktop Compose components / skins). This is a 
    Column
     of items that keeps track of its selection (with global Up / Down handlers). The parts that come from Aurora - selected and rollover row highlights, as well as animated transitions on rollover and selections, including animating the foreground of the texts and the icons.
    aurora-list-highlights.mov
    👍 1
    🍭 7
    🎉 1
    i
    • 2
    • 2
  • k

    Kirill Grouchnikov

    06/01/2021, 1:56 PM
    At some point, we'll need desktop-grade containers that support multi-selection (ability to Ctrl / Shift select ranges of items), reordering, etc. Not sure if it should come from JB or from us as the community.
    c
    • 2
    • 1
  • c

    Colton Idle

    06/01/2021, 4:12 PM
    Sorry in advance for my questions. I am converting my plain old android + compose project (composable are in a separate module... ready to share!) to JB compose with multiplatform. I will use threads, for each question I encounter. 1. Converting my android compose project to be multiplatform compose... what do I do with these dependencies in my android app modules build.gradle?
    i
    u
    • 3
    • 32
  • c

    Colton Idle

    06/01/2021, 4:39 PM
    2. I know that Preview isn't available in desktop yet, but my current compose only module includes a few @Preview annotations. Do I basically have no choice but to delete them for now? Or is there some dependency I can introduce for right now that will allow me to compile with @Preview annotations, and preview in Android Studio?
    a
    • 2
    • 1
  • c

    Colton Idle

    06/01/2021, 4:42 PM
    3. I'm currently using
    import androidx.compose.ui.util.lerp
    in my android only compose module. But converting it to JB compose doesn't work because it can't find it. Am I missing some util dependency that's available or is lerp not available in JB compose?
    i
    o
    • 3
    • 4
  • y

    Yan Pujante

    06/01/2021, 4:57 PM
    Trying M4 and getting
    Unresolved reference: hasFocus
    for
    FocusState
    . Both in the IDE and on the command line. Am I doing something wrong?
    k
    • 2
    • 4
  • y

    Yan Pujante

    06/01/2021, 5:15 PM
    I am not sure how to adapt the code
    val userPreference = UserPreference()
    
    Window(
      size = userPreference.windowSize,
      resizable = true,
      title = "Test",
      events = WindowEvents(onResize = userPreference::onWindowResize)
    ) {
      App(userPreference)
    }
    to the new Window api. It looks like I can use
    val state = rememberWindowState(size = userPreference.windowSize)
    , but I am not sure how to call
    onWindowResize
    when
    state.size
    changes...
    i
    • 2
    • 6
  • d

    Dirk Hoffmann

    06/01/2021, 7:26 PM
    so I learned foundation is independant from MetrialTheme stuff. Foundation has a
    fun defaultScrollbarStyle() = ScrollbarStyle(
        minimalHeight = 16.dp,
        thickness = 8.dp,
        shape = RectangleShape,
        hoverDurationMillis = 0,
        unhoverColor = Color.Black.copy(alpha = 0.12f),
        hoverColor = Color.Black.copy(alpha = 0.12f)
    )
    that it passes down via a
    val LocalScrollbarStyle = staticCompositionLocalOf { defaultScrollbarStyle() }
    now on dynamically changing dark/light themes whilst Runtime, what is "the" supposed way that hover related Colors are dependant on
    MaterialTheme.colors
    and the recomposition honours them even when changing the theme whilst runtime ?
    k
    i
    • 3
    • 4
  • f

    Felipe Gaiad

    06/02/2021, 1:05 AM
    Hi! I've been using Cloud Firestore (Firebase) for online database in my Android app. What similar tool have you been using for Desktop?
    :not-kotlin: 3
    o
    • 2
    • 1
  • x

    xxfast

    06/02/2021, 4:29 AM
    Hi all - Having issues with setting up desktop-compose in my project. As soon as i add any compose dependencies, my
    commonMain
    source set gets excluded from the build. I’m using AS Arctic fox 2020.3.1 with jetbrains compose
    0.4.0-build179
    desktop-compose.mov
    i
    • 2
    • 17
  • d

    Dirk Hoffmann

    06/02/2021, 10:33 AM
    Is there such thing as a
    LazyColumn
    with Scrollbar for compose-desktop?
    i
    • 2
    • 1
  • y

    Yan Pujante

    06/02/2021, 3:29 PM
    I have noticed that with M4 after closing the app (clicking the close icon on macOS), there is a quite noticeable delay after the window disappear and the app actually terminates (I would say 2-3s). See image:
    s
    l
    • 3
    • 5
  • c

    Colton Idle

    06/02/2021, 4:37 PM
    My android only project is now android and desktop! I'm still using these dependencies:
    implementation("androidx.compose.runtime:runtime-livedata:1.0.0-beta07")
    implementation("androidx.compose.ui:ui-viewbinding:1.0.0-beta07")
    in my android app module but a few threads above it was recommended to not mix and match JB compose and Google compose. What dep should I use instead of the above? I will say that I'm using those above and everything seems to compile and run just fine.
    j
    i
    • 3
    • 13
  • s

    SrSouza

    06/02/2021, 5:28 PM
    Should we expect support of constraint layout on CFD in the future?
    j
    o
    • 3
    • 2
  • d

    David Dupraz

    06/02/2021, 8:25 PM
    Hello ! I'm currently programming an online card game for my bachelor thesis (on Windows, using JVM). But I have a big issue implementing the drag gesture of the cards. A card moves while dragged, but when mouse button is released, two things happen: • card is added to the new row (this is the normal behaviour) • but dragged card stays displayed and so creates problems of display and duplication I join a video showing the issue and put in a thread the code. This is a shortened version of the code (just to replicate the problem), the real project is significantly bigger. I use Compose 0.4.0 and Kotlin 1.5.10. I am struggling with that issue for a long time now, so.... any help would be appreciated :)
    HEIG game 2021-06-02 21-23-27.mp4
    b
    o
    i
    • 4
    • 11
  • c

    Colton Idle

    06/02/2021, 11:44 PM
    When going from compose android to compose I can remove this buildFeature compose = true flag... right?
    buildFeatures {
            buildConfig = true
            compose = true
            viewBinding = true
    }
    i
    • 2
    • 5
  • j

    Jacob Bosco

    06/03/2021, 5:21 AM
    Hi, I am new to Compose and I'm having some doubts about state management. I have an
    AppState
    object and it has some values in nested properties that I want to access. If I use
    mutableStateOf()
    , the state only updates when the entire
    AppState
    object is changed not when its properties change. I have also tried kotllin Flow for the first time but the only solution I could get was to make each of the properties a flow and then individually watch them in the main compose function. Is there any other way to manage state where I need to watch nested properties?
    a
    c
    m
    • 4
    • 25
Powered by Linen
Title
j

Jacob Bosco

06/03/2021, 5:21 AM
Hi, I am new to Compose and I'm having some doubts about state management. I have an
AppState
object and it has some values in nested properties that I want to access. If I use
mutableStateOf()
, the state only updates when the entire
AppState
object is changed not when its properties change. I have also tried kotllin Flow for the first time but the only solution I could get was to make each of the properties a flow and then individually watch them in the main compose function. Is there any other way to manage state where I need to watch nested properties?
a

Albert Chang

06/03/2021, 5:32 AM
You can use
mutableStateOf()
at property level. Something similar to this.
j

Jacob Bosco

06/03/2021, 5:37 AM
Is
structuralEqualityPolicy()
the thing that helps deal with the nested properties?
a

Albert Chang

06/03/2021, 5:44 AM
No. That has nothing to do with whether it is a property or not. Read the doc for what it is used for.
j

Jacob Bosco

06/03/2021, 6:06 AM
I looked at the link you sent but i couldn't find anything different from what was doing. Adding the equality policy didn't make any difference cause that is the default value already.
class AppState {
    var fileState = mutableStateOf(File(""))
    var coreState = mutableStateOf(emptyCore())

    private fun createCore() {
        val (instructions: List<Instruction>, parsedVariableData: List<ParsedData>) = Parser.parseDataFromFile(fileState.value)
        val program = Program(
            instructions = instructions,
            parsedData = parsedVariableData
        )
        coreState.value = Core(program = program)
    }

    val loadFile: (File) -> Unit = {
        fileState.value = it
        createCore()
    }

    val executeProgram: () -> Unit = coreState.value::runProgram
}
This is my state file, when I update the file, the UI related to the file updates but the ones that related to the core do not. I don't get why that's happening.
a

Albert Chang

06/03/2021, 6:14 AM
You can do something like this:
class AppState {
    var file by mutableStateOf(File(""))
    val core by derivedStateOf {
        val (instructions: List<Instruction>, parsedVariableData: List<ParsedData>) = Parser.parseDataFromFile(file)
        val program = Program(
            instructions = instructions,
            parsedData = parsedVariableData
        )
        Core(program = program)
    }
}
And if you meant that
executeProgram
is not updating, it's expected because you are not updating it.
j

Jacob Bosco

06/03/2021, 6:24 AM
runProgram
updates it's internal state. If I use
derivedStateOf
then it won't be able to reflect that change.
Cause as far as I understand,
derivedStateOf
will evaluate the block that I pass to it when I call
core.value
so it'll create a new core every-time something changes.
a

Albert Chang

06/03/2021, 6:30 AM
What is
runProgram
? And you don't want
core
to be updated every time
file
changes? Can you describe what you want more specifically?
j

Jacob Bosco

06/03/2021, 6:35 AM
I am trying to create an ARM simulator. I load a program (with some instructions) into the core and when i run it the properties of the core like the
memoryArray
and
registerArray
will get updated ( will have new values after running instructions like ADD, SUB etc.). The instructions come from the file, so when I load a new file I have to parse it and for now it creates a new core. So when
file
changes I need a new core, but after
runProgram
I need the same core but its property values will be different.
a

Albert Chang

06/03/2021, 6:41 AM
So when 
file
 changes I need a new core
The code I posted above does exactly this. If you want the properties of
Core
to be observable, just define them as states (e.g.
var memoryArray by mutableStateOf(emptyArray())
).
j

Jacob Bosco

06/03/2021, 6:49 AM
So I have to do this for all the properties?
registerArray
has some values that I need to observe that are nested in some more objects. I already thought of doing this but doing it individually for all of them is repetitive and fragile so I was trying to find a better approach.
a

Albert Chang

06/03/2021, 6:53 AM
I don't think
var memoryArray by mutableStateOf(emptyArray())
and
var memoryArray = emptyArray()
differ much in terms of verbosity. You can't expect properties to automatically become observable.
j

Jacob Bosco

06/03/2021, 6:55 AM
I am trying to keep the UI logic and the application logic separate in different modules so if you meant I have to place the
memoryArray by mutableStateOf
where
Core
or
MemoryArray
is defined I can't do that
a

Albert Chang

06/03/2021, 6:56 AM
What make you think
mutableStateOf()
is UI logic?
j

Jacob Bosco

06/03/2021, 6:57 AM
It's specific to Compose right
If later I want to make the UI using Tornado FX I'll have to change that
a

Albert Chang

06/03/2021, 7:02 AM
Then you have to use
StateFlow
. Anyway you need an observable mechanism as
You can't expect properties to automatically become observable.
j

Jacob Bosco

06/03/2021, 7:03 AM
For now I'll just go with what you said making each of them properties a
mutableStateOf
but I'll try to make them properties in
AppState
by individually referencing them from the
core
variable.
Yeah or I'll try with Flows again.
Thanks 👍
👍 1
c

Colton Idle

06/03/2021, 12:57 PM
I had this problem too at first where using mutableStateOf felt wrong because it felt like I was strongly tying myself to compose. Now I just use it instead of trying to use flows or anything and everything is easy and it just works. /shruggie
m

Michael Paus

06/04/2021, 8:11 AM
I also found it helpful to use persistent data structures to represent more complex state. This way the
mutableStateOf
always changes when any of the nested properties is changed.
View count: 3