Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bagusandinata committed Aug 23, 2020
2 parents c0fe213 + c454b73 commit 8112474
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,95 @@ dependencies: [
.package(url: "https://github.com/bagusandinata/BAStateTableView.git", from: "1.0.2")
]
```

## :hotsprings: How to use
**1.** Set custom class `BAStateTableView` in UITableView IB/Storyboards.

![alt text](https://github.com/bagusandinata/BAStateTableView/blob/master/Assets/Screen%20Shot%202020-08-23%20at%2017.00.48.png?raw=true)

**2.** Import `BAStateTableView` in proper place.

```
import BAStateTableView
```

**3.** Using state basic loading.
##### Default basic loading

```
tableView.setState(.loading())
```

##### Custom basic loading

```
tableView.setState(.loading(indicatorWidth: 100, indicatorHeight: 100, indicatorColor: .gray, backgroundColor: .white))
```

**4.** Using state custom loading.

```
tableView.ba_loadingView = UIView.nib(withType: CustomLoadingView.self)
tableView.setState(.customLoadingView)
```

**5.** Using state skeleton loading.

##### Please set view skeletonable active in cell

##### * Using code:

```
view.isSkeletonable = true
view.skeletonCornerRadius = 10 (Optional)
```

##### * Using IB/Storyboards::

![alt text](https://github.com/bagusandinata/BAStateTableView/blob/master/Assets/Screen%20Shot%202020-08-23%20at%2017.02.57.png?raw=true)

##### You can setup custom skeleton animation

```
tableView.config = SkeletonConfig(colors: SkeletonGradient(baseColor: .gray).colors, gradientDirection: .leftRight, animationDuration: 1.5, transitionShow: .none, transitionHide: .crossDissolve(2.5))
```

##### When you use skeleton loading set UITableViewDataSource

```
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch (tableView as! BAStateTableView).currentState {
case .availableData:
return data.count
case .skeletonLoading:
return 10
default:
return 0
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueCell(with: ExampleCell.self, indexPath: indexPath)!
switch (tableView as! BAStateTableView).currentState {
case .availableData:
cell.labelExample.text = data.exampleText
return cell
default:
return cell
}
}
```

**6.** Using state custom empty data.

```
tableView.ba_emptyView = UIView.nib(withType: EmptyView.self)
tableView.setState(.emptyData)
```

**7.** Using state custom available data.

```
tableView.setState(.availableData)
```

0 comments on commit 8112474

Please sign in to comment.