60 lines
1.4 KiB
Swift
60 lines
1.4 KiB
Swift
//
|
|
// ReportViewModel.swift
|
|
// AutoCat
|
|
//
|
|
// Created by Selim Mustafaev on 16.11.2024.
|
|
// Copyright © 2024 Selim Mustafaev. All rights reserved.
|
|
//
|
|
|
|
import AutoCatCore
|
|
import SwiftUI
|
|
|
|
@MainActor
|
|
@Observable
|
|
class ReportViewModel {
|
|
|
|
@ObservationIgnored @Service var api: ApiServiceProtocol
|
|
@ObservationIgnored @Service var storageService: StorageServiceProtocol
|
|
|
|
var coordinator: ReportCoordinator?
|
|
|
|
var vehicle: VehicleDto
|
|
var hud: ACHud?
|
|
|
|
var plateNumber: String {
|
|
if vehicle.outdated, let current = vehicle.currentNumber {
|
|
"\(vehicle.number) (\(current))"
|
|
} else {
|
|
vehicle.number
|
|
}
|
|
}
|
|
|
|
var steerignWheelPosition: String {
|
|
vehicle.isRightWheel == true
|
|
? NSLocalizedString("Right", comment: "")
|
|
: NSLocalizedString("Left", comment: "")
|
|
}
|
|
|
|
var isJapanese: String {
|
|
vehicle.isJapanese == true
|
|
? NSLocalizedString("Yes", comment: "")
|
|
: NSLocalizedString("No", comment: "")
|
|
}
|
|
|
|
init(vehicle: VehicleDto) {
|
|
self.vehicle = vehicle
|
|
}
|
|
|
|
func openEvents() {
|
|
coordinator?.openEvents(vehicle: vehicle)
|
|
}
|
|
|
|
func openOsago() {
|
|
coordinator?.openOsago(contracts: vehicle.osagoContracts)
|
|
}
|
|
|
|
func openOwners() {
|
|
coordinator?.openOwners(ownerships: vehicle.ownershipPeriods)
|
|
}
|
|
}
|