Skip to content

Commit

Permalink
Merge pull request #8 from p-x9/feature/encode-if-present
Browse files Browse the repository at this point in the history
fix not to export null value
  • Loading branch information
p-x9 authored Dec 23, 2022
2 parents d39d40b + bb120fb commit 8145561
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions Sources/SDCALayer/Model/Layer/JCAGradientLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public class JCAGradientLayer: JCALayer {

var container = encoder.container(keyedBy: CodingKeys.self)

try container.encode(colors, forKey: .colors)
try container.encode(locations, forKey: .locations)
try container.encodeIfPresent(colors, forKey: .colors)
try container.encodeIfPresent(locations, forKey: .locations)

try container.encode(startPoint, forKey: .startPoint)
try container.encode(endPoint, forKey: .endPoint)
try container.encodeIfPresent(startPoint, forKey: .startPoint)
try container.encodeIfPresent(endPoint, forKey: .endPoint)

try container.encode(type, forKey: .type)
try container.encodeIfPresent(type, forKey: .type)
}

public override func applyProperties(to target: CALayer) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SDCALayer/Model/Layer/JCAScrollLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class JCAScrollLayer: JCALayer {

var container = encoder.container(keyedBy: CodingKeys.self)

try container.encode(scrollMode, forKey: .scrollMode)
try container.encodeIfPresent(scrollMode, forKey: .scrollMode)
}

public override func applyProperties(to target: CALayer) {
Expand Down
24 changes: 12 additions & 12 deletions Sources/SDCALayer/Model/Layer/JCAShapeLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,25 @@ public class JCAShapeLayer: JCALayer {

var container = encoder.container(keyedBy: CodingKeys.self)

try container.encode(path, forKey: .path)
try container.encode(fillColor, forKey: .fillColor)
try container.encodeIfPresent(path, forKey: .path)
try container.encodeIfPresent(fillColor, forKey: .fillColor)

try container.encode(fillRule, forKey: .fillRule)
try container.encodeIfPresent(fillRule, forKey: .fillRule)

try container.encode(strokeColor, forKey: .strokeColor)
try container.encodeIfPresent(strokeColor, forKey: .strokeColor)

try container.encode(strokeStart, forKey: .strokeStart)
try container.encode(strokeEnd, forKey: .strokeEnd)
try container.encodeIfPresent(strokeStart, forKey: .strokeStart)
try container.encodeIfPresent(strokeEnd, forKey: .strokeEnd)

try container.encode(lineWidth, forKey: .lineWidth)
try container.encode(miterLimit, forKey: .miterLimit)
try container.encodeIfPresent(lineWidth, forKey: .lineWidth)
try container.encodeIfPresent(miterLimit, forKey: .miterLimit)

try container.encode(lineCap, forKey: .lineCap)
try container.encode(lineJoin, forKey: .lineJoin)
try container.encodeIfPresent(lineCap, forKey: .lineCap)
try container.encodeIfPresent(lineJoin, forKey: .lineJoin)

try container.encode(lineDashPhase, forKey: .lineDashPhase)
try container.encodeIfPresent(lineDashPhase, forKey: .lineDashPhase)

try container.encode(lineDashPattern, forKey: .lineDashPattern)
try container.encodeIfPresent(lineDashPattern, forKey: .lineDashPattern)
}

public override func applyProperties(to target: CALayer) {
Expand Down
16 changes: 8 additions & 8 deletions Sources/SDCALayer/Model/Layer/JCATextLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@ public class JCATextLayer: JCALayer {

var container = encoder.container(keyedBy: CodingKeys.self)

try container.encode(string, forKey: .string)
try container.encodeIfPresent(string, forKey: .string)

try container.encode(font, forKey: .font)
try container.encode(fontSize, forKey: .fontSize)
try container.encodeIfPresent(font, forKey: .font)
try container.encodeIfPresent(fontSize, forKey: .fontSize)

try container.encode(foregroundColor, forKey: .foregroundColor)
try container.encodeIfPresent(foregroundColor, forKey: .foregroundColor)

try container.encode(isWrapped, forKey: .isWrapped)
try container.encodeIfPresent(isWrapped, forKey: .isWrapped)

try container.encode(truncationMode, forKey: .truncationMode)
try container.encodeIfPresent(truncationMode, forKey: .truncationMode)

try container.encode(alignmentMode, forKey: .alignmentMode)
try container.encodeIfPresent(alignmentMode, forKey: .alignmentMode)

try container.encode(allowsFontSubpixelQuantization, forKey: .allowsFontSubpixelQuantization)
try container.encodeIfPresent(allowsFontSubpixelQuantization, forKey: .allowsFontSubpixelQuantization)
}

public override func applyProperties(to target: CALayer) {
Expand Down

0 comments on commit 8145561

Please sign in to comment.