From fa81de0a66946168839d01c7045e2f48e376a4fa Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Thu, 21 Mar 2024 00:33:03 +0100 Subject: [PATCH] Implemented the TableCell protocol in the UI library. --- .../Sources/Protocols/CellIdentifiable.swift | 16 --------- .../UI/Kit/Sources/Protocols/TableCell.swift | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 16 deletions(-) delete mode 100644 Libraries/UI/Kit/Sources/Protocols/CellIdentifiable.swift create mode 100644 Libraries/UI/Kit/Sources/Protocols/TableCell.swift diff --git a/Libraries/UI/Kit/Sources/Protocols/CellIdentifiable.swift b/Libraries/UI/Kit/Sources/Protocols/CellIdentifiable.swift deleted file mode 100644 index d44056b..0000000 --- a/Libraries/UI/Kit/Sources/Protocols/CellIdentifiable.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// CellIdentifiable.swift -// ReviewsUIKit -// -// Created by Javier Cicchelli on 21/03/2024. -// Copyright © 2024 Röck+Cöde VoF. All rights reserved. -// - -import UIKit - -public protocol CellIdentifiable: UITableViewCell { - - // MARK: Properties - static var cellID: String { get } - -} diff --git a/Libraries/UI/Kit/Sources/Protocols/TableCell.swift b/Libraries/UI/Kit/Sources/Protocols/TableCell.swift new file mode 100644 index 0000000..e158213 --- /dev/null +++ b/Libraries/UI/Kit/Sources/Protocols/TableCell.swift @@ -0,0 +1,33 @@ +// +// TableCell.swift +// ReviewsUIKit +// +// Created by Javier Cicchelli on 21/03/2024. +// Copyright © 2024 Röck+Cöde VoF. All rights reserved. +// + +import UIKit + +public protocol TableCell: UITableViewCell { + + // MARK: Properties + static var cellID: String { get } + + // MARK: Functions + static func dequeue(from tableView: UITableView) -> UITableViewCell? + static func register(in tableView: UITableView) + +} + +// MARK: - Implementations +extension TableCell { + + public static func dequeue(from tableView: UITableView) -> UITableViewCell? { + tableView.dequeueReusableCell(withIdentifier: cellID) + } + + public static func register(in tableView: UITableView) { + tableView.register(Self.self, forCellReuseIdentifier: cellID) + } + +}