Skip to content

Commit bd1c03e

Browse files
committed
2 parents 73cb538 + 90f9e7a commit bd1c03e

1 file changed

Lines changed: 40 additions & 13 deletions

File tree

README.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,50 @@ It provides a **generic**, **type-safe**, and **highly customizable** way to man
2626
---
2727

2828
## 📜 CHeaderView
29-
A **customizable section header** that supports a **title** and **optional action buttons**, making it easy to display section information dynamically.
29+
A **customizable section header** that supports a **title** ,**optional action buttons** and **optional icon for title**, making it easy to display section information dynamically.
3030
- A dynamic title (bold, resizable font)
31+
- Optiona left-aligned icon
3132
- Optional right-aligned buttons (e.g., “All List”, custom actions)
3233
- Auto-layout with UIStackView
3334
- Button tap callback closure
35+
36+
### HeaderIcon
37+
Defines the icon displayed next to the title.
3438
```swift
35-
header.configure(
36-
with: (title: "Recommended", sizeType: .medium, buttonTypes: [.allList, .custom("More")])
37-
) { buttonType in
38-
print("Tapped:", buttonType)
39+
40+
public enum TitleIconType {
41+
case systemImage(String) // SF Symbols
42+
case imageAsstes(String) // Asset Catalog images
3943
}
44+
45+
public struct HeaderIcon {
46+
public let image: TitleIconType
47+
public let tintColor: HeaderItemColor
48+
}
49+
50+
```
51+
52+
### HeaderViewItem
53+
The main configuration model for CHeaderView.
54+
```swift
55+
public struct HeaderViewItem {
56+
public let title: String // Header title text
57+
public var icon: HeaderIcon? // Optional title icon
58+
public let sizeType: SectionSizeType // Header size / font style
59+
public var buttonTypes: [TitleForSectionButtonType] // Action buttons displayed on the right
60+
}
61+
62+
```
63+
### Configure
64+
```swift
65+
header.configure(with: .init(
66+
title: item.title,
67+
icon: item.icon,
68+
sizeType: item.sizeType,
69+
buttonTypes: item.buttonTypes)) { [weak self] tappedType in
70+
guard let self else { return }
71+
source.onTappedTitleButton(buttonType: tappedType, section: indexPath.section)
72+
}
4073
```
4174
---
4275

@@ -63,14 +96,8 @@ public protocol GenericCollectionDataSourceProtocol {
6396
### Default Implementations
6497

6598
```swift
66-
public extension GenericCollectionDataSourceProtocol {
67-
func titleForSection(at section: Int) -> (
68-
title: String,
69-
sizeType: SectionSizeType,
70-
buttonType: [TitleForSectionButtonType]?
71-
) { ("", .small, nil) }
72-
73-
func onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int) { }
99+
func titleForSection(at section: Int) -> HeaderViewItem
100+
func onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int) { }
74101
}
75102
```
76103

0 commit comments

Comments
 (0)