Yelp / salsa

A tool for exporting iOS components into Sketch 📱💎
MIT License
62 stars 7 forks source link

Add the ability to snap instance of view? #4

Open aunnnn opened 6 years ago

aunnnn commented 6 years ago

First of all, thanks for the hard work!

Would like to know your opinion on adding new set of APIs to Salsa for capturing UIView instance conveniently. Seems like the current code forces us to instantiate new UIView instances and return them via static function:

static func artboardElements() -> [[ArtboardElement]] 

One usecase of this is to allow it to snap views during the UI automation. I experimented with it to generate Sketch file as visual documentation of an app (removing filtering/purging to keep exact copy of view hierarchies).

The additional APIs could be something like what I did there: https://github.com/aunnnn/salsa-AutoSketch/blob/master/Salsa/Salsa%2BAutoSketch.swift

mrabiciu commented 6 years ago

Woah I love this!

At some point I had something like:

extension UIWindow {
  func makeArtboard(name: String) -> Artboard {
    return Artboard(name: name, layers: [makeSketchGroup()], frame: group.frame, color: .white)
  }
}

for snapshotting the current window, but wasn't sure if it would be useful to include in the library. What you have looks like a more refined version of that!

I'd love to include this in Salsa! I'd be happy to take a pull request 😄