Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 89027fd

Browse files
author
Amir Khorsandi
committed
Improve code generation
1 parent 0f7af31 commit 89027fd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Samples/PagingLayoutSamples/Modules/LayoutDesigner/OptionsCodeGenerator.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ private extension SnapshotTransformViewOptions.PiecesValue {
188188

189189
private extension UIColor {
190190
func generateInitCode() -> String {
191+
if self == .black {
192+
return ".black"
193+
}
194+
if self == .white {
195+
return ".white"
196+
}
191197
var red: CGFloat = 0
192198
var green: CGFloat = 0
193199
var blue: CGFloat = 0
@@ -230,14 +236,16 @@ private extension ScaleTransformViewOptions.Rotation3dOptions {
230236

231237
private extension CGSize {
232238
func generateInitCode() -> String {
233-
".init(width: \(width.format()), height: \(height.format()))"
239+
if self == .zero { return ".zero" }
240+
return ".init(width: \(width.format()), height: \(height.format()))"
234241
}
235242
}
236243

237244

238245
private extension CGPoint {
239246
func generateInitCode() -> String {
240-
".init(x: \(x.format()), y: \(y.format()))"
247+
if self == .zero { return ".zero" }
248+
return ".init(x: \(x.format()), y: \(y.format()))"
241249
}
242250
}
243251

0 commit comments

Comments
 (0)