Code Monkey home page Code Monkey logo

wizelinelabs / wlemptystate Goto Github PK

View Code? Open in Web Editor NEW
317.0 317.0 26.0 892 KB

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.

Home Page: https://cocoapods.org/pods/WLEmptyState

License: MIT License

Ruby 8.69% Swift 91.31%
empty-state emptydataset ios placeholder uicollectionview uikit uitableview

wlemptystate's People

Contributors

abel7x avatar alexandercg avatar calosth avatar leonardo-garcia avatar lojals avatar p-daemon avatar squallone avatar zippi-md avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wlemptystate's Issues

Improve Readme

Improve Readme adding documentation of how to use the control.

👻In a UICollectionView the EmptyStateView get stuck behind the cells

Describe the bug
When using a UICollectionView and the numbers of cells change from zero to any number the EmptyStateView stays in the view hierarchy.

To Reproduce
Steps to reproduce the behavior:

  1. Having a 'UICollectionView' implemented.
  2. Change the number returned In the method collectionView(_:numberOfItemsInSection:) from zero to any other number.

Expected behavior
The EmptyStateView should be removed from the view hierarchy when the number of items in the UICollectionView goes from zero to any number greater than zero.

Screenshots
WLEmptyState-bug

Smartphone:

  • Device: iPhone 11 Pro
  • OS: iOS 13.4
  • Version: 3.1.0

Memory leaks

Describe the bug
Controllers do not deallocate from memory when using this framework

To Reproduce

self.tableView.emptyStateDataSource = self
self.tableView.emptyStateDelegate = self

extension VC: WLEmptyStateDataSource, WLEmptyStateDelegate {

func enableScrollForEmptyState() -> Bool {
    return true
}

func customViewForEmptyState() -> UIView? {
    return UIView()
}

}

Smartphone (please complete the following information):

  • Device: 14
  • OS: 17

Improve Error Handling

In the meantime we're just printing errors, those should be informed in a better way.

Add a Logger dependency or something.

How do I use this on all tableviews

if I want to add WLEmptyState to all my Tableviews in an existing project.
What should I do?
I don't want to set it separately on each viewController

Integrate CI

Choose and integrate a CI server that build and run our tests.

Empty state always shown if `numberOfSections` is not implemented

Describe the bug
If a UIViewController, which implements UITableViewDataSource does not implement the optional method numberOfSections, the UITableView always shows the empty state, even if the numberOfRownInSection method return a number != 0.

Expected behavior
The empty state should not be shown if the numberOfSections is not implemented, it should be shown if the numberOfSections method is implemented and returns 0.

Smartphone (please complete the following information):

  • Device: iPhone6
  • OS: iOS 12.2
  • Version 1.0.2

Additional context
The problem should be in these lines of UITable+Extensions file:

    private var numberOfItems: Int {
        var items = 0
        let numberOfSections = dataSource?.numberOfSections?(in: self) ?? 0
        for section in 0..<numberOfSections {
            items += dataSource?.tableView(self, numberOfRowsInSection: section) ?? 0
        }
        return items
    }

The numberOfSections method (as UITableViewDataSource protocol documentation) should default to 1 if not implemented, but with this code if numberOfSections is not implemented it defaults to 0.

Outdated docs

In several places of the documentation (Readme, repo description, WLEmptyState.swift comments) you say that it works on UITableView without mentioning that it also works on UICollectionView.

Empty state always shown if the emptyStateDataSource is nil

Describe the bug
Always the empty state is shown despite the emptyStateDataSource is not implemented in the tableView, causing that swizzledReload method adds the emptyStateView

 if numberOfItems == 0 && self.subviews.count > 1 {
            addSubview(emptyStateView)
            if let emptyStateView = emptyStateView as? EmptyStateView {
                emptyStateView.titleLabel.attributedText = self.emptyStateDataSource?.titleForEmptyDataSet()
                emptyStateView.descriptionLabel.attributedText = self.emptyStateDataSource?.descriptionForEmptyDataSet()
                emptyStateView.image.image = self.emptyStateDataSource?.imageForEmptyDataSet()
            } else {
                emptyStateView.translatesAutoresizingMaskIntoConstraints = false
                emptyStateView.heightAnchor.constraint(equalTo: heightAnchor).isActive = true
                emptyStateView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
                emptyStateView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
                emptyStateView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
            }
        }

To Reproduce
Steps to reproduce the behavior:

  1. Configure the empty state in the AppDelegate
  2. Implement a UITableViewController
  3. Run and compile the app
  4. Click the Debug View Hierarchy button on Xcode and see the emptyStateView at the top

Expected behavior
If the emptyStateDataSource is nil the emptyStateView shouldn't be shown

Screenshots
Screen Shot 2019-07-31 at 7 57 01 PM

循环引用问题cyclic Referenced

emptyStateDelegate、emptyStateDataSource
objc_setAssociatedObject(self, &AssociatedKeys.emptyStateDataSource, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)

->

            objc_setAssociatedObject(self, &AssociatedKeys.emptyStateDataSource, newValue, .OBJC_ASSOCIATION_ASSIGN)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.