אליהו הדס
10/27/2024, 12:52 AMNotification(
title = "Hello Kotlin!",
message = "This is a cross-platform notification :rocket:",
largeImage = Res.getUri("drawable/notification_image.png"),
onActivated = { Log.d("NotificationLog", "Notification activated!") },
onDismissed = { reason -> Log.d("NotificationLog", "Notification dismissed: $reason") }
) {
Button("Click Me!") {
Log.d("NotificationLog", "Callback received with zero boilerplate!")
}
}
Get started with Compose Native Notification today and bring smooth, interactive notifications to your multiplatform projects: https://github.com/kdroidFilter/ComposeNativeNotification 🚀
We can’t wait for your feedback! ✨Alex Styl
10/27/2024, 8:42 AMNotification()
was a composable, but it's not. very odd choice to see composable looking code on a click listener, especially because i cannot really do much with it (ie set custom text or use my own composable in it)אליהו הדס
10/27/2024, 8:45 AMאליהו הדס
10/27/2024, 8:48 AMאליהו הדס
10/27/2024, 8:49 AMAlex Styl
10/27/2024, 2:17 PMNo it's not a composable since it's a native elementcomposables are about kotlin code, not the underlying tech they use to render ui. glance for example is still composables but internally does the rending using android remoteviews which are 'antive elements'.
what could you do in a notification?it not about what to do with a notification, but what can i do with composables. if it looks like a composable, i expect it to work as a composable (such as using my own components, such as Text(), animate colors as states etc)
אליהו הדס
10/27/2024, 2:26 PMTray(
iconPath = iconPath,
windowsIconPath = windowsIconPath,
tooltip = "My Application",
primaryAction = {
Log.i(logTag, "Primary action triggered")
},
primaryActionLinuxLabel = "Open Application"
) {
SubMenu(label = "Options") {
Item(label = "Setting 1") {
Log.i(logTag, "Setting 1 selected")
}
SubMenu(label = "Advanced Sub-options") {
Item(label = "Advanced Option 1") {
Log.i(logTag, "Advanced Option 1 selected")
}
Item(label = "Advanced Option 2") {
Log.i(logTag, "Advanced Option 2 selected")
}
}
}
Item(label = "Exit", isEnabled = true) {
Log.i(logTag, "Exiting the application")
dispose()
exitProcess(0)
}
Item(label = "Version 1.0.0", isEnabled = false)
}
and otherwise what do you suggest? to rename the function to sendNotification() for example?Alex Styl
10/27/2024, 2:30 PMאליהו הדס
10/27/2024, 2:30 PMAlex Styl
10/27/2024, 2:31 PMאליהו הדס
10/27/2024, 2:31 PMAlex Styl
10/27/2024, 2:32 PMאליהו הדס
10/27/2024, 2:33 PMAlex Styl
10/27/2024, 2:35 PMAlex Styl
10/27/2024, 2:36 PMאליהו הדס
10/27/2024, 3:31 PMthe important bit here is that is a library for compose. i know how it works (ie composition) how to show/hide stuff.for my tray system, I planned that we could recompose it as we are used to, it will arrive soon. on the other hand for notifications, at the beginning I had called it Knotify, but as I had to integrate the shared resources of compose to create a unified api with android, I renamed it to compose native notification, but it is true that it was perhaps a mistake. Thank you very much in any case, but what would you advise me concretely?
אליהו הדס
10/27/2024, 3:35 PMAlex Styl
10/27/2024, 3:39 PMwhat would you advise me concretelyadvise about what exactly?
אליהו הדס
10/27/2024, 3:40 PMAlex Styl
10/27/2024, 3:44 PMAdam Brown
10/28/2024, 8:15 AMSkaldebane
10/30/2024, 3:19 PM@Composable
functions (whether they emit UI or not doesn't matter).
The stuff JetBrains did for the system tray on desktop were actual @Composable
functions! Ones that responded to state changes, disappeared when the functions left the composition, etc...
Your library functions aren't, but they follow the Compose naming conventions, and are imperative (not declarative) in nature. The DSL is awesome, just make e.g. function names camelCase
instead of PascalCase
, and clearly name imperative functions as such (e,g, button
is a declarative function, it just declares that we want a button, but notification
is imperative, it immediately runs side effects to show the notification).
You could for example have a notification
/ createNotification
function that simply returns a Notification
class, but isn't sent immediately, until we call some sort of send()
function. That would also make hiding notifications very easy, take the same object and call hide()
.
For the one you currently have, rename it to sendNotification
(that takes a lambda as usual), which will send the notification immediately.
Here's how this would look like:אליהו הדס
10/30/2024, 3:25 PM