This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open class WobbleAnimator: Animator { | |
public var sensitivity: CGPoint = CGPoint(x: 1, y: 1) | |
func scrollVelocity(collectionView: CollectionView) -> CGPoint { | |
guard collectionView.hasReloaded else { | |
return .zero | |
} | |
let velocity = collectionView.bounds.origin - collectionView.lastLoadBounds.origin | |
if collectionView.isReloading { | |
return velocity - collectionView.contentOffsetChange |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftyJSON | |
struct Place: JSONAutoRepresentable{ | |
var id: String? | |
var name: String? | |
var position: String? | |
// sourcery:inline:auto:Place.JSONAutoRepresentable | |
init(_ json: JSON) { | |
id = json["id"].string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Transaction: JSONAutoRepresentable { | |
var amount: String? | |
var balance: String? //balance after transaction | |
var createdAt: String? | |
//sourcery: skip | |
var place: Places? // where the transaction was made | |
//sourcery: jsonKey = "partner" | |
var partnerName: String? | |
// sourcery:inline:auto:Transaction.JSONAutoRepresentable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for type in types.based.JSONAutoRepresentable| %} | |
// sourcery:inline:auto:{{ type.name }}.JSONAutoRepresentable | |
init(_ json: JSON) { | |
{% for variable in type.storedVariables where variable|!annotated:"skip" %} | |
{% elif variable.type.based.JSONAutoRepresentable %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(json["{{ variable.name|camelToSnakeCase }}"]) | |
{% elif variable.isArray %} | |
{{ variable.name }} = json["{{ variable.name|camelToSnakeCase }}"].arrayValue.map({{ variable.typeName.array.elementTypeName.unwrappedTypeName }}.init) | |
{% elif variable.type.kind == "enum" %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(rawValue: json["{{ variable.name|camelToSnakeCase }}"].stringValue) ?? {{ variable.defaultValue }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% else %} | |
{{ variable.name }} = json["{{ variable.name|camelToSnakeCase }}"].{{ variable.unwrappedTypeName|lowerFirstLetter }}{% ifnot variable.isOptional %}Value{% endif %} | |
{% endif %} | |
{% endfor %} | |
} | |
// sourcery:end | |
{% endfor %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for variable in type.storedVariables where variable|!annotated:"skip" %} | |
.... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if variable.annotations.jsonKey %} | |
{{ variable.name }} = json["{{ variable.annotations.jsonKey}}"].{{ variable.unwrappedTypeName|lowerFirstLetter }}{% ifnot variable.isOptional %}Value{% endif %} | |
{% else %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{% elif variable.type.kind == "enum" %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(rawValue: json["{{ variable.name|camelToSnakeCase }}"].stringValue) ?? {{ variable.defaultValue }} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{% elif variable.type.based.JSONAutoRepresentable %} | |
{{ variable.name }} = {{ variable.unwrappedTypeName }}(json["{{ variable.name|camelToSnakeCase }}"]) | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
{% elif variable.isArray %} | |
{{ variable.name }} = json["{{ variable.name|camelToSnakeCase }}"].arrayValue.map({{ variable.typeName.array.elementTypeName.unwrappedTypeName }}.init) | |
... |
NewerOlder