//
//  VehicleStatsViewController.swift
//  BleDemo
//
//  Created by Aaron.Ang on 13/6/22.
//  Copyright © 2022 Cartrack. All rights reserved.
//

import UIKit
import CartrackBleLockSDK

class VehicleStatsViewController: UIViewController {

    var vehicleStats: VehicleStats?

    @IBOutlet weak var odometerLabel: UILabel!
    @IBOutlet weak var engineHoursLabel: UILabel!
    @IBOutlet weak var engineRPMLabel: UILabel!
    @IBOutlet weak var fuelLevelLabel: UILabel!
    @IBOutlet weak var hazardsLabel: UILabel!
    @IBOutlet weak var indicatorsLabel: UILabel!
    @IBOutlet weak var brakesLabel: UILabel!
    @IBOutlet weak var handBrakeLabel: UILabel!
    @IBOutlet weak var lightsLabel: UILabel!
    @IBOutlet weak var reverseGearLabel: UILabel!
    @IBOutlet weak var driverDoorLabel: UILabel!
    @IBOutlet weak var passengerDoorLabel: UILabel!
    @IBOutlet weak var driverSeatbeltLabel: UILabel!
    @IBOutlet weak var passengerSeatbeltLabel: UILabel!
    @IBOutlet weak var hornLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setup()
    }

    private func setup() {
      guard let vehicleStats = self.vehicleStats else { return }
      
      self.odometerLabel.text = "\(vehicleStats.odometer)KM"
      self.engineHoursLabel.text = "\(vehicleStats.engineHours)"
      self.engineRPMLabel.text = "\(vehicleStats.engineRPM)"
      self.fuelLevelLabel.text = "\(vehicleStats.fuelLevel)"
      self.hazardsLabel.text = "\(vehicleStats.hazardsIsOn ? "On" : "Off")"
      self.indicatorsLabel.text = vehicleStats.indicators.description
      self.brakesLabel.text = "\(vehicleStats.brakesIsActive ? "Active" : "Inactive")"
      self.handBrakeLabel.text = "\(vehicleStats.handBrakeIsActive ? "Active" : "Inactive")"
      self.lightsLabel.text = "\(vehicleStats.lightsIsOn ? "On" : "Off")"
      self.reverseGearLabel.text = "\(vehicleStats.reverseGearIsActive ? "Active" : "Inactive")"
      self.driverDoorLabel.text = "\(vehicleStats.driverDoorIsOpen ? "Open" : "Closed")"
      self.passengerDoorLabel.text = "\(vehicleStats.passengerDoorIsOpen ? "Open" : "Closed")"
      self.driverSeatbeltLabel.text = "\(vehicleStats.driverSeatbeltIsEngage ? "Engaged" : "Not Engaged")"
      self.passengerSeatbeltLabel.text = "\(vehicleStats.passengerSeatbeltIsEngage ? "Engaged" : "Not Engaged")"
      self.hornLabel.text = "\(vehicleStats.hornIsActive ? "Active" : "Inactive")"
    }
}
