- Notifications
You must be signed in to change notification settings - Fork4
A Snackbar for macOS applications
License
NotificationsYou must be signed in to change notification settings
iSapozhnik/Snackbar
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A lightweight and customizable Snackbar component for Cocoa, designed to display brief informative messages to users.
- Display short messages or notifications to users
- Customizable appearance, including background color, text color, and animation duration
- Support for action buttons and callback handlers
- Easy integration into existing Cocoa projects
Swift PAckage manager is your friend.
Make a theme
extensionSnackbarThemewhere Self==DefaultSnackbarTheme{staticvarinfo:SnackbarTheme{DefaultSnackbarTheme(withStyle:.info)}staticvaralert:SnackbarTheme{DefaultSnackbarTheme(withStyle:.alert)}staticvarwarning:SnackbarTheme{DefaultSnackbarTheme(withStyle:.warning)}staticvarsuccess:SnackbarTheme{DefaultSnackbarTheme(withStyle:.success)}}structDefaultSnackbarTheme:SnackbarTheme{varstyle:SnackbarStyleinit(withStyle style:SnackbarStyle){self.style= style}vartextColor:NSColor{.labelColor}varbackgroundColor:NSColor{switch style{case.alert:return.systemRedcase.success:return.systemGreencase.warning:return.systemOrangecase.info:return.systemBlue}}varborderColor:NSColor{.secondaryLabelColor}}
Snackbar with action buttons and icon.
lettheme:SnackbarTheme=.alertletactions=[SnackbarAction( title:NSLocalizedString("Remove", comment:""), icon:nil, type:.primary, action:{}),SnackbarAction( title:NSLocalizedString("Later", comment:""), icon:nil, type:.secondary, action:{}),]Snackbar.show( theme: theme, type:.permanent, title:NSLocalizedString("Are you sure you want to remove all spaces?", comment:"").text, subtitle:NSLocalizedString("You can not undo this action", comment:"").text, actions: actions, actionsLayout:.horizontal, hasActionsSeparator:false, icon:NSImage(named:"your_icon"), fromWindow: view.window)
This project is licensed under the MIT License. See theLICENSE file for details.
Contributions are welcome! Please refer to theContribution Guidelines for more details.
If you like Snackbar, consider also to check the app (Lasso - Window Manager for macOS) where I'm using it'.