//
//  SettingsDetailsViewModel.swift
//  1Weather
//
//  Created by Dmitry Stepanets on 27.03.2021.
//

import UIKit
import Localize_Swift

class SettingsDetailsViewModel: ViewModelProtocol {
    //Public
    let rowType:SettingsRow
    weak var delegate:ViewModelDelegate?
    
    var temperatures:[String] {
        return TemperatureType.allCases.map{ $0.rawValue.localized() }
    }
    var winds:[String] {
        return WindSpeedType.allCases.map{ $0.rawValue.localized() }
    }
    var pressures:[String] {
        return PressureType.allCases.map{ $0.rawValue.localized() }
    }
    var distances:[String] {
        return DistanceType.allCases.map{ $0.rawValue.localized() }
    }
    var languages:[String] {
        return Localize.availableLanguages()
    }
    
    //Selected
    var selectedTemperatureIndex: Int {
        return TemperatureType.allCases.firstIndex{ Settings.shared.temperatureType == $0 } ?? -1
    }
    var selectedWindIndex: Int {
        return WindSpeedType.allCases.firstIndex{ Settings.shared.windSpeedType == $0 } ?? -1
    }
    var selectedPressureIndex:Int {
        return PressureType.allCases.firstIndex{ Settings.shared.pressureType == $0 } ?? -1
    }
    var selectedDistanceIndex:Int {
        return DistanceType.allCases.firstIndex{ Settings.shared.distanceType == $0 } ?? -1
    }
    var selectedLanguageIndex:Int {
        return Localize.availableLanguages().firstIndex{ $0 == Localize.currentLanguage()} ?? -1
    }
    
    init(rowType: SettingsRow) {
        self.rowType = rowType
    }
}
