All Projects → wizeline → Wlemptystate

wizeline / Wlemptystate

Licence: mit
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.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Wlemptystate

Tabanimated
A skeleton screen framework based on native for iOS. (一个由iOS原生组件映射出骨架屏的框架,包含快速植入,低耦合,兼容复杂视图等特点,提供国内主流骨架屏动画的加载方案,同时支持上拉加载更多、自定制动画。)
Stars: ✭ 2,909 (+853.77%)
Mutual labels:  uicollectionview, uitableview, placeholder
ios ui recipe showcase
iOSアプリ開発 - UI実装であると嬉しいレシピブック掲載サンプル
Stars: ✭ 54 (-82.3%)
Mutual labels:  uitableview, uicollectionview, uikit
Skeletonview
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
Stars: ✭ 10,804 (+3442.3%)
Mutual labels:  uicollectionview, uitableview, placeholder
Gskstretchyheaderview
A generic stretchy header for UITableView and UICollectionView
Stars: ✭ 1,624 (+432.46%)
Mutual labels:  uikit, uicollectionview, uitableview
Pagingkit
PagingKit provides customizable menu UI. It has more flexible layout and design than the other libraries.
Stars: ✭ 1,030 (+237.7%)
Mutual labels:  uikit, uicollectionview, uitableview
Owl
A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Stars: ✭ 423 (+38.69%)
Mutual labels:  uikit, uicollectionview, uitableview
Hgplaceholders
Nice library to show placeholders and Empty States for any UITableView/UICollectionView in your project
Stars: ✭ 2,048 (+571.48%)
Mutual labels:  uicollectionview, uitableview, placeholder
Viewanimator
ViewAnimator brings your UI to life with just one line
Stars: ✭ 6,592 (+2061.31%)
Mutual labels:  uikit, uicollectionview, uitableview
Basecomponents
BaseComponents aims to provide easily reusable and understandable components to increase productivity with UIKit and Foundation APIs
Stars: ✭ 92 (-69.84%)
Mutual labels:  uikit, uicollectionview, uitableview
Squaremosaiclayout
An extandable mosaic UICollectionViewLayout with a focus on extremely flexible customizations 🔶
Stars: ✭ 243 (-20.33%)
Mutual labels:  uikit, uicollectionview, uitableview
StackableTableView
A UITableView subclass that enables setting an array of views for both headers and footers utilizing UIStackView
Stars: ✭ 72 (-76.39%)
Mutual labels:  uitableview, uikit
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (-77.38%)
Mutual labels:  uitableview, uicollectionview
HDEmptyView
一个Swift语言封装的EmptyView显示库,可作用于WKWebView、UITableView、UICollectionView 无网络提醒或者空数据提醒
Stars: ✭ 29 (-90.49%)
Mutual labels:  uitableview, uicollectionview
UIComponent
Write UI in crazy speed, with great perf & no limitations.
Stars: ✭ 333 (+9.18%)
Mutual labels:  uicollectionview, uikit
GenericCells
Creating generic UITableViewCells and UICollectionViewCells instead of subclasses.
Stars: ✭ 81 (-73.44%)
Mutual labels:  uitableview, uicollectionview
TinyCoordinator
The Swift version of ThinningCoordinator focus on lighter view controllers.
Stars: ✭ 18 (-94.1%)
Mutual labels:  uitableview, uicollectionview
STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (-88.2%)
Mutual labels:  placeholder, uikit
Cyanic
Declarative, state-driven UI framework
Stars: ✭ 32 (-89.51%)
Mutual labels:  uitableview, uicollectionview
TableViewKit
Empowering UITableView with painless multi-type cell support and built-in automatic state transition animations
Stars: ✭ 105 (-65.57%)
Mutual labels:  uitableview, uikit
Transfiguration
Mystical way to transform data into reusable view in Swift
Stars: ✭ 14 (-95.41%)
Mutual labels:  uitableview, uicollectionview

WLEmptyState_Banner WLEmptyState CI Version Carthage compatible Twitter MIT license

Table of Content

Overview

WLEmptyState 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.

Running an Example Project

To run the Example project:

  1. Clone the repo with the following command:

    git clone [email protected]:wizeline/WLEmptyState.git

  2. Move to the Example directory and run the following command:

    pod install

Installing WLEmptyState

CocoaPods

WLEmptyState is available through CocoaPods. To install it, add the following command to your Podfile:

pod 'WLEmptyState'

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:

github "wizeline/WLEmptyState"

Configuring WLEmptyState

The WLEmptyState component uses Method Swizzling. Therefore, to configure WLEmptyState, follow these steps:

  1. Import the module in the AppDelegate class by adding import WLEmptyState.

  2. Call the static method configure() on application(_ application:, didFinishLaunchingWithOptions:) method.

    Your AppDelegate class should look like this:

    import WLEmptyState
        ...
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        WLEmptyState.configure()
        return true
    }
    

Using WLEmptyState

Once you have configured WLEmptyState, you can use it for your UITableViewController or UICollectionViewController. You need to conform the WLEmptyStateDataSource protocol. For example,

class YourTableViewController: UITableViewController, WLEmptyStateDataSource {

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.emptyStateDataSource = self
    }

}

After you run your project with an empty dataset for your entity, you'll be able to see a default WLEmptyState view.

Default Image

Default WLEmptyState

Customizing Default WLEmptyState

If 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:

  • Customize Image
func imageForEmptyDataSet() -> UIImage? {
    return UIImage(named: "bubble_icon")
}
  • Customize Title
func titleForEmptyDataSet() -> NSAttributedString {
    let title = NSAttributedString(string: "No messages", attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .headline)])
    return title
}
  • Customize Description
func descriptionForEmptyDataSet() -> NSAttributedString {
    let title = NSAttributedString(string: "There's no messages to show.", attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .caption1)])
    return title
}

Customized Image

Creating your own EmptyState

Using customViewForEmptyState() allows you to provide your own implementation for Empty State.

func customViewForEmptyState() -> UIView? {
  let activityIndicatorView = UIActivityIndicatorView()
  activityIndicatorView.startAnimating()
  activityIndicatorView.color = .purple
  return activityIndicatorView
}

Simulator Screen Shot - iPhone X - 2019-07-24 at 16 07 43

Disable scroll

You 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:

// Conform the WLEmptyStateDelegate protocol
class YourTableViewController: UITableViewController, WLEmptyStateDataSource, WLEmptyStateDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        tableView.emptyStateDataSource = self        
        tableView.emptyStateDelegate = self // Set your delegate
    }

    func enableScrollForEmptyState() -> Bool {        
        // To enable/disable the scroll return true or false
        return false
    }

}

Contributing to WLEmptyState

We 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 and follow the Code of conduct. If you face any problem with the code, please open an issue on GitHub.

List of Contributors. ⭐️

License

WLEmptyState is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].