Open Arkkimaagi opened 10 years ago
@Arkkimaagi, I understand the issue that this PR addresses, but I'm not too jazzed about the actual implementation. Particularly the fact that after a command that's supposedly about "finding", we're not actually giving the user a way to get to the results (i.e. to select the symbols we find). What you've implemented sounds like "symbol summary" to me.
How about re-framing this in terms of "Find next instance of symbol"/"Find previous instance of symbol" that would actually select the next/previous instance, instead of popping up an alert? This way, if your selection doesn't move from the symbol you've currently selected, you can be sure that it's not used elsewhere.
What do you think? Has anyone else dealt with the same problem?
Yes, the approach can be renamed to symbol summary. It would probably be a better name for this.
The current pr was just a quick demonstration of what solved my immediate need. Like I said in PR, it's not pretty and probably the code should be run from a library, so that it's not duplicated.
Selecting the found symbol does not sound perfect tho. Sketch does not seem to scroll the layer list to a proper place and I do not know what we should do in case the symbol is found from multiple pages.
Sketch needs better tools for scripts and definitely better documentation too. If we could do a notification instead of an alert, that would be nicer. Or maybe a status bar message. Or pop up a window with html content and controls that could trigger functions, those would be awesome.
Anyways, I can use my own script for my needs, and if you get inspiration to do something cool that solves the issue, great. Then my PR did it's job. :)
You can close this if you wish, I do not really mind. :)
btw. thanks for the awesome plugin
@Arkkimaagi if you want to show a message in the UI without opening an alert dialog, there's showMessage:
. It displays a subtle message on the top bar, and it fades away after some seconds (or whenever you click the canvas).
Here's a bit of code I'm using on Sketch Generator:
[doc showMessage: "Sketch Generator: " + total_assets + " assets exported in " + ((new Date() - start_time) / 1000) + " seconds"];
It's useful for displaying extra information, but don't count on it to show anything important as it will probably be missed by the user : )
Sometimes I'm not sure if I have used the name of my symbol already. If I use accidentally the same name twice, bad things will happen. Like if I already had a "button" symbol on this document on another page and I just forgot about it, old ones would be replaced.
With this simple approach I can check if there's other symbols with same tag name before syncing.
It's basically a copy of the original "Sync Symbol.sketchplugin" file, but I removed bunch of code and added a simple counter with an alert telling how many symbols are found and on what pages.
It would probably be prettier if we'd combine the common code into a library file and import the library.
(This is a redone pull request as I forgot to branch last time.)