From e877733de945d40441a751e9c36c332f90ff7742 Mon Sep 17 00:00:00 2001 From: Nikita Vasilev Date: Wed, 10 Jun 2026 15:51:20 +0400 Subject: [PATCH] feat: add data source and delegate setup for collection and table views --- .../Extensions/FlexUI+UICollectionView.swift | 11 +++++++ .../Extensions/FlexUI+UITableView.swift | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Sources/FlexUI/Classes/Extensions/FlexUI+UITableView.swift diff --git a/Sources/FlexUI/Classes/Extensions/FlexUI+UICollectionView.swift b/Sources/FlexUI/Classes/Extensions/FlexUI+UICollectionView.swift index bcb38a1..8636470 100644 --- a/Sources/FlexUI/Classes/Extensions/FlexUI+UICollectionView.swift +++ b/Sources/FlexUI/Classes/Extensions/FlexUI+UICollectionView.swift @@ -140,4 +140,15 @@ public extension FlexUI where Component: UICollectionView { component.isPagingEnabled = isPagingEnabled return self } + + /// Sets the refresh control associated with the scroll view. + /// + /// - Parameter refreshControl: The refresh control associated with the scroll view. + /// - Returns: The current instance of `FlexUI` for further configuration. + @discardableResult + @MainActor + func refreshControl(_ refreshControl: UIRefreshControl) -> Self { + component.refreshControl = refreshControl + return self + } } diff --git a/Sources/FlexUI/Classes/Extensions/FlexUI+UITableView.swift b/Sources/FlexUI/Classes/Extensions/FlexUI+UITableView.swift new file mode 100644 index 0000000..5bfbe24 --- /dev/null +++ b/Sources/FlexUI/Classes/Extensions/FlexUI+UITableView.swift @@ -0,0 +1,33 @@ +// +// flex-ui +// Copyright © 2026 Space Code. All rights reserved. +// + +import UIKit + +/// An extension to `FlexUI` that adds helper methods for configuring `UITableView` properties. +/// These methods allow for fluent configuration of properties such as scroll indicators, selection, +/// and registration of cells and headers. +public extension FlexUI where Component: UITableView { + /// Sets the delegate for the table view. + /// + /// - Parameter delegate: The delegate object that conforms to `UITableViewDelegate`. + /// - Returns: The current instance of `FlexUI` for further configuration. + @discardableResult + @MainActor + func delegate(_ delegate: UITableViewDelegate?) -> Self { + component.delegate = delegate + return self + } + + /// Sets the data source for the table view. + /// + /// - Parameter dataSource: The data source object that conforms to `UITableViewDataSource`. + /// - Returns: The current instance of `FlexUI` for further configuration. + @discardableResult + @MainActor + func dataSource(_ dataSource: UITableViewDataSource?) -> Self { + component.dataSource = dataSource + return self + } +}