Skip to content

Commit

Permalink
rename delegate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Ovalle committed Aug 1, 2019
1 parent aa2e537 commit c6714fa
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions Example/Tests/DelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ class DelegateTests: XCTestCase {
func testShouldScrollDelegatePropertyOnTableDefault() {
let defaultTableViewController = DefaultTableViewController()

let shouldScrollTableView = defaultTableViewController.tableView.emptyStateDelegate?.emptyStateShouldScroll()
XCTAssertEqual(true, shouldScrollTableView)
let enableScrollForEmptyState = defaultTableViewController.tableView.emptyStateDelegate?.enableScrollForEmptyState()
XCTAssertEqual(true, enableScrollForEmptyState)
}

func testShouldScrollDelegatePropertyOnTableCustom() {
let customTableViewController = CustomEmptyStateTableViewController()

let shouldScrollTableView = customTableViewController.tableView.emptyStateDelegate?.emptyStateShouldScroll()
XCTAssertEqual(false, shouldScrollTableView)
let enableScrollForEmptyState = customTableViewController.tableView.emptyStateDelegate?.enableScrollForEmptyState()
XCTAssertEqual(false, enableScrollForEmptyState)
}

// MARK: - UICollectionView
func testShouldScrollDelegatePropertyOnCollectionDefault() {
let defaultCollectionViewController = DefaultCollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

let shouldScrollTableView = defaultCollectionViewController.collectionView.emptyStateDelegate?.emptyStateShouldScroll()
XCTAssertEqual(true, shouldScrollTableView)
let enableScrollForEmptyState = defaultCollectionViewController.collectionView.emptyStateDelegate?.enableScrollForEmptyState()
XCTAssertEqual(true, enableScrollForEmptyState)
}

func testShouldScrollDelegatePropertyOnCollectionCustom() {
let customCollectionViewController = CustomCollectionViewController(collectionViewLayout: UICollectionViewFlowLayout())

let shouldScrollTableView = customCollectionViewController.collectionView.emptyStateDelegate?.emptyStateShouldScroll()
XCTAssertEqual(false, shouldScrollTableView)
let enableScrollForEmptyState = customCollectionViewController.collectionView.emptyStateDelegate?.enableScrollForEmptyState()
XCTAssertEqual(false, enableScrollForEmptyState)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension UICollectionView: WLEmptyStateProtocol {

if numberOfItems == 0 && self.subviews.count > 1 {
originalScrollingValue = isScrollEnabled
isScrollEnabled = emptyStateDelegate?.emptyStateShouldScroll() ?? DefaultConstants.shouldScrollOnEmptyState
isScrollEnabled = emptyStateDelegate?.enableScrollForEmptyState() ?? DefaultConstants.enableScrollForEmptyState

backgroundView = emptyStateView
if let emptyStateView = emptyStateView as? EmptyStateView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension UITableView: WLEmptyStateProtocol {

if numberOfItems == 0 && self.subviews.count > 1 {
originalScrollingValue = isScrollEnabled
isScrollEnabled = emptyStateDelegate?.emptyStateShouldScroll() ?? DefaultConstants.shouldScrollOnEmptyState
isScrollEnabled = emptyStateDelegate?.enableScrollForEmptyState() ?? DefaultConstants.enableScrollForEmptyState

addSubview(emptyStateView)
if let emptyStateView = emptyStateView as? EmptyStateView {
Expand Down
2 changes: 1 addition & 1 deletion WLEmptyState/Classes/Misc/DefaultConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import Foundation

enum DefaultConstants {

static let shouldScrollOnEmptyState: Bool = true
static let enableScrollForEmptyState: Bool = true

}
6 changes: 3 additions & 3 deletions WLEmptyState/Classes/Protocols/WLEmptyStateDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import Foundation

public protocol WLEmptyStateDelegate: class {
func emptyStateShouldScroll() -> Bool
func enableScrollForEmptyState() -> Bool
}

public extension WLEmptyStateDelegate {

func emptyStateShouldScroll() -> Bool {
return DefaultConstants.shouldScrollOnEmptyState
func enableScrollForEmptyState() -> Bool {
return DefaultConstants.enableScrollForEmptyState
}

}

0 comments on commit c6714fa

Please sign in to comment.