Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Snackbar for macOS applications

License

NotificationsYou must be signed in to change notification settings

iSapozhnik/Snackbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License

A lightweight and customizable Snackbar component for Cocoa, designed to display brief informative messages to users.

Demo

Features

  • 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

Installation

Cocoapods

Swift PAckage manager is your friend.

Usage

Initialization

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}}

Displaying a Snackbar

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)

License

This project is licensed under the MIT License. See theLICENSE file for details.

Contributing

Contributions are welcome! Please refer to theContribution Guidelines for more details.

Support

If you like Snackbar, consider also to check the app (Lasso - Window Manager for macOS) where I'm using it'.


[8]ページ先頭

©2009-2025 Movatter.jp