Skip to content

Conversation

@pathartl
Copy link

Photino's ability to create notifications is extremely basic and only allows setting the title and message. This PR aims to add support for more complex Windows notifications.

Breaking changes:

  • Photino::ShowNotification has been removed
  • WinToastLib has been updated to v1.3.2

Implementation:
PhotinoWindow has a new method called CreateNotification that is used to build a notification. The notification can then be shown by calling Show(). Action buttons can also be added to the notification with a callback.

Example:

window
    .CreateNotification(PhotinoNotificationType.ToastImageAndText04)
    .AddText("Photino.Native")
    .AddText("This is the first line of a test notification")
    .AddText("This is the second line of a test notification")
    .AddText("via Photino") // On Windows, the fourth line of text gets set to the attribution text
    .SetImagePath("testImage.jpg")
    .AddAction("Show" (notification) =>
    {
        Log("Show button clicked!");
    })
    .AddAction("Hide")
    .Show();

On the C++ side, in keeping with the intention of Photino being cross platform a layer of abstraction on top of WinToastLib has been created. Photino now has its own PhotinoNotification type. This should allow notifications for Linux and macOS to be added later on. I tried to keep the implementation as platform agnostic as possible, so some changes may need to be made to the enum namings, but names are currently heavily borrowed from Windows/WinToastLib.

Main definition of the Notification type. Each notification can have callbacks registered to it, so that activation/dismissal isn't handled globally. This will allow for more complex handling of notifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant