From c127a6c465494e70915bf10a243f3230a42366d8 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 21 Jan 2025 09:13:41 -0600 Subject: [PATCH] commented the code and removed self. Signed-off-by: Matt Bruce --- .../ViewModels/EmployeeCellViewModel.swift | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/EmployeeDirectory/ViewModels/EmployeeCellViewModel.swift b/EmployeeDirectory/ViewModels/EmployeeCellViewModel.swift index d86c241..0b7199e 100644 --- a/EmployeeDirectory/ViewModels/EmployeeCellViewModel.swift +++ b/EmployeeDirectory/ViewModels/EmployeeCellViewModel.swift @@ -8,8 +8,11 @@ import Foundation import UIKit +/// ViewModel that will be used along with the EmployeeTableViewCell. @MainActor public class EmployeeCellViewModel: ObservableObject { + // MARK: - Properties + private let employee: Employee public private(set) var uuid: String @@ -21,18 +24,21 @@ public class EmployeeCellViewModel: ObservableObject { public private(set) var employeeType: String @Published public private(set) var smallPhoto: UIImage? + // MARK: - Initializer + public init(employee: Employee) { self.employee = employee // Initialize properties - self.uuid = employee.uuid.uuidString - self.fullName = employee.fullName - self.phoneNumber = employee.phoneNumber?.formatUSNumber() - self.emailAddress = employee.emailAddress - self.biography = employee.biography - self.team = employee.team - self.employeeType = employee.employeeType.description + uuid = employee.uuid.uuidString + fullName = employee.fullName + phoneNumber = employee.phoneNumber?.formatUSNumber() + emailAddress = employee.emailAddress + biography = employee.biography + team = employee.team + employeeType = employee.employeeType.description + // Fetch the image for the url if it exists if let endpoint = employee.photoURLSmall { Task{ if let smallPhotoURL = URL(string: endpoint) {