Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Novichkov committed Apr 16, 2018
2 parents 59d6b24 + cd01372 commit 00bd738
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
Binary file not shown.
Binary file removed .github/LinearGradientPlayground.zip
Binary file not shown.
Binary file removed .github/screenshot.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zepcode",
"version": "0.5.4",
"version": "0.5.5",
"description": "Generates Swift snippets from colors, fonts and layers.",
"lint-staged": {
"src/**/*.{js,json}": [
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ function layer(context, layerParams) {

if (layerParams.opacity !== 1) {
const opacity = Math.round(layerParams.opacity * 100) / 100;
string += `view.alpha = ${opacity}\n`;
string += `view.alpha = ${opacity}`;
}

if (layerParams.borders.length) {
const border = layerParams.borders[0];
const { color } = border.fill;
string += `view.layer.borderWidth = ${border.thickness.toString()}\n`;
string += `\nview.layer.borderWidth = ${border.thickness.toString()}`;

if (color !== undefined) {
const borderColorString = zepcodeInstance.cgColorString(
border.fill.color
);
string += `view.layer.borderColor = ${borderColorString}\n`;
string += `\nview.layer.borderColor = ${borderColorString}`;
}
}

if (layerParams.borderRadius > 0) {
string += `view.layer.cornerRadius = ${layerParams.borderRadius}`;
string += `\nview.layer.cornerRadius = ${layerParams.borderRadius}`;
}

if (layerParams.shadows.length) {
const shadow = layerParams.shadows[0];
string += zepcodeInstance.shadow(shadow);
string += `\n${zepcodeInstance.shadow(shadow)}`;
}

let result = {};
Expand Down
8 changes: 4 additions & 4 deletions src/templates/color-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const colorExtensionTemplate = (colors, needHeader, extensionOptions) =>`import
extension UIColor {
${
extensionOptions.useCustomColorInitializer
? `\n convenience init(r red: Int, g green: Int, b blue: Int, a: CGFloat = 1) { // swiftlint:disable:this identifier_name
self.init(red: CGFloat(red) / 255,
green: CGFloat(green) / 255,
blue: CGFloat(blue) / 255,
? `\n convenience init(r: Int, g: Int, b: Int, a: CGFloat = 1) { // swiftlint:disable:this identifier_name
self.init(red: CGFloat(r) / 255,
green: CGFloat(g) / 255,
blue: CGFloat(b) / 255,
alpha: a)
}\n`
: ``}
Expand Down
19 changes: 9 additions & 10 deletions src/templates/linear-gradient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,24 @@ final class LinearGradientLayer: CALayer {
final class GradientView: UIView {
lazy var gradientLayer: LinearGradientLayer = {
let gradientLayer = LinearGradientLayer()
gradientLayer.colors = [${colorStopsString}]
return gradientLayer
}()
lazy var gradientLayer = layer as! LinearGradientLayer
override class var layerClass: AnyClass {
return LinearGradientLayer.self
}
override init(frame: CGRect) {
super.init(frame: frame)
layer.insertSublayer(gradientLayer, at: 0)
configure()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
layer.insertSublayer(gradientLayer, at: 0)
configure()
}
override func layoutSubviews() {
super.layoutSubviews()
gradientLayer.frame = bounds
func configure() {
gradientLayer.colors = [${colorStopsString}]
}
}`;

Expand Down

0 comments on commit 00bd738

Please sign in to comment.