Skip to content

Commit

Permalink
Add function builder
Browse files Browse the repository at this point in the history
After merging PR #3 , update the README to mention the feature.
  • Loading branch information
mbarnach authored Oct 26, 2020
1 parent a7d3547 commit 9a70684
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,36 @@ webAPI.send(ephemeral: Message(blocks: [],

`SwiftySlack` has been tested on all the Slack blocks templates (see the tests).

## Using the function builder

Thanks to @kaphacius we can now use the function builder to send messages.
It makes Slack messages similar to use SwiftUI :tada:

```swift
let message = Message(to: channel, alternateText: #function) {
SectionBlock(text: MarkdownText("You have a new request:\n*<google.com|Fred Enriquez - Time Off request>*"))
DividerBlock()
SectionBlock(text: MarkdownText("*Type:*\nPaid time off\n*When:*\nAug 10-Aug 13\n*Hours:* 16.0 (2 days)\n*Remaining balance:* 32.0 hours (4 days)\n*Comments:* \"Family in town, going camping!\""),
accessory: ImageElement(image_url: URL(string: "https://api.slack.com/img/blocks/bkb_template_images/approvalsNewDevice.png")!,
alt_text: "computer thumbnail"))
ContextBlock(elements: [
ContextBlock.ContextElement(image: ImageElement(image_url: URL(string: "https://api.slack.com/img/blocks/bkb_template_images/notificationsWarningIcon.png")!,
alt_text: "notifications warning icon")),
ContextBlock.ContextElement(text: MarkdownText("*Conflicts with Team Huddle: 4:15-4:30pm*"))
]
)
ActionsBlock(elements: [
ButtonElement(text: PlainText(text: "Approve", emoji: true),
value: "click_me_123",
style: .primary),
ButtonElement(text: PlainText(text: "Deny", emoji: true),
value: "click_me_123",
style: .danger)
]
)
}
```

## Features:

Currently `SwiftySlack` supports:
Expand All @@ -120,6 +150,7 @@ Currently `SwiftySlack` supports:
* Update messages.
* Schedule messages and delete them.
* Reaction to messages.
* Function builder for ease of writing messages.

## Notes:

Expand Down

0 comments on commit 9a70684

Please sign in to comment.