Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about unzipping the sketch file and generating code based the json files? #36

Open
Creemli opened this issue Jun 12, 2018 · 3 comments

Comments

@Creemli
Copy link

Creemli commented Jun 12, 2018

I noticed that u have been generated code with svg files which are exported by sketch. As we all know, there are some compatibility between svg and sketch file.

After I find the news about sketch 43: https://sketchplugins.com/d/87-new-file-format-in-sketch-43, maybe using the sketch source file is better, how do you think?

@chrisachard
Copy link
Collaborator

@Creemli Yep! That's something we're looking into. I'm also looking at creating a Sketch plugin, which would let you do it right from the app itself

@Creemli
Copy link
Author

Creemli commented Jun 20, 2018

@chrisachard I am also working on this, and has created RN code with formatted sketch file which has many many limits such as naming in one style, grouping with right orders, and so on.
The biggest problem I met is about how to translate the absolute position layout into flex layout, do you have some suggestions? Thank you very much~~

@chrisachard
Copy link
Collaborator

@Creemli That sounds awesome! If you plan to open source it, I'd love to see it when it's ready.

Yes, converting from absolute to flex box was a big tricky part. Check out https://github.com/nanohop/sketch-to-react-native/blob/master/src/flex.js for how I did it (start at the "flexBox" function) - but here's the basic algorithm:

  1. Get all the component's x, y, width and height
  2. Put them into a tree based on what is nested inside of what - so try to develop a "parent/child" tree of components
  3. Iterate over that tree, and make wrapping Views where neccessary to put things into flex columns, and then flex rows
  4. Do that recursively until you are done with the tree

I hope that helps some - feel free to reach out with any other questions!

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

No branches or pull requests

2 participants