Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit 17cfea7

Browse files
Redefine All API
1 parent a62ff46 commit 17cfea7

16 files changed

Lines changed: 544 additions & 313 deletions

Demo/Demo.xcodeproj/project.pbxproj

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,107 @@
166166
name = Products;
167167
sourceTree = "<group>";
168168
};
169+
B38F54FE1F976D6000993075 /* Default */ = {
170+
isa = PBXGroup;
171+
children = (
172+
B3B543091F062A9700408912 /* ConfigHeaderFooterController.swift */,
173+
B3B543081F062A9700408912 /* ConfigBannerController.swift */,
174+
B3B5430C1F062A9700408912 /* DefaultBannerController.swift */,
175+
B3B5430D1F062A9700408912 /* DefaultCollectionViewController.swift */,
176+
B3B5430E1F062A9700408912 /* DefaultScrollViewController.swift */,
177+
B3B5430F1F062A9700408912 /* DefaultTableViewController.swift */,
178+
B3B543101F062A9700408912 /* DefaultWebViewController.swift */,
179+
);
180+
name = Default;
181+
sourceTree = "<group>";
182+
};
183+
B38F55001F976DF000993075 /* Util */ = {
184+
isa = PBXGroup;
185+
children = (
186+
B3B543071F062A9700408912 /* BaseTableViewController.swift */,
187+
B3B543551F062A9700408912 /* RowModel.swift */,
188+
B3B543561F062A9700408912 /* SectionModel.swift */,
189+
B3B543C91F062A9700408912 /* Util.swift */,
190+
);
191+
name = Util;
192+
sourceTree = "<group>";
193+
};
194+
B38F55011F976DFF00993075 /* Custom */ = {
195+
isa = PBXGroup;
196+
children = (
197+
B38F55031F976E3200993075 /* Taobao */,
198+
B38F55081F976E6500993075 /* Elastic */,
199+
B38F55071F976E5D00993075 /* Yahoo */,
200+
B38F55061F976E4C00993075 /* Dianping */,
201+
B38F55021F976E2A00993075 /* QQVideo */,
202+
B38F55051F976E4300993075 /* Curve */,
203+
B38F55041F976E3A00993075 /* Youku */,
204+
);
205+
name = Custom;
206+
sourceTree = "<group>";
207+
};
208+
B38F55021F976E2A00993075 /* QQVideo */ = {
209+
isa = PBXGroup;
210+
children = (
211+
B3B543531F062A9700408912 /* QQVideoRefreshHeader.swift */,
212+
B3B543541F062A9700408912 /* QQVideoTableViewController.swift */,
213+
);
214+
name = QQVideo;
215+
sourceTree = "<group>";
216+
};
217+
B38F55031F976E3200993075 /* Taobao */ = {
218+
isa = PBXGroup;
219+
children = (
220+
B3B543C71F062A9700408912 /* TaoBaoRefreshHeader.swift */,
221+
B3B543C81F062A9700408912 /* TaobaoTableViewController.swift */,
222+
);
223+
name = Taobao;
224+
sourceTree = "<group>";
225+
};
226+
B38F55041F976E3A00993075 /* Youku */ = {
227+
isa = PBXGroup;
228+
children = (
229+
B3B543D01F062A9700408912 /* YoukuRefreshHeader.swift */,
230+
B3B543D11F062A9700408912 /* YoukuTableViewController.swift */,
231+
);
232+
name = Youku;
233+
sourceTree = "<group>";
234+
};
235+
B38F55051F976E4300993075 /* Curve */ = {
236+
isa = PBXGroup;
237+
children = (
238+
B3B5430A1F062A9700408912 /* CurveMaskTableViewController.swift */,
239+
B3B5430B1F062A9700408912 /* CurveRefreshHeader.swift */,
240+
);
241+
name = Curve;
242+
sourceTree = "<group>";
243+
};
244+
B38F55061F976E4C00993075 /* Dianping */ = {
245+
isa = PBXGroup;
246+
children = (
247+
B3B543111F062A9700408912 /* DianpingRefreshHeader.swift */,
248+
B3B543121F062A9700408912 /* DianpingTableviewController.swift */,
249+
);
250+
name = Dianping;
251+
sourceTree = "<group>";
252+
};
253+
B38F55071F976E5D00993075 /* Yahoo */ = {
254+
isa = PBXGroup;
255+
children = (
256+
B3B543CB1F062A9700408912 /* YahooWeatherRefreshHeader.swift */,
257+
B3B543CC1F062A9700408912 /* YahooWeatherTableViewController.swift */,
258+
);
259+
name = Yahoo;
260+
sourceTree = "<group>";
261+
};
262+
B38F55081F976E6500993075 /* Elastic */ = {
263+
isa = PBXGroup;
264+
children = (
265+
B3B543131F062A9700408912 /* ElasticHeaderTableViewController.swift */,
266+
);
267+
name = Elastic;
268+
sourceTree = "<group>";
269+
};
169270
B3B541181F061C3800408912 /* Products */ = {
170271
isa = PBXGroup;
171272
children = (
@@ -194,30 +295,9 @@
194295
isa = PBXGroup;
195296
children = (
196297
B3B543521F062A9700408912 /* MainViewController.swift */,
197-
B3B543531F062A9700408912 /* QQVideoRefreshHeader.swift */,
198-
B3B543541F062A9700408912 /* QQVideoTableViewController.swift */,
199-
B3B543551F062A9700408912 /* RowModel.swift */,
200-
B3B543561F062A9700408912 /* SectionModel.swift */,
201-
B3B543C71F062A9700408912 /* TaoBaoRefreshHeader.swift */,
202-
B3B543C81F062A9700408912 /* TaobaoTableViewController.swift */,
203-
B3B543C91F062A9700408912 /* Util.swift */,
204-
B3B543CB1F062A9700408912 /* YahooWeatherRefreshHeader.swift */,
205-
B3B543CC1F062A9700408912 /* YahooWeatherTableViewController.swift */,
206-
B3B543D01F062A9700408912 /* YoukuRefreshHeader.swift */,
207-
B3B543D11F062A9700408912 /* YoukuTableViewController.swift */,
208-
B3B543071F062A9700408912 /* BaseTableViewController.swift */,
209-
B3B543081F062A9700408912 /* ConfigBannerController.swift */,
210-
B3B543091F062A9700408912 /* ConfigHeaderFooterController.swift */,
211-
B3B5430A1F062A9700408912 /* CurveMaskTableViewController.swift */,
212-
B3B5430B1F062A9700408912 /* CurveRefreshHeader.swift */,
213-
B3B5430C1F062A9700408912 /* DefaultBannerController.swift */,
214-
B3B5430D1F062A9700408912 /* DefaultCollectionViewController.swift */,
215-
B3B5430E1F062A9700408912 /* DefaultScrollViewController.swift */,
216-
B3B5430F1F062A9700408912 /* DefaultTableViewController.swift */,
217-
B3B543101F062A9700408912 /* DefaultWebViewController.swift */,
218-
B3B543111F062A9700408912 /* DianpingRefreshHeader.swift */,
219-
B3B543121F062A9700408912 /* DianpingTableviewController.swift */,
220-
B3B543131F062A9700408912 /* ElasticHeaderTableViewController.swift */,
298+
B38F55001F976DF000993075 /* Util */,
299+
B38F54FE1F976D6000993075 /* Default */,
300+
B38F55011F976DFF00993075 /* Custom */,
221301
);
222302
name = ViewControllers;
223303
sourceTree = "<group>";

Demo/Demo/AppDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616

1717
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
19+
if #available(iOS 11.0, *) {
20+
UITableView.appearance().contentInsetAdjustmentBehavior = .never
21+
}
1922
return true
2023
}
2124

Demo/Demo/BaseTableViewController.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ import UIKit
1010

1111
class BaseTableViewController: UITableViewController {
1212
var models = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
13+
1314
override func viewDidLoad() {
1415
super.viewDidLoad()
1516
self.tableView.tableFooterView = UIView(frame: CGRect.zero)
1617
}
18+
1719
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
1820
return models.count
1921
}
22+
2023
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
2124
return 44.0
2225
}
26+
2327
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
2428
var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
2529
if cell == nil {
@@ -28,6 +32,7 @@ class BaseTableViewController: UITableViewController {
2832
cell?.textLabel?.text = "\(models[(indexPath as NSIndexPath).row])"
2933
return cell!
3034
}
35+
3136
deinit{
3237
print("Deinit of \(NSStringFromClass(type(of: self)))")
3338
}

Demo/Demo/DefaultCollectionViewController.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ import UIKit
1111
import PullToRefreshKit
1212

1313
class DefaultCollectionViewController:UIViewController,UICollectionViewDataSource{
14-
var collectionView:UICollectionView?
14+
var collectionView:UICollectionView!
1515
override func viewDidLoad() {
1616
self.view.backgroundColor = UIColor.white
1717
self.setUpCollectionView()
18-
_ = self.collectionView?.setUpHeaderRefresh({ [weak self] in
18+
self.collectionView.configRefreshHeader(with: DefaultRefreshHeader.header()) {
1919
delay(1.0, closure: {
20-
self?.collectionView?.endHeaderRefreshing(.success,delay: 0.3)
20+
self.collectionView.switchRefreshHeader(to: .normal(.success, 0.5));
2121
});
22-
})
23-
_ = self.collectionView?.setUpFooterRefresh({ [weak self] in
22+
}
23+
self.collectionView.configRefreshFooter(with: DefaultRefreshFooter.footer()) {
2424
delay(1.0, closure: {
25-
self?.collectionView?.endFooterRefreshing()
25+
self.collectionView.switchRefreshFooter(to: .normal)
2626
});
27-
})
27+
};
28+
2829
}
2930
func setUpCollectionView(){
3031
let flowLayout = UICollectionViewFlowLayout()

Demo/Demo/DefaultScrollViewController.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ import UIKit
1111
import PullToRefreshKit
1212

1313
class DefaultScrollViewController:UIViewController{
14-
var scrollView:UIScrollView?
14+
var scrollView: UIScrollView!
1515
override func viewDidLoad() {
1616
super.viewDidLoad()
1717
self.view.backgroundColor = UIColor.white
1818
self.automaticallyAdjustsScrollViewInsets = false
1919
setUpScrollView()
20-
_ = scrollView?.setUpHeaderRefresh({ [weak self] in
21-
delay(1.0, closure: {
22-
self?.scrollView?.endHeaderRefreshing(.success,delay: 0.3)
20+
let header = DefaultRefreshHeader.header()
21+
header.textLabel.textColor = UIColor.white;
22+
header.spinner.activityIndicatorViewStyle = .white
23+
scrollView.configRefreshHeader(with: header) {
24+
delay(1.0, closure: {
25+
self.scrollView.switchRefreshHeader(to: .normal(.success, 0.5));
2326
})
24-
}).SetUp({ (header) in
25-
header.textLabel.textColor = UIColor.white
26-
header.spinner.activityIndicatorViewStyle = .white
27-
})
27+
};
2828
}
29+
2930
func setUpScrollView(){
3031
self.scrollView = UIScrollView(frame: CGRect(x: 0,y: 0,width: 300,height: 300))
3132
self.scrollView?.backgroundColor = UIColor.lightGray

Demo/Demo/MainViewController.swift

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,21 @@
99
import UIKit
1010
import AudioToolbox
1111
import PullToRefreshKit
12+
1213
/*
13-
如果你喜欢这个库,一个★就是对我最好的支持,项目地址 https://github.com/LeoMobileDeveloper/PullToRefreshKit
14+
如果你喜欢这个库,一个★就是最好的支持,项目地址 https://github.com/LeoMobileDeveloper/PullToRefreshKit
1415
*/
1516
class MainViewController: UITableViewController {
1617
var models = [SectionModel]()
1718
override func viewDidLoad() {
1819
let section0 = SectionModel(rowsCount: 5,
1920
sectionTitle:"Default",
2021
rowsTitles: ["Tableview","CollectionView","ScrollView","Banners","WebView"],
21-
rowsTargetControlerNames:["DefaultTableViewController","DefaultCollectionViewController","DefaultScrollViewController","DefaultBannerController","DefaultWebViewController"])
22+
rowsTargetControlerNames:["DefaultTableViewController",
23+
"DefaultCollectionViewController",
24+
"DefaultScrollViewController",
25+
"DefaultBannerController",
26+
"DefaultWebViewController"])
2227
let section1 = SectionModel(rowsCount: 1,
2328
sectionTitle:"Build In",
2429
rowsTitles: ["Elastic",],
@@ -31,40 +36,43 @@ class MainViewController: UITableViewController {
3136
let section3 = SectionModel(rowsCount: 6,
3237
sectionTitle:"Customize",
3338
rowsTitles: ["YahooWeather","Curve Mask","Youku","TaoBao","QQ Video","DianPing"],
34-
rowsTargetControlerNames:["YahooWeatherTableViewController","CurveMaskTableViewController","YoukuTableViewController","TaobaoTableViewController","QQVideoTableviewController","DianpingTableviewController"])
39+
rowsTargetControlerNames:["YahooWeatherTableViewController",
40+
"CurveMaskTableViewController",
41+
"YoukuTableViewController",
42+
"TaobaoTableViewController",
43+
"QQVideoTableviewController",
44+
"DianpingTableviewController"])
3545
models.append(section0)
3646
models.append(section1)
3747
models.append(section2)
3848
models.append(section3)
39-
self.tableView.setUpHeaderRefresh { [weak self] in
40-
let delayTime = DispatchTime.now() + Double(Int64(2 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
41-
DispatchQueue.main.asyncAfter(deadline: delayTime) {
42-
self?.tableView.endHeaderRefreshing(.success,delay:0.3)
43-
}
44-
}.SetUp { (header) in
45-
header.setThemeColor(themeColor: UIColor.blue)
49+
let header = DefaultRefreshHeader.header()
50+
self.tableView.configRefreshHeader(with: header) {
51+
delay(2, closure: {
52+
self.tableView.switchRefreshHeader(to: .normal(.success, 0.5))
53+
})
4654
}
4755
self.tableView.tableFooterView = UIView(frame: CGRect.zero)
48-
if #available(iOS 11.0, *) {
49-
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.never
50-
} else {
51-
}
5256
}
5357

5458
override func numberOfSections(in tableView: UITableView) -> Int {
5559
return models.count
5660
}
61+
5762
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
5863
return 30.0
5964
}
65+
6066
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
6167
let sectionModel = models[section]
6268
return sectionModel.sectionTitle
6369
}
70+
6471
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
6572
let sectionModel = models[section]
6673
return sectionModel.rowsCount
6774
}
75+
6876
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
6977
var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
7078
if cell == nil {
@@ -74,6 +82,7 @@ class MainViewController: UITableViewController {
7482
cell?.textLabel?.text = sectionModel.rowsTitles[(indexPath as NSIndexPath).row]
7583
return cell!
7684
}
85+
7786
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
7887
tableView.deselectRow(at: indexPath, animated: true)
7988
let sectionModel = models[(indexPath as NSIndexPath).section]

PullToRefreshKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
B36DBDCC1FB425D600901DC8 /* Availability.swift in Sources */ = {isa = PBXBuildFile; fileRef = B36DBDCB1FB425D600901DC8 /* Availability.swift */; };
1011
B3B540CD1F061B8300408912 /* PullToRefreshKit.h in Headers */ = {isa = PBXBuildFile; fileRef = B3B540CB1F061B8300408912 /* PullToRefreshKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
1112
B3B541091F061C2300408912 /* arrow_down@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = B3B540F71F061C2300408912 /* arrow_down@3x.png */; };
1213
B3B5410A1F061C2300408912 /* arrow_left@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = B3B540F81F061C2300408912 /* arrow_left@3x.png */; };
@@ -25,6 +26,7 @@
2526
/* End PBXBuildFile section */
2627

2728
/* Begin PBXFileReference section */
29+
B36DBDCB1FB425D600901DC8 /* Availability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Availability.swift; sourceTree = "<group>"; };
2830
B3B540C81F061B8300408912 /* PullToRefreshKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PullToRefreshKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2931
B3B540CB1F061B8300408912 /* PullToRefreshKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PullToRefreshKit.h; sourceTree = "<group>"; };
3032
B3B540CC1F061B8300408912 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -116,6 +118,7 @@
116118
B3B541061F061C2300408912 /* PullToRefresh.swift */,
117119
B3B541071F061C2300408912 /* Right.swift */,
118120
B3B541081F061C2300408912 /* Utils.swift */,
121+
B36DBDCB1FB425D600901DC8 /* Availability.swift */,
119122
);
120123
path = Classes;
121124
sourceTree = "<group>";
@@ -212,6 +215,7 @@
212215
B3B541131F061C2300408912 /* Left.swift in Sources */,
213216
B3B541141F061C2300408912 /* PullToRefresh.swift in Sources */,
214217
B3B541151F061C2300408912 /* Right.swift in Sources */,
218+
B36DBDCC1FB425D600901DC8 /* Availability.swift in Sources */,
215219
B3B541121F061C2300408912 /* Header.swift in Sources */,
216220
B3B541111F061C2300408912 /* Footer.swift in Sources */,
217221
B3B541101F061C2300408912 /* ElasticRefreshHeader.swift in Sources */,

0 commit comments

Comments
 (0)