Skip to content

Commit d0c9d09

Browse files
committed
support multiple vertical spaces
1 parent 4f683ba commit d0c9d09

File tree

8 files changed

+19
-14
lines changed

8 files changed

+19
-14
lines changed

Example/EmptyDataDemoTableViewController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ class EmptyDataDemoTableViewController: UITableViewController, TBEmptyDataSetDat
116116
return 0
117117
}
118118

119+
func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] {
120+
return [25, 8]
121+
}
122+
119123
func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? {
120124
if isLoading {
121125
let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .Gray)

Example/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.5</string>
18+
<string>1.6</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>6</string>
22+
<string>7</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat {
5757
// return the vertical offset for EmptyDataSet, default is 0
5858
}
5959

60-
func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat {
61-
// return the vertical space for EmptyDataSet, default is 12
60+
func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] {
61+
// return the vertical spaces from top to bottom for EmptyDataSet, default is [12, 12]
6262
}
6363

6464
func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? {

TBEmptyDataSet.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = "TBEmptyDataSet"
4-
s.version = "1.5"
4+
s.version = "1.6"
55
s.summary = "An extension of UITableView/UICollectionView's super class, it will display a placeholder when the data is empty."
66

77
s.homepage = "https://github.com/teambition/TBEmptyDataSet"

TBEmptyDataSet/EmptyDataView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class EmptyDataView: UIView {
7777
}
7878

7979
var verticalOffset: CGFloat!
80-
var verticalSpace: CGFloat!
80+
var verticalSpaces: [CGFloat]!
8181

8282
// MARK: - Helper
8383
private func removeAllConstraints() {
@@ -172,7 +172,8 @@ class EmptyDataView: UIView {
172172
for (index, viewString) in viewStrings.enumerate() {
173173
verticalFormat += "[\(viewString)]"
174174
if index != viewStrings.count - 1 {
175-
verticalFormat += "-\(verticalSpace)-"
175+
let verticalSpace = index < verticalSpaces.count ? verticalSpaces[index] : DefaultValues.verticalSpace
176+
verticalFormat += "-(\(verticalSpace))-"
176177
}
177178
}
178179

TBEmptyDataSet/ProtocolExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public extension TBEmptyDataSetDataSource {
3333
return DefaultValues.verticalOffset
3434
}
3535

36-
func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat {
37-
return DefaultValues.verticalSpace
36+
func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat] {
37+
return [DefaultValues.verticalSpace, DefaultValues.verticalSpace]
3838
}
3939

4040
func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView? {

TBEmptyDataSet/Supporting Files/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.5</string>
18+
<string>1.6</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

TBEmptyDataSet/TBEmptyDataSet.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public protocol TBEmptyDataSetDataSource: NSObjectProtocol {
1717
func backgroundColorForEmptyDataSet(scrollView: UIScrollView!) -> UIColor?
1818

1919
func verticalOffsetForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat
20-
func verticalSpaceForEmptyDataSet(scrollView: UIScrollView!) -> CGFloat
20+
func verticalSpacesForEmptyDataSet(scrollView: UIScrollView!) -> [CGFloat]
2121

2222
func customViewForEmptyDataSet(scrollView: UIScrollView!) -> UIView?
2323
}
@@ -124,8 +124,8 @@ extension UIScrollView: UIGestureRecognizerDelegate {
124124
return emptyDataSetDataSource?.verticalOffsetForEmptyDataSet(self) ?? DefaultValues.verticalOffset
125125
}
126126

127-
private func emptyDataSetVerticalSpace() -> CGFloat {
128-
return emptyDataSetDataSource?.verticalSpaceForEmptyDataSet(self) ?? DefaultValues.verticalSpace
127+
private func emptyDataSetVerticalSpaces() -> [CGFloat] {
128+
return emptyDataSetDataSource?.verticalSpacesForEmptyDataSet(self) ?? [DefaultValues.verticalSpace, DefaultValues.verticalSpace]
129129
}
130130

131131
private func emptyDataSetCustomView() -> UIView? {
@@ -252,7 +252,7 @@ extension UIScrollView: UIGestureRecognizerDelegate {
252252
emptyDataView.resetEmptyDataView()
253253

254254
emptyDataView!.verticalOffset = emptyDataSetVerticalOffset()
255-
emptyDataView!.verticalSpace = emptyDataSetVerticalSpace()
255+
emptyDataView!.verticalSpaces = emptyDataSetVerticalSpaces()
256256

257257
if let customView = emptyDataSetCustomView() {
258258
emptyDataView.customView = customView

0 commit comments

Comments
 (0)