-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conform tableview to protocols(reuse and configure)
- Loading branch information
Showing
8 changed files
with
218 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...es/UIComponents/Controllers/BaseCollectionViewController/BaseCollectionReusableView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// BaseCollectionReusableView.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
|
||
open class BaseCollectionReusableView: UICollectionReusableView, IConfigurable { | ||
|
||
open override class var reuseIdentifier: String { | ||
String(describing: BaseCollectionReusableView.self) | ||
} | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupViews() | ||
layoutViews() | ||
configureViews() | ||
} | ||
required public init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
open func configure(_ parametr: Any) { } | ||
} | ||
|
||
// MARK: - Configure | ||
@objc | ||
extension BaseCollectionReusableView { | ||
/// Добавляет подвиды на представление. | ||
/// Добавьте код для добавления подвидов на представление, | ||
/// таких как их инициализация, настройка свойств и добавление на представление. | ||
open func setupViews() { } | ||
|
||
/// Устанавливает ограничения для подвидов внутри представления. | ||
/// Добавьте код для установки ограничений для подвидов, | ||
/// таких как установка автолейаут-ограничений, задание отступов и т.д. | ||
open func layoutViews() { } | ||
|
||
/// Настраивает внешний вид представления. | ||
/// Добавьте код для настройки внешнего вида представления, | ||
/// таких как установка фона, цветов, шрифтов и других свойств визуальных элементов. | ||
/// Вы также можете применять стили, добавлять тени, закруглять углы и т.д. | ||
open func configureViews() { } | ||
} |
47 changes: 47 additions & 0 deletions
47
Sources/UIComponents/Controllers/BaseTableViewController/BaseTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// BaseTableViewCell.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
open class BaseTableViewCell: UICollectionViewCell, IConfigurable { | ||
|
||
open override class var reuseIdentifier: String { | ||
String(describing: BaseTableViewCell.self) | ||
} | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setupViews() | ||
layoutViews() | ||
configureViews() | ||
} | ||
required public init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
open func configure(_ parametr: Any) { } | ||
} | ||
|
||
// MARK: - Configure | ||
@objc | ||
extension BaseTableViewCell { | ||
/// Добавляет подвиды на представление. | ||
/// Добавьте код для добавления подвидов на представление, | ||
/// таких как их инициализация, настройка свойств и добавление на представление. | ||
open func setupViews() { } | ||
|
||
/// Устанавливает ограничения для подвидов внутри представления. | ||
/// Добавьте код для установки ограничений для подвидов, | ||
/// таких как установка автолейаут-ограничений, задание отступов и т.д. | ||
open func layoutViews() { } | ||
|
||
/// Настраивает внешний вид представления. | ||
/// Добавьте код для настройки внешнего вида представления, | ||
/// таких как установка фона, цветов, шрифтов и других свойств визуальных элементов. | ||
/// Вы также можете применять стили, добавлять тени, закруглять углы и т.д. | ||
open func configureViews() { } | ||
} |
47 changes: 47 additions & 0 deletions
47
Sources/UIComponents/Controllers/BaseTableViewController/BaseTableViewHeaderFooterView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
open class BaseTableViewHeaderFooterView: UITableViewHeaderFooterView, IConfigurable { | ||
|
||
open override class var reuseIdentifier: String { | ||
String(describing: BaseTableViewCell.self) | ||
} | ||
public override init(reuseIdentifier: String?) { | ||
super.init(reuseIdentifier: reuseIdentifier) | ||
setupViews() | ||
layoutViews() | ||
configureViews() | ||
} | ||
|
||
required public init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
open func configure(_ parametr: Any) { } | ||
} | ||
|
||
// MARK: - Configure | ||
@objc | ||
extension BaseTableViewHeaderFooterView { | ||
/// Добавляет подвиды на представление. | ||
/// Добавьте код для добавления подвидов на представление, | ||
/// таких как их инициализация, настройка свойств и добавление на представление. | ||
open func setupViews() { } | ||
|
||
/// Устанавливает ограничения для подвидов внутри представления. | ||
/// Добавьте код для установки ограничений для подвидов, | ||
/// таких как установка автолейаут-ограничений, задание отступов и т.д. | ||
open func layoutViews() { } | ||
|
||
/// Настраивает внешний вид представления. | ||
/// Добавьте код для настройки внешнего вида представления, | ||
/// таких как установка фона, цветов, шрифтов и других свойств визуальных элементов. | ||
/// Вы также можете применять стили, добавлять тени, закруглять углы и т.д. | ||
open func configureViews() { } | ||
} |
14 changes: 14 additions & 0 deletions
14
Sources/UIComponents/Extensions/UICollectionReusableView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// UICollectionReusableView.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UICollectionReusableView: IReusableView { | ||
@objc public class var reuseIdentifier: String { | ||
String(describing: UICollectionReusableView.self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// UITableView.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UITableView { | ||
/// Регистрирует указанные типы ячеек для использования в таблице. | ||
/// - Parameter cells: Типы ячеек, которые необходимо зарегистрировать. | ||
func registerCells(_ cells: UITableViewCell.Type...) { | ||
cells.forEach { cell in | ||
register(cell.self, forCellReuseIdentifier: cell.reuseIdentifier) | ||
} | ||
} | ||
|
||
/// Регистрирует указанные типы представлений для использования в таблице. | ||
/// - Parameter cells: Типы представлений, которые необходимо зарегистрировать. | ||
func registerReuseViews(_ views: UITableViewHeaderFooterView.Type...) { | ||
views.forEach { view in | ||
register(view.self, forHeaderFooterViewReuseIdentifier: view.reuseIdentifier) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// UITableViewCell.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UITableViewCell: IReusableView { | ||
@objc public class var reuseIdentifier: String { | ||
String(describing: UITableViewCell.self) | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
Sources/UIComponents/Extensions/UITableViewHeaderFooterView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// UITableViewHeaderFooterView.swift | ||
// | ||
// | ||
// Created by Дмитрий Корчагин on 7/1/24. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UITableViewHeaderFooterView: IReusableView { | ||
@objc public class var reuseIdentifier: String { | ||
String(describing: UITableViewHeaderFooterView.self) | ||
} | ||
} |