Skip to content

Instantly share code, notes, and snippets.

@benjohnde
Created September 17, 2018 14:17
Show Gist options
  • Save benjohnde/1787ef1071e672f46244d738060508e7 to your computer and use it in GitHub Desktop.
Save benjohnde/1787ef1071e672f46244d738060508e7 to your computer and use it in GitHub Desktop.
export default function(name, shapes) {
const generatedRects = shapes.map(({
shapeName,
x,
y,
width,
height,
cornerRadius,
border
}) => {
return `
// ${shapeName}
self.addRect(
x: ${x},
y: ${y},
width: ${width},
height: ${height},
cornerRadius: ${cornerRadius},
border: Border(
color: UIColor(
red: ${border.color.red},
green: ${border.color.green},
blue: ${border.color.blue},
alpha: ${border.color.alpha}
),
thickness: 2
)
)
`
}).join('')
return `
// GENERATED BY SKETCH, DO NOT TOUCH THIS
// ${name}.swift
// GENERATED BY SKETCH, DO NOT TOUCH THIS
import Foundation
import UIKit
class ${name}: GenericOverlay {
override func make() {
${generatedRects}
super.make()
}
}
`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment