Make drawings persist (save) to the backend
Closed this issue · 2 comments
mschmulen commented
Currently Drawings are not saved to the backed so all the beautiful pictures and drawing that the child does is lost in the app interaction session.
AC:
- Drawings are saved after the kid make a modification to a drawing
- Kids can open up legacy drawings and improve them
- Adults and others can view readonly the drawing the kid has made.
mschmulen commented
dev notes:
- add "layer" to drawings.
- add "color" to drawing ( make use of codable enums, https://blog.untitledkingdom.com/codable-enums-in-swift-3ab3dacf30ce)
- swiftUI Color notes: https://troz.net/post/2020/swiftui-color/
case name(String)
case email(String)
}```
extension LoginType: Codable {
enum Key: CodingKey {
case rawValue
case associatedValue
}
enum CodingError: Error {
case unknownValue
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: Key.self)
let rawValue = try container.decode(Int.self, forKey: .rawValue)
switch rawValue {
case 0:
let userName = try container.decode(String.self, forKey: .associatedValue)
self = .name(userName)
case 1:
let email = try container.decode(String.self, forKey: .associatedValue)
self = .email(email)
default:
throw CodingError.unknownValue
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: Key.self)
switch self {
case .name(let userName):
try container.encode(0, forKey: .rawValue)
try container.encode(userName, forKey: .associatedValue)
case .email(let email):
try container.encode(1, forKey: .rawValue)
try container.encode(email, forKey: .associatedValue)
}
}
}
https://blog.untitledkingdom.com/codable-enums-in-swift-3ab3dacf30ce
https://github.com/gregiOS/Playgrounds/
mschmulen commented
Done.