Exploring the use of compose desktop for a project...
# compose-desktop
j
Exploring the use of compose desktop for a project I'm working on. Would like it to be a menu bar app on macos and a system tray app in Windows. Are there any examples / tutorials available? Thanks
1
c
The jetbrains toolbox app is an example, but I don't think the source is public.
j
Ah. Wonder if they'd consider doing an example?
a
Just create Tray object without Window
Copy code
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.window.Notification
import androidx.compose.ui.window.Tray
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberTrayState

@OptIn(ExperimentalComposeUiApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class)
fun main() = application() {
    val trayState = rememberTrayState()
    Tray(
        state = trayState,
        icon = TrayIcon,
        menu = {
            Item(
                "Exit",
                onClick = {
                    exitApplication()
                }
            )
        }
    )
}

object TrayIcon : Painter() {
    override val intrinsicSize = Size(256f, 256f)

    override fun DrawScope.onDraw() {
        drawOval(Color(0xFFFFA500))
    }
}
Added it to Tray tutorial
🎉 2
e
@Alexander Kurasov[JB] where?
a
e
thanks
you may want to start each tutorial with a letter, so they get ordered properly.. ie
A_Getting_Started
a
Thank you for feedback! Actually we are going to rework the tutorial structure to make it more usable.
e
would the Edu plugin be useful in this case? Note: I don't know it yet
a
Not sure, maybe will try it
e
btw, on Ubuntu I get this weird chars for
\t
a
could you report it to github, please?
e
sure
🙏 1
it's there
a
I see. Most probably it won’t be fixed before next release. I’ll check if there is the same issue on Mac
On Mac it is fine. BTW, have you checked it on any of recent builds? There were some fixes related to text
e
Copy code
id("org.jetbrains.compose") version "1.0.0-beta6-dev462"
g
I have a project which is a menu bar app, if someone needs a reference -> https://github.com/Giuliopime/ZenBreak
j
@Giuliopime ZenBreak is really nice. I'm a long time BreakTimer user but it carries Electron's trademark lagginess. ZenBreak is so fast! Thanks for building it 😄
g
Hey appreciate it! It's unfortunate that Jetbrains seemed to not care about it at all for the student contest :/