{"id":20656976,"url":"https://github.com/ahmedalmasri/snadapter","last_synced_at":"2025-04-19T12:27:42.032Z","repository":{"id":62454092,"uuid":"182443591","full_name":"ahmedAlmasri/SNAdapter","owner":"ahmedAlmasri","description":"iOS swift tableview and collectionView Adapter","archived":false,"fork":false,"pushed_at":"2020-04-09T20:31:26.000Z","size":94,"stargazers_count":39,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-10T04:18:05.932Z","etag":null,"topics":["adapter","associated","associated-type","collectionview","collectionviewcell","generic","tableview","tableviewcell"],"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/ahmedAlmasri.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}},"created_at":"2019-04-20T18:55:09.000Z","updated_at":"2023-05-13T17:43:08.000Z","dependencies_parsed_at":"2022-11-02T00:00:56.419Z","dependency_job_id":null,"html_url":"https://github.com/ahmedAlmasri/SNAdapter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedAlmasri%2FSNAdapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedAlmasri%2FSNAdapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedAlmasri%2FSNAdapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmedAlmasri%2FSNAdapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmedAlmasri","download_url":"https://codeload.github.com/ahmedAlmasri/SNAdapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224952042,"owners_count":17397495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adapter","associated","associated-type","collectionview","collectionviewcell","generic","tableview","tableviewcell"],"created_at":"2024-11-16T18:17:51.526Z","updated_at":"2024-11-16T18:17:52.140Z","avatar_url":"https://github.com/ahmedAlmasri.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/ahmedalmasri/SNAdapter/blob/master/images/Banner.png?raw=true\"\u003e\u003c/img\u003e\n\nA declarative type-safe framework for building fast and flexible lists with TableView \u0026 CollectionView, No more delegates and datasource. Just a fully type-safe declarative content approach\n\n[![CI Status](https://img.shields.io/travis/ahmedAlmasri/SNAdapter.svg?style=flat)](https://travis-ci.org/ahmedAlmasri/SNAdapter)\n[![Version](https://img.shields.io/cocoapods/v/SNAdapter.svg?style=flat)](https://cocoapods.org/pods/SNAdapter)\n[![License](https://img.shields.io/cocoapods/l/SNAdapter.svg?style=flat)](https://cocoapods.org/pods/SNAdapter)\n[![Platform](https://img.shields.io/cocoapods/p/SNAdapter.svg?style=flat)](https://cocoapods.org/pods/SNAdapter)\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Using\n\n**Step 1**: Import the `SNAdapter` module in swift.\n\n```swift\nimport SNAdapter\n```\n# TableView \n\n\n**Step 1**:   declare a new class or struct conform from `SNCellableModel`\n\n```swift\n\nstruct MyModel: SNCellableModel {\n\n  let title: String\n}\n\n```\n\n**Step 2**:  declare a new `UITableViewCell`  conform from `SNCellable`\n\n```swift\n\nclass MyCell: UITableViewCell, SNCellable {\n\n  func configure(_ object: SNCellableModel?) {\n    guard let myModel = object as? MyModel else { return }\n\n    self.textLabel?.text = myModel.title\n  }\n\n}\n\n```\n**Step 3**: Take a reference to `SNTableViewSection`  and `SNTableViewAdapter` into your controller.\n\n```swift\n private var mySection: SNTableViewSection\u003cMyModel, MyCell\u003e!\n private var myAdapter: SNTableViewAdapter!\n```\n**Step 4**: Initialize the `SNTableViewSection`  and `SNTableViewAdapter` in your viewDidLoad .\n\n```swift\noverride func viewDidLoad() {\n  super.viewDidLoad()\n  ///....\n  \n  // MARK: - call setup section\n\n  setupMySection()\n  \n  ///...\n}\n\nprivate func setupMySection() {\n\n mySection = SNTableViewSection\u003cMyModel, MyCell\u003e(items: getMyListData())\n myAdapter = SNTableViewAdapter(sections: [mySection])\n myTableView.setAdapter(myAdapter)\n \n}\n\nprivate func getMyListData() -\u003e [MyModel] {\n\nreturn [MyModel(title: \"Item 1\"), MyModel(title: \"Item 2\")]\n\n}\n\n```\n## More Example \n\n* [Pagination (Load More) Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/TableView/Paging)\n* [Sections Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/TableView/Sections)\n* [Actions Delegate Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/TableView/ActionDelegate)\n\n\n# CollectionView \n\n\n\n**Step 1**:  declare new `UICollectionViewCell`  inherent form `SNCellable`\n\n```swift\n\nclass MyCell: UICollectionViewCell, SNCellable {\n\n @IBOutlet weak var titleLabel: UILabel!\n \nfunc configure(_ object: SNCellableModel?) {\nguard let myModel = object as? MyModel else { return }\n\n  titleLabel.text = myModel.title\n}\n\n}\n\n```\n**Step 2**: Take a reference to `SNCollectionViewSection`  and `SNCollectionViewAdapter` into your controller.\n\n```swift\nprivate var mySection: SNCollectionViewSection\u003cMyModel, MyCell\u003e!\nprivate var myAdapter: SNCollectionViewAdapter!\n```\n**Step 3**: Initialize the `SNCollectionViewSection`  and `SNCollectionViewAdapter` in your viewDidLoad .\n\n```swift\noverride func viewDidLoad() {\nsuper.viewDidLoad()\n///....\n\n// MARK: - call setup section\n\nsetupMySection()\n\n///...\n}\n\nprivate func setupMySection() {\n\nmySection = SNCollectionViewSection\u003cMyModel, MyCell\u003e(items: getMyListData())\nmyAdapter = SNCollectionViewAdapter(sections: [mySection])\nmyCollectionView.setAdapter(myAdapter)\n\n}\n\nprivate func getMyListData() -\u003e [MyModel] {\n\nreturn [MyModel(title: \"Item 1\"), MyModel(title: \"Item 2\")]\n\n}\n\n```\n## More Example \n\n* [Pagination (Load More) Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/TableView/Paging)\n* [Header  Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/CollectionView/Header)\n* [Actions Delegate Example](https://github.com/ahmedAlmasri/SNAdapter/blob/master/Example/SNAdapter/TableView/ActionDelegate)\n\n\n## Requirements\n* Swift 4.2+\n* Xcode 10.0+\n* iOS 11.0+\n\n## Installation\n\nSNAdapter is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'SNAdapter'\n```\n\n## Author\n\nahmedAlmasri, ahmed.almasri@ymail.com\n\n## License\n\nSNAdapter is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedalmasri%2Fsnadapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmedalmasri%2Fsnadapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmedalmasri%2Fsnadapter/lists"}