Skip to content
This repository has been archived by the owner on Jul 4, 2020. It is now read-only.

Actions for the "Tweet Current Song" shortcut #20

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alexito4
Copy link
Contributor

@alexito4 alexito4 commented Jan 5, 2019

Branches from #19

To get familiar with the library I tried to replicate the "Tweet Current Song" shortcut:

To acomplish this I had to:

  • Added an Xcode playground to develop on the Mac.
  • case .string in Aggrandizements to get title, artist, etc from a song.
  • tweet action
  • getCurrentSong action
  • getText action

With this I was able to replicate the shortcut with the following code:

    + getCurrentSong().savingOutput(to: song)
    + getText("Listening to \(title) by \(artist) using Swift!").savingOutput(to: tweetText)
    + list(["\(tweetText)", "\(albumArtwork)"])
    + tweet()

The plist is the same as the one created by the App except the content of the list action.

screen shot 2019-01-05 at 11 43 44

The implementation of the list action assumes [String] but seems like the app supports different types. It works with this example but we may want to look into it to make other uses posible.

@@ -1,6 +1,6 @@
import Foundation

public func withInterpolatedText(_ string: String) -> Any {
func withInterpolatedText(_ string: String) -> Any {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this public for a bit to facilitate the creation of Actions in the playground itself, which is easier than doing it in the framework files.

@@ -39,12 +39,16 @@ public func exportShortcut(_ actionContainer: ActionContainer) -> Data {
return try! PropertyListSerialization.data(fromPropertyList: buildShortcut(actionContainer), format: .binary, options: 0)
}

public func exportShortcut(_ shortcut: PropertyList) -> Data {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it easier to save the shortcut on the mac and send it to the phone for testing.

}
save(ext: "shortcut")
// TESTING
save(ext: "plist")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to save a plist version of the shortcut to be able to open it and compare it with the original.

@a2
Copy link
Owner

a2 commented Jan 9, 2019

This looks great! A couple of notes:

  1. Let's rebase your changes off of master
  2. Do we want to keep ShortcutsSwiftXcode.playground or should we move that into the Playground Book itself?

@alexito4
Copy link
Contributor Author

The changes have been rebased 🎉

In terms of the playgrounds, that's up to you. I personally like to have the Xcode playground to work from the Mac, specially since currently I don't have my iPad with me. The actions should already be available on the Playground Book (but I haven't been able to try that). I can move it an give it a try when I have the iPad 👍

But are you happy keeping the Xcode playground to facilitate development of actions from the Mac?

And what's the vision with the book? You want to keep adding pages demonstrating new actions?

Cheers 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants