Commit 096f59fc by 刘卓鑫

修复多彩蓝牙洗衣bug

parent b611ce6c
......@@ -83,6 +83,14 @@
1C96F78322F960F6002DCA9B /* ZXHomePageUserFeedbackCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C96F78222F960F6002DCA9B /* ZXHomePageUserFeedbackCell.m */; };
1C96F78622F9611B002DCA9B /* ZXHomePageKefuReplyCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C96F78522F9611B002DCA9B /* ZXHomePageKefuReplyCell.m */; };
1C96F78922F997F0002DCA9B /* ZXHomePageMeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C96F78822F997F0002DCA9B /* ZXHomePageMeViewController.m */; };
1C9D29B72396093400E240EB /* ZXNewOrderDetailCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29B62396093300E240EB /* ZXNewOrderDetailCell.m */; };
1C9D29C72396339D00E240EB /* UIColor+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29BA2396339D00E240EB /* UIColor+PYSearchExtension.m */; };
1C9D29C82396339D00E240EB /* PYSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29BB2396339D00E240EB /* PYSearchViewController.m */; };
1C9D29C92396339D00E240EB /* PYSearchSuggestionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29BC2396339D00E240EB /* PYSearchSuggestionViewController.m */; };
1C9D29CA2396339D00E240EB /* PYSearchConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29BE2396339D00E240EB /* PYSearchConst.m */; };
1C9D29CB2396339D00E240EB /* PYSearch.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1C9D29BF2396339D00E240EB /* PYSearch.bundle */; };
1C9D29CC2396339D00E240EB /* NSBundle+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29C02396339D00E240EB /* NSBundle+PYSearchExtension.m */; };
1C9D29CD2396339D00E240EB /* UIView+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C9D29C62396339D00E240EB /* UIView+PYSearchExtension.m */; };
1CA144F52387CC00007A4092 /* ZXTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CA144F42387CBFF007A4092 /* ZXTaskViewController.m */; };
1CA31627225C6AB2005ECF2B /* ZXAnnouncementView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CA31626225C6AB2005ECF2B /* ZXAnnouncementView.m */; };
1CA7E88B229E8E310014E95F /* JDSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1CA7E889229E8E310014E95F /* JDSDK.bundle */; };
......@@ -165,13 +173,6 @@
1CF863122304116A0007EBC6 /* ZXLoginAnimationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CF863112304116A0007EBC6 /* ZXLoginAnimationView.m */; };
1CFDEC7E235FE98B007701A5 /* ZXAliMaMaManagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC7D235FE98B007701A5 /* ZXAliMaMaManagerViewController.m */; };
1CFDEC84235FFD3E007701A5 /* ZXFliterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC83235FFD3E007701A5 /* ZXFliterView.m */; };
1CFDEC9423602A9E007701A5 /* UIColor+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8723602A9E007701A5 /* UIColor+PYSearchExtension.m */; };
1CFDEC9523602A9E007701A5 /* PYSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8823602A9E007701A5 /* PYSearchViewController.m */; };
1CFDEC9623602A9E007701A5 /* PYSearchSuggestionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8923602A9E007701A5 /* PYSearchSuggestionViewController.m */; };
1CFDEC9723602A9E007701A5 /* PYSearchConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8B23602A9E007701A5 /* PYSearchConst.m */; };
1CFDEC9823602A9E007701A5 /* PYSearch.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8C23602A9E007701A5 /* PYSearch.bundle */; };
1CFDEC9923602A9E007701A5 /* NSBundle+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC8D23602A9E007701A5 /* NSBundle+PYSearchExtension.m */; };
1CFDEC9A23602A9E007701A5 /* UIView+PYSearchExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CFDEC9323602A9E007701A5 /* UIView+PYSearchExtension.m */; };
2215B61C1F95B12B00C37778 /* BYHelp.m in Sources */ = {isa = PBXBuildFile; fileRef = 2215B60C1F95B12300C37778 /* BYHelp.m */; };
2215B61D1F95B12B00C37778 /* GraphicsCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2215B60E1F95B12300C37778 /* GraphicsCode.m */; };
2215B61E1F95B12B00C37778 /* HYSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 2215B6101F95B12300C37778 /* HYSegmentedControl.m */; };
......@@ -880,6 +881,22 @@
1C96F78522F9611B002DCA9B /* ZXHomePageKefuReplyCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXHomePageKefuReplyCell.m; sourceTree = "<group>"; };
1C96F78722F997F0002DCA9B /* ZXHomePageMeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXHomePageMeViewController.h; sourceTree = "<group>"; };
1C96F78822F997F0002DCA9B /* ZXHomePageMeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXHomePageMeViewController.m; sourceTree = "<group>"; };
1C9D29B52396093300E240EB /* ZXNewOrderDetailCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXNewOrderDetailCell.h; sourceTree = "<group>"; };
1C9D29B62396093300E240EB /* ZXNewOrderDetailCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXNewOrderDetailCell.m; sourceTree = "<group>"; };
1C9D29B92396339D00E240EB /* NSBundle+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+PYSearchExtension.h"; sourceTree = "<group>"; };
1C9D29BA2396339D00E240EB /* UIColor+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+PYSearchExtension.m"; sourceTree = "<group>"; };
1C9D29BB2396339D00E240EB /* PYSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchViewController.m; sourceTree = "<group>"; };
1C9D29BC2396339D00E240EB /* PYSearchSuggestionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchSuggestionViewController.m; sourceTree = "<group>"; };
1C9D29BD2396339D00E240EB /* UIView+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+PYSearchExtension.h"; sourceTree = "<group>"; };
1C9D29BE2396339D00E240EB /* PYSearchConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchConst.m; sourceTree = "<group>"; };
1C9D29BF2396339D00E240EB /* PYSearch.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = PYSearch.bundle; sourceTree = "<group>"; };
1C9D29C02396339D00E240EB /* NSBundle+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+PYSearchExtension.m"; sourceTree = "<group>"; };
1C9D29C12396339D00E240EB /* PYSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearch.h; sourceTree = "<group>"; };
1C9D29C22396339D00E240EB /* PYSearchSuggestionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchSuggestionViewController.h; sourceTree = "<group>"; };
1C9D29C32396339D00E240EB /* PYSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchViewController.h; sourceTree = "<group>"; };
1C9D29C42396339D00E240EB /* UIColor+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+PYSearchExtension.h"; sourceTree = "<group>"; };
1C9D29C52396339D00E240EB /* PYSearchConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchConst.h; sourceTree = "<group>"; };
1C9D29C62396339D00E240EB /* UIView+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+PYSearchExtension.m"; sourceTree = "<group>"; };
1CA144F32387CBFF007A4092 /* ZXTaskViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXTaskViewController.h; sourceTree = "<group>"; };
1CA144F42387CBFF007A4092 /* ZXTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXTaskViewController.m; sourceTree = "<group>"; };
1CA31625225C6AB2005ECF2B /* ZXAnnouncementView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXAnnouncementView.h; sourceTree = "<group>"; };
......@@ -1033,20 +1050,6 @@
1CFDEC7D235FE98B007701A5 /* ZXAliMaMaManagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXAliMaMaManagerViewController.m; sourceTree = "<group>"; };
1CFDEC82235FFD3E007701A5 /* ZXFliterView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZXFliterView.h; sourceTree = "<group>"; };
1CFDEC83235FFD3E007701A5 /* ZXFliterView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ZXFliterView.m; sourceTree = "<group>"; };
1CFDEC8623602A9E007701A5 /* NSBundle+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+PYSearchExtension.h"; sourceTree = "<group>"; };
1CFDEC8723602A9E007701A5 /* UIColor+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+PYSearchExtension.m"; sourceTree = "<group>"; };
1CFDEC8823602A9E007701A5 /* PYSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchViewController.m; sourceTree = "<group>"; };
1CFDEC8923602A9E007701A5 /* PYSearchSuggestionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchSuggestionViewController.m; sourceTree = "<group>"; };
1CFDEC8A23602A9E007701A5 /* UIView+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+PYSearchExtension.h"; sourceTree = "<group>"; };
1CFDEC8B23602A9E007701A5 /* PYSearchConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PYSearchConst.m; sourceTree = "<group>"; };
1CFDEC8C23602A9E007701A5 /* PYSearch.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = PYSearch.bundle; sourceTree = "<group>"; };
1CFDEC8D23602A9E007701A5 /* NSBundle+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+PYSearchExtension.m"; sourceTree = "<group>"; };
1CFDEC8E23602A9E007701A5 /* PYSearch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearch.h; sourceTree = "<group>"; };
1CFDEC8F23602A9E007701A5 /* PYSearchSuggestionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchSuggestionViewController.h; sourceTree = "<group>"; };
1CFDEC9023602A9E007701A5 /* PYSearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchViewController.h; sourceTree = "<group>"; };
1CFDEC9123602A9E007701A5 /* UIColor+PYSearchExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+PYSearchExtension.h"; sourceTree = "<group>"; };
1CFDEC9223602A9E007701A5 /* PYSearchConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PYSearchConst.h; sourceTree = "<group>"; };
1CFDEC9323602A9E007701A5 /* UIView+PYSearchExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+PYSearchExtension.m"; sourceTree = "<group>"; };
2215B60B1F95B12300C37778 /* BYHelp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BYHelp.h; sourceTree = "<group>"; };
2215B60C1F95B12300C37778 /* BYHelp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BYHelp.m; sourceTree = "<group>"; };
2215B60D1F95B12300C37778 /* GraphicsCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsCode.h; sourceTree = "<group>"; };
......@@ -2434,6 +2437,27 @@
path = customViews;
sourceTree = "<group>";
};
1C9D29B82396339D00E240EB /* PYSearch */ = {
isa = PBXGroup;
children = (
1C9D29B92396339D00E240EB /* NSBundle+PYSearchExtension.h */,
1C9D29BA2396339D00E240EB /* UIColor+PYSearchExtension.m */,
1C9D29BB2396339D00E240EB /* PYSearchViewController.m */,
1C9D29BC2396339D00E240EB /* PYSearchSuggestionViewController.m */,
1C9D29BD2396339D00E240EB /* UIView+PYSearchExtension.h */,
1C9D29BE2396339D00E240EB /* PYSearchConst.m */,
1C9D29BF2396339D00E240EB /* PYSearch.bundle */,
1C9D29C02396339D00E240EB /* NSBundle+PYSearchExtension.m */,
1C9D29C12396339D00E240EB /* PYSearch.h */,
1C9D29C22396339D00E240EB /* PYSearchSuggestionViewController.h */,
1C9D29C32396339D00E240EB /* PYSearchViewController.h */,
1C9D29C42396339D00E240EB /* UIColor+PYSearchExtension.h */,
1C9D29C52396339D00E240EB /* PYSearchConst.h */,
1C9D29C62396339D00E240EB /* UIView+PYSearchExtension.m */,
);
path = PYSearch;
sourceTree = "<group>";
};
1CA144F22387CBDC007A4092 /* Task(任务) */ = {
isa = PBXGroup;
children = (
......@@ -2591,28 +2615,6 @@
path = Controller;
sourceTree = "<group>";
};
1CFDEC8523602A9E007701A5 /* PYSearch */ = {
isa = PBXGroup;
children = (
1CFDEC8623602A9E007701A5 /* NSBundle+PYSearchExtension.h */,
1CFDEC8D23602A9E007701A5 /* NSBundle+PYSearchExtension.m */,
1CFDEC8C23602A9E007701A5 /* PYSearch.bundle */,
1CFDEC8E23602A9E007701A5 /* PYSearch.h */,
1CFDEC9223602A9E007701A5 /* PYSearchConst.h */,
1CFDEC8B23602A9E007701A5 /* PYSearchConst.m */,
1CFDEC8F23602A9E007701A5 /* PYSearchSuggestionViewController.h */,
1CFDEC8923602A9E007701A5 /* PYSearchSuggestionViewController.m */,
1CFDEC9023602A9E007701A5 /* PYSearchViewController.h */,
1CFDEC8823602A9E007701A5 /* PYSearchViewController.m */,
1CFDEC9123602A9E007701A5 /* UIColor+PYSearchExtension.h */,
1CFDEC8723602A9E007701A5 /* UIColor+PYSearchExtension.m */,
1CFDEC8A23602A9E007701A5 /* UIView+PYSearchExtension.h */,
1CFDEC9323602A9E007701A5 /* UIView+PYSearchExtension.m */,
);
name = PYSearch;
path = "../../../../../../Downloads/PYSearch-master/PYSearch";
sourceTree = "<group>";
};
2264A4901F57EEE7003918FB /* AlertView */ = {
isa = PBXGroup;
children = (
......@@ -3924,6 +3926,8 @@
A756C58621F9B58F0006E418 /* ZXNewPayTypeActivityTableViewCell.m */,
1CD9E5602296446E00FFDA29 /* ZXNewPayOrderRechargeCell.h */,
1CD9E5612296446E00FFDA29 /* ZXNewPayOrderRechargeCell.m */,
1C9D29B52396093300E240EB /* ZXNewOrderDetailCell.h */,
1C9D29B62396093300E240EB /* ZXNewOrderDetailCell.m */,
);
path = view;
sourceTree = "<group>";
......@@ -4303,7 +4307,7 @@
A7DECC7A2079F0E20039EC22 /* Vendor(三方) */ = {
isa = PBXGroup;
children = (
1CFDEC8523602A9E007701A5 /* PYSearch */,
1C9D29B82396339D00E240EB /* PYSearch */,
1CB3AC1023053BE0006F1724 /* CropImage */,
1C3AE7B722F0482D0045C969 /* SGQRCode */,
1CD9E566229B7C7500FFDA29 /* JDSDK */,
......@@ -5124,7 +5128,6 @@
22D62BA11F68D8DF00134AC1 /* DeleteAlertView.xib in Resources */,
A7265BE820CA3AEF0084B814 /* menu-holder@2x.png in Resources */,
22E36C961F558D1B00073AC2 /* BeanCell.xib in Resources */,
1CFDEC9823602A9E007701A5 /* PYSearch.bundle in Resources */,
A75180B520A2F8B7002DF5ED /* JDPayFoundation.bundle in Resources */,
A705C01521D4B067004F1628 /* UIBarButtonItemGrid@3x.png in Resources */,
A7F3E18121B5330F00010E23 /* index.html in Resources */,
......@@ -5144,6 +5147,7 @@
A7F3E16E21B5330F00010E23 /* README.txt in Resources */,
22E36C981F558D1B00073AC2 /* PayTypeCell.xib in Resources */,
22E36CD11F55975500073AC2 /* TicketCell.xib in Resources */,
1C9D29CB2396339D00E240EB /* PYSearch.bundle in Resources */,
1CA7E88B229E8E310014E95F /* JDSDK.bundle in Resources */,
A7F3E18221B5330F00010E23 /* upload.html in Resources */,
A705C00D21D4B067004F1628 /* PlayButtonOverlayLarge@3x.png in Resources */,
......@@ -5259,6 +5263,7 @@
A7F3E01121B530F500010E23 /* ZXBookDetailModel.m in Sources */,
A7B0589C211A80EC00304B38 /* ZXDrinkViewController.m in Sources */,
A7AB5FFB20AC31050066950A /* JXLayoutButton.m in Sources */,
1C9D29C82396339D00E240EB /* PYSearchViewController.m in Sources */,
A7F3E17321B5330F00010E23 /* HTTPConnection.m in Sources */,
1C3AE7C422F0482D0045C969 /* ZXScannerViewController.m in Sources */,
A745DBFA210089BC00D0C648 /* ZXPutMenuTimeCell.m in Sources */,
......@@ -5279,7 +5284,6 @@
1CD9E56D229CD7D900FFDA29 /* ZXBDSteamTableViewCell.m in Sources */,
A7F3E02221B530F500010E23 /* ZXBookSearchListCell.m in Sources */,
A7F3E17021B5330F00010E23 /* DDNumber.m in Sources */,
1CFDEC9723602A9E007701A5 /* PYSearchConst.m in Sources */,
1CB3AC092304E369006F1724 /* ZXMePageMenuModel.m in Sources */,
2215B61D1F95B12B00C37778 /* GraphicsCode.m in Sources */,
A7F3E1A721B5330F00010E23 /* XDSPhotoBrowser.m in Sources */,
......@@ -5289,6 +5293,7 @@
A705C01F21D4B067004F1628 /* MWTapDetectingView.m in Sources */,
A7F3E1B421B5330F00010E23 /* XDSMenuBottomView.m in Sources */,
A7C868512112FE6B001831BA /* ZXPayCompletedController.m in Sources */,
1C9D29C92396339D00E240EB /* PYSearchSuggestionViewController.m in Sources */,
1CD9E5212283FE1200FFDA29 /* ZXBathAlert.m in Sources */,
A7F3E01E21B530F500010E23 /* ZXBookCageCell.m in Sources */,
A754365721D33182005584CC /* AppDelegate.m in Sources */,
......@@ -5299,6 +5304,7 @@
A7F3E1A821B5330F00010E23 /* XDSReadPageViewController.m in Sources */,
A72BE4B621D5CD030069C0E1 /* AlertStyleSimple.m in Sources */,
1CF4C0AF22F3CCF700944C63 /* ZXHomePageSteamCell.m in Sources */,
1C9D29CA2396339D00E240EB /* PYSearchConst.m in Sources */,
1CB3AC0F23053245006F1724 /* ZXOauthHasDCAccountViewController.m in Sources */,
A756C5A321F9B5960006E418 /* ZXNewPayLessMoneyModel.m in Sources */,
A73F429B20DC9C060074A00D /* ZXWashPayWayCell.m in Sources */,
......@@ -5334,7 +5340,6 @@
A7054B4320E398CA005537B2 /* ZXChooseView.m in Sources */,
A7DECC962079F0E30039EC22 /* ZXBannerJumpViewController.m in Sources */,
A756C5AE21F9B5960006E418 /* ZXOrderPayController.m in Sources */,
1CFDEC9A23602A9E007701A5 /* UIView+PYSearchExtension.m in Sources */,
1CC256DF234DE9A400C43041 /* ZXBQTChildViewController.m in Sources */,
1CB9AF66237102B400ED0434 /* DC_CountingDownView.m in Sources */,
A745DBEE2100303B00D0C648 /* ZXGoPutMenuCell.m in Sources */,
......@@ -5396,6 +5401,7 @@
1C3AE7C622F0482D0045C969 /* SGQRCodeScanView.m in Sources */,
A7F3E16521B5330F00010E23 /* GCDAsyncSocket.m in Sources */,
1CC15429230D5B7400582EC1 /* ZXAimiWalletAlertView.m in Sources */,
1C9D29CC2396339D00E240EB /* NSBundle+PYSearchExtension.m in Sources */,
22E36C931F558D1B00073AC2 /* FetchWalletTopUpDataModel.m in Sources */,
A75436E921D34594005584CC /* CampasVersionUpdateModel.m in Sources */,
A7F3E17421B5330F00010E23 /* HTTPMessage.m in Sources */,
......@@ -5475,7 +5481,6 @@
A7F3E1BA21B5330F00010E23 /* XDSReadViewConst.m in Sources */,
22704ACF1F48170900B8D786 /* UserCenterModel.m in Sources */,
A7C6432C216F0037003E9AE7 /* GTMBase64.m in Sources */,
1CFDEC9423602A9E007701A5 /* UIColor+PYSearchExtension.m in Sources */,
A7EB7E6A20C919FB00B0AF49 /* ZTHomeViewController+Extension.m in Sources */,
A7F3E17221B5330F00010E23 /* HTTPAuthenticationRequest.m in Sources */,
2267AF571F565D9600F7C44C /* DeleteDeviceModel.m in Sources */,
......@@ -5483,7 +5488,6 @@
A78C039620C93CD900327AFC /* New_SchoolMulityCell.m in Sources */,
A756C5CD21FAA6050006E418 /* SDCollectionViewCell.m in Sources */,
A7E632C821781D070011F2CA /* ShowAttbutsStrViewController.m in Sources */,
1CFDEC9923602A9E007701A5 /* NSBundle+PYSearchExtension.m in Sources */,
1C73BEFE22448E050078947F /* ZXBDADTableViewCell.m in Sources */,
A7F3E00F21B530F500010E23 /* ZXTopCateListController.m in Sources */,
A7F3E00621B530F500010E23 /* ZXBookOrderListManagerVc.m in Sources */,
......@@ -5504,6 +5508,7 @@
1CF4C0A622F2D00C00944C63 /* ZXAnnouceListViewController.m in Sources */,
1C394122230BC9D5005048EB /* ZXRSADCell.m in Sources */,
A7DECCA22079F0E30039EC22 /* ZXPayManager.m in Sources */,
1C9D29C72396339D00E240EB /* UIColor+PYSearchExtension.m in Sources */,
A75436EC21D346E7005584CC /* payModelItem.m in Sources */,
A7ED820220E613A000683D41 /* ZXWashOperationModel.m in Sources */,
A770521B211D231D00798513 /* ZXDrinkService.m in Sources */,
......@@ -5590,13 +5595,13 @@
1C394124230BC9D5005048EB /* ZXNewsViewController.m in Sources */,
A7FE8D7620C8F7D30028B721 /* New_OperationCell.m in Sources */,
A783E4452109BC650074623C /* ChineseString.m in Sources */,
1CFDEC9623602A9E007701A5 /* PYSearchSuggestionViewController.m in Sources */,
A75436E821D34594005584CC /* UpdateVersionModel.m in Sources */,
A7F3E00E21B530F500010E23 /* ZXColorfulTopController.m in Sources */,
1CB10F1C233C63C900F94688 /* ZXAdViewService.m in Sources */,
1CF86307230280FB0007EBC6 /* AppUpdateVersion.m in Sources */,
A756C5CB21FAA6050006E418 /* SDCycleScrollView.m in Sources */,
A7F3E19721B5330F00010E23 /* CXMLNode_XPathExtensions.m in Sources */,
1C9D29B72396093400E240EB /* ZXNewOrderDetailCell.m in Sources */,
A783E4462109BC660074623C /* pinyin.m in Sources */,
22E36C951F558D1B00073AC2 /* BeanCell.m in Sources */,
A7F3E00A21B530F500010E23 /* ZXColorfulBookController.m in Sources */,
......@@ -5720,6 +5725,7 @@
A7C579E821DEFD780074DDEA /* ZXTXAdTool.m in Sources */,
A7DF4A452105856F00A81B7E /* HMSegmentedControl.m in Sources */,
22E36CAC1F558D9800073AC2 /* RefreshBarCodeModel.m in Sources */,
1C9D29CD2396339D00E240EB /* UIView+PYSearchExtension.m in Sources */,
A75436D621D34567005584CC /* ZXChooseSchoolViewController.m in Sources */,
1C8F4A642321EFF800AAF24A /* ZXAdTool.m in Sources */,
1CB9AF6F237102B400ED0434 /* DC_ZXWashOrderModel.m in Sources */,
......@@ -5740,7 +5746,6 @@
A79C9D2C20DA2D0C00D7D18E /* WashCLoseTableViewCell.m in Sources */,
1CB9AF5E237102B400ED0434 /* DC_ZXWashPayWayCell.m in Sources */,
A7DECCE42079F7D40039EC22 /* HMScannerBorder.m in Sources */,
1CFDEC9523602A9E007701A5 /* PYSearchViewController.m in Sources */,
A7EB7E6D20C9268E00B0AF49 /* HomeSectionView.m in Sources */,
A7AB5FE220AC0C390066950A /* UIView+ADGifLoading.m in Sources */,
A705BFBF21D4AFD8004F1628 /* HTTPDataResponse.m in Sources */,
......
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "C4FA1D40-0820-4DB8-948B-CEB11FFE9947"
uuid = "24E7D5E1-10A3-487A-966B-1C35513A0621"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "3E6B07A2-DF06-4544-AD09-D2200F31F394"
uuid = "96557369-655F-42BF-AE49-2D82094721D9"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
......@@ -18,192 +18,68 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "D27F3EA6-7795-48BB-AEC3-BC5851869566"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BDAD/ZXBDTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "359"
endingLineNumber = "359"
landmarkName = "-rewardedVideoAdDidClose:withPlayingProgress:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6EDFFD59-E444-4924-805F-44A7B75E56A5"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "102"
endingLineNumber = "102"
landmarkName = "-createRewardedVideoAdWithController:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B3BFBC86-4F77-411D-BE84-00BD3C015D6F"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "106"
endingLineNumber = "106"
landmarkName = "-createRewardedVideoAdWithController:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "BCEE29E8-B1FE-4369-AB76-AD84BA29CD0D"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "110"
endingLineNumber = "110"
landmarkName = "-nativeExpressRewardedVideoAdDidLoad:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "5C1278E6-F57B-4225-854F-7DC212D99AF7"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "114"
endingLineNumber = "114"
landmarkName = "-nativeExpressRewardedVideoAd:didFailWithError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B9102605-E063-411A-B490-261C6BB8EC1D"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "118"
endingLineNumber = "118"
landmarkName = "-nativeExpressRewardedVideoAdDidDownLoadVideo:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CC0A2426-E2A6-4AF8-9FBD-0AAE82E1D665"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "122"
endingLineNumber = "122"
landmarkName = "-nativeExpressRewardedVideoAdViewRenderSuccess:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E4E4E557-6F6A-48A1-9714-0AE82D9802C1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "131"
endingLineNumber = "131"
landmarkName = "-nativeExpressRewardedVideoAdWillVisible:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E3F215BD-6FC1-4381-A634-A82FD8C922C4"
shouldBeEnabled = "Yes"
uuid = "DF65BB8E-2F5D-4744-AB64-5AD00E61C4DC"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
filePath = "ColorfulSchool/Classes/Tool(&#x5de5;&#x5177;)/ZXTool.m"
timestampString = "588735277.853282"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "127"
endingLineNumber = "127"
landmarkName = "-nativeExpressRewardedVideoAdViewRenderFail:error:"
startingLineNumber = "1765"
endingLineNumber = "1765"
landmarkName = "+alimamaTest"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "95F9AB98-B7EF-48B1-8331-903D9917B1A1"
uuid = "D8554AAF-B489-498B-BDE9-957DEC5B5AEC"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
filePath = "ColorfulSchool/Classes/JTJY(&#x91d1;&#x56fe;&#x6559;&#x80b2;)/ZXJTJYViewController.m"
timestampString = "583656856.343848"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "135"
endingLineNumber = "135"
landmarkName = "-nativeExpressRewardedVideoAdDidVisible:"
startingLineNumber = "124"
endingLineNumber = "124"
landmarkName = "-webView:didFailNavigation:withError:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "CE397208-1542-44B6-A2C4-8BA29D86045A"
uuid = "0C19F851-04D3-4B2C-8FCA-6D2C5E1F33BE"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
filePath = "ColorfulSchool/Classes/NewFirstPage(&#x65b0;&#x7248;&#x9996;&#x9875;)/Controllers/ZTHomeViewController+Extension.m"
timestampString = "585484152.378459"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "143"
endingLineNumber = "143"
landmarkName = "-nativeExpressRewardedVideoAdDidClose:"
startingLineNumber = "346"
endingLineNumber = "346"
landmarkName = "-firstPageJumpActionWithInfo:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B81B6351-6883-4D21-B0AF-38769F71763B"
uuid = "116887C0-B195-4AA1-9707-E0029E6AF773"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ColorfulSchool/Classes/AD(&#x5e7f;&#x544a;)/BUAD/BUADTool.m"
filePath = "ColorfulSchool/Classes/Operation(&#x81ea;&#x52a9;&#x670d;&#x52a1;)/appointmentBath(&#x9884;&#x7ea6;&#x6d17;&#x6d74;)/ViewModel/ZXAppointBathService.m"
timestampString = "585499296.668223"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "147"
endingLineNumber = "147"
landmarkName = "-nativeExpressRewardedVideoAdDidClick:"
startingLineNumber = "225"
endingLineNumber = "225"
landmarkName = "+dealAccountActionWithOperationMode:isBlueBath:completed:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
......
//
//
......@@ -33,5 +33,19 @@
@property (nonatomic, strong) NSArray *consumeRefundOrders;
@property (nonatomic, strong) NSArray *baseData;
@property (nonatomic, strong) NSArray *consumeData;
@end
@interface orderItem : NSObject
/** */
@property (nonatomic, copy) NSString *color;
/** */
@property (nonatomic, copy) NSString *name;
/** */
@property (nonatomic, copy) NSString *value;
@end
//
//
......@@ -9,5 +9,14 @@
#import "CommonModel.h"
@implementation CommonModel
/* 数组中存储模型数据,需要说明数组中存储的模型数据类型 */
+(NSDictionary *)mj_objectClassInArray
{
return @{@"baseData" : @"orderItem", @"consumeData" : @"orderItem"};
}
@end
@implementation orderItem
@end
//
//
......@@ -228,7 +228,6 @@
[ZXTool showText:@"设备开启成功"];
[self backToFirst];
}
}
});
}];
......@@ -246,9 +245,7 @@
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.bluetoothManager cutBluetoothAndSocketConnect];
self.bluetoothManager.delegate = nil;
self.bluetoothManager = nil;
[self.bluetoothManager closeSelf];
}
- (void)dealloc {
......
//
//
......@@ -49,6 +49,11 @@ NS_ASSUME_NONNULL_BEGIN
//主动断开 所有链接 在接口调用失败的时候使用
- (void) cutBluetoothAndSocketConnect;
//断开连接
- (void) closeSelf;
@end
NS_ASSUME_NONNULL_END
//
//
......@@ -64,8 +64,6 @@
- - clientSocket {
if (!_clientSocket) {
}
return _clientSocket;
}
......@@ -185,7 +183,7 @@
if (self.clientSocket.isConnected == NO) {
times += 0.5;
if (self.clientSocket.isConnected == NO) {
[self.clientSocket connectToHost:self.socketUrl onPort:self.socketPort viaInterface:nil withTimeout:-1 error:nil];
[self.clientSocket connectToHost:self.socketUrl onPort:self.socketPort viaInterface:nil withTimeout:-1 error:nil];
}
}
......@@ -574,6 +572,10 @@
[self.delegate startFireInterfaceByStatus:2];
}
}
} else if ([text containsString:[NSString stringWithFormat:@"[<%@,60", self.currentPeripheralName]]) {
NSLog(@"=============收到服务器发送给蓝牙的开启设备指令");
NSString *result = [[text componentsSeparatedByString:@","].lastObject stringByReplacingOccurrencesOfString:@">]" withString:@""];
[self.tempData addObject:[result dataUsingEncoding:NSUTF8StringEncoding]];
} else {
//发送给蓝牙
if (data.length > 100) {
......@@ -591,7 +593,7 @@
}
if (self.selectedPeripheral && self.currentCharacteristic) {
NSLog(@"😁开始发送队列消息--%@", self.tempData);
NSLog(@"😁=============开始发送队列消息--%@", self.tempData);
NSData *data = self.tempData[0];//去第一个
if (data.length > 20) {
......@@ -623,7 +625,7 @@
// 链接失败
- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(NSError *)err{
//重连
NSLog(@"😇😇😇😇😇😇 socket连接已经断开---%@", [ZXTool getTimeNow]);
NSLog(@"==============socket链接失败或者断开===================");
if (self.isServiceCut == NO) {
......@@ -645,7 +647,7 @@
[self.clientSocket disconnect];//断开socket
self.clientSocket.delegate = nil;
self.clientSocket = nil;
// self.centralManager.delegate = nil;
// self.centralManager = nil;
self.isServiceCut = YES;//触发服务端中断指
......@@ -667,4 +669,18 @@
}
return _tempData;
}
- (void)closeSelf {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self cutBluetoothAndSocketConnect];
self.delegate = nil;
self.centralManager.delegate = nil;
self.centralManager = nil;
self.clientSocket.delegate = nil;
self.clientSocket = nil;
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self class];
});
});
}
@end
//
//
......@@ -10,9 +10,10 @@
#import "enlargeClickRegionBtn.h"
#import "ZXNewOrderDetailTableViewCell.h"
#import "ZXNewPayOrder.h"
#import "ZXNewOrderDetailCell.h"
@interface ZXNewOrderDetailViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) ZXNewPayOrder *order;
@property (nonatomic, strong) CommonModel *order;
@end
......@@ -24,19 +25,43 @@
[self createNabar];
[self.view addSubview:self.myTableView];
[ZXTool requestDataWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/consumeOrder/getDetail?id=%ld", [kUserDefaults objectForKey:@"NEW_PAY"], (long)self.orderId] para:nil completed:^(CommonModel *common, NSString *error) {
// [ZXTool requestDataWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/consumeOrder/getDetail?id=%ld", [kUserDefaults objectForKey:@"NEW_PAY"], (long)self.orderId] para:nil completed:^(CommonModel *common, NSString *error) {
// dispatch_async(dispatch_get_main_queue(), ^{
// [ZXTool hideLoadingAnimation];
// if (error) {
// [ZXTool showErrorMsg:error];
// } else {
// ZXNewPayOrder *order = [ZXNewPayOrder mj_objectWithKeyValues:common.data];
// order.tkData = common.consumeRefundOrders;
// self.order = order;
// [self.myTableView reloadData];
// }
// });
// }];
[ZXTool requestDataWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/consumeOrder/getDetailNew?id=%ld", [kUserDefaults objectForKey:@"NEW_PAY"], (long)self.orderId] para:nil completed:^(CommonModel *common, NSString *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool hideLoadingAnimation];
if (error) {
[ZXTool showErrorMsg:error];
} else {
ZXNewPayOrder *order = [ZXNewPayOrder mj_objectWithKeyValues:common.data];
order.tkData = common.consumeRefundOrders;
self.order = order;
for (orderItem *item in common.baseData) {
if (!item.color || [item.color isEqualToString:@""] || [item.color isKindOfClass:[NSNull class]] || [item.color isEqualToString:@"null"] || [item.color isEqualToString:@"<null>"]) {
item.color = @"#333333";
}
}
for (orderItem *item in common.consumeData) {
if (!item.color || [item.color isEqualToString:@""] || [item.color isKindOfClass:[NSNull class]] || [item.color isEqualToString:@"null"] || [item.color isEqualToString:@"<null>"]) {
item.color = @"#333333";
}
}
self.order = common;
[self.myTableView reloadData];
}
});
}];
}
- (void) createNabar {
self.view.backgroundColor = [UIColor whiteColor];
......@@ -97,12 +122,19 @@
return self.order?1:0;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ZXNewOrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZXNewOrderDetailTableViewCell"];
// ZXNewOrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZXNewOrderDetailTableViewCell"];
// if (cell == nil) {
// cell = [[ZXNewOrderDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ZXNewOrderDetailTableViewCell"];
// }
// cell.orderDetail = self.order;
// return cell;
ZXNewOrderDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ZXNewOrderDetailCell"];
if (cell == nil) {
cell = [[ZXNewOrderDetailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ZXNewOrderDetailTableViewCell"];
cell = [[ZXNewOrderDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ZXNewOrderDetailCell"];
}
cell.order = self.order;
cell.orderDetail = self.order;
return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 470 * k6Scale;
......
//
//
// ZXNewOrderDetailCell.h
// ColorfulSchool
//
// Created by 刘卓鑫 on 2019/12/3.
// Copyright © 2019 Colorful Any Door. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZXNewOrderDetailCell : UITableViewCell
@property (nonatomic, strong) CommonModel *orderDetail;
@end
NS_ASSUME_NONNULL_END
//
//
// ZXNewOrderDetailTableViewCell.m
// ColorfulSchool
//
// Created by liuZX on 2019/1/8.
// Copyright © 2019年 Colorful Any Door. All rights reserved.
//
#import "ZXNewOrderDetailCell.h"
@interface ZXNewOrderDetailCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *base1LeftLabel;
@property (nonatomic, strong) UILabel *base1RightLabel;
@property (nonatomic, strong) UILabel *base2LeftLabel;
@property (nonatomic, strong) UILabel *base2RightLabel;
@property (nonatomic, strong) UILabel *base3LeftLabel;
@property (nonatomic, strong) UILabel *base3RightLabel;
@property (nonatomic, strong) UILabel *base4LeftLabel;
@property (nonatomic, strong) UILabel *base4RightLabel;
@property (nonatomic, strong) UILabel *base5LeftLabel;
@property (nonatomic, strong) UILabel *base5RightLabel;
@property (nonatomic, strong) UILabel *base6LeftLabel;
@property (nonatomic, strong) UILabel *base6RightLabel;
@property (nonatomic, strong) UILabel *firstLeftLabel;
@property (nonatomic, strong) UILabel *secondLeftLabel;
@property (nonatomic, strong) UILabel *thirdLeftLabel;
@property (nonatomic, strong) UILabel *fourthLeftLabel;
@property (nonatomic, strong) UILabel *fifthLeftLabel;
@property (nonatomic, strong) UILabel *sixthLeftLabel;
@property (nonatomic, strong) UILabel *seventhLeftLabel;
@property (nonatomic, strong) UILabel *eightLeftLabel;
@property (nonatomic, strong) UILabel *firstRightLabel;
@property (nonatomic, strong) UILabel *secondRightabel;
@property (nonatomic, strong) UILabel *thirdRightLabel;
@property (nonatomic, strong) UILabel *fourthRightLabel;
@property (nonatomic, strong) UILabel *fifthRightLabel;
@property (nonatomic, strong) UILabel *sixthRightLabel;
@property (nonatomic, strong) UILabel *seventhRightLabel;
@property (nonatomic, strong) UILabel *eightRightLabel;
@end
@implementation ZXNewOrderDetailCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
//2019 12 3日 11:35 王进需求 暂时注释
// UILabel *label1 = [[UILabel alloc] init];
// [self.contentView addSubview:label1];
// label1.textColor = kTitleBlackColor;
// label1.font = kFontSize(14 * k6Scale);
// label1.text = @"成都多彩任意门科技有限公司";
// [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
// make.centerX.equalTo(self.contentView);
// make.top.mas_equalTo(self.contentView.mas_top).offset(21 * k6Scale);
// }];
// UIImageView *icon = [[UIImageView alloc] init];
// [self.contentView addSubview:icon];
// icon.image = [UIImage imageNamed:@"pay_logo_icon"];
// [icon mas_makeConstraints:^(MASConstraintMaker *make) {
// make.right.equalTo(label1.mas_left).offset(-8 * k6Scale);
// make.centerY.equalTo(label1);
// make.width.mas_equalTo(21 * k6Scale);
// make.height.mas_equalTo(18 * k6Scale);
// }];
self.titleLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.titleLabel];
self.titleLabel.textColor = kTitleBlackColor;
self.titleLabel.font = [UIFont boldSystemFontOfSize:20 * k6Scale];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.mas_equalTo(self.contentView.mas_top).offset(30 * k6Scale);
}];
self.base1LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base1LeftLabel];
self.base1LeftLabel.textColor = kContentGrayColor;
self.base1LeftLabel.font = kFontSize(14 * k6Scale);
self.base1LeftLabel.text = @"商品说明";
[self.base1LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(15 * k6Scale);
}];
self.base1RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base1RightLabel];
self.base1RightLabel.textColor = kContentGrayColor;
self.base1RightLabel.font = kFontSize(14 * k6Scale);
[self.base1RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.base1LeftLabel);
}];
self.base2LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base2LeftLabel];
self.base2LeftLabel.textColor = kContentGrayColor;
self.base2LeftLabel.font = kFontSize(14 * k6Scale);
self.base2LeftLabel.text = @"消费时间";
[self.base2LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.base1LeftLabel.mas_left);
make.top.mas_equalTo(self.base1LeftLabel.mas_bottom).offset(7 * k6Scale);
}];
self.base2RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base2RightLabel];
self.base2RightLabel.textColor = kContentGrayColor;
self.base2RightLabel.font = kFontSize(14 * k6Scale);
[self.base2RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.base2LeftLabel);
}];
self.base3LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base3LeftLabel];
self.base3LeftLabel.textColor = kContentGrayColor;
self.base3LeftLabel.font = kFontSize(14 * k6Scale);
self.base3LeftLabel.text = @"订单号";
[self.base3LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.base2LeftLabel.mas_left);
make.top.mas_equalTo(self.base2LeftLabel.mas_bottom).offset(7 * k6Scale);
}];
self.base3RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base3RightLabel];
self.base3RightLabel.textColor = kContentGrayColor;
self.base3RightLabel.font = kFontSize(14 * k6Scale);
[self.base3RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.base3LeftLabel);
}];
self.base4LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base4LeftLabel];
self.base4LeftLabel.textColor = kContentGrayColor;
self.base4LeftLabel.font = kFontSize(14 * k6Scale);
self.base4LeftLabel.text = @"所属区域";
[self.base4LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.base3LeftLabel.mas_left);
make.top.mas_equalTo(self.base3LeftLabel.mas_bottom).offset(7 * k6Scale);
}];
self.base4RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base4RightLabel];
self.base4RightLabel.textColor = kContentGrayColor;
self.base4RightLabel.font = kFontSize(14 * k6Scale);
[self.base4RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(_base4LeftLabel);
}];
self.base5LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base5LeftLabel];
self.base5LeftLabel.textColor = kContentGrayColor;
self.base5LeftLabel.font = kFontSize(14 * k6Scale);
self.base5LeftLabel.text = @"设备编号";
[self.base5LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.base4LeftLabel.mas_left);
make.top.mas_equalTo(self.base4LeftLabel.mas_bottom).offset(7 * k6Scale);
}];
self.base5RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base5RightLabel];
self.base5RightLabel.textColor = kContentGrayColor;
self.base5RightLabel.font = kFontSize(14 * k6Scale);
[self.base5RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.base5LeftLabel);
}];
self.base6LeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base6LeftLabel];
self.base6LeftLabel.textColor = kContentGrayColor;
self.base6LeftLabel.font = kFontSize(14 * k6Scale);
self.base6LeftLabel.text = @"设备位置";
[self.base6LeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.base5LeftLabel.mas_left);
make.top.mas_equalTo(self.base5LeftLabel.mas_bottom).offset(7 * k6Scale);
}];
self.base6RightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.base6RightLabel];
self.base6RightLabel.textColor = kContentGrayColor;
self.base6RightLabel.font = kFontSize(14 * k6Scale);
[self.base6RightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.width.mas_lessThanOrEqualTo(250 * k6Scale);
make.centerY.equalTo(self.base6LeftLabel);
}];
UIImageView *line = [[UIImageView alloc] init];
[self.contentView addSubview:line];
line.image = [UIImage imageNamed:@"xiangqing_xuxian_bg"];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_base6LeftLabel.mas_left);
make.right.equalTo(self.base6RightLabel.mas_right);
make.top.equalTo(self.base6RightLabel.mas_bottom).offset(14 * k6Scale);
make.height.mas_equalTo(1);
}];
self.firstLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.firstLeftLabel];
self.firstLeftLabel.textColor = kTitleBlackColor;
self.firstLeftLabel.font = kFontSize(14 * k6Scale);
[self.firstLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(line).offset(12 * k6Scale);
}];
self.firstRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.firstRightLabel];
self.firstRightLabel.textColor = kTitleBlackColor;
self.firstRightLabel.font = kFontSize(14 * k6Scale);
[self.firstRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.firstLeftLabel);
}];
self.secondLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.secondLeftLabel];
self.secondLeftLabel.textColor = kTitleBlackColor;
self.secondLeftLabel.font = kFontSize(14 * k6Scale);
[self.secondLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.firstLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.secondRightabel = [[UILabel alloc] init];
[self.contentView addSubview:self.secondRightabel];
self.secondRightabel.textColor = kTitleBlackColor;
self.secondRightabel.font = kFontSize(14 * k6Scale);
[self.secondRightabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.secondLeftLabel);
}];
self.thirdLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.thirdLeftLabel];
self.thirdLeftLabel.textColor = kTitleBlackColor;
self.thirdLeftLabel.font = kFontSize(14 * k6Scale);
[self.thirdLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.secondLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.thirdRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.thirdRightLabel];
self.thirdRightLabel.textColor = kTitleBlackColor;
self.thirdRightLabel.font = kFontSize(14 * k6Scale);
[self.thirdRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.thirdLeftLabel);
}];
self.fourthLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.fourthLeftLabel];
self.fourthLeftLabel.textColor = kTitleBlackColor;
self.fourthLeftLabel.font = kFontSize(14 * k6Scale);
[self.fourthLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.thirdLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.fourthRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.fourthRightLabel];
self.fourthRightLabel.textColor = kTitleBlackColor;
self.fourthRightLabel.font = kFontSize(14 * k6Scale);
[self.fourthRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.fourthLeftLabel);
}];
self.fifthLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.fifthLeftLabel];
self.fifthLeftLabel.textColor = kTitleBlackColor;
self.fifthLeftLabel.font = kFontSize(14 * k6Scale);
[self.fifthLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.fourthLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.fifthRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.fifthRightLabel];
self.fifthRightLabel.textColor = kTitleBlackColor;
self.fifthRightLabel.font = kFontSize(14 * k6Scale);
[self.fifthRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.fifthLeftLabel);
}];
self.sixthLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.sixthLeftLabel];
self.sixthLeftLabel.textColor = kTitleBlackColor;
self.sixthLeftLabel.font = kFontSize(14 * k6Scale);
[self.sixthLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.fifthLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.sixthRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.sixthRightLabel];
self.sixthRightLabel.textColor = kTitleBlackColor;
self.sixthRightLabel.font = kFontSize(14 * k6Scale);
[self.sixthRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.sixthLeftLabel);
}];
self.seventhLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.seventhLeftLabel];
self.seventhLeftLabel.textColor = kTitleBlackColor;
self.seventhLeftLabel.font = kFontSize(14 * k6Scale);
[self.seventhLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.sixthLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.seventhRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.seventhRightLabel];
self.seventhRightLabel.textColor = kTitleBlackColor;
self.seventhRightLabel.font = kFontSize(14 * k6Scale);
[self.seventhRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.seventhLeftLabel);
}];
self.eightLeftLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.eightLeftLabel];
self.eightLeftLabel.textColor = kTitleBlackColor;
self.eightLeftLabel.font = kFontSize(14 * k6Scale);
[self.eightLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.mas_left).offset(16 * k6Scale);
make.top.mas_equalTo(self.seventhLeftLabel.mas_bottom).offset(10 * k6Scale);
}];
self.eightRightLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.eightRightLabel];
self.eightRightLabel.textColor = kTitleBlackColor;
self.eightRightLabel.font = kFontSize(14 * k6Scale);
[self.eightRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.centerY.equalTo(self.eightLeftLabel);
}];
}
return self;
}
- (void)setOrderDetail:(CommonModel *)orderDetail {
_orderDetail = orderDetail;
self.titleLabel.text = _orderDetail.title;
for (int i = 0; i < _orderDetail.baseData.count; i++) {
orderItem *item = _orderDetail.baseData[i];
if (i == 0) {
self.base1LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base1RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 1) {
self.base2LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base2RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 2) {
self.base3LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base3RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 3) {
self.base4LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base4RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 4) {
self.base5LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base5RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 5) {
self.base6LeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.base6RightLabel.attributedText = [self toAtts:item.value textColor:item.color];
}
}
for (int i = 0; i < _orderDetail.consumeData.count; i++) {
orderItem *item = _orderDetail.consumeData[i];
if (i == 0) {
self.firstLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.firstRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 1) {
self.secondLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.secondRightabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 2) {
self.thirdLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.thirdRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 3) {
self.fourthLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.fourthRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 4) {
self.fifthLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.fifthRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 5) {
self.sixthLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.sixthRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 6) {
self.seventhLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.seventhRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
} else if (i == 7) {
self.eightLeftLabel.attributedText = [self toAtts:item.name textColor:item.color];
self.eightRightLabel.attributedText = [self toAtts:item.value textColor:item.color];
}
}
}
- (NSAttributedString *) toAtts:(NSString *) str textColor:(NSString *) color {
return [[NSAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:color]}];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
//
//
......@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface ZXNewOrderDetailTableViewCell : UITableViewCell
@property (nonatomic, strong) ZXNewPayOrder *order;
@property (nonatomic, strong) CommonModel *orderDetail;
@end
NS_ASSUME_NONNULL_END
//
//
......@@ -176,15 +176,14 @@
}];
self.deviceAddressLabel = [[UILabel alloc] init];
[self.contentView addSubview:self.deviceAddressLabel];
self.deviceAddressLabel.textColor = kContentGrayColor;
self.deviceAddressLabel.font = kFontSize(14 * k6Scale);
[self.deviceAddressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.contentView.mas_right).offset(-16 * k6Scale);
make.left.equalTo(label7.mas_right).offset(10 * k6Scale);
make.width.mas_lessThanOrEqualTo(250 * k6Scale);
make.centerY.equalTo(label7);
}];
[label7 setContentCompressionResistancePriority:UILayoutPriorityRequired
forAxis:UILayoutConstraintAxisHorizontal];
UIImageView *line = [[UIImageView alloc] init];
[self.contentView addSubview:line];
......@@ -341,7 +340,11 @@
self.thirdRightLabel.textColor = kTitleBlackColor;
BOOL isHasTK = _order.tkData.count;//是否有退款
NSString *refundMoney;
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
refundMoney = [NSString stringWithFormat:@"-%.2f", [dic[@"refundMoney"] doubleValue]];
}
//同时抵扣豆和艾米
if (_order.deductionBean > 0 && _order.deductionMoney > 0) {
......@@ -360,7 +363,6 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.sixthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.sixthRightLabel.attributedText = [self toAtts:refundMoney];
......@@ -386,7 +388,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fifthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.fifthRightLabel.attributedText = [self toAtts:refundMoney];
self.sixthLeftLabel.text = @"支付时间";
......@@ -422,7 +424,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fifthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.fifthRightLabel.attributedText = [self toAtts:refundMoney];
......@@ -448,7 +450,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fourthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.fourthRightLabel.attributedText = [self toAtts:refundMoney];
......@@ -484,7 +486,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fifthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.fifthRightLabel.attributedText = [self toAtts:refundMoney];
self.sixthLeftLabel.text = @"支付时间";
......@@ -512,7 +514,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fourthLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.fourthRightLabel.attributedText = [self toAtts:refundMoney];
......@@ -543,7 +545,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.fourthLeftLabel.text = tkType==1?@"全部退款":@"部分退款";
self.fourthRightLabel.text = refundMoney;
self.fifthLeftLabel.text = @"支付时间";
......@@ -568,7 +570,7 @@
if (isHasTK) {
NSDictionary *dic = _order.tkData.firstObject;
NSInteger tkType = [dic[@"refundState"] integerValue];
NSString *refundMoney = [@"-" stringByAppendingString:[dic[@"refundMoney"] stringValue]];
self.thirdLeftLabel.attributedText = tkType==1?[self toAtts:@"全部退款"]:[self toAtts:@"部分退款"];
self.thirdRightLabel.attributedText = [self toAtts:refundMoney];
self.fourthLeftLabel.text = @"支付时间";
......@@ -599,6 +601,11 @@
self.deviceAddressLabel.text = _order.equipmentPosition;
}
- (void)setOrderDetail:(CommonModel *)orderDetail {
_orderDetail = orderDetail;
self.moneyLabel.text = _orderDetail.title;
}
- (NSString *) payType:(ZXNewPayOrder *) typeModel {
NSString *type = typeModel.payType;
......
//
//
......@@ -49,7 +49,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
}
#pragma mark - 是否需要展示第三方登录按钮
......@@ -401,11 +401,11 @@
[UIApplication sharedApplication].statusBarStyle = 0;
self.navigationController.navigationBar.hidden = YES;
[UIApplication sharedApplication].statusBarHidden = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_AUTH_RESULT object:nil];
}
#pragma mark - 微信授权成功
- (void) aouthSuccess:(NSNotification *) nof {
......@@ -473,6 +473,10 @@
};
[self.navigationController pushViewController:oauthVc animated:YES];
}
} else {
dispatch_async(dispatch_get_main_queue(), ^{
[ZXTool showText:error];
});
}
});
......
//
//
......@@ -20,6 +20,9 @@ kSINGLETON_FOR_HEADER(ZXTaskManager)
@property (nonatomic, assign) NSInteger status;
/** 任务是否完成 */
@property (nonatomic, assign) BOOL isTaskCompleted;
@end
NS_ASSUME_NONNULL_END
//
//
......@@ -30,6 +30,11 @@
/** */
@property (nonatomic, copy) NSString *wxCode;
/** */
@property (nonatomic, strong) UIView *adSuperView;
@end
@implementation ZXTaskViewController
......@@ -46,8 +51,7 @@
[self preloadCSJRewardAd];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
......@@ -83,12 +87,14 @@
}
#pragma mark - 添加广告
- (void) addBannerAd {
[ZXTool requestDataHideLoadingToastWithType:kXMHTTPMethodGET url:[NSString stringWithFormat:@"%@/advert/get/initdata?pageNo=TASK_PAGE", [kUserDefaults objectForKey:@"Task"]] para:nil completed:^(CommonModel *common, NSString *error) {
if (common && common.data && common.data[@"adverts"]) {
NSArray *arr = common.data[@"adverts"];
for (NSDictionary *dic in arr) {
if ([dic[@"type"] integerValue] == 5) {
dispatch_async(dispatch_get_main_queue(), ^{
[self createBannerAd];
});
}
......@@ -98,28 +104,35 @@
}
#pragma mark - 创建广告
- (void) createBannerAd {
UIView *adSuperView = [[UIView alloc] init];
[self.view addSubview:adSuperView];
adSuperView.backgroundColor = UIColor.whiteColor;
[adSuperView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.height.mas_equalTo(kScreenWidth * 0.15);
make.bottom.equalTo(self.view.mas_bottom).offset(self.isTaskHomePage?-kTabBarHeight:0);
}];
if (self.adSuperView == nil) {
self.adSuperView = [[UIView alloc] init];
[self.view addSubview:self.adSuperView];
self.adSuperView.backgroundColor = UIColor.whiteColor;
[self.adSuperView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.height.mas_equalTo(kScreenWidth * 0.15);
make.bottom.equalTo(self.view.mas_bottom).offset(self.isTaskHomePage?-kTabBarHeight:0);
}];
enlargeClickRegionBtn *closeButton = [[enlargeClickRegionBtn alloc] init];
[adSuperView addSubview:closeButton];
[closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.equalTo(adSuperView);
make.width.height.mas_equalTo(30 * k6Scale);
}];
[self.adSuperView addSubview:closeButton];
[closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.equalTo(self.adSuperView);
make.width.height.mas_equalTo(30 * k6Scale);
}];
[[closeButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
adSuperView.hidden = YES;
[adSuperView removeFromSuperview];
self.adSuperView.hidden = YES;
}];
[[[BUADTool alloc] init] loadBannerAdWithController:self superView:adSuperView];
}
for (UIView *v in self.adSuperView.subviews) {
if (![v isKindOfClass:[enlargeClickRegionBtn class]]) {
[v removeFromSuperview];
}
}
self.adSuperView.hidden = NO;
[[[BUADTool alloc] init] loadBannerAdWithController:self superView:self.adSuperView];
}
#pragma mark - ========== 加载失败的时候 创建holder ==========
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error {
......@@ -184,11 +197,13 @@
NSArray *arr = message.body;
NSString *classStr = arr[3];
NSInteger taskType = [arr[1] integerValue];
if (taskType == 3 && ([classStr isEqualToString:@""] || classStr == nil)) {
return;
}
self.jsFuncName = arr[0];
[ZXTaskManager sharedZXTaskManager].taskCode = arr[2];
[ZXTaskManager sharedZXTaskManager].isTaskCompleted = (taskType == 3);
switch (taskType) {
case 1: {//激励视频
[self taskRewardVideo];
......@@ -283,6 +298,8 @@
if (@available(iOS 11, *)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:kWX_AUTH_RESULT object:nil];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
......@@ -293,9 +310,12 @@
[self ba_JS_OC];
//如果有任务id 代表还有任务完成需要提示
if (ZXTaskManager.sharedZXTaskManager.taskCode && ![ZXTaskManager.sharedZXTaskManager.taskCode isEqualToString:@""]) {
if (ZXTaskManager.sharedZXTaskManager.taskCode && ![ZXTaskManager.sharedZXTaskManager.taskCode isEqualToString:@""] && ZXTaskManager.sharedZXTaskManager.isTaskCompleted) {
[self taskCompleted];
}
ZXTaskManager.sharedZXTaskManager.isTaskCompleted = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aouthSuccess:) name:kWX_AUTH_RESULT object:nil];
}
- (void)didReceiveMemoryWarning {
......@@ -313,7 +333,7 @@
- (void) preloadCSJRewardAd {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];
model.userId = @"123";
model.userId = CacheUserId;
self.rewardedAd = [[BUNativeExpressRewardedVideoAd alloc] initWithSlotID:@"933112439" rewardedVideoModel:model];
self.rewardedAd.delegate = self;
[self.rewardedAd loadAdData];
......@@ -329,7 +349,6 @@
[self.rewardedAd showAdFromRootViewController:self.navigationController];
[self.reward load];
}
}
#pragma mark - BUNativeExpressRewardedVideoAdDelegate
......@@ -365,7 +384,7 @@
- (void)nativeExpressRewardedVideoAdWillClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
//关闭视频
[ZXTaskManager sharedZXTaskManager].isTaskCompleted = 1;
}
- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
......@@ -449,8 +468,6 @@
}
});
}];
}
#pragma mark - 回调前端已经任务完成
......@@ -501,6 +518,9 @@
if (error) {
[ZXTool showText:error];
} else {
if (self.jsFuncName == nil || [self.jsFuncName isEqualToString:@""]) {
self.jsFuncName = @"bindWechatCallback";
}
[self.webView evaluateJavaScript:[NSString stringWithFormat:@"%@()", self.jsFuncName] completionHandler:^(id _Nullable res, NSError * _Nullable error) {
}];
......
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NSBundle (PYSearchExtension)
/**
Get the localized string
@param key key for localized string
@return a localized string
*/
+ (NSString *)py_localizedStringForKey:(NSString *)key;
/**
Get the path of `PYSearch.bundle`.
@return path of the `PYSearch.bundle`
*/
+ (NSBundle *)py_searchBundle;
/**
Get the image in the `PYSearch.bundle` path
@param name name of image
@return a image
*/
+ (UIImage *)py_imageNamed:(NSString *)name;
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "NSBundle+PYSearchExtension.h"
#import "PYSearchViewController.h"
@implementation NSBundle (PYSearchExtension)
+ (NSBundle *)py_searchBundle
{
static NSBundle *searchBundle = nil;
if (nil == searchBundle) {
//Default use `[NSBundle mainBundle]`.
searchBundle = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"PYSearch" ofType:@"bundle"]];
/**
If you use pod import and configure `use_frameworks` in Podfile, [NSBundle mainBundle] does not load the `PYSearch.fundle` resource file in `PYSearch.framework`.
*/
if (nil == searchBundle) { // Empty description resource file in `PYSearch.framework`.
searchBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[PYSearchViewController class]] pathForResource:@"PYSearch" ofType:@"bundle"]];
}
}
return searchBundle;
}
+ (NSString *)py_localizedStringForKey:(NSString *)key;
{
return [self py_localizedStringForKey:key value:nil];
}
+ (NSString *)py_localizedStringForKey:(NSString *)key value:(NSString *)value
{
static NSBundle *bundle = nil;
if (nil == bundle) {
NSString *language = [NSLocale preferredLanguages].firstObject;
if ([language hasPrefix:@"en"]) language = @"en";
else if ([language hasPrefix:@"es"]) language = @"es";
else if ([language hasPrefix:@"fr"]) language = @"fr";
else if ([language hasPrefix:@"zh"]) {
if ([language rangeOfString:@"Hans"].location != NSNotFound) {
language = @"zh-Hans";
} else {
language = @"zh-Hant";
}
} else {
language = @"en";
}
// Find resources from `PYSearch.bundle`
bundle = [NSBundle bundleWithPath:[[NSBundle py_searchBundle] pathForResource:language ofType:@"lproj"]];
}
value = [bundle localizedStringForKey:key value:value table:nil];
return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil];
}
+ (UIImage *)py_imageNamed:(NSString *)name
{
CGFloat scale = [[UIScreen mainScreen] scale];
name = 3.0 == scale ? [NSString stringWithFormat:@"%@@3x.png", name] : [NSString stringWithFormat:@"%@@2x.png", name];
UIImage *image = [UIImage imageWithContentsOfFile:[[[NSBundle py_searchBundle] resourcePath] stringByAppendingPathComponent:name]];
return image;
}
@end
"PYSearchSearchPlaceholderText" = "Search content";
"PYSearchSearchPlaceholderText" = "Search content";
"PYSearchHotSearchText" = "Popular searches";
"PYSearchSearchHistoryText" = "Search history";
"PYSearchEmptySearchHistoryText" = "Clear the search history";
"PYSearchEmptyButtonText" = "Clear";
"PYSearchEmptySearchHistoryLogText" = "Clear the search history";
"PYSearchCancelButtonText" = "Cancel";
"PYSearchBackButtonText" = "Back";
"PYSearchSearchPlaceholderText" = "Buscar contenido";
"PYSearchSearchPlaceholderText" = "Buscar contenido";
"PYSearchHotSearchText" = "Búsquedas populares";
"PYSearchSearchHistoryText" = "Buscar Historia";
"PYSearchEmptySearchHistoryText" = "Borrar el historial de búsqueda";
"PYSearchEmptyButtonText" = "Borrar";
"PYSearchEmptySearchHistoryLogText" = "Borrar el historial de búsqueda";
"PYSearchCancelButtonText" = "Cancelar";
"PYSearchBackButtonText" = "Volver a";
"PYSearchSearchPlaceholderText" = "Recherche de contenu";
"PYSearchSearchPlaceholderText" = "Recherche de contenu";
"PYSearchHotSearchText" = "Recherches populaires";
"PYSearchSearchHistoryText" = "Historique des recherches";
"PYSearchEmptySearchHistoryText" = "Effacer l'historique des recherches";
"PYSearchEmptyButtonText" = "Effacer";
"PYSearchEmptySearchHistoryLogText" = "Effacer l'historique des recherches";
"PYSearchCancelButtonText" = "Annuler";
"PYSearchBackButtonText" = "Retour à";
"PYSearchSearchPlaceholderText" = "搜索內容";
"PYSearchSearchPlaceholderText" = "搜索內容";
"PYSearchHotSearchText" = "熱門搜索";
"PYSearchSearchHistoryText" = "搜索歷史";
"PYSearchEmptySearchHistoryText" = "清空搜索歷史";
"PYSearchEmptyButtonText" = "清空";
"PYSearchEmptySearchHistoryLogText" = "清空搜索歷史";
"PYSearchCancelButtonText" = "取消";
"PYSearchBackButtonText" = "返回";
//
//
// 代码地址: https://github.com/iphone5solo/PYSearch
// 代码地址: http://www.code4app.com/thread-11175-1-1.html
// Created by CoderKo1o.
// Copyright © 2016年 iphone5solo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "PYSearchViewController.h"
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "UIView+PYSearchExtension.h"
#import "UIColor+PYSearchExtension.h"
#import "NSBundle+PYSearchExtension.h"
#define PYSEARCH_MARGIN 10
#define PYSEARCH_BACKGROUND_COLOR PYSEARCH_COLOR(255, 255, 255)
#ifdef DEBUG
#define PYSEARCH_LOG(...) NSLog(__VA_ARGS__)
#else
#define PYSEARCH_LOG(...)
#endif
#define PYSEARCH_COLOR(r,g,b) [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:1.0]
#define PYSEARCH_RANDOM_COLOR PYSEARCH_COLOR(arc4random_uniform(256),arc4random_uniform(256),arc4random_uniform(256))
#define PYSEARCH_DEPRECATED(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)
#define PYSEARCH_REALY_SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define PYSEARCH_REALY_SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define PYScreenW (PYSEARCH_REALY_SCREEN_WIDTH < PYSEARCH_REALY_SCREEN_HEIGHT ? PYSEARCH_REALY_SCREEN_WIDTH : PYSEARCH_REALY_SCREEN_HEIGHT)
#define PYScreenH (PYSEARCH_REALY_SCREEN_WIDTH > PYSEARCH_REALY_SCREEN_HEIGHT ? PYSEARCH_REALY_SCREEN_WIDTH : PYSEARCH_REALY_SCREEN_HEIGHT)
#define PYSEARCH_SCREEN_SIZE CGSizeMake(PYScreenW, PYScreenH)
#define PYSEARCH_SEARCH_HISTORY_CACHE_PATH [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"PYSearchhistories.plist"] // the path of search record cached
UIKIT_EXTERN NSString *const PYSearchSearchPlaceholderText;
UIKIT_EXTERN NSString *const PYSearchHotSearchText;
UIKIT_EXTERN NSString *const PYSearchSearchHistoryText;
UIKIT_EXTERN NSString *const PYSearchEmptySearchHistoryText;
UIKIT_EXTERN NSString *const PYSearchEmptyButtonText;
UIKIT_EXTERN NSString *const PYSearchEmptySearchHistoryLogText;
UIKIT_EXTERN NSString *const PYSearchCancelButtonText;
UIKIT_EXTERN NSString *const PYSearchBackButtonText;
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
NSString *const PYSearchSearchPlaceholderText = @"PYSearchSearchPlaceholderText";
NSString *const PYSearchHotSearchText = @"PYSearchHotSearchText";
NSString *const PYSearchSearchHistoryText = @"PYSearchSearchHistoryText";
NSString *const PYSearchEmptySearchHistoryText = @"PYSearchEmptySearchHistoryText";
NSString *const PYSearchEmptyButtonText = @"PYSearchEmptyButtonText";
NSString *const PYSearchEmptySearchHistoryLogText = @"PYSearchEmptySearchHistoryLogText";
NSString *const PYSearchCancelButtonText = @"PYSearchCancelButtonText";
NSString *const PYSearchBackButtonText = @"PYSearchBackButtonText";
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void(^PYSearchSuggestionDidSelectCellBlock)(UITableViewCell *selectedCell);
@protocol PYSearchSuggestionViewDataSource <NSObject, UITableViewDataSource>
@required
- (UITableViewCell *)searchSuggestionView:(UITableView *)searchSuggestionView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
- (NSInteger)searchSuggestionView:(UITableView *)searchSuggestionView numberOfRowsInSection:(NSInteger)section;
@optional
- (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)searchSuggestionView;
- (CGFloat)searchSuggestionView:(UITableView *)searchSuggestionView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
@interface PYSearchSuggestionViewController : UITableViewController
@property (nonatomic, weak) id<PYSearchSuggestionViewDataSource> dataSource;
@property (nonatomic, copy) NSArray<NSString *> *searchSuggestions;
@property (nonatomic, copy) PYSearchSuggestionDidSelectCellBlock didSelectCellBlock;
+ (instancetype)searchSuggestionViewControllerWithDidSelectCellBlock:(PYSearchSuggestionDidSelectCellBlock)didSelectCellBlock;
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "PYSearchSuggestionViewController.h"
#import "PYSearchConst.h"
@interface PYSearchSuggestionViewController ()
@property (nonatomic, assign) UIEdgeInsets originalContentInsetWhenKeyboardShow;
@property (nonatomic, assign) UIEdgeInsets originalContentInsetWhenKeyboardHidden;
@property (nonatomic, assign) BOOL keyboardDidShow;
@end
@implementation PYSearchSuggestionViewController
+ (instancetype)searchSuggestionViewControllerWithDidSelectCellBlock:(PYSearchSuggestionDidSelectCellBlock)didSelectCellBlock
{
PYSearchSuggestionViewController *searchSuggestionVC = [[self alloc] init];
searchSuggestionVC.didSelectCellBlock = didSelectCellBlock;
searchSuggestionVC.automaticallyAdjustsScrollViewInsets = NO;
return searchSuggestionVC;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
if ([self.tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) { // For the adapter iPad
self.tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradFrameDidShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradFrameDidHidden:) name:UIKeyboardDidHideNotification object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if (self.keyboardDidShow) {
self.originalContentInsetWhenKeyboardShow = self.tableView.contentInset;
} else {
self.originalContentInsetWhenKeyboardHidden = self.tableView.contentInset;
}
}
- (void)keyboradFrameDidShow:(NSNotification *)notification
{
self.keyboardDidShow = YES;
[self setSearchSuggestions:_searchSuggestions];
}
- (void)keyboradFrameDidHidden:(NSNotification *)notification
{
self.keyboardDidShow = NO;
self.originalContentInsetWhenKeyboardHidden = UIEdgeInsetsMake(-30, 0, 30, 0);
[self setSearchSuggestions:_searchSuggestions];
}
#pragma mark - setter
- (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions
{
_searchSuggestions = [searchSuggestions copy];
[self.tableView reloadData];
/**
* Adjust the searchSugesstionView when the keyboard changes.
* more information can see : https://github.com/iphone5solo/PYSearch/issues/61
*/
if (self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) {
self.tableView.contentInset = self.originalContentInsetWhenKeyboardShow;
} else if (!self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) {
self.tableView.contentInset = self.originalContentInsetWhenKeyboardHidden;
}
self.tableView.contentOffset = CGPointMake(0, -self.tableView.contentInset.top);
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0) { // iOS 11
self.tableView.contentInset = UIEdgeInsetsMake(-30, 0, 0, 0);
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if ([self.dataSource respondsToSelector:@selector(numberOfSectionsInSearchSuggestionView:)]) {
return [self.dataSource numberOfSectionsInSearchSuggestionView:tableView];
}
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:numberOfRowsInSection:)]) {
return [self.dataSource searchSuggestionView:tableView numberOfRowsInSection:section];
}
return self.searchSuggestions.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) {
UITableViewCell *cell= [self.dataSource searchSuggestionView:tableView cellForRowAtIndexPath:indexPath];
if (cell) return cell;
}
static NSString *cellID = @"PYSearchSuggestionCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.textLabel.textColor = [UIColor darkGrayColor];
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.backgroundColor = [UIColor clearColor];
UIImageView *line = [[UIImageView alloc] initWithImage: [NSBundle py_imageNamed:@"cell-content-line"]];
line.py_height = 0.5;
line.alpha = 0.7;
line.py_x = PYSEARCH_MARGIN;
line.py_y = 43;
line.py_width = PYScreenW;
[cell.contentView addSubview:line];
}
cell.imageView.image = [NSBundle py_imageNamed:@"search"];
cell.textLabel.text = self.searchSuggestions[indexPath.row];
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:heightForRowAtIndexPath:)]) {
return [self.dataSource searchSuggestionView:tableView heightForRowAtIndexPath:indexPath];
}
return 44.0;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (self.didSelectCellBlock) self.didSelectCellBlock([tableView cellForRowAtIndexPath:indexPath]);
}
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "PYSearchConst.h"
@class PYSearchViewController, PYSearchSuggestionViewController;
typedef void(^PYDidSearchBlock)(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText);
/**
style of popular search
*/
typedef NS_ENUM(NSInteger, PYHotSearchStyle) {
PYHotSearchStyleNormalTag, // normal tag without border
PYHotSearchStyleColorfulTag, // colorful tag without border, color of background is randrom and can be custom by `colorPol`
PYHotSearchStyleBorderTag, // border tag, color of background is `clearColor`
PYHotSearchStyleARCBorderTag, // broder tag with ARC, color of background is `clearColor`
PYHotSearchStyleRankTag, // rank tag, color of background can be custom by `rankTagBackgroundColorHexStrings`
PYHotSearchStyleRectangleTag, // rectangle tag, color of background is `clearColor`
PYHotSearchStyleDefault = PYHotSearchStyleNormalTag // default is `PYHotSearchStyleNormalTag`
};
/**
style of search history
*/
typedef NS_ENUM(NSInteger, PYSearchHistoryStyle) {
PYSearchHistoryStyleCell, // style of UITableViewCell
PYSearchHistoryStyleNormalTag, // style of PYHotSearchStyleNormalTag
PYSearchHistoryStyleColorfulTag, // style of PYHotSearchStyleColorfulTag
PYSearchHistoryStyleBorderTag, // style of PYHotSearchStyleBorderTag
PYSearchHistoryStyleARCBorderTag, // style of PYHotSearchStyleARCBorderTag
PYSearchHistoryStyleDefault = PYSearchHistoryStyleCell // default is `PYSearchHistoryStyleCell`
};
/**
mode of search result view controller display
*/
typedef NS_ENUM(NSInteger, PYSearchResultShowMode) {
PYSearchResultShowModeCustom, // custom, can be push or pop and so on.
PYSearchResultShowModePush, // push, dispaly the view of search result by push
PYSearchResultShowModeEmbed, // embed, dispaly the view of search result by embed
PYSearchResultShowModeDefault = PYSearchResultShowModeCustom // defualt is `PYSearchResultShowModeCustom`
};
/**
mode of search view controller display
*/
typedef NS_ENUM(NSInteger, PYSearchViewControllerShowMode) {
PYSearchViewControllerShowModeModal, // modal, dispaly the view of searchViewController by modal
PYSearchViewControllerShowModePush, // push, dispaly the view of searchViewController by push
PYSearchViewControllerShowDefault = PYSearchViewControllerShowModeModal // defualt is `PYSearchViewControllerShowModeModal`
};
/**
The protocol of data source, you can custom the suggestion view by implement these methods the data scource.
*/
@protocol PYSearchViewControllerDataSource <NSObject>
@optional
/**
Return a `UITableViewCell` object.
@param searchSuggestionView view which display search suggestions
@param indexPath indexPath of row
@return a `UITableViewCell` object
*/
- (UITableViewCell *)searchSuggestionView:(UITableView *)searchSuggestionView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
/**
Return number of rows in section.
@param searchSuggestionView view which display search suggestions
@param section index of section
@return number of rows in section
*/
- (NSInteger)searchSuggestionView:(UITableView *)searchSuggestionView numberOfRowsInSection:(NSInteger)section;
/**
Return number of sections in search suggestion view.
@param searchSuggestionView view which display search suggestions
@return number of sections
*/
- (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)searchSuggestionView;
/**
Return height for row.
@param searchSuggestionView view which display search suggestions
@param indexPath indexPath of row
@return height of row
*/
- (CGFloat)searchSuggestionView:(UITableView *)searchSuggestionView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
/**
The protocol of delegate
*/
@protocol PYSearchViewControllerDelegate <NSObject, UITableViewDelegate>
@optional
/**
Called when search begain.
@param searchViewController search view controller
@param searchBar search bar
@param searchText text for search
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController
didSearchWithSearchBar:(UISearchBar *)searchBar
searchText:(NSString *)searchText;
/**
Called when popular search is selected.
@param searchViewController search view controller
@param index index of tag
@param searchText text for search
Note: `searchViewController:didSearchWithSearchBar:searchText:` will not be called when this method is implemented.
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController
didSelectHotSearchAtIndex:(NSInteger)index
searchText:(NSString *)searchText;
/**
Called when search history is selected.
@param searchViewController search view controller
@param index index of tag or row
@param searchText text for search
Note: `searchViewController:didSearchWithSearchBar:searchText:` will not be called when this method is implemented.
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController
didSelectSearchHistoryAtIndex:(NSInteger)index
searchText:(NSString *)searchText;
/**
Called when search suggestion is selected.
@param searchViewController search view controller
@param index index of row
@param searchText text for search
Note: `searchViewController:didSearchWithSearchBar:searchText:` will not be called when this method is implemented.
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController
didSelectSearchSuggestionAtIndex:(NSInteger)index
searchText:(NSString *)searchText PYSEARCH_DEPRECATED("Use searchViewController:didSelectSearchSuggestionAtIndexPath:searchText:");
/**
Called when search suggestion is selected, the method support more custom of search suggestion view.
@param searchViewController search view controller
@param indexPath indexPath of row
@param searchBar search bar
Note: `searchViewController:didSearchWithSearchBar:searchText:` and `searchViewController:didSelectSearchSuggestionAtIndex:searchText:` will not be called when this method is implemented.
Suggestion: To ensure that can cache selected custom search suggestion records, you need to set `searchBar.text` = "custom search text".
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController didSelectSearchSuggestionAtIndexPath:(NSIndexPath *)indexPath
searchBar:(UISearchBar *)searchBar;
/**
Called when search text did change, you can reload data of suggestion view thought this method.
@param searchViewController search view controller
@param searchBar search bar
@param searchText text for search
*/
- (void)searchViewController:(PYSearchViewController *)searchViewController
searchTextDidChange:(UISearchBar *)searchBar
searchText:(NSString *)searchText;
/**
Called when cancel item did press, default execute `[self dismissViewControllerAnimated:YES completion:nil]`.
@param searchViewController search view controller
*/
- (void)didClickCancel:(PYSearchViewController *)searchViewController;
/**
Called when back item did press, default execute `[self.navigationController popViewControllerAnimated:YES]`.
@param searchViewController search view controller
*/
- (void)didClickBack:(PYSearchViewController *)searchViewController;
@end
@interface PYSearchViewController : UIViewController
/**
The delegate
*/
@property (nonatomic, weak) id<PYSearchViewControllerDelegate> delegate;
/**
The data source
*/
@property (nonatomic, weak) id<PYSearchViewControllerDataSource> dataSource;
/**
Ranking the background color of the corresponding hexadecimal string (eg: @"#ffcc99") array (just four colors) when `hotSearchStyle` is `PYHotSearchStyleRankTag`.
*/
@property (nonatomic, strong) NSArray<NSString *> *rankTagBackgroundColorHexStrings;
/**
The pool of color which are use in colorful tag when `hotSearchStyle` is `PYHotSearchStyleColorfulTag`.
*/
@property (nonatomic, strong) NSMutableArray<UIColor *> *colorPol;
/**
Whether swap the popular search and search history location, default is NO.
Note: It is‘t effective when `searchHistoryStyle` is `PYSearchHistoryStyleCell`.
*/
@property (nonatomic, assign) BOOL swapHotSeachWithSearchHistory;
/**
The element of popular search
*/
@property (nonatomic, copy) NSArray<NSString *> *hotSearches;
/**
The tags of popular search
*/
@property (nonatomic, copy) NSArray<UILabel *> *hotSearchTags;
/**
The label of popular search header
*/
@property (nonatomic, weak) UILabel *hotSearchHeader;
/**
Whether show popular search, default is YES.
*/
@property (nonatomic, assign) BOOL showHotSearch;
/**
The title of popular search
*/
@property (nonatomic, copy) NSString *hotSearchTitle;
/**
The tags of search history
*/
@property (nonatomic, copy) NSArray<UILabel *> *searchHistoryTags;
/**
The label of search history header
*/
@property (nonatomic, weak) UILabel *searchHistoryHeader;
/**
The title of search history
*/
@property (nonatomic, copy) NSString *searchHistoryTitle;
/**
Whether show search history, default is YES.
Note: search record is not cache when it is NO.
*/
@property (nonatomic, assign) BOOL showSearchHistory;
/**
The path of cache search record, default is `PYSEARCH_SEARCH_HISTORY_CACHE_PATH`.
*/
@property (nonatomic, copy) NSString *searchHistoriesCachePath;
/**
The number of cache search record, default is 20.
*/
@property (nonatomic, assign) NSUInteger searchHistoriesCount;
/**
Whether remove the space of search string, default is YES.
*/
@property (nonatomic, assign) BOOL removeSpaceOnSearchString;
/**
The button of empty search record when `searchHistoryStyle` is’t `PYSearchHistoryStyleCell`.
*/
@property (nonatomic, weak) UIButton *emptyButton;
/**
The label od empty search record when `searchHistoryStyle` is `PYSearchHistoryStyleCell`.
*/
@property (nonatomic, weak) UILabel *emptySearchHistoryLabel;
/**
The style of popular search, default is `PYHotSearchStyleNormalTag`.
*/
@property (nonatomic, assign) PYHotSearchStyle hotSearchStyle;
/**
The style of search histrory, default is `PYSearchHistoryStyleCell`.
*/
@property (nonatomic, assign) PYSearchHistoryStyle searchHistoryStyle;
/**
The mode of display search result view controller, default is `PYSearchResultShowModeCustom`.
*/
@property (nonatomic, assign) PYSearchResultShowMode searchResultShowMode;
/**
The mode of display search view controller, default is `PYSearchViewControllerShowModeModal`.
*/
@property (nonatomic, assign) PYSearchViewControllerShowMode searchViewControllerShowMode;
/**
The search bar
*/
@property (nonatomic, weak) UISearchBar *searchBar;
/**
The text field of search bar
*/
@property (nonatomic, weak) UITextField *searchTextField;
/**
The background color of search bar.
*/
@property (nonatomic, strong) UIColor *searchBarBackgroundColor;
/**
The cornerRadius of `_UISearchBarSearchFieldBackgroundView` which from `self.searchTextField.subviews`, default is 0.0.
*/
@property (nonatomic, assign) CGFloat searchBarCornerRadius;
/**
The barButtonItem of cancel
*/
@property (nonatomic, strong) UIBarButtonItem *cancelBarButtonItem;
/**
The customView of cancelBarButtonItem
*/
@property (nonatomic, weak) UIButton *cancelButton;
/**
The barButtonItem of back
*/
@property (nonatomic, strong) UIBarButtonItem *backBarButtonItem;
/**
The customView of backBarButtonItem
*/
@property (nonatomic, weak) UIButton *backButton;
/**
The search suggestion view
*/
@property (nonatomic, weak, readonly) UITableView *searchSuggestionView;
/**
The block which invoked when search begain.
*/
@property (nonatomic, copy) PYDidSearchBlock didSearchBlock;
/**
The element of search suggestions
Note: it is't effective when `searchSuggestionHidden` is NO or cell of suggestion view is custom.
*/
@property (nonatomic, copy) NSArray<NSString *> *searchSuggestions;
/**
Whether hidden search suggstion view, default is NO.
*/
@property (nonatomic, assign) BOOL searchSuggestionHidden;
/**
The view controller of search result.
*/
@property (nonatomic, strong) UIViewController *searchResultController;
/**
Whether show search result view when search text did change, default is NO.
Note: it is effective only when `searchResultShowMode` is `PYSearchResultShowModeEmbed`.
*/
@property (nonatomic, assign) BOOL showSearchResultWhenSearchTextChanged;
/**
Whether show search result view when search bar become first responder again.
Note: it is effective only when `searchResultShowMode` is `PYSearchResultShowModeEmbed`.
*/
@property (nonatomic, assign) BOOL showSearchResultWhenSearchBarRefocused;
/**
Whether show keyboard when return to search result, default is YES.
*/
@property (nonatomic, assign) BOOL showKeyboardWhenReturnSearchResult;
/**
Creates an instance of searchViewContoller with popular searches and search bar's placeholder.
@param hotSearches popular searchs
@param placeholder placeholder of search bar
@return new instance of `PYSearchViewController` class
*/
+ (instancetype)searchViewControllerWithHotSearches:(NSArray<NSString *> *)hotSearches
searchBarPlaceholder:(NSString *)placeholder;
/**
Creates an instance of searchViewContoller with popular searches, search bar's placeholder and the block which invoked when search begain.
@param hotSearches popular searchs
@param placeholder placeholder of search bar
@param block block which invoked when search begain
@return new instance of `PYSearchViewController` class
Note: The `delegate` has a priority greater than the `block`, `block` is't effective when `searchViewController:didSearchWithSearchBar:searchText:` is implemented.
*/
+ (instancetype)searchViewControllerWithHotSearches:(NSArray<NSString *> *)hotSearches
searchBarPlaceholder:(NSString *)placeholder
didSearchBlock:(PYDidSearchBlock)block;
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "PYSearchViewController.h"
#import "PYSearchConst.h"
#import "PYSearchSuggestionViewController.h"
#define PYRectangleTagMaxCol 3
#define PYTextColor PYSEARCH_COLOR(113, 113, 113)
#define PYSEARCH_COLORPolRandomColor self.colorPol[arc4random_uniform((uint32_t)self.colorPol.count)]
@interface PYSearchViewController () <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource, PYSearchSuggestionViewDataSource, UIGestureRecognizerDelegate> {
id <UIGestureRecognizerDelegate> _previousInteractivePopGestureRecognizerDelegate;
}
/**
The header view of search view
*/
@property (nonatomic, weak) UIView *headerView;
/**
The view of popular search
*/
@property (nonatomic, weak) UIView *hotSearchView;
/**
The view of search history
*/
@property (nonatomic, weak) UIView *searchHistoryView;
/**
The records of search
*/
@property (nonatomic, strong) NSMutableArray *searchHistories;
/**
Whether keyboard is showing.
*/
@property (nonatomic, assign) BOOL keyboardShowing;
/**
The height of keyborad
*/
@property (nonatomic, assign) CGFloat keyboardHeight;
/**
The search suggestion view contoller
*/
@property (nonatomic, weak) PYSearchSuggestionViewController *searchSuggestionVC;
/**
The content view of popular search tags
*/
@property (nonatomic, weak) UIView *hotSearchTagsContentView;
/**
The tags of rank
*/
@property (nonatomic, copy) NSArray<UILabel *> *rankTags;
/**
The text labels of rank
*/
@property (nonatomic, copy) NSArray<UILabel *> *rankTextLabels;
/**
The view of rank which contain tag and text label.
*/
@property (nonatomic, copy) NSArray<UIView *> *rankViews;
/**
The content view of search history tags.
*/
@property (nonatomic, weak) UIView *searchHistoryTagsContentView;
/**
The base table view of search view controller
*/
@property (nonatomic, strong) UITableView *baseSearchTableView;
/**
Whether did press suggestion cell
*/
@property (nonatomic, assign) BOOL didClickSuggestionCell;
/**
The current orientation of device
*/
@property (nonatomic, assign) UIDeviceOrientation currentOrientation;
/**
The width of cancel button
*/
@property (nonatomic, assign) CGFloat cancelButtonWidth;
@end
@implementation PYSearchViewController
- (instancetype)init
{
if (self = [super init]) {
[self setup];
}
return self;
}
- (void)awakeFromNib
{
[super awakeFromNib];
[self setup];
}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
if (self.currentOrientation != [[UIDevice currentDevice] orientation]) { // orientation changed, reload layout
self.hotSearches = self.hotSearches;
self.searchHistories = self.searchHistories;
self.currentOrientation = [[UIDevice currentDevice] orientation];
}
CGFloat adaptWidth = 0.0;
UISearchBar *searchBar = self.searchBar;
UITextField *searchField = self.searchTextField;
UIView *titleView = self.navigationItem.titleView;
UIButton *backButton = self.navigationItem.leftBarButtonItem.customView;
UIButton *cancelButton = self.navigationItem.rightBarButtonItem.customView;
UIEdgeInsets backButtonLayoutMargins = UIEdgeInsetsZero;
UIEdgeInsets cancelButtonLayoutMargins = UIEdgeInsetsZero;
UIEdgeInsets navigationBarLayoutMargins = UIEdgeInsetsZero;
UINavigationBar *navigationBar = self.navigationController.navigationBar;
if (@available(iOS 8.0, *)) {
backButton.layoutMargins = UIEdgeInsetsMake(8, 0, 8, 8);
backButtonLayoutMargins = backButton.layoutMargins;
cancelButton.layoutMargins = UIEdgeInsetsMake(8, 8, 8, 0);
cancelButtonLayoutMargins = cancelButton.layoutMargins;
navigationBarLayoutMargins = navigationBar.layoutMargins;
}
if (self.searchViewControllerShowMode == PYSearchViewControllerShowModePush) {
UIButton *backButton = self.navigationItem.leftBarButtonItem.customView;
UIImageView *imageView = backButton.imageView;
UIView *titleLabel = backButton.titleLabel;
[backButton sizeToFit];
[imageView sizeToFit];
[titleLabel sizeToFit];
backButton.py_height = navigationBar.py_height;
backButton.py_width = titleLabel.py_width + imageView.py_width / 2.0 + backButtonLayoutMargins.left + backButtonLayoutMargins.right;
adaptWidth = backButton.py_width + 8;
} else { // Default is PYSearchViewControllerShowModeModal
[cancelButton sizeToFit];
[cancelButton.titleLabel sizeToFit];
self.cancelButtonWidth = cancelButton.py_width + cancelButtonLayoutMargins.left + cancelButtonLayoutMargins.right;
adaptWidth = self.cancelButtonWidth + 8;
}
adaptWidth = adaptWidth + navigationBarLayoutMargins.left + navigationBarLayoutMargins.right;
// Adapt the search bar layout problem in the navigation bar on iOS 11
// More details : https://github.com/iphone5solo/PYSearch/issues/108
if (@available(iOS 11.0, *)) { // iOS 11
if (self.searchViewControllerShowMode == PYSearchViewControllerShowModeModal) {
NSLayoutConstraint *leftLayoutConstraint = [searchBar.leftAnchor constraintEqualToAnchor:titleView.leftAnchor];
if (navigationBarLayoutMargins.left > PYSEARCH_MARGIN) {
[leftLayoutConstraint setConstant:0];
} else {
[leftLayoutConstraint setConstant:PYSEARCH_MARGIN - navigationBarLayoutMargins.left];
}
}
searchBar.py_height = self.view.py_width > self.view.py_height ? 24 : 30;
searchBar.py_width = self.view.py_width - adaptWidth - PYSEARCH_MARGIN;
searchField.frame = searchBar.bounds;
cancelButton.py_width = self.cancelButtonWidth;
} else {
titleView.py_y = self.view.py_width > self.view.py_height ? 4 : 7;
titleView.py_height = self.view.py_width > self.view.py_height ? 24 : 30;
if (self.searchViewControllerShowMode == PYSearchViewControllerShowModePush) {
titleView.py_width = self.view.py_width - adaptWidth - PYSEARCH_MARGIN;
} else {
titleView.py_x = PYSEARCH_MARGIN * 1.5;
titleView.py_width = self.view.py_width - self.cancelButtonWidth - titleView.py_x * 2 - 3;
}
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self viewDidLayoutSubviews];
}
- (BOOL)prefersStatusBarHidden
{
return NO;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBar.hidden = NO;
[self setSearchHistoryStyle:self.searchHistoryStyle]; // in method viewDidAppear,the view flashes when searchHistory count > 0
//
// if (self.cancelButtonWidth == 0) { // Just adapt iOS 11.2
// [self viewDidLayoutSubviews];
// }
//
// // Adjust the view according to the `navigationBar.translucent`
// if (NO == self.navigationController.navigationBar.translucent) {
// self.baseSearchTableView.contentInset = UIEdgeInsetsMake(0, 0, self.view.py_y, 0);
// self.searchSuggestionVC.view.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame) - self.view.py_y, self.view.py_width, self.view.py_height + self.view.py_y);
// if (!self.navigationController.navigationBar.barTintColor) {
// self.navigationController.navigationBar.barTintColor = PYSEARCH_COLOR(249, 249, 249);
// }
// }
//
// if (NULL == self.searchResultController.parentViewController) {
// [self.searchBar becomeFirstResponder];
// } else if (YES == self.showKeyboardWhenReturnSearchResult) {
// [self.searchBar becomeFirstResponder];
// }
// if (_searchViewControllerShowMode == PYSearchViewControllerShowModePush) {
// if (self.navigationController.viewControllers.count > 1) {
// _previousInteractivePopGestureRecognizerDelegate = self.navigationController.interactivePopGestureRecognizer.delegate;
// self.navigationController.interactivePopGestureRecognizer.delegate = self;
// }
// }
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Fixed search history view may not be displayed or other problem at the first time.
[self setSearchHistoryStyle:self.searchHistoryStyle];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.searchBar resignFirstResponder];
if (_searchViewControllerShowMode == PYSearchViewControllerShowModePush) {
self.navigationController.interactivePopGestureRecognizer.delegate = _previousInteractivePopGestureRecognizerDelegate;
}
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
+ (instancetype)searchViewControllerWithHotSearches:(NSArray<NSString *> *)hotSearches searchBarPlaceholder:(NSString *)placeholder
{
PYSearchViewController *searchVC = [[self alloc] init];
searchVC.hotSearches = hotSearches;
searchVC.searchBar.placeholder = placeholder;
return searchVC;
}
+ (instancetype)searchViewControllerWithHotSearches:(NSArray<NSString *> *)hotSearches searchBarPlaceholder:(NSString *)placeholder didSearchBlock:(PYDidSearchBlock)block
{
PYSearchViewController *searchVC = [self searchViewControllerWithHotSearches:hotSearches searchBarPlaceholder:placeholder];
searchVC.didSearchBlock = [block copy];
return searchVC;
}
#pragma mark - Lazy
- (UITableView *)baseSearchTableView
{
if (!_baseSearchTableView) {
UITableView *baseSearchTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
baseSearchTableView.backgroundColor = [UIColor clearColor];
baseSearchTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
if ([baseSearchTableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) { // For the adapter iPad
baseSearchTableView.cellLayoutMarginsFollowReadableWidth = NO;
}
baseSearchTableView.delegate = self;
baseSearchTableView.dataSource = self;
[self.view addSubview:baseSearchTableView];
_baseSearchTableView = baseSearchTableView;
}
return _baseSearchTableView;
}
- (PYSearchSuggestionViewController *)searchSuggestionVC
{
if (!_searchSuggestionVC) {
PYSearchSuggestionViewController *searchSuggestionVC = [[PYSearchSuggestionViewController alloc] initWithStyle:UITableViewStyleGrouped];
__weak typeof(self) _weakSelf = self;
searchSuggestionVC.didSelectCellBlock = ^(UITableViewCell *didSelectCell) {
__strong typeof(_weakSelf) _swSelf = _weakSelf;
_swSelf.searchBar.text = didSelectCell.textLabel.text;
NSIndexPath *indexPath = [_swSelf.searchSuggestionVC.tableView indexPathForCell:didSelectCell];
if ([_swSelf.delegate respondsToSelector:@selector(searchViewController:didSelectSearchSuggestionAtIndexPath:searchBar:)]) {
[_swSelf.delegate searchViewController:_swSelf didSelectSearchSuggestionAtIndexPath:indexPath searchBar:_swSelf.searchBar];
[_swSelf saveSearchCacheAndRefreshView];
} else if ([_swSelf.delegate respondsToSelector:@selector(searchViewController:didSelectSearchSuggestionAtIndex:searchText:)]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[_swSelf.delegate searchViewController:_swSelf didSelectSearchSuggestionAtIndex:indexPath.row searchText:_swSelf.searchBar.text];
#pragma clang diagnostic pop
[_swSelf saveSearchCacheAndRefreshView];
} else {
[_swSelf searchBarSearchButtonClicked:_swSelf.searchBar];
}
};
searchSuggestionVC.view.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), PYScreenW, PYScreenH);
searchSuggestionVC.view.backgroundColor = self.baseSearchTableView.backgroundColor;
searchSuggestionVC.view.hidden = YES;
_searchSuggestionView = (UITableView *)searchSuggestionVC.view;
searchSuggestionVC.dataSource = self;
[self.view addSubview:searchSuggestionVC.view];
[self addChildViewController:searchSuggestionVC];
_searchSuggestionVC = searchSuggestionVC;
}
return _searchSuggestionVC;
}
- (UIButton *)emptyButton
{
if (!_emptyButton) {
UIButton *emptyButton = [[UIButton alloc] init];
emptyButton.titleLabel.font = self.searchHistoryHeader.font;
[emptyButton setTitleColor:PYTextColor forState:UIControlStateNormal];
[emptyButton setTitle:[NSBundle py_localizedStringForKey:PYSearchEmptyButtonText] forState:UIControlStateNormal];
[emptyButton setImage:[NSBundle py_imageNamed:@"empty"] forState:UIControlStateNormal];
[emptyButton addTarget:self action:@selector(emptySearchHistoryDidClick) forControlEvents:UIControlEventTouchUpInside];
[emptyButton sizeToFit];
emptyButton.py_width += PYSEARCH_MARGIN;
emptyButton.py_height += PYSEARCH_MARGIN;
emptyButton.py_centerY = self.searchHistoryHeader.py_centerY;
emptyButton.py_x = self.searchHistoryView.py_width - emptyButton.py_width;
emptyButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[self.searchHistoryView addSubview:emptyButton];
_emptyButton = emptyButton;
}
return _emptyButton;
}
- (UIView *)searchHistoryTagsContentView
{
if (!_searchHistoryTagsContentView) {
UIView *searchHistoryTagsContentView = [[UIView alloc] init];
searchHistoryTagsContentView.py_width = self.searchHistoryView.py_width;
searchHistoryTagsContentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
searchHistoryTagsContentView.py_y = CGRectGetMaxY(self.hotSearchTagsContentView.frame) + PYSEARCH_MARGIN;
[self.searchHistoryView addSubview:searchHistoryTagsContentView];
_searchHistoryTagsContentView = searchHistoryTagsContentView;
}
return _searchHistoryTagsContentView;
}
- (UILabel *)searchHistoryHeader
{
if (!_searchHistoryHeader) {
UILabel *titleLabel = [self setupTitleLabel:[NSBundle py_localizedStringForKey:PYSearchSearchHistoryText]];
[self.searchHistoryView addSubview:titleLabel];
_searchHistoryHeader = titleLabel;
}
return _searchHistoryHeader;
}
- (UIView *)searchHistoryView
{
if (!_searchHistoryView) {
UIView *searchHistoryView = [[UIView alloc] init];
searchHistoryView.py_x = self.hotSearchView.py_x;
searchHistoryView.py_y = self.hotSearchView.py_y;
searchHistoryView.py_width = self.headerView.py_width - searchHistoryView.py_x * 2;
searchHistoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.headerView addSubview:searchHistoryView];
_searchHistoryView = searchHistoryView;
}
return _searchHistoryView;
}
- (NSMutableArray *)searchHistories
{
if (!_searchHistories) {
_searchHistories = [NSMutableArray arrayWithArray:[NSKeyedUnarchiver unarchiveObjectWithFile:self.searchHistoriesCachePath]];
}
return _searchHistories;
}
- (NSMutableArray *)colorPol
{
if (!_colorPol) {
NSArray *colorStrPol = @[@"009999", @"0099cc", @"0099ff", @"00cc99", @"00cccc", @"336699", @"3366cc", @"3366ff", @"339966", @"666666", @"666699", @"6666cc", @"6666ff", @"996666", @"996699", @"999900", @"999933", @"99cc00", @"99cc33", @"660066", @"669933", @"990066", @"cc9900", @"cc6600" , @"cc3300", @"cc3366", @"cc6666", @"cc6699", @"cc0066", @"cc0033", @"ffcc00", @"ffcc33", @"ff9900", @"ff9933", @"ff6600", @"ff6633", @"ff6666", @"ff6699", @"ff3366", @"ff3333"];
NSMutableArray *colorPolM = [NSMutableArray array];
for (NSString *colorStr in colorStrPol) {
UIColor *color = [UIColor py_colorWithHexString:colorStr];
[colorPolM addObject:color];
}
_colorPol = colorPolM;
}
return _colorPol;
}
- (void)setup
{
self.view.backgroundColor = [UIColor whiteColor];
self.baseSearchTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.navigationController.navigationBar.backIndicatorImage = nil;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
UIButton *cancleButton = [UIButton buttonWithType:UIButtonTypeSystem];
cancleButton.titleLabel.font = [UIFont systemFontOfSize:17];
[cancleButton setTitle:[NSBundle py_localizedStringForKey:PYSearchCancelButtonText] forState:UIControlStateNormal];
[cancleButton addTarget:self action:@selector(cancelDidClick) forControlEvents:UIControlEventTouchUpInside];
cancleButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
cancleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
[cancleButton sizeToFit];
cancleButton.py_width += PYSEARCH_MARGIN;
self.cancelButton = cancleButton;
self.cancelBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:cancleButton];
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
UIImage *backImage = [NSBundle py_imageNamed:@"back"];
backButton.titleLabel.font = [UIFont systemFontOfSize:17];
[backButton setTitle:[NSBundle py_localizedStringForKey:PYSearchBackButtonText] forState:UIControlStateNormal];
[backButton setImage:backImage forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(backDidClick) forControlEvents:UIControlEventTouchUpInside];
backButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[backButton.imageView sizeToFit];
backButton.contentEdgeInsets = UIEdgeInsetsMake(0, -ceil(backImage.size.width / 2.0), 0, 0);
backButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
[backButton sizeToFit];
backButton.py_width += 5;
self.backButton = backButton;
self.backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
/**
* Initialize settings
*/
self.hotSearchStyle = PYHotSearchStyleDefault;
self.searchHistoryStyle = PYHotSearchStyleDefault;
self.searchResultShowMode = PYSearchResultShowModeDefault;
self.searchViewControllerShowMode = PYSearchViewControllerShowDefault;
self.searchSuggestionHidden = NO;
self.searchHistoriesCachePath = PYSEARCH_SEARCH_HISTORY_CACHE_PATH;
self.searchHistoriesCount = 20;
self.showSearchHistory = YES;
self.showHotSearch = YES;
self.showSearchResultWhenSearchTextChanged = NO;
self.showSearchResultWhenSearchBarRefocused = NO;
self.showKeyboardWhenReturnSearchResult = YES;
self.removeSpaceOnSearchString = YES;
self.searchBarCornerRadius = 0.0;
UIView *titleView = [[UIView alloc] init];
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:titleView.bounds];
[titleView addSubview:searchBar];
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0) { // iOS 11
[NSLayoutConstraint activateConstraints:@[
[searchBar.topAnchor constraintEqualToAnchor:titleView.topAnchor],
[searchBar.leftAnchor constraintEqualToAnchor:titleView.leftAnchor],
[searchBar.rightAnchor constraintEqualToAnchor:titleView.rightAnchor],
[searchBar.bottomAnchor constraintEqualToAnchor:titleView.bottomAnchor]
]];
} else {
searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
self.navigationItem.titleView = titleView;
searchBar.placeholder = [NSBundle py_localizedStringForKey:PYSearchSearchPlaceholderText];
searchBar.backgroundImage = [NSBundle py_imageNamed:@"clearImage"];
searchBar.delegate = self;
for (UIView *subView in [[searchBar.subviews lastObject] subviews]) {
if ([[subView class] isSubclassOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)subView;
textField.font = [UIFont systemFontOfSize:14 * k6Scale];
_searchTextField = textField;
break;
}
}
// kViewRadius(self.navigationItem.titleView, 5 * k6Scale);
// kViewRadius(searchBar, 5 * k6Scale);
self.searchBar = searchBar;
if (_searchTextField) {
_searchTextField.textColor = UIColor.blackColor;
_searchTextField.font = kFontSize(14 *k6Scale);
kViewRadius(_searchTextField, 5 * k6Scale);
// kViewRadius([[_searchTextField superview] superview], 5 * k6Scale);
// [_searchTextField becomeFirstResponder];
_searchTextField.leftView = nil;
}
// self.searchBar.searchTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:[NSBundle py_localizedStringForKey:PYSearchSearchPlaceholderText] attributes:@{NSFontAttributeName:kFontSize(14 * k6Scale), NSForegroundColorAttributeName:RGB(222, 222, 222)}];
UIView *headerView = [[UIView alloc] init];
headerView.py_width = PYScreenW;
headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UIView *hotSearchView = [[UIView alloc] init];
hotSearchView.py_x = PYSEARCH_MARGIN * 1.5;
hotSearchView.py_width = headerView.py_width - hotSearchView.py_x * 2;
hotSearchView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
UILabel *titleLabel = [self setupTitleLabel:[NSBundle py_localizedStringForKey:PYSearchHotSearchText]];
self.hotSearchHeader = titleLabel;
[hotSearchView addSubview:titleLabel];
UIView *hotSearchTagsContentView = [[UIView alloc] init];
hotSearchTagsContentView.py_width = hotSearchView.py_width;
hotSearchTagsContentView.py_y = CGRectGetMaxY(titleLabel.frame) + PYSEARCH_MARGIN;
hotSearchTagsContentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[hotSearchView addSubview:hotSearchTagsContentView];
[headerView addSubview:hotSearchView];
self.hotSearchTagsContentView = hotSearchTagsContentView;
self.hotSearchView = hotSearchView;
self.headerView = headerView;
self.baseSearchTableView.tableHeaderView = headerView;
UIView *footerView = [[UIView alloc] init];
footerView.py_width = PYScreenW;
UILabel *emptySearchHistoryLabel = [[UILabel alloc] init];
emptySearchHistoryLabel.textColor = [UIColor darkGrayColor];
emptySearchHistoryLabel.font = [UIFont systemFontOfSize:13];
emptySearchHistoryLabel.userInteractionEnabled = YES;
emptySearchHistoryLabel.text = [NSBundle py_localizedStringForKey:PYSearchEmptySearchHistoryText];
emptySearchHistoryLabel.textAlignment = NSTextAlignmentCenter;
emptySearchHistoryLabel.py_height = 49;
[emptySearchHistoryLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(emptySearchHistoryDidClick)]];
emptySearchHistoryLabel.py_width = footerView.py_width;
emptySearchHistoryLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.emptySearchHistoryLabel = emptySearchHistoryLabel;
[footerView addSubview:emptySearchHistoryLabel];
footerView.py_height = emptySearchHistoryLabel.py_height;
self.baseSearchTableView.tableFooterView = footerView;
self.hotSearches = nil;
}
- (UILabel *)setupTitleLabel:(NSString *)title
{
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.text = title;
titleLabel.font = [UIFont systemFontOfSize:13];
titleLabel.tag = 1;
titleLabel.textColor = PYTextColor;
[titleLabel sizeToFit];
titleLabel.py_x = 0;
titleLabel.py_y = 0;
return titleLabel;
}
- (void)setupHotSearchRectangleTags
{
UIView *contentView = self.hotSearchTagsContentView;
contentView.py_width = PYSEARCH_REALY_SCREEN_WIDTH;
contentView.py_x = -PYSEARCH_MARGIN * 1.5;
contentView.py_y += 2;
contentView.backgroundColor = [UIColor whiteColor];
self.baseSearchTableView.backgroundColor = [UIColor py_colorWithHexString:@"#efefef"];
// remove all subviews in hotSearchTagsContentView
[self.hotSearchTagsContentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
CGFloat rectangleTagH = 40;
NSMutableArray *rectangleTagLabelsM = [NSMutableArray array];
for (int i = 0; i < self.hotSearches.count; i++) {
UILabel *rectangleTagLabel = [[UILabel alloc] init];
rectangleTagLabel.userInteractionEnabled = YES;
rectangleTagLabel.font = [UIFont systemFontOfSize:14];
rectangleTagLabel.textColor = PYTextColor;
rectangleTagLabel.backgroundColor = [UIColor clearColor];
rectangleTagLabel.text = self.hotSearches[i];
rectangleTagLabel.py_width = contentView.py_width / PYRectangleTagMaxCol;
rectangleTagLabel.py_height = rectangleTagH;
rectangleTagLabel.textAlignment = NSTextAlignmentCenter;
[rectangleTagLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tagDidCLick:)]];
rectangleTagLabel.py_x = rectangleTagLabel.py_width * (i % PYRectangleTagMaxCol);
rectangleTagLabel.py_y = rectangleTagLabel.py_height * (i / PYRectangleTagMaxCol);
[contentView addSubview:rectangleTagLabel];
[rectangleTagLabelsM addObject:rectangleTagLabel];
}
self.hotSearchTags = [rectangleTagLabelsM copy];
contentView.py_height = CGRectGetMaxY(contentView.subviews.lastObject.frame);
self.hotSearchView.py_height = CGRectGetMaxY(contentView.frame) + PYSEARCH_MARGIN * 2;
self.baseSearchTableView.tableHeaderView.py_height = self.headerView.py_height = MAX(CGRectGetMaxY(self.hotSearchView.frame), CGRectGetMaxY(self.searchHistoryView.frame));
for (int i = 0; i < PYRectangleTagMaxCol - 1; i++) {
UIImageView *verticalLine = [[UIImageView alloc] initWithImage:[NSBundle py_imageNamed:@"cell-content-line-vertical"]];
verticalLine.py_height = contentView.py_height;
verticalLine.alpha = 0.7;
verticalLine.py_x = contentView.py_width / PYRectangleTagMaxCol * (i + 1);
verticalLine.py_width = 0.5;
[contentView addSubview:verticalLine];
}
for (int i = 0; i < ceil(((double)self.hotSearches.count / PYRectangleTagMaxCol)) - 1; i++) {
UIImageView *verticalLine = [[UIImageView alloc] initWithImage:[NSBundle py_imageNamed:@"cell-content-line"]];
verticalLine.py_height = 0.5;
verticalLine.alpha = 0.7;
verticalLine.py_y = rectangleTagH * (i + 1);
verticalLine.py_width = contentView.py_width;
[contentView addSubview:verticalLine];
}
[self layoutForDemand];
// Note:When the operating system for the iOS 9.x series tableHeaderView height settings are invalid, you need to reset the tableHeaderView
[self.baseSearchTableView setTableHeaderView:self.baseSearchTableView.tableHeaderView];
}
- (void)setupHotSearchRankTags
{
UIView *contentView = self.hotSearchTagsContentView;
[self.hotSearchTagsContentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
NSMutableArray *rankTextLabelsM = [NSMutableArray array];
NSMutableArray *rankTagM = [NSMutableArray array];
NSMutableArray *rankViewM = [NSMutableArray array];
for (int i = 0; i < self.hotSearches.count; i++) {
UIView *rankView = [[UIView alloc] init];
rankView.py_height = 40;
rankView.py_width = (self.baseSearchTableView.py_width - PYSEARCH_MARGIN * 3) * 0.5;
rankView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[contentView addSubview:rankView];
// rank tag
UILabel *rankTag = [[UILabel alloc] init];
rankTag.textAlignment = NSTextAlignmentCenter;
rankTag.font = [UIFont systemFontOfSize:10];
rankTag.layer.cornerRadius = 3;
rankTag.clipsToBounds = YES;
rankTag.text = [NSString stringWithFormat:@"%d", i + 1];
[rankTag sizeToFit];
rankTag.py_width = rankTag.py_height += PYSEARCH_MARGIN * 0.5;
rankTag.py_y = (rankView.py_height - rankTag.py_height) * 0.5;
[rankView addSubview:rankTag];
[rankTagM addObject:rankTag];
// rank text
UILabel *rankTextLabel = [[UILabel alloc] init];
rankTextLabel.text = self.hotSearches[i];
rankTextLabel.userInteractionEnabled = YES;
[rankTextLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tagDidCLick:)]];
rankTextLabel.textAlignment = NSTextAlignmentLeft;
rankTextLabel.backgroundColor = [UIColor clearColor];
rankTextLabel.textColor = PYTextColor;
rankTextLabel.font = [UIFont systemFontOfSize:14];
rankTextLabel.py_x = CGRectGetMaxX(rankTag.frame) + PYSEARCH_MARGIN;
rankTextLabel.py_width = (self.baseSearchTableView.py_width - PYSEARCH_MARGIN * 3) * 0.5 - rankTextLabel.py_x;
rankTextLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
rankTextLabel.py_height = rankView.py_height;
[rankTextLabelsM addObject:rankTextLabel];
[rankView addSubview:rankTextLabel];
UIImageView *line = [[UIImageView alloc] initWithImage:[NSBundle py_imageNamed:@"cell-content-line"]];
line.py_height = 0.5;
line.alpha = 0.7;
line.py_x = -PYScreenW * 0.5;
line.py_y = rankView.py_height - 1;
line.py_width = self.baseSearchTableView.py_width;
line.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[rankView addSubview:line];
[rankViewM addObject:rankView];
// set tag's background color and text color
switch (i) {
case 0: // NO.1
rankTag.backgroundColor = [UIColor py_colorWithHexString:self.rankTagBackgroundColorHexStrings[0]];
rankTag.textColor = [UIColor whiteColor];
break;
case 1: // NO.2
rankTag.backgroundColor = [UIColor py_colorWithHexString:self.rankTagBackgroundColorHexStrings[1]];
rankTag.textColor = [UIColor whiteColor];
break;
case 2: // NO.3
rankTag.backgroundColor = [UIColor py_colorWithHexString:self.rankTagBackgroundColorHexStrings[2]];
rankTag.textColor = [UIColor whiteColor];
break;
default: // Other
rankTag.backgroundColor = [UIColor py_colorWithHexString:self.rankTagBackgroundColorHexStrings[3]];
rankTag.textColor = PYTextColor;
break;
}
}
self.rankTextLabels = rankTextLabelsM;
self.rankTags = rankTagM;
self.rankViews = rankViewM;
for (int i = 0; i < self.rankViews.count; i++) { // default is two column
UIView *rankView = self.rankViews[i];
rankView.py_x = (PYSEARCH_MARGIN + rankView.py_width) * (i % 2);
rankView.py_y = rankView.py_height * (i / 2);
}
contentView.py_height = CGRectGetMaxY(self.rankViews.lastObject.frame);
self.hotSearchView.py_height = CGRectGetMaxY(contentView.frame) + PYSEARCH_MARGIN * 2;
self.baseSearchTableView.tableHeaderView.py_height = self.headerView.py_height = MAX(CGRectGetMaxY(self.hotSearchView.frame), CGRectGetMaxY(self.searchHistoryView.frame));
[self layoutForDemand];
// Note:When the operating system for the iOS 9.x series tableHeaderView height settings are invalid, you need to reset the tableHeaderView
[self.baseSearchTableView setTableHeaderView:self.baseSearchTableView.tableHeaderView];
}
- (void)setupHotSearchNormalTags
{
self.hotSearchTags = [self addAndLayoutTagsWithTagsContentView:self.hotSearchTagsContentView tagTexts:self.hotSearches];
[self setHotSearchStyle:self.hotSearchStyle];
}
- (void)setupSearchHistoryTags
{
self.baseSearchTableView.tableFooterView = nil;
self.searchHistoryTagsContentView.py_y = PYSEARCH_MARGIN;
self.emptyButton.py_y = self.searchHistoryHeader.py_y - PYSEARCH_MARGIN * 0.5;
self.searchHistoryTagsContentView.py_y = CGRectGetMaxY(self.emptyButton.frame) + PYSEARCH_MARGIN;
self.searchHistoryTags = [self addAndLayoutTagsWithTagsContentView:self.searchHistoryTagsContentView tagTexts:[self.searchHistories copy]];
}
- (NSArray *)addAndLayoutTagsWithTagsContentView:(UIView *)contentView tagTexts:(NSArray<NSString *> *)tagTexts;
{
[contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
NSMutableArray *tagsM = [NSMutableArray array];
for (int i = 0; i < tagTexts.count; i++) {
UILabel *label = [self labelWithTitle:tagTexts[i]];
[label addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tagDidCLick:)]];
[contentView addSubview:label];
[tagsM addObject:label];
}
CGFloat currentX = 0;
CGFloat currentY = 0;
CGFloat countRow = 0;
CGFloat countCol = 0;
for (int i = 0; i < contentView.subviews.count; i++) {
UILabel *subView = contentView.subviews[i];
// When the number of search words is too large, the width is width of the contentView
if (subView.py_width > contentView.py_width) subView.py_width = contentView.py_width;
if (currentX + subView.py_width + PYSEARCH_MARGIN * countRow > contentView.py_width) {
subView.py_x = 0;
subView.py_y = (currentY += subView.py_height) + PYSEARCH_MARGIN * ++countCol;
currentX = subView.py_width;
countRow = 1;
} else {
subView.py_x = (currentX += subView.py_width) - subView.py_width + PYSEARCH_MARGIN * countRow;
subView.py_y = currentY + PYSEARCH_MARGIN * countCol;
countRow ++;
}
}
contentView.py_height = CGRectGetMaxY(contentView.subviews.lastObject.frame);
if (self.hotSearchTagsContentView == contentView) { // popular search tag
self.hotSearchView.py_height = CGRectGetMaxY(contentView.frame) + PYSEARCH_MARGIN * 2;
} else if (self.searchHistoryTagsContentView == contentView) { // search history tag
self.searchHistoryView.py_height = CGRectGetMaxY(contentView.frame) + PYSEARCH_MARGIN * 2;
}
[self layoutForDemand];
self.baseSearchTableView.tableHeaderView.py_height = self.headerView.py_height = MAX(CGRectGetMaxY(self.hotSearchView.frame), CGRectGetMaxY(self.searchHistoryView.frame));
self.baseSearchTableView.tableHeaderView.hidden = NO;
// Note:When the operating system for the iOS 9.x series tableHeaderView height settings are invalid, you need to reset the tableHeaderView
[self.baseSearchTableView setTableHeaderView:self.baseSearchTableView.tableHeaderView];
return [tagsM copy];
}
- (void)layoutForDemand {
if (NO == self.swapHotSeachWithSearchHistory) {
self.hotSearchView.py_y = PYSEARCH_MARGIN * 2;
self.searchHistoryView.py_y = self.hotSearches.count > 0 && self.showHotSearch ? CGRectGetMaxY(self.hotSearchView.frame) : PYSEARCH_MARGIN * 1.5;
} else { // swap popular search whith search history
self.searchHistoryView.py_y = PYSEARCH_MARGIN * 1.5;
self.hotSearchView.py_y = self.searchHistories.count > 0 && self.showSearchHistory ? CGRectGetMaxY(self.searchHistoryView.frame) : PYSEARCH_MARGIN * 2;
}
}
#pragma mark - setter
- (void)setRankTextLabels:(NSArray<UILabel *> *)rankTextLabels
{
// popular search tagLabel's tag is 1, search history tagLabel's tag is 0.
for (UILabel *rankLabel in rankTextLabels) {
rankLabel.tag = 1;
}
_rankTextLabels= rankTextLabels;
}
- (void)setSearchBarCornerRadius:(CGFloat)searchBarCornerRadius
{
_searchBarCornerRadius = searchBarCornerRadius;
for (UIView *subView in self.searchTextField.subviews) {
if ([NSStringFromClass([subView class]) isEqualToString:@"_UISearchBarSearchFieldBackgroundView"]) {
subView.layer.cornerRadius = searchBarCornerRadius;
subView.clipsToBounds = YES;
break;
}
}
}
- (void)setSwapHotSeachWithSearchHistory:(BOOL)swapHotSeachWithSearchHistory
{
_swapHotSeachWithSearchHistory = swapHotSeachWithSearchHistory;
self.hotSearches = self.hotSearches;
self.searchHistories = self.searchHistories;
}
- (void)setHotSearchTitle:(NSString *)hotSearchTitle
{
_hotSearchTitle = [hotSearchTitle copy];
self.hotSearchHeader.text = _hotSearchTitle;
}
- (void)setSearchHistoryTitle:(NSString *)searchHistoryTitle
{
_searchHistoryTitle = [searchHistoryTitle copy];
if (PYSearchHistoryStyleCell == self.searchHistoryStyle) {
[self.baseSearchTableView reloadData];
} else {
self.searchHistoryHeader.text = _searchHistoryTitle;
}
}
- (void)setShowSearchResultWhenSearchTextChanged:(BOOL)showSearchResultWhenSearchTextChanged
{
_showSearchResultWhenSearchTextChanged = showSearchResultWhenSearchTextChanged;
if (YES == _showSearchResultWhenSearchTextChanged) {
self.searchSuggestionHidden = YES;
}
}
- (void)setShowHotSearch:(BOOL)showHotSearch
{
_showHotSearch = showHotSearch;
[self setHotSearches:self.hotSearches];
[self setSearchHistoryStyle:self.searchHistoryStyle];
}
- (void)setShowSearchHistory:(BOOL)showSearchHistory
{
_showSearchHistory = showSearchHistory;
[self setHotSearches:self.hotSearches];
[self setSearchHistoryStyle:self.searchHistoryStyle];
}
- (void)setCancelBarButtonItem:(UIBarButtonItem *)cancelBarButtonItem
{
_cancelBarButtonItem = cancelBarButtonItem;
self.navigationItem.rightBarButtonItem = cancelBarButtonItem;
}
- (void)setCancelButton:(UIButton *)cancelButton
{
_cancelButton = cancelButton;
self.navigationItem.rightBarButtonItem.customView = cancelButton;
}
- (void)setSearchHistoriesCachePath:(NSString *)searchHistoriesCachePath
{
_searchHistoriesCachePath = [searchHistoriesCachePath copy];
self.searchHistories = nil;
if (PYSearchHistoryStyleCell == self.searchHistoryStyle) {
[self.baseSearchTableView reloadData];
} else {
[self setSearchHistoryStyle:self.searchHistoryStyle];
}
}
- (void)setHotSearchTags:(NSArray<UILabel *> *)hotSearchTags
{
// popular search tagLabel's tag is 1, search history tagLabel's tag is 0.
for (UILabel *tagLabel in hotSearchTags) {
tagLabel.tag = 1;
}
_hotSearchTags = hotSearchTags;
}
- (void)setSearchBarBackgroundColor:(UIColor *)searchBarBackgroundColor
{
_searchBarBackgroundColor = searchBarBackgroundColor;
_searchTextField.backgroundColor = searchBarBackgroundColor;
}
- (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) {
// set searchSuggestion is nil when cell of suggestion view is custom.
_searchSuggestions = nil;
return;
}
_searchSuggestions = [searchSuggestions copy];
self.searchSuggestionVC.searchSuggestions = [searchSuggestions copy];
self.baseSearchTableView.hidden = !self.searchSuggestionHidden && [self.searchSuggestionVC.tableView numberOfRowsInSection:0];
self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0];
}
- (void)setRankTagBackgroundColorHexStrings:(NSArray<NSString *> *)rankTagBackgroundColorHexStrings
{
if (rankTagBackgroundColorHexStrings.count < 4) {
NSArray *colorStrings = @[@"#f14230", @"#ff8000", @"#ffcc01", @"#ebebeb"];
_rankTagBackgroundColorHexStrings = colorStrings;
} else {
_rankTagBackgroundColorHexStrings = @[rankTagBackgroundColorHexStrings[0], rankTagBackgroundColorHexStrings[1], rankTagBackgroundColorHexStrings[2], rankTagBackgroundColorHexStrings[3]];
}
self.hotSearches = self.hotSearches;
}
- (void)setHotSearches:(NSArray *)hotSearches
{
_hotSearches = hotSearches;
if (0 == hotSearches.count || !self.showHotSearch) {
self.hotSearchHeader.hidden = YES;
self.hotSearchTagsContentView.hidden = YES;
if (PYSearchHistoryStyleCell == self.searchHistoryStyle) {
UIView *tableHeaderView = self.baseSearchTableView.tableHeaderView;
tableHeaderView.py_height = PYSEARCH_MARGIN * 1.5;
[self.baseSearchTableView setTableHeaderView:tableHeaderView];
}
return;
};
self.baseSearchTableView.tableHeaderView.hidden = NO;
self.hotSearchHeader.hidden = NO;
self.hotSearchTagsContentView.hidden = NO;
if (PYHotSearchStyleDefault == self.hotSearchStyle
|| PYHotSearchStyleColorfulTag == self.hotSearchStyle
|| PYHotSearchStyleBorderTag == self.hotSearchStyle
|| PYHotSearchStyleARCBorderTag == self.hotSearchStyle) {
[self setupHotSearchNormalTags];
} else if (PYHotSearchStyleRankTag == self.hotSearchStyle) {
[self setupHotSearchRankTags];
} else if (PYHotSearchStyleRectangleTag == self.hotSearchStyle) {
[self setupHotSearchRectangleTags];
}
[self setSearchHistoryStyle:self.searchHistoryStyle];
}
- (void)setSearchHistoryStyle:(PYSearchHistoryStyle)searchHistoryStyle
{
_searchHistoryStyle = searchHistoryStyle;
if (!self.searchHistories.count || !self.showSearchHistory || UISearchBarStyleDefault == searchHistoryStyle) {
self.searchHistoryHeader.hidden = YES;
self.searchHistoryTagsContentView.hidden = YES;
self.searchHistoryView.hidden = YES;
self.emptyButton.hidden = YES;
return;
};
self.searchHistoryHeader.hidden = NO;
self.searchHistoryTagsContentView.hidden = NO;
self.searchHistoryView.hidden = NO;
self.emptyButton.hidden = NO;
[self setupSearchHistoryTags];
switch (searchHistoryStyle) {
case PYSearchHistoryStyleColorfulTag:
for (UILabel *tag in self.searchHistoryTags) {
tag.textColor = [UIColor whiteColor];
tag.layer.borderColor = nil;
tag.layer.borderWidth = 0.0;
tag.backgroundColor = PYSEARCH_COLORPolRandomColor;
}
break;
case PYSearchHistoryStyleBorderTag:
for (UILabel *tag in self.searchHistoryTags) {
tag.backgroundColor = [UIColor clearColor];
tag.layer.borderColor = PYSEARCH_COLOR(223, 223, 223).CGColor;
tag.layer.borderWidth = 0.5;
}
break;
case PYSearchHistoryStyleARCBorderTag:
for (UILabel *tag in self.searchHistoryTags) {
tag.backgroundColor = [UIColor clearColor];
tag.layer.borderColor = PYSEARCH_COLOR(223, 223, 223).CGColor;
tag.layer.borderWidth = 0.5;
tag.layer.cornerRadius = tag.py_height * 0.5;
}
break;
default:
break;
}
}
- (void)setHotSearchStyle:(PYHotSearchStyle)hotSearchStyle
{
_hotSearchStyle = hotSearchStyle;
switch (hotSearchStyle) {
case PYHotSearchStyleColorfulTag:
for (UILabel *tag in self.hotSearchTags) {
tag.textColor = [UIColor whiteColor];
tag.layer.borderColor = nil;
tag.layer.borderWidth = 0.0;
tag.backgroundColor = PYSEARCH_COLORPolRandomColor;
}
break;
case PYHotSearchStyleBorderTag:
for (UILabel *tag in self.hotSearchTags) {
tag.backgroundColor = [UIColor clearColor];
tag.layer.borderColor = PYSEARCH_COLOR(223, 223, 223).CGColor;
tag.layer.borderWidth = 0.5;
}
break;
case PYHotSearchStyleARCBorderTag:
for (UILabel *tag in self.hotSearchTags) {
tag.backgroundColor = [UIColor clearColor];
tag.layer.borderColor = PYSEARCH_COLOR(223, 223, 223).CGColor;
tag.layer.borderWidth = 0.5;
tag.layer.cornerRadius = tag.py_height * 0.5;
}
break;
case PYHotSearchStyleRectangleTag:
self.hotSearches = self.hotSearches;
break;
case PYHotSearchStyleRankTag:
self.rankTagBackgroundColorHexStrings = nil;
break;
default:
break;
}
}
- (void)setSearchViewControllerShowMode:(PYSearchViewControllerShowMode)searchViewControllerShowMode
{
_searchViewControllerShowMode = searchViewControllerShowMode;
if (_searchViewControllerShowMode == PYSearchViewControllerShowModeModal) { // modal
self.navigationItem.hidesBackButton = YES;
self.navigationItem.rightBarButtonItem = _cancelBarButtonItem;
self.navigationItem.leftBarButtonItem = nil;
} else if (_searchViewControllerShowMode == PYSearchViewControllerShowModePush) { // push
self.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = _backBarButtonItem;
self.navigationItem.rightBarButtonItem = nil;
}
}
- (void)cancelDidClick
{
[self.searchBar resignFirstResponder];
if ([self.delegate respondsToSelector:@selector(didClickCancel:)]) {
[self.delegate didClickCancel:self];
return;
}
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)backDidClick
{
[self.searchBar resignFirstResponder];
if ([self.delegate respondsToSelector:@selector(didClickBack:)]) {
[self.delegate didClickBack:self];
return;
}
[self.navigationController popViewControllerAnimated:YES];
}
- (void)keyboardDidShow:(NSNotification *)noti
{
NSDictionary *info = noti.userInfo;
self.keyboardHeight = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
self.keyboardShowing = YES;
// Adjust the content inset of suggestion view
self.searchSuggestionVC.tableView.contentInset = UIEdgeInsetsMake(-30, 0, self.keyboardHeight + 30, 0);
}
- (void)emptySearchHistoryDidClick
{
[self.searchHistories removeAllObjects];
[NSKeyedArchiver archiveRootObject:self.searchHistories toFile:self.searchHistoriesCachePath];
if (PYSearchHistoryStyleCell == self.searchHistoryStyle) {
[self.baseSearchTableView reloadData];
} else {
self.searchHistoryStyle = self.searchHistoryStyle;
}
if (YES == self.swapHotSeachWithSearchHistory) {
self.hotSearches = self.hotSearches;
}
PYSEARCH_LOG(@"%@", [NSBundle py_localizedStringForKey:PYSearchEmptySearchHistoryLogText]);
}
- (void)tagDidCLick:(UITapGestureRecognizer *)gr
{
UILabel *label = (UILabel *)gr.view;
self.searchBar.text = label.text;
// popular search tagLabel's tag is 1, search history tagLabel's tag is 0.
if (1 == label.tag) {
if ([self.delegate respondsToSelector:@selector(searchViewController:didSelectHotSearchAtIndex:searchText:)]) {
[self.delegate searchViewController:self didSelectHotSearchAtIndex:[self.hotSearchTags indexOfObject:label] searchText:label.text];
[self saveSearchCacheAndRefreshView];
} else {
[self searchBarSearchButtonClicked:self.searchBar];
}
} else {
if ([self.delegate respondsToSelector:@selector(searchViewController:didSelectSearchHistoryAtIndex:searchText:)]) {
[self.delegate searchViewController:self didSelectSearchHistoryAtIndex:[self.searchHistoryTags indexOfObject:label] searchText:label.text];
[self saveSearchCacheAndRefreshView];
} else {
[self searchBarSearchButtonClicked:self.searchBar];
}
}
PYSEARCH_LOG(@"Search %@", label.text);
}
- (UILabel *)labelWithTitle:(NSString *)title
{
UILabel *label = [[UILabel alloc] init];
label.userInteractionEnabled = YES;
label.font = [UIFont systemFontOfSize:12];
label.text = title;
label.textColor = [UIColor grayColor];
label.backgroundColor = [UIColor py_colorWithHexString:@"#fafafa"];
label.layer.cornerRadius = 3;
label.clipsToBounds = YES;
label.textAlignment = NSTextAlignmentCenter;
[label sizeToFit];
label.py_width += 20;
label.py_height += 14;
return label;
}
- (void)saveSearchCacheAndRefreshView
{
UISearchBar *searchBar = self.searchBar;
[searchBar resignFirstResponder];
NSString *searchText = searchBar.text;
if (self.removeSpaceOnSearchString) { // remove sapce on search string
searchText = [searchBar.text stringByReplacingOccurrencesOfString:@" " withString:@""];
}
if (self.showSearchHistory && searchText.length > 0) {
[self.searchHistories removeObject:searchText];
[self.searchHistories insertObject:searchText atIndex:0];
if (self.searchHistories.count > self.searchHistoriesCount) {
[self.searchHistories removeLastObject];
}
[NSKeyedArchiver archiveRootObject:self.searchHistories toFile:self.searchHistoriesCachePath];
if (PYSearchHistoryStyleCell == self.searchHistoryStyle) {
[self.baseSearchTableView reloadData];
} else {
self.searchHistoryStyle = self.searchHistoryStyle;
}
}
[self handleSearchResultShow];
}
- (void)handleSearchResultShow
{
switch (self.searchResultShowMode) {
case PYSearchResultShowModePush:
self.searchResultController.view.hidden = NO;
[self.navigationController pushViewController:self.searchResultController animated:YES];
break;
case PYSearchResultShowModeEmbed:
if (self.searchResultController) {
[self.view addSubview:self.searchResultController.view];
[self addChildViewController:self.searchResultController];
self.searchResultController.view.hidden = NO;
self.searchResultController.view.py_y = NO == self.navigationController.navigationBar.translucent ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame);
self.searchResultController.view.py_height = self.view.py_height - self.searchResultController.view.py_y;
self.searchSuggestionVC.view.hidden = YES;
} else {
PYSEARCH_LOG(@"PYSearchDebug: searchResultController cannot be nil when searchResultShowMode is PYSearchResultShowModeEmbed.");
}
break;
case PYSearchResultShowModeCustom:
break;
default:
break;
}
}
#pragma mark - PYSearchSuggestionViewDataSource
- (NSInteger)numberOfSectionsInSearchSuggestionView:(UITableView *)searchSuggestionView
{
if ([self.dataSource respondsToSelector:@selector(numberOfSectionsInSearchSuggestionView:)]) {
return [self.dataSource numberOfSectionsInSearchSuggestionView:searchSuggestionView];
}
return 1;
}
- (NSInteger)searchSuggestionView:(UITableView *)searchSuggestionView numberOfRowsInSection:(NSInteger)section
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:numberOfRowsInSection:)]) {
NSInteger numberOfRow = [self.dataSource searchSuggestionView:searchSuggestionView numberOfRowsInSection:section];
searchSuggestionView.hidden = self.searchSuggestionHidden || !self.searchBar.text.length || 0 == numberOfRow;
self.baseSearchTableView.hidden = !searchSuggestionView.hidden;
return numberOfRow;
}
return self.searchSuggestions.count;
}
- (UITableViewCell *)searchSuggestionView:(UITableView *)searchSuggestionView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:cellForRowAtIndexPath:)]) {
return [self.dataSource searchSuggestionView:searchSuggestionView cellForRowAtIndexPath:indexPath];
}
return nil;
}
- (CGFloat)searchSuggestionView:(UITableView *)searchSuggestionView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.dataSource respondsToSelector:@selector(searchSuggestionView:heightForRowAtIndexPath:)]) {
return [self.dataSource searchSuggestionView:searchSuggestionView heightForRowAtIndexPath:indexPath];
}
return 44.0;
}
#pragma mark - UISearchBarDelegate
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
if ([self.delegate respondsToSelector:@selector(searchViewController:didSearchWithSearchBar:searchText:)]) {
[self.delegate searchViewController:self didSearchWithSearchBar:searchBar searchText:searchBar.text];
[self saveSearchCacheAndRefreshView];
return;
}
if (self.didSearchBlock) self.didSearchBlock(self, searchBar, searchBar.text);
[self saveSearchCacheAndRefreshView];
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
if (PYSearchResultShowModeEmbed == self.searchResultShowMode && self.showSearchResultWhenSearchTextChanged) {
[self handleSearchResultShow];
self.searchResultController.view.hidden = 0 == searchText.length;
} else if (self.searchResultController) {
self.searchResultController.view.hidden = YES;
}
self.baseSearchTableView.hidden = searchText.length && !self.searchSuggestionHidden && [self.searchSuggestionVC.tableView numberOfRowsInSection:0];
self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || !searchText.length || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0];
if (self.searchSuggestionVC.view.hidden) {
self.searchSuggestions = nil;
}
[self.view bringSubviewToFront:self.searchSuggestionVC.view];
if ([self.delegate respondsToSelector:@selector(searchViewController:searchTextDidChange:searchText:)]) {
[self.delegate searchViewController:self searchTextDidChange:searchBar searchText:searchText];
}
}
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
if (PYSearchResultShowModeEmbed == self.searchResultShowMode) {
self.searchResultController.view.hidden = 0 == searchBar.text.length || !self.showSearchResultWhenSearchBarRefocused;
self.searchSuggestionVC.view.hidden = self.searchSuggestionHidden || !searchBar.text.length || ![self.searchSuggestionVC.tableView numberOfRowsInSection:0];
if (self.searchSuggestionVC.view.hidden) {
self.searchSuggestions = nil;
}
self.baseSearchTableView.hidden = searchBar.text.length && !self.searchSuggestionHidden && ![self.searchSuggestionVC.tableView numberOfRowsInSection:0];
}
[self setSearchSuggestions:self.searchSuggestions];
return YES;
}
- (void)closeDidClick:(UIButton *)sender
{
UITableViewCell *cell = (UITableViewCell *)sender.superview;
[self.searchHistories removeObject:cell.textLabel.text];
[NSKeyedArchiver archiveRootObject:self.searchHistories toFile:self.searchHistoriesCachePath];
[self.baseSearchTableView reloadData];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
self.baseSearchTableView.tableFooterView.hidden = 0 == self.searchHistories.count || !self.showSearchHistory;
return self.showSearchHistory && PYSearchHistoryStyleCell == self.searchHistoryStyle ? self.searchHistories.count : 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"PYSearchHistoryCellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.textLabel.textColor = PYTextColor;
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.backgroundColor = [UIColor clearColor];
UIButton *closetButton = [[UIButton alloc] init];
closetButton.py_size = CGSizeMake(cell.py_height, cell.py_height);
[closetButton setImage:[NSBundle py_imageNamed:@"close"] forState:UIControlStateNormal];
UIImageView *closeView = [[UIImageView alloc] initWithImage:[NSBundle py_imageNamed:@"close"]];
[closetButton addTarget:self action:@selector(closeDidClick:) forControlEvents:UIControlEventTouchUpInside];
closeView.contentMode = UIViewContentModeCenter;
cell.accessoryView = closetButton;
UIImageView *line = [[UIImageView alloc] initWithImage:[NSBundle py_imageNamed:@"cell-content-line"]];
line.py_height = 0.5;
line.alpha = 0.7;
line.py_x = PYSEARCH_MARGIN;
line.py_y = 43;
line.py_width = tableView.py_width;
line.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell.contentView addSubview:line];
}
cell.imageView.image = [NSBundle py_imageNamed:@"search_history"];
cell.textLabel.text = self.searchHistories[indexPath.row];
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return self.showSearchHistory && self.searchHistories.count && PYSearchHistoryStyleCell == self.searchHistoryStyle ? (self.searchHistoryTitle.length ? self.searchHistoryTitle : [NSBundle py_localizedStringForKey:PYSearchSearchHistoryText]) : nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return self.searchHistories.count && self.showSearchHistory && PYSearchHistoryStyleCell == self.searchHistoryStyle ? 25 : 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
self.searchBar.text = cell.textLabel.text;
if ([self.delegate respondsToSelector:@selector(searchViewController:didSelectSearchHistoryAtIndex:searchText:)]) {
[self.delegate searchViewController:self didSelectSearchHistoryAtIndex:indexPath.row searchText:cell.textLabel.text];
[self saveSearchCacheAndRefreshView];
} else {
[self searchBarSearchButtonClicked:self.searchBar];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (self.keyboardShowing) {
// Adjust the content inset of suggestion view
self.searchSuggestionVC.tableView.contentInset = UIEdgeInsetsMake(-30, 0, 30, 0);
[self.searchBar resignFirstResponder];
}
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer
{
return self.navigationController.childViewControllers.count > 1;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer
{
return self.navigationController.viewControllers.count > 1;
}
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (PYSearchExtension)
/**
Returns the corresponding color according to the hexadecimal string.
@param hexString hexadecimal string(eg:@"#ccff88")
@return new instance of `UIColor` class
*/
+ (instancetype)py_colorWithHexString:(NSString *)hexString;
/**
Returns the corresponding color according to the hexadecimal string and alpha.
@param hexString hexadecimal string(eg:@"#ccff88")
@param alpha alpha
@return new instance of `UIColor` class
*/
+ (instancetype)py_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha;
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "UIColor+PYSearchExtension.h"
@implementation UIColor (PYSearchExtension)
+ (instancetype)py_colorWithHexString:(NSString *)hexString
{
NSString *colorString = [[hexString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
if (colorString.length < 6) {
return [UIColor clearColor];
}
if ([colorString hasPrefix:@"0X"]) {
colorString = [colorString substringFromIndex:2];
}
if ([colorString hasPrefix:@"#"]) {
colorString = [colorString substringFromIndex:1];
}
if (colorString.length != 6) {
return [UIColor clearColor];
}
NSRange range;
range.location = 0;
range.length = 2;
// r
NSString *rString = [colorString substringWithRange:range];
// g
range.location = 2;
NSString *gString = [colorString substringWithRange:range];
// b
range.location = 4;
NSString *bString = [colorString substringWithRange:range];
unsigned int r, g, b;
[[NSScanner scannerWithString:rString] scanHexInt:&r];
[[NSScanner scannerWithString:gString] scanHexInt:&g];
[[NSScanner scannerWithString:bString] scanHexInt:&b];
return [UIColor colorWithRed:(float)r / 255.0 green:(float)g / 255.0 blue:(float)b / 255.0 alpha:1.0];
}
+ (instancetype)py_colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha
{
return [[self py_colorWithHexString:hexString] colorWithAlphaComponent:alpha];
}
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (PYSearchExtension)
@property (nonatomic, assign) CGFloat py_x;
@property (nonatomic, assign) CGFloat py_y;
@property (nonatomic, assign) CGFloat py_centerX;
@property (nonatomic, assign) CGFloat py_centerY;
@property (nonatomic, assign) CGFloat py_width;
@property (nonatomic, assign) CGFloat py_height;
@property (nonatomic, assign) CGSize py_size;
@property (nonatomic, assign) CGPoint py_origin;
@end
//
//
// GitHub: https://github.com/iphone5solo/PYSearch
// Created by CoderKo1o.
// Copyright © 2016 iphone5solo. All rights reserved.
//
#import "UIView+PYSearchExtension.h"
@implementation UIView (PYSearchExtension)
- (void)setPy_x:(CGFloat)py_x
{
CGRect frame = self.frame;
frame.origin.x = py_x;
self.frame = frame;
}
- (CGFloat)py_x
{
return self.py_origin.x;
}
- (void)setPy_centerX:(CGFloat)py_centerX
{
CGPoint center = self.center;
center.x = py_centerX;
self.center = center;
}
- (CGFloat)py_centerX
{
return self.center.x;
}
-(void)setPy_centerY:(CGFloat)py_centerY
{
CGPoint center = self.center;
center.y = py_centerY;
self.center = center;
}
- (CGFloat)py_centerY
{
return self.center.y;
}
- (void)setPy_y:(CGFloat)py_y
{
CGRect frame = self.frame;
frame.origin.y = py_y;
self.frame = frame;
}
- (CGFloat)py_y
{
return self.frame.origin.y;
}
- (void)setPy_size:(CGSize)py_size
{
CGRect frame = self.frame;
frame.size = py_size;
self.frame = frame;
}
- (CGSize)py_size
{
return self.frame.size;
}
- (void)setPy_height:(CGFloat)py_height
{
CGRect frame = self.frame;
frame.size.height = py_height;
self.frame = frame;
}
- (CGFloat)py_height
{
return self.frame.size.height;
}
- (void)setPy_width:(CGFloat)py_width
{
CGRect frame = self.frame;
frame.size.width = py_width;
self.frame = frame;
}
-(CGFloat)py_width
{
return self.frame.size.width;
}
- (void)setPy_origin:(CGPoint)py_origin
{
CGRect frame = self.frame;
frame.origin = py_origin;
self.frame = frame;
}
- (CGPoint)py_origin
{
return self.frame.origin;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment