//
//  LabelAttributeColorModel.swift
//  MVMCoreUI
//
//  Created by Ryan on 11/21/19.
//  Copyright © 2019 Verizon Wireless. All rights reserved.
//


@objcMembers public class LabelAttributeColorModel: LabelAttributeModel {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    override public class var identifier: String { "color" }
    
    var textColor: Color?
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case textColor
    }
    
    public init(_ textColor: Color?, _ location: Int, _ length: Int){
        self.textColor = textColor
        super.init(location, length)
    }
    
    //--------------------------------------------------
    // MARK: - Codec
    //--------------------------------------------------
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        textColor = try typeContainer.decodeIfPresent(Color.self, forKey: .textColor)
        try super.init(from: decoder)
    }
    
    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encodeIfPresent(textColor, forKey: .textColor)
    }
}
