//
//  BarsCarouselIndicatorModel.swift
//  MVMCoreUI
//
//  Created by Kevin Christiano on 3/3/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//

import UIKit


open class BarsCarouselIndicatorModel: CarouselIndicatorModel {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    public class override var identifier: String {
        return "barsCarouselIndicator"
    }
    
    public var currentIndicatorColor: Color = Color(uiColor: .mvmBlack)
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case currentIndicatorColor
    }
    
    //--------------------------------------------------
    // MARK: - Codec
    //--------------------------------------------------
    
    public override init() {
        super.init()
    }
    
    public required init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        
        if let currentIndicatorColor = try typeContainer.decodeIfPresent(Color.self, forKey: .currentIndicatorColor) {
            self.currentIndicatorColor = currentIndicatorColor
        }
        
        try super.init(from: decoder)
    }
    
    public override func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(currentIndicatorColor, forKey: .currentIndicatorColor)
        try super.encode(to: encoder)
    }
}
