Created
July 17, 2020 15:55
-
-
Save helje5/2f9c33a44f74c43be897c4fe92466823 to your computer and use it in GitHub Desktop.
Demo for SwiftBlocksUI: Clip Slack messages using a Message Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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