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

    Michael Paus

    02/14/2022, 5:11 PM
    I need to create an ImageBitmap from raw ARGB pixels contained in an IntArray. On Android I do this like this
    override fun imageBitmapFromArgb(rawArgbImageData: IntArray, width: Int, height: Int): ImageBitmap {
        val image = ImageBitmap(width, height, ImageBitmapConfig.Argb8888, true, ColorSpaces.Srgb)
        image.asAndroidBitmap().setPixels(rawArgbImageData, 0, width, 0, 0, width, height)
        return image
    }
    but there does not seem to be a suitable way to do the same on desktop. The Skia bitmap does not seem to have a
    setPixels
    method.
    o
    • 2
    • 3
  • f

    frank

    02/14/2022, 9:18 PM
    Hi, I'm starting with Compose for Desktop and I'm following https://github.com/JetBrains/compose-jb/blob/master/FEATURES.md#features-currently-available-in-compose-for-desktop Do you know if exist any book, Course etc … or if there is someone who is creating it for follow him.
    g
    m
    • 3
    • 4
  • s

    SrSouza

    02/15/2022, 2:14 AM
    Hi folks, there is any official compose desktop project sample that could be used as a Showcase of Compose on Desktop?
    o
    • 2
    • 1
  • p

    pajatopmr

    02/15/2022, 6:39 AM
    `checkIsDisplayed()`not implemented? I found this article on Desktop Compose layout testing which looks to provide the exact solution I need for testing with non-Android Desktop Compose. When I run the code (see below) it looks an awful lot like some needed code is not written yet. Can someone from JetBrains elaborate and answer the questions: 1. Is the code necessary for the test to work in fact not implemented, in which case, can I do anything to help get it implemented? 2. Perhaps I am using an invalid mix of versions; is my build.gradle.kts file correct? If not, which part did I get wrong? 3. @olonho is there a road map for Compose Desktop testing infrastructure available for public consumption? 4. I'm guessing that for Compose UI testing today, Android is the only game in town. Would that be a good guess?
    o
    i
    +2
    • 5
    • 10
  • a

    albrechtroehm

    02/15/2022, 10:04 AM
    Hi everyone, I’m trying to build a form to fill in project details which needs a datepicker. As suggested in the channel i tryed to use the LGoodDatePicker. I made some progress and i can now open the datepicker when the trailing icon of a textfield is clicked. I just need to figure out how to hook everything up correctly, but I’m also quite unsure if this is the right approach. Any feedback would be appreciated. Code in the thread
    • 1
    • 2
  • k

    Kebbin

    02/15/2022, 12:49 PM
    Hello @Igor Demin! How are you? Just wondering if you guys have had any success sorting the Object Touch Targets issue with the 3D transformation? Thanks! Cheers.
    i
    • 2
    • 4
  • j

    jcechace

    02/15/2022, 6:55 PM
    Hi. Does somebody have an experience with compose desktop being used from java? Writing new components is not an issue. We are interesting in creating desktop application with Java (educational course, java is required). Since we want to avoid Swing we are exploring other options.
    k
    c
    +3
    • 6
    • 19
  • s

    spierce7

    02/15/2022, 7:42 PM
    with(LocalDensity.current) {
        window.minimumSize = Dimension(400.dp.roundToPx(), 250.dp.roundToPx())
    }
    Is there a way to subscribe to the local density as state so that if it changes it triggers a re-draw?
    d
    a
    i
    • 4
    • 9
  • g

    gnu

    02/15/2022, 10:26 PM
    I built a little Snake game using Compose for Desktop. Thanks to @Sebastian Aigner for the excellent blog post about his Asteroid game. I couldn't have done without it. https://github.com/gnu11111/snake-compose-for-desktop https://dev.to/kotlin/how-i-built-an-asteroids-game-using-jetpack-compose-for-desktop-309l
    👍🏻 2
    👍 4
    🤩 8
    👍🏼 1
    s
    • 2
    • 1
  • a

    Ahmad Daneshvar

    02/15/2022, 10:47 PM
    Hey guys, I had a question. Does anybody knows why
    TextField
    has some sort of padding, that causes the content cut (Please look at attached image)? And how I can eliminate it? Just please consider I don’t want to decrease font size or increase the height of
    TextField
    or
    OutlinedTextField
    to match the content. I am looking for another way. I also tried
    Modifier.padding
    on the textField and didn’t matter. Thank you in advance.
    k
    y
    • 3
    • 8
  • m

    MaxUt

    02/16/2022, 12:05 PM
    Hi there, quick question. What's the best way to perform a async call in a Composable ? I used to call my repositories from ViewModels but I don't know the appropriate way to do so with Compose Desktop. Here is a quick example:
    @Composable
    fun RoomsScreen(
        onRoomClick: (Int) -> Unit,
        onBack: () -> Unit
    ) {
        val rooms = remember { mutableStateOf(emptyList<WSRoom>()) }
        rooms.value = runBlocking { RoomRepository.getAllRooms() }
    
        ...
    }
    Here I've noticed that the RoomRepository.getAllRooms gets called every recomposition. What are your recommandation to avoid that ?
    h
    m
    a
    • 4
    • 13
  • k

    Kebbin

    02/16/2022, 12:44 PM
    Hello all, Is there a Status Bar component I can easily add to my CfD program, similar to the way MenuBar works? Or do I need to just create a custom area with text and icon objects etc? Thanks!
    k
    d
    • 3
    • 24
  • e

    Emily V

    02/17/2022, 6:23 AM
    Hi, I got kind of a newbie question on how to properly hoist state when using a SwingPanel inside my Composable… When my application starts, the UI contains a few ui components. One of them is JFreeChart which is hosted inside a JPanel which I add inside a SwingPanel composable. Something like that:
    var chartFrame: ChartPanel? = null
    
    @Composable
    private fun TheChart() {
        Card(elevation = 5.dp, shape = RoundedCornerShape(0.dp), modifier = Modifier.fillMaxSize()) {
            if (chartFrame == null) {
                val series = XYSeries("Sensors Reading")
                series.add(0, 3)
                series.add(1, 4)
                series.add(2, 5)
                series.add(3, 6)
                series.add(4, 7)
                series.add(5, 3)
                val dataset = XYSeriesCollection(series)
                val chart: JFreeChart = ChartFactory.createXYLineChart("Test", "Time (seconds)", "Sensors value", dataset)
                val frame = ChartPanel(chart)
                frame.isVisible = true
                chartFrame = frame
            }
    
            Box {
                SwingPanel(
                    factory = {
                        JPanel().apply {
                            layout = BoxLayout(this, BoxLayout.Y_AXIS)
                            add(chartFrame)
                        }
                    })
            }
        }
    }
    This renders great and looks as it should. Now, when I want to push in new data, I basically need to update the dataset, and I do that by adding x,y values to the series object. Now obviously this needs to be hoisted out of the Composable and get pushed into the function as a parameter. But I am not entirely sure on how to architect that properly in Compose. I also added a check for null to make sure not to recreate the chart object on each recomposition and I think this is not ideal here. Can any one assist?
    d
    • 2
    • 9
  • n

    Naveed

    02/17/2022, 1:53 PM
    Is there a better way to move text to the vertical center of a
    Row
    ? than
    padding(top = 8.dp)
    ? I have tried
    .wrapContentHeight(Alignment.CenterVertically)
    in the modifier and it does not do anything, the text stays stuck at the top.
    f
    • 2
    • 4
  • t

    Thomas

    02/17/2022, 7:13 PM
    androidx.compose.ui.renderComposeScene
    seems to have disappeared in
    1.2.0-alpha01-dev620
    (upgrading from
    1.1.0-alpha04
    ). Where did it go?
    k
    • 2
    • 2
  • c

    czuckie

    02/17/2022, 9:14 PM
    hey all, are Tray icons a bit buggy on Gnome? I just get a black rectangle (and clicking on it to reveal the menu, pops the menu on the wrong screen, d'oh!)
    k
    • 2
    • 6
  • p

    pajatopmr

    02/17/2022, 9:37 PM
    The compose-jb issue #368 documents the difficulties users of Compose Multiplatform have been having trying to write non-Android GUI tests. It clearly identifies an example (ScrollBarTest) that actually works. But there are many operations, particularly
    checkIsDisplayed()
    , that are not currently implemented in the
    ui-test-junit4
    component thus causing a serious problem for those of us wanting to write GUI tests for our Compose Multiplatform apps. To address this problem, I have volunteered to work on implementing some of these not yet implemented functions. The first step is to set up a development environment for this work. That environment is the subject of this post, a Readers Digest version of material provided by @Igor Demin (for which I am so, so grateful). The basic work is described in https://android.googlesource.com/platform/frameworks/support.git/+/refs/heads/android-arch-work-release/README.md and essentially entails: 1. Getting the source code 2. Setting up java 3. Setting up Android Studio 4. Verifying the development setup by running a working test 5. Developing a fix, with test, for some unimplemented method 6. Getting the code reviewed by @olonho and/or @Igor Demin 7. Generating a PR to the JetBrains fork Getting the source code The source code is obtained using a Google tool, '`repo`', which is a layer on top of git. For work on Compose Multiplatform, the branch to use is "androidx-main". The download uses ~40G and takes a while. A gigabit network, or better, is highly recommended. The repo installation instructions can be found at https://source.android.com/setup/develop#installing-repo . I used homebrew (
    brew install repo
    ) on a MacBook Pro. Once repo is installed, the branch (androidx-main) is initialized and downloaded using steps from https://source.android.com/setup/build/downloading : mkdir <path/for/androidx-main/code> cd <path/for/androidx-main/code> repo init -u https://android/googlesource.com/platform/manifest repo init -u https://android.googlesource.com/platform/manifest -b androidx-main repo sync -c -j8 Setting up Java The Compose Multiplatform team recommends using JDK15 but I have been using JDK11 successfully for ui-test-junit4 so far. Homebrew is an excellent way to manage multiple JDK versions simultaneously, particularly Open JDK. I am also told that JDK11 is provided by the
    repo
    download, but I seem to recall needing an installed JDK11 at one point. Setting up Android Studio At this point, when the script completes, we are ready to use Android Studio (Dolphin), which is included in the download of "androidx-main", as a source file editor by executing:
    cd frameworks/support
    ./gradlew studio
    Verifying the development setup by running a working test The next step is to verify that the ScrollBarTest can be run successfully. While this usually can be done using Android Studio or Gradle, a known bug in Dolphin generates a "Nothing here" message so we use Gradle with:
    ./gradlew cleanDesktopTest :compose:foundation:foundation:desktopTest --tests "androidx.compose.foundation.ScrollbarTest"
    The remaining three steps will be performed in the coming days and I will edit this post accordingly. My hope is that others will find this documentation useful and enable them to contribute fixes also.
    👍🏻 1
    👍 2
    k
    m
    i
    • 4
    • 3
  • t

    Tim Almdal

    02/17/2022, 10:47 PM
    Hi all, I've just started "playing" with Compose and I have seen some tantalizing hints on the web regarding using icon packs within a desktop application. Can anyone point me at any examples or samples on how I can include icons into my application. Thx
    k
    c
    d
    • 4
    • 6
  • l

    luen

    02/18/2022, 5:46 AM
    how to make an element not handle mouse events? For example, as in css: pointer-events: none;
    k
    • 2
    • 3
  • n

    Naveed

    02/18/2022, 12:47 PM
    How can one stop a text field from expanding as you type something inside it that goes beyond its width? It would be nice for the text to scroll left as you type more into the text field.
    • 1
    • 2
  • l

    Landry Norris

    02/18/2022, 4:07 PM
    Is there a YouTrack for Compose-JB? I can’t seem to find one from searching.
    j
    i
    • 3
    • 2
  • m

    Miquel Àngel Román

    02/18/2022, 8:07 PM
    Hi! I've got a simple app that uses compose desktop. I'm trying to
    ./gradlew packageDeb
    from a macOS in order to later deploy it on a raspberry pi. I've asked @theapache64 but seems like packaging needs to be done on the same platform. Does anybody know a workaround?
    b
    r
    +3
    • 6
    • 10
  • a

    Alexander Maryanovsky

    02/19/2022, 1:23 PM
    Can I access the parent window in a composition?
    k
    • 2
    • 6
  • b

    Big Chungus

    02/19/2022, 9:07 PM
    Has anyone got an article or a tutorial to share explaining how to integrate CfD with some OO framework like JavaFX?
    k
    d
    • 3
    • 5
  • t

    Trammel May

    02/20/2022, 12:05 AM
    getting the following error in a bazel build
    Caused by: java.lang.AbstractMethodError: Receiver class androidx.compose.compiler.plugins.kotlin.ComposeComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:610)
    	... 47 more
    k
    • 2
    • 2
  • k

    Kebbin

    02/20/2022, 7:28 AM
    Quick question, our Kotlin / CfD code can be exported to Android and iOS apps? With all the right background config I haven't learnt yet, I guess, but possible or not?
    d
    m
    • 3
    • 16
  • e

    Enrico Saggiorato

    02/20/2022, 2:08 PM
    Hi, I was trying to read the Android documentation about state holders, but I don't really get it, I think I need to read some more examples... Do you guys know any apps that use that design pattern that I can look at as an example?
    k
    c
    • 3
    • 3
  • a

    Alexander Maryanovsky

    02/20/2022, 9:04 PM
    Where is the repository for compose desktop? Is it Open Source? Can I contribute?
    a
    k
    • 3
    • 12
  • m

    Marcello Galhardo

    02/20/2022, 9:32 PM
    Where can I find an example of how Jetbrains Toolbox aligns the screen bellow the Menu Bar item? I looked into Compose Desktop samples but I did not find anything similar...
    👀 1
    k
    s
    • 3
    • 6
  • l

    lhwdev

    02/21/2022, 9:20 AM
    Not sure if only Intelij problem or happening to somebody else, but encountering this when writing this Compose code in MPP jvm source set, IDE shows 'Highlighting is temporary suspended due to internal error.'
    m
    • 2
    • 3
Powered by Linen
Title
l

lhwdev

02/21/2022, 9:20 AM
Not sure if only Intelij problem or happening to somebody else, but encountering this when writing this Compose code in MPP jvm source set, IDE shows 'Highlighting is temporary suspended due to internal error.'
It seems some error came from
getValue
as the stacktrace shows:
Untitled.txt
m

Michael Paus

02/21/2022, 1:37 PM
I’ve seen that quite often recently but I did not investigate it any further because I thought it is just some issue with the EAP pre-release.
l

lhwdev

02/22/2022, 2:52 AM
But happened with • Compose 1.0.0 & 1.0.1 • Kotlin 1.5.31 & 1.6.0 • Intellij IDEA 2021.3.2 • clean installation & new project from template as far as for me.
View count: 5