{"id":2907,"url":"https://github.com/WizelineLabs/WLEmptyState","last_synced_at":"2025-08-03T12:31:38.324Z","repository":{"id":34702197,"uuid":"161220814","full_name":"WizelineLabs/WLEmptyState","owner":"WizelineLabs","description":"WLEmptyState is an iOS based component that lets you customize the view when the dataset of a UITableView or a UICollectionView is empty. We created a sample project with the WLEmptyState component to show how you can use it.","archived":false,"fork":false,"pushed_at":"2022-07-22T03:07:15.000Z","size":892,"stargazers_count":316,"open_issues_count":6,"forks_count":26,"subscribers_count":23,"default_branch":"main","last_synced_at":"2024-04-13T23:14:51.478Z","etag":null,"topics":["empty-state","emptydataset","ios","placeholder","uicollectionview","uikit","uitableview"],"latest_commit_sha":null,"homepage":"https://cocoapods.org/pods/WLEmptyState","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/WizelineLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-10T18:46:16.000Z","updated_at":"2024-04-13T09:59:14.000Z","dependencies_parsed_at":"2022-08-08T01:16:22.850Z","dependency_job_id":null,"html_url":"https://github.com/WizelineLabs/WLEmptyState","commit_stats":null,"previous_names":["wizeline/wlemptystate"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WizelineLabs%2FWLEmptyState","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WizelineLabs%2FWLEmptyState/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WizelineLabs%2FWLEmptyState/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WizelineLabs%2FWLEmptyState/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WizelineLabs","download_url":"https://codeload.github.com/WizelineLabs/WLEmptyState/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227298885,"owners_count":17760396,"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":["empty-state","emptydataset","ios","placeholder","uicollectionview","uikit","uitableview"],"created_at":"2024-01-05T20:16:26.001Z","updated_at":"2024-12-07T00:31:04.688Z","avatar_url":"https://github.com/WizelineLabs.png","language":"Swift","funding_links":[],"categories":["UI","Libs","Recently Updated"],"sub_categories":["Table View / Collection View","UI","[Feb 04, 2025](/content/2025/02/04/README.md)"],"readme":"![WLEmptyState_Banner](https://user-images.githubusercontent.com/6756995/55449438-bf01f300-5588-11e9-9c0d-dd48bd5babb4.png)\n![WLEmptyState CI](https://github.com/wizeline/WLEmptyState/workflows/WLEmptyState%20CI/badge.svg)\n[![Version](https://img.shields.io/cocoapods/v/WLEmptyState.svg?style=flat)](https://cocoapods.org/pods/WLEmptyState)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Twitter](https://img.shields.io/twitter/follow/theWizeline.svg?label=Wizeline%20\u0026style=flat)](http://twitter.com/thewizeline)\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n\n## Table of Content \u003c!-- omit in toc --\u003e\n\n- [Overview](#overview)\n- [Running an Example Project](#running-an-example-project)\n  - [Installing WLEmptyState](#installing-wlemptystate)\n  - [Configuring WLEmptyState](#configuring-wlemptystate)\n  - [Using WLEmptyState](#using-wlemptystate)\n- [Customizing WLEmptyState](#customizing-wlemptystate)\n- [Contributing to WLEmptyState](#contributing-to-wlemptystate)\n- [Author](#author)\n- [License](#license)\n\n## Overview\n\nWLEmptyState is an iOS based component that lets you customize the message when the dataset of `UITableView` or `UICollectionView` is empty. We created a sample project with the WLEmptyState component to show how you can use it.\n\n## Running an Example Project\n\nTo run the `Example` project:\n\n1. Clone the repo with the following command:\n\n    `git clone git@github.com:wizeline/WLEmptyState.git`\n\n2. Move to the `Example` directory and run the following command:\n\n    `pod install`\n\n### Installing WLEmptyState\n\n#### CocoaPods\n\nWLEmptyState is available through [CocoaPods](https://cocoapods.org). To install it, add the following command to your Podfile:\n\n```ruby\npod 'WLEmptyState'\n```\n\n#### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate WLEmptyState into your Xcode project using Carthage, specify it in your Cartfile:\n\n```ruby\ngithub \"wizeline/WLEmptyState\"\n```\n\n### Configuring WLEmptyState\n\nThe WLEmptyState component uses [Method Swizzling](https://nshipster.com/method-swizzling/). Therefore, to configure `WLEmptyState`, follow these steps:\n\n1. Import the module in the `AppDelegate` class by adding `import WLEmptyState`.\n\n2. Call the static method `configure()` on `application(_ application:, didFinishLaunchingWithOptions:)` method.\n\n    Your `AppDelegate` class should look like this:\n\n    ```Swift\n    import WLEmptyState\n        ...\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -\u003e Bool {\n        WLEmptyState.configure()\n        return true\n    }\n    ```\n\n### Using WLEmptyState\n\nOnce you have configured `WLEmptyState`, you can use it for your `UITableViewController` or `UICollectionViewController`. You need to conform the `WLEmptyStateDataSource` protocol. For example,\n\n```Swift\nclass YourTableViewController: UITableViewController, WLEmptyStateDataSource {\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        tableView.emptyStateDataSource = self\n    }\n\n}\n```\n\nAfter you run your project with an empty dataset for your entity, you'll be able to see a default `WLEmptyState` view.\n\n**Default Image**\n\n![Default WLEmptyState](https://user-images.githubusercontent.com/6756995/52525837-21b7cc00-2c75-11e9-8ef4-6c2ca226ddb3.png)\n\n## Customizing Default WLEmptyState\nIf you want to customize the text, description, or image, of the default component you need to implement the `WLEmptyStateDataSource` function. You can find the code for customization in the following list:\n\n- Customize Image\n\n```Swift\nfunc imageForEmptyDataSet() -\u003e UIImage? {\n    return UIImage(named: \"bubble_icon\")\n}\n```\n\n- Customize Title\n\n```Swift\nfunc titleForEmptyDataSet() -\u003e NSAttributedString {\n    let title = NSAttributedString(string: \"No messages\", attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])\n    return title\n}\n```\n\n- Customize Description\n\n```Swift\nfunc descriptionForEmptyDataSet() -\u003e NSAttributedString {\n    let title = NSAttributedString(string: \"There's no messages to show.\", attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption1)])\n    return title\n}\n```\n\n**Customized Image**\n\n\u003cimg src=\"https://user-images.githubusercontent.com/3466367/52595877-8fe6c500-2e14-11e9-85f3-2937746d4b24.png\" width=\"300\"\u003e\n\n## Creating your own EmptyState\nUsing `customViewForEmptyState()` allows you to provide your own implementation for Empty State.\n\n```Swift\nfunc customViewForEmptyState() -\u003e UIView? {\n  let activityIndicatorView = UIActivityIndicatorView()\n  activityIndicatorView.startAnimating()\n  activityIndicatorView.color = .purple\n  return activityIndicatorView\n}\n```\n![Simulator Screen Shot - iPhone X - 2019-07-24 at 16 07 43](https://user-images.githubusercontent.com/6756995/61828904-62735e00-ae2d-11e9-8020-2014ac3bfb17.png)\n\n## Disable scroll\nYou can disable the scroll when the Empty State is showing. You only need to conform the `WLEmptyStateDelegate` protocol and return `false` in the `enableScrollForEmptyState()` function:\n\n```Swift\n// Conform the WLEmptyStateDelegate protocol\nclass YourTableViewController: UITableViewController, WLEmptyStateDataSource, WLEmptyStateDelegate {\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        tableView.emptyStateDataSource = self        \n        tableView.emptyStateDelegate = self // Set your delegate\n    }\n\n    func enableScrollForEmptyState() -\u003e Bool {        \n        // To enable/disable the scroll return true or false\n        return false\n    }\n\n}\n```\n\n## Contributing to WLEmptyState\n\nWe actively welcome your pull requests. We are trying to make contributions to this project as transparent and accessible as possible, please read our [Contributing guidelines](contributing.md) and follow the [Code of conduct](CODE_OF_CONDUCT.md).\nIf you face any problem with the code, please open an issue on GitHub.\n\nList of [Contributors](https://github.com/wizeline/WLEmptyState/graphs/contributors). ⭐️\n\n## License\n\nWLEmptyState 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%2FWizelineLabs%2FWLEmptyState","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWizelineLabs%2FWLEmptyState","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWizelineLabs%2FWLEmptyState/lists"}