{"id":46391697,"url":"https://github.com/engingulek/genericcollectionviewkit","last_synced_at":"2026-03-05T09:03:02.646Z","repository":{"id":324104887,"uuid":"1094402859","full_name":"engingulek/GenericCollectionViewKit","owner":"engingulek","description":"A lightweight and reusable framework for UICollectionView written in Swift.","archived":false,"fork":false,"pushed_at":"2026-01-13T18:48:17.000Z","size":49,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-13T19:24:29.855Z","etag":null,"topics":["collectionview","generic-programming"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/engingulek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-11T16:57:37.000Z","updated_at":"2026-01-11T22:31:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/engingulek/GenericCollectionViewKit","commit_stats":null,"previous_names":["engingulek/genericcollectionviewkit"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/engingulek/GenericCollectionViewKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engingulek%2FGenericCollectionViewKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engingulek%2FGenericCollectionViewKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engingulek%2FGenericCollectionViewKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engingulek%2FGenericCollectionViewKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/engingulek","download_url":"https://codeload.github.com/engingulek/GenericCollectionViewKit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engingulek%2FGenericCollectionViewKit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collectionview","generic-programming"],"created_at":"2026-03-05T09:03:01.613Z","updated_at":"2026-03-05T09:03:02.580Z","avatar_url":"https://github.com/engingulek.png","language":"Swift","readme":"# 🧩 Generic Collection View Framework\n\nA lightweight and reusable framework for **UICollectionView** written in Swift.  \nIt provides a **generic**, **type-safe**, and **highly customizable** way to manage collection view data, section headers, delegates, and layouts. Compatible with **Swift 5.9+ / iOS 14+**.\n\n---\n\n## ✨ Features\n\n- ✅ Generic and reusable `UICollectionViewDataSource`  \n- ✅ Generic and reusable `UICollectionViewDelegate`  \n- ✅ Generic and reusable `UICollectionViewCompositionalLayout`  \n- ✅ Clean protocol-oriented architecture  \n- ✅ Supports dynamic section headers (titles + buttons)  \n- ✅ Strongly typed, type-safe, and fully generic  \n- ✅ Predefined layout templates for common scenarios  \n- ✅ Minimal boilerplate with default implementations\n\n| Feature                   | Description                                                                         |\n| ------------------------- | ----------------------------------------------------------------------------------- |\n| 🧩 **Type Safety**        | Strong typing everywhere ensures no `AnyObject` confusion                           |\n| ⚡ **Reusable**            | Write once, reuse across multiple collection views, headers, delegates, and layouts |\n| 🧼 **Clean Architecture** | Separates data, layout, delegate, and UI logic                                      |\n| 🧠 **Extensible**         | Easily extend with default methods, custom buttons, or layout templates             |\n\n---\n\n## 📜 CHeaderView\nA **customizable section header** that supports a **title** ,**optional action buttons** and **optional icon for title**, making it easy to display section information dynamically.  \n- A dynamic title (bold, resizable font)\n- Optiona left-aligned icon\n- Optional right-aligned buttons (e.g., “All List”, custom actions)\n- Auto-layout with UIStackView\n- Button tap callback closure\n\n  ### HeaderIcon\n Defines the icon displayed next to the title.\n```swift\n\npublic enum TitleIconType {\n    case systemImage(String) // SF Symbols\n    case imageAsstes(String) // Asset Catalog images\n}\n\npublic struct HeaderIcon {\n    public let image: TitleIconType\n    public let tintColor: HeaderItemColor\n}\n\n```\n\n ### HeaderViewItem\n The main configuration model for CHeaderView.\n```swift\npublic struct HeaderViewItem {\n    public let title: String // Header title text\n    public var icon: HeaderIcon? // Optional title icon\n    public let sizeType: SectionSizeType // Header size / font style\n    public var buttonTypes: [TitleForSectionButtonType] // Action buttons displayed on the right\n}\n\n```\n ### Configure\n```swift\n header.configure(with: .init(\n            title: item.title,\n            icon: item.icon,\n            sizeType: item.sizeType,\n            buttonTypes: item.buttonTypes)) { [weak self] tappedType in\n                guard let self else { return }\n                source.onTappedTitleButton(buttonType: tappedType, section: indexPath.section)\n            }\n```\n---\n\n## GenericCollectionDataSourceProtocol\nA **protocol-oriented**, **type-safe**, and **reusable** approach for managing collection view data.  \nDefines a clean contract for `UICollectionView` data handling — sections, cells, and optional headers.\n\n```swift\npublic protocol GenericCollectionDataSourceProtocol {\n    associatedtype CellItem\n    \n    func numberOfSections() -\u003e Int\n    func numberOfRowsInSection(in section: Int) -\u003e Int\n    func cellForItem(section: Int, item: Int) -\u003e CellItem\n    func cellIdentifier(at section: Int) -\u003e String\n    func titleForSection(at section: Int) -\u003e (\n        title: String,\n        sizeType: SectionSizeType,\n        buttonType: [TitleForSectionButtonType]?\n    )\n    func onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int)\n}\n```\n### Default Implementations\n\n```swift\nfunc titleForSection(at section: Int) -\u003e HeaderViewItem\nfunc onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int) { }\n}\n```\n\n### Supporting Types\n\nSectionSizeType\nControls the font size for section titles:\n\n```swift\npublic enum SectionSizeType {\n    case large, medium, small\n    var size: CGFloat { ... }\n}\n\n```\n\nTitleForSectionButtonType\nRepresents possible header button types:\n\n```swift\npublic enum TitleForSectionButtonType {\n    case allList\n    case custom(String)\n    var title: String { ... }\n}\n```\n\n###  Example Usage \n\n```swift\nstruct MyModel { let name: String }\n\nfinal class MyCollectionDataSource: GenericCollectionDataSourceProtocol {\n    typealias CellItem = MyModel\n    \n    func numberOfSections() -\u003e Int { 2 }\n    func numberOfRowsInSection(in section: Int) -\u003e Int { 5 }\n    func cellForItem(section: Int, item: Int) -\u003e MyModel { MyModel(name: \"Item \\(item)\") }\n    func cellIdentifier(at section: Int) -\u003e String { \"MyCell\" }\n    \n    func titleForSection(at section: Int) -\u003e (\n        title: String,\n        sizeType: SectionSizeType,\n        buttonType: [TitleForSectionButtonType]?\n    ) {\n        (title: \"Section \\(section)\", sizeType: .medium, buttonType: [.allList, .custom(\"Filter\")])\n    }\n    \n    func onTappedTitleButton(buttonType: TitleForSectionButtonType, section: Int) {\n        print(\"Tapped \\(buttonType) in section \\(section)\")\n    }\n}\n\n```\n\n### Integration Example\n\n\n```swift\nlet mySource = MyCollectionDataSource()\nlet dataSource = GenericCollectionDataSource(source: mySource) { identifier, cell, item in\n    guard let cell = cell as? MyCollectionViewCell,\n          let model = item as? MyModel else { return }\n    cell.configure(with: model)\n}\n\ncollectionView.dataSource = dataSource\n```\n\n## Generic Collection Delegate Source Protocol\n\nA lightweight and reusable UICollectionView delegate written in Swift.\nIt provides **a generic, type-safe, and protocol-oriented** way to handle item selection and scroll events in collection views.\n\n```swift\npublic protocol GenericCollectionDelegateSourceProtocol {\n    func didSelectItem(section: Int, item: Int)\n    func scrollViewDidScroll(endOfPage: Bool)\n}\n```\n\n### Default Implementations\n```swift\npublic extension GenericCollectionDelegateSourceProtocol {\n    func scrollViewDidScroll(endOfPage: Bool) { }\n    func didSelectItem(section: Int, item: Int) { }\n}\n```\n\n### Example Usage\n```swift\nfinal class MyDelegateSource: GenericCollectionDelegateSourceProtocol {\n    func didSelectItem(section: Int, item: Int) { print(\"Selected item \\(item) in section \\(section)\") }\n    func scrollViewDidScroll(endOfPage: Bool) { if endOfPage { print(\"Reached end of page ✅\") } }\n}\n```\n\n### Integration Example\n\n```swift\nlet source = MyDelegateSource()\nlet delegate = GenericCollectionDelegate(source: source)\ncollectionView.delegate = delegate\n```\n\n## Generic Collection Layout Provider Protocol\nA lightweight and reusable UICollectionViewCompositionalLayout framework written in Swift.\nProvides **a generic, type-safe, and flexible** way to configure collection view layouts.\n\n```swift\npublic protocol GenericCollectionLayoutProviderProtocol {\n    func layout(for sectionIndex: Int) -\u003e LayoutSource\n}\n```\n### LayoutSource\n\nDescribes the structure and behavior of the layout:\n\n```swift\npublic struct LayoutSource {\n    public init(groupOrientation: ScrollDirection,\n                itemSize: SizeInfo,\n                groupSize: SizeInfo,\n                sectionInsets: (top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat),\n                interItemSpacing: CGFloat,\n                interGroupSpacing: CGFloat,\n                scrollDirection: ScrollDirection) { ... }\n}\n\n```\n\n#### Supporting Types\n```swift\npublic enum DimensionType { case fractional, absolute, none }\n\npublic struct SizeInfo {\n    let width: (type: DimensionType, value: CGFloat)\n    let height: (type: DimensionType, value: CGFloat)\n}\n\npublic enum ScrollDirection { case horizontal, vertical }\n```\n\n### Example Usage\n\n```swift\nfinal class MyLayoutSource: GenericCollectionLayoutProviderProtocol {\n    func layout(for sectionIndex: Int) -\u003e LayoutSource {\n        switch sectionIndex {\n        case 0: return LayoutSourceTeamplate.horizontalSingleRow.template\n        case 1: return LayoutSourceTeamplate.verticalTwoPerRow.template\n        default: return LayoutSourceTeamplate.none.template\n        }\n    }\n}\n\nlet layoutProvider = GenericCollectionLayoutProvider(source: MyLayoutSource())\nlet layout = layoutProvider.createLayout()\nlet collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)\n\n```\n## Tutorial Video\n\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\n     \u003cvideo width=\"320\" height=\"140\" src = \"https://github.com/user-attachments/assets/8f652c61-6440-4757-8431-025c4549274d\"\u003e\n    \u003c/td\u003e\n    \u003ctd\u003e\n    \u003cvideo width=\"320\" height=\"140\" src = \"https://github.com/user-attachments/assets/483a0e53-5a24-4890-af49-0425c015d90c\"\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n## 🧰 Installation\n\n```swift\n\ndependencies: [\n.package(url: \"https://github.com/engingulek/GenericCollectionViewKit.git\", from: \"0.0.7\")\n]\n\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengingulek%2Fgenericcollectionviewkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengingulek%2Fgenericcollectionviewkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengingulek%2Fgenericcollectionviewkit/lists"}