Skip to content

Commit

Permalink
Merge pull request #16 from p-x9/feature/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
p-x9 authored Apr 4, 2024
2 parents 02101a3 + 8c8d493 commit c56a0ee
Show file tree
Hide file tree
Showing 28 changed files with 493 additions and 426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/p-x9/IndirectlyCodable.git",
"state" : {
"revision" : "81bfc339dde53a3739f82517dbef0e4cac1d9cc3",
"version" : "0.0.1"
"revision" : "548af634dc3277a5448ea9801b206c0037185f1e",
"version" : "0.1.0"
}
},
{
"identity" : "keypathvalue",
"kind" : "remoteSourceControl",
"location" : "https://github.com/p-x9/KeyPathValue.git",
"state" : {
"revision" : "6aeb41d6c5564ae1f18e8b7a4bc5733d739558e3",
"version" : "0.0.1"
"revision" : "8938b8f8d74a70c6b2d6a94b02e7d5753eb001db",
"version" : "0.1.0"
}
},
{
Expand Down
4 changes: 0 additions & 4 deletions Example/calayer-ws/calayer-ws/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
Expand All @@ -32,6 +30,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

3 changes: 0 additions & 3 deletions Example/calayer-ws/calayer-ws/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?


func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
Expand Down Expand Up @@ -48,6 +47,4 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// to restore the scene back to its current state.
}


}

