Story location picking

This commit is contained in:
Ilya Laktyushin
2023-07-30 15:01:25 +02:00
parent b3146436dc
commit b70586eb28
43 changed files with 2397 additions and 133 deletions

View File

@@ -10,6 +10,7 @@ public enum CodableDrawingEntity: Equatable {
case simpleShape(DrawingSimpleShapeEntity)
case bubble(DrawingBubbleEntity)
case vector(DrawingVectorEntity)
case location(DrawingLocationEntity)
public init?(entity: DrawingEntity) {
if let entity = entity as? DrawingStickerEntity {
@@ -22,6 +23,8 @@ public enum CodableDrawingEntity: Equatable {
self = .bubble(entity)
} else if let entity = entity as? DrawingVectorEntity {
self = .vector(entity)
} else if let entity = entity as? DrawingLocationEntity {
self = .location(entity)
} else {
return nil
}
@@ -39,6 +42,8 @@ public enum CodableDrawingEntity: Equatable {
return entity
case let .vector(entity):
return entity
case let .location(entity):
return entity
}
}
}
@@ -55,6 +60,7 @@ extension CodableDrawingEntity: Codable {
case simpleShape
case bubble
case vector
case location
}
public init(from decoder: Decoder) throws {
@@ -71,6 +77,8 @@ extension CodableDrawingEntity: Codable {
self = .bubble(try container.decode(DrawingBubbleEntity.self, forKey: .entity))
case .vector:
self = .vector(try container.decode(DrawingVectorEntity.self, forKey: .entity))
case .location:
self = .location(try container.decode(DrawingLocationEntity.self, forKey: .entity))
}
}
@@ -92,6 +100,9 @@ extension CodableDrawingEntity: Codable {
case let .vector(payload):
try container.encode(EntityType.vector, forKey: .type)
try container.encode(payload, forKey: .entity)
case let .location(payload):
try container.encode(EntityType.location, forKey: .type)
try container.encode(payload, forKey: .entity)
}
}
}