39 lines
795 B
Go
39 lines
795 B
Go
package events
|
|
|
|
import "fmt"
|
|
|
|
type ButtonPressed struct {
|
|
ID string `json:"id"`
|
|
SwipedID string `json:"swipedId,omitempty"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (e ButtonPressed) EventDescription() string {
|
|
if e.SwipedID != "" {
|
|
return fmt.Sprintf("ButtonPressed(name:%s, swipe:%s->%s)", e.Name, e.SwipedID, e.ID)
|
|
} else {
|
|
return fmt.Sprintf("ButtonPressed(name:%s, id:%s)", e.Name, e.ID)
|
|
}
|
|
}
|
|
|
|
func (e ButtonPressed) TriggerKind() string {
|
|
return "ButtonPressed:" + e.Name
|
|
}
|
|
|
|
func (e ButtonPressed) TriggerValue(key string) (string, bool) {
|
|
switch key {
|
|
case "name":
|
|
return e.Name, true
|
|
case "id":
|
|
return e.ID, true
|
|
case "swipedFromId", "swipedId":
|
|
if e.SwipedID != "" {
|
|
return e.SwipedID, true
|
|
} else {
|
|
return "", false
|
|
}
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|