8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/p-x9/IndirectlyCodable.git",
"state" : {
"revision" : "81bfc339dde53a3739f82517dbef0e4cac1d9cc3",
"version" : "0.0.1"
"revision" : "548af634dc3277a5448ea9801b206c0037185f1e",
"version" : "0.1.0"
}
},
{
"identity" : "keypathvalue",
"kind" : "remoteSourceControl",
"location" : "https://github.com/p-x9/KeyPathValue.git",
"state" : {
"revision" : "6aeb41d6c5564ae1f18e8b7a4bc5733d739558e3",
"version" : "0.0.1"
"revision" : "8938b8f8d74a70c6b2d6a94b02e7d5753eb001db",
"version" : "0.1.0"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ let package = Package(
.library(
name: "SDCALayer",
targets: ["SDCALayer"]
),
)
],
dependencies: [
.package(url: "https://github.com/p-x9/IndirectlyCodable.git", .upToNextMinor(from: "0.0.1")),
.package(url: "https://github.com/p-x9/KeyPathValue.git", .upToNextMinor(from: "0.0.1")),
.package(url: "https://github.com/p-x9/IndirectlyCodable.git", from: "0.1.0"),
.package(url: "https://github.com/p-x9/KeyPathValue.git", from: "0.1.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1")
],
targets: [
Expand All @@ -31,6 +31,6 @@ let package = Package(
.testTarget(
name: "SDCALayerTests",
dependencies: ["SDCALayer"]
),
)
]
)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class JAALayer: JCALayer {

// apply properties to model from target
// targe -> model
public override func reverseApplyProperties(with target: CALayer) {
super.reverseApplyProperties(with: target)
public override func applyProperties(with target: CALayer) {
super.applyProperties(with: target)

guard let target = target as? AALayer else { return }

Expand Down
5 changes: 4 additions & 1 deletion Sources/SDCALayer/Extension/CATransform3D+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import QuartzCore

extension CATransform3D: Codable {
private enum CodingKeys: String, CodingKey {
case m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
case m11, m12, m13, m14
case m21, m22, m23, m24
case m31, m32, m33, m34
case m41, m42, m43, m44
}

public func encode(to encoder: Encoder) throws {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SDCALayer/Extension/Codable+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension Encodable {
return encoder
}

var jsonString: String? {
var jsonString: String? {
guard let data = try? Self.jsonEncoder.encode(self) else {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
import QuartzCore

extension CAGradientLayer {
public typealias Target = JCAGradientLayer
public typealias Model = JCAGradientLayer

open override class var codableTypeName: String {
String(reflecting: Target.self)
String(reflecting: Model.self)
}
}

extension CAGradientLayerType: IndirectlyCodable {
public typealias Target = JCAGradientLayerType

public func codable() -> JCAGradientLayerType? {
.init(with: self)
}
extension CAGradientLayerType: RawIndirectlyCodable {
public typealias Model = JCAGradientLayerType
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import QuartzCore

extension CALayer: IndirectlyCodable {
public typealias Target = JCALayer
public typealias Model = JCALayer

public func codable() -> JCALayer? {
guard let layerClass = NSClassFromString(Self.codableTypeName) as? JCALayer.Type else {
Expand All @@ -21,22 +21,31 @@ extension CALayer: IndirectlyCodable {

@objc
open class var codableTypeName: String {
String(reflecting: Target.self)
String(reflecting: Model.self)
}
}

extension CALayerCornerCurve: IndirectlyCodable {
public typealias Target = JCALayerCornerCurve
extension CALayerCornerCurve: RawIndirectlyCodable {
public typealias Model = JCALayerCornerCurve
}

public func codable() -> JCALayerCornerCurve? {
.init(with: self)
}
extension CACornerMask: RawIndirectlyCodable {
public typealias Model = JCACornerMask
}

extension CACornerMask: IndirectlyCodable {
public typealias Target = JCACornerMask
extension CALayerContentsGravity: RawIndirectlyCodable {
public typealias Model = JCALayerContentsGravity
}

public func codable() -> JCACornerMask? {
.init(with: self)
}
extension CALayerContentsFormat: RawIndirectlyCodable {
public typealias Model = JCALayerContentsFormat
}

extension CALayerContentsFilter: RawIndirectlyCodable {
public typealias Model = JCALayerContentsFilter
}

extension CAEdgeAntialiasingMask: RawIndirectlyCodable {
public typealias Model = JCAEdgeAntialiasingMask
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@
import QuartzCore

extension CAScrollLayer {
public typealias Target = JCAScrollLayer
public typealias Model = JCAScrollLayer

open override class var codableTypeName: String {
String(reflecting: Target.self)
String(reflecting: Model.self)
}
}

extension CAScrollLayerScrollMode: IndirectlyCodable {
public typealias Target = JCAScrollLayerScrollMode

public func codable() -> JCAScrollLayerScrollMode? {
.init(with: self)
}
extension CAScrollLayerScrollMode: RawIndirectlyCodable {
public typealias Model = JCAScrollLayerScrollMode
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,21 @@
import QuartzCore

extension CAShapeLayer {
public typealias Target = JCAShapeLayer
public typealias Model = JCAShapeLayer

open override class var codableTypeName: String {
String(reflecting: Target.self)
String(reflecting: Model.self)
}
}

extension CAShapeLayerFillRule: IndirectlyCodable {
public typealias Target = JCAShapeLayerFillRule

public func codable() -> JCAShapeLayerFillRule? {
.init(with: self)
}
extension CAShapeLayerFillRule: RawIndirectlyCodable {
public typealias Model = JCAShapeLayerFillRule
}

extension CAShapeLayerLineCap: IndirectlyCodable {
public typealias Target = JCAShapeLayerLineCap

public func codable() -> JCAShapeLayerLineCap? {
.init(with: self)
}
extension CAShapeLayerLineCap: RawIndirectlyCodable {
public typealias Model = JCAShapeLayerLineCap
}

extension CAShapeLayerLineJoin: IndirectlyCodable {
public typealias Target = JCAShapeLayerLineJoin

public func codable() -> JCAShapeLayerLineJoin? {
.init(with: self)
}
extension CAShapeLayerLineJoin: RawIndirectlyCodable {
public typealias Model = JCAShapeLayerLineJoin
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,17 @@
import QuartzCore

extension CATextLayer {
public typealias Target = JCATextLayer
public typealias Model = JCATextLayer

open override class var codableTypeName: String {
String(reflecting: Target.self)
String(reflecting: Model.self)
}
}

extension CATextLayerTruncationMode: IndirectlyCodable {
public typealias Target = JCATextLayerTruncationMode

public func codable() -> JCATextLayerTruncationMode? {
.init(with: self)
}
extension CATextLayerTruncationMode: RawIndirectlyCodable {
public typealias Model = JCATextLayerTruncationMode
}

extension CATextLayerAlignmentMode: IndirectlyCodable {
public typealias Target = JCATextLayerAlignmentMode

public func codable() -> JCATextLayerAlignmentMode? {
.init(with: self)
}
extension CATextLayerAlignmentMode: RawIndirectlyCodable {
public typealias Model = JCATextLayerAlignmentMode
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import QuartzCore

extension CGColor: IndirectlyCodable {
public typealias Target = JCGColor
public typealias Model = JCGColor

public func applyProperties(to target: JCGColor) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import QuartzCore

extension CGPath: IndirectlyCodable {
public typealias Target = JCGPath
public typealias Model = JCGPath

public func codable() -> JCGPath? {
.init(with: self)
Expand Down
38 changes: 0 additions & 38 deletions Sources/SDCALayer/Extension/NSUIColor+.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/SDCALayer/Model/JCGColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import QuartzCore

public class JCGColor: ObjectConvertiblyCodable {
public class JCGColor: IndirectlyCodableModel {
public typealias Target = CGColor

public let code: String?
Expand Down
5 changes: 2 additions & 3 deletions Sources/SDCALayer/Model/JCGPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import CoreGraphics

public class JCGPath: ObjectConvertiblyCodable {
public class JCGPath: IndirectlyCodableModel {
public typealias Target = CGPath

public var pathElements: [JCGPathElement]?
Expand All @@ -29,7 +29,7 @@ public class JCGPath: ObjectConvertiblyCodable {
.filter {
let isValid = $0.elementType != nil && $0.elementType!.numberOfPoints <= $0.points.count
if !isValid {
print("⚠️[warning] SDCALayer invalid path element")
print("⚠️ [SDCALayer] invalid path element")
}
return isValid
}
Expand Down Expand Up @@ -57,7 +57,6 @@ public class JCGPath: ObjectConvertiblyCodable {
}
}


public struct JCGPathElement: Codable {
public var type: String
public var points: [CGPoint]
Expand Down
Loading

0 comments on commit c56a0ee

Please sign in to comment.