//
//  StatusElement.swift
//  SIIMpaPrinterSample
//

import Foundation
import SwiftUI

struct StatusElement: Identifiable, Hashable {
    var id = UUID()
    
    var title: String = ""
    var status: StatusState = .noStatus
    
    init(_ title: String) {
        self.title = title
    }
    
    mutating func setStatus(_ status: StatusState) {
        self.status = status
    }
    
}

enum StatusState: String {
    case noStatus = "-"
    case online = "Online"
    case offline = "Offline"
    case err = "Err"
    case no = "NO"
    case on = "ON"
    case off = "OFF"
    case feeding = "Feeding"
    case stop = "Stop"
    case writing = "Writing"
    
    case battery_none = "NONE"
    case battery_lev4 = "Lev4"
    case battery_lev3 = "Lev3"
    case battery_lev2 = "Lev2"
    case battery_lev1 = "lev1"
    
    var color: Color {
        switch self {
            case .noStatus:
                return .primary
            case .online:
                return .green
            case .offline:
                return .red
            case .err:
                return .red
            case .no:
                return .blue
            case .on:
                return .red
            case .off:
                return .blue
            case .feeding:
                return .red
            case .stop:
                return .blue
            case .writing:
                return .red
            case .battery_none:
                return .blue
            case .battery_lev4:
                return .blue
            case .battery_lev3:
                return .blue
            case .battery_lev2:
                return .blue
            case .battery_lev1:
                return .blue
        }
    }
}
