https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
z

zt

10/01/2023, 10:04 PM
I'm struggling with how to divide my business logic and ui code in my desktop app. I'm making a file manager app using compose so theres really only one screen. Voyager has a nice API but im not sure how to effectively use it with just one screen. I might be overthinking how to set it up. Right now i just have global variables as a temporary solution
c

Casey Brooks

10/01/2023, 11:52 PM
Voyager is mostly for navigation, its screen model doesn’t really offer much if you’re not needing the backstack capabilities to tie it to. But if you’ve outgrown the core state management capabilities of Compose, or just want a better way to manage and test that logic, you should consider adopting a proper state management library like Ballast (disclaimer, I’m the author). As a bonus, if you find you like the API and then find you need navigation, Ballast offers that too
z

zt

10/02/2023, 4:11 AM
oh I remember looking at this library. only thing I disliked was the string style navigation but ill try it out
c

Casey Brooks

10/05/2023, 9:39 PM
The internals of the library do require URLs for navigation, but I intentionally designed the API so that you could theoretically use some other mechanism for the API surface that your application code interacts with. I just created a small example showing how you might use data classes, annotations, and KSP to define your routes, which you might be interested in. The KSP processor isn’t actually implemented, but it does show what kind of generated code would be sufficient to abstract away the String-based URL routing API. https://github.com/copper-leaf/ballast/blob/docs/examples/navigationWithCustomRoutes/src/commonMain/kotlin/com/copperleaf/ballast/examples/navigation/AppScreen.kt
3 Views