Skip to content

Commit

Permalink
Merge pull request #30 from emirhanbattalbas/feature/tableview
Browse files Browse the repository at this point in the history
Tableview's initine style selection added
  • Loading branch information
aslanmehmetsalih authored May 7, 2021
2 parents 42233cd + 9aed6f9 commit e293fd4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 9 additions & 2 deletions Example/Tests/UITableViewBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,15 @@ class UITableViewBuilderTests: XCTestCase {

XCTAssertEqual(tableView.accessibilityIdentifier, accessibilityIdentifier)
}


func testStyle() {
let style: UITableView.Style = .grouped
let tableView = UITableViewBuilder(style)
.build()

XCTAssertEqual(tableView.style, style)
}

func testCellRegistration() {
let cellIdentifier = "TestTableViewCell"
let tableView = UITableViewBuilder()
Expand All @@ -193,7 +201,6 @@ class UITableViewBuilderTests: XCTestCase {
break
}
}

XCTAssertTrue(isContainsIdentifier)
}
}
12 changes: 7 additions & 5 deletions MobilliumBuilders/Classes/UITableViewBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import UIKit

public class UITableViewBuilder<T: UITableView> {

public let tableView = T()

public init() { }


public var tableView = T()

public init(_ style: UITableView.Style = .plain) {
tableView = T(frame: .zero, style: style)
}

@discardableResult
public func backgroundColor(_ backgroundColor: UIColor) -> Self {
self.tableView.backgroundColor = backgroundColor
Expand Down

0 comments on commit e293fd4

Please sign in to comment.