Logo

How to navigate using Jetpack Compose Navigation with examples

Published on June 18, 2023

What is Jetpack Compose Desktop

According to Jetbrains, Jetpack Compose Desktop promises fast reactive desktop UI development using Kotlin on desktop applications.

Jetpack Compose Desktop generates a JVM app and its UI is powered by everyone's favorite Jetpack Compose. This has both benefits and disadvantages compared to building native apps which we will cover next.

What kind of applications can you build using Jetpack Compose Desktop

The great thing about Jetpack Compose Desktop is the ability to write code once and create apps for different platforms. This includes MacOS, Windows and Linux desktops.

Jetpack Compose Desktop shines when it comes to applications that do not integrate with the system. As a matter of fact the development experience is great as you use a modern UI framework to build your UI and creating windows is pretty straightforward.

Jetpack Compose Desktop and system integration: Not great

Keep in mind that you are not going to get the full native experience using Jetpack Compose Desktop. Any sort of system integration does not work as you might expect. There is the Tray composable which is used to create native looking Tray menus. To my experience it works somewhat alright for MacOS, but it looks really dated on Windows platforms. I have not tried it out on Linux. The customizations are too limiting. You can only set text items without any icons.

Overall, any integration with the system is extremely limiting. Jetpack Compose Desktop does not support rich notifications. You can display notifications but you cannot dismiss them programmatically. You cannot set actions to the notifications or customize their icon or sounds. The alternative solution to this is implementing your own Notification system.

This limitation also comes to other system functionality such as sharing content to your Jetpack Compose app by right clicking desktop files, Share to... actions which are typical to Desktop applications.

Using Native APIs is not supported

Using Native APIs seems really hard to do. It is in theory possible to use native APIs via a Java Bridge but the documentation and material to do this online seems limited and dated. Even if you are able to use the Java Bridge you should be able to understand each different platform's APIs and language to do the wiring.

As a solo developer building my own products, this was incredibly limiting. I could push towards trying to figure out how to create a bridge between Compose Desktop and Native but the effort put into this does not justify the return. In my case I would rather focus on improving my product instead of fighting the technology I have to work with.

Packaging tools are not there yet

Jetpack Compose Desktop comes with a gradle plugin which is used to package your app for different operating systems. Right now the plugin requires you to build the app from each operating system on that respective operating system (ie you need to be building on Windows to create a Windows executable).

The customization options of the plugin seem great at first but in reality they are lacking. For MacOS builds, the plugin provides a way to notarize your app, which is a process required by Apple to distribute MacOS applications. However, you can only notarize pkg or dmg files using the plugin. That might have been alright (I would love to see a zip version instead) if you could choose the icon for the dmg files. Right now any dmg files created using the Jetpack Compose Desktop will have Java's Duke as the icon:

Becompose

Professionally crafted Jetpack Compose UI components & resources.

Job Board
  • Browse Jobs
  • Post Android Job

Let's explore together

Perfect for those using Android Views and want to move to Jetpack Compose.

Social Media

Logo
Logo
Logo

Becompose - ©2024