Skip to content

Instantly share code, notes, and snippets.

@helje5
Created July 17, 2020 15:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save helje5/2f9c33a44f74c43be897c4fe92466823 to your computer and use it in GitHub Desktop.
Demo for SwiftBlocksUI: Clip Slack messages using a Message Action
#!/usr/bin/swift sh
import SwiftBlocksUI // @SwiftBlocksUI ~> 0.8.0
dotenv.config()
struct ClipItForm: Blocks {
@State(\.messageText) var messageText
@State var importance = "medium"
var body: some Blocks {
View("Save it to ClipIt!") {
TextEditor("Message Text", text: $messageText)
Picker("Importance", selection: $importance,
placeholder: "Select importance")
{
"High 💎💎✨".tag("high")
"Medium 💎" .tag("medium")
"Low ⚪️" .tag("low")
}
Submit("CliptIt") {
console.log("Clipping:", self.messageText, self.importance)
}
}
}
}
struct ClipIt: App {
var body: some Endpoints {
Group { // only necessary w/ Swift <5.3
Use(logger("dev"),
bodyParser.urlencoded(),
sslCheck(verifyToken(allowUnsetInDebug: true)))
MessageAction("clipit") {
ClipItForm()
}
}
}
}
try ClipIt.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment