-
Notifications
You must be signed in to change notification settings - Fork 8
/
toast.go
41 lines (34 loc) · 790 Bytes
/
toast.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package toast
type Audio string
type NotificationOption func(*notification)
// WithTitle
//
// The main title/heading for the notification.
func WithTitle(title string) NotificationOption {
return func(n *notification) {
n.Title = title
}
}
// WithMessage
//
// The single/multi line message to display for the notification.
func WithMessage(msg string) NotificationOption {
return func(n *notification) {
n.Message = msg
}
}
// WithAudio
//
// The audio to play when displaying the notification
func WithAudio(audio Audio) NotificationOption {
return func(n *notification) {
n.Audio = audio
}
}
type notifier interface {
push() error
}
func Push(message string, opts ...NotificationOption) error {
var n notifier = newNotification(message, opts...)
return n.push()
}