diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 5d79ae2..def8a53 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -60,7 +60,6 @@ 3D1C509B221A9EDF0096AE43 /* CustomTopBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D1C4F72221A9EDD0096AE43 /* CustomTopBar.m */; }; 3D1C509C221A9EDF0096AE43 /* ModifyLoginPasswordResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4F73221A9EDD0096AE43 /* ModifyLoginPasswordResult.h */; }; 3D1C509D221A9EDF0096AE43 /* GetContactMessageResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4F74221A9EDD0096AE43 /* GetContactMessageResult.h */; }; - 3D1C509E221A9EDF0096AE43 /* Toast+UIView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D1C4F75221A9EDD0096AE43 /* Toast+UIView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 3D1C509F221A9EDF0096AE43 /* YProgressView.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4F76221A9EDD0096AE43 /* YProgressView.h */; }; 3D1C50A0221A9EDF0096AE43 /* TouchButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4F77221A9EDD0096AE43 /* TouchButton.h */; }; 3D1C50A1221A9EDF0096AE43 /* UIViewExt.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D1C4F79221A9EDD0096AE43 /* UIViewExt.m */; }; @@ -155,7 +154,6 @@ 3D1C50FB221A9EE00096AE43 /* ProgressImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4FDE221A9EDD0096AE43 /* ProgressImageView.h */; }; 3D1C50FC221A9EE00096AE43 /* TouchButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D1C4FDF221A9EDD0096AE43 /* TouchButton.m */; }; 3D1C50FD221A9EE00096AE43 /* YProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D1C4FE0221A9EDD0096AE43 /* YProgressView.m */; }; - 3D1C50FE221A9EE00096AE43 /* Toast+UIView.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4FE1221A9EDD0096AE43 /* Toast+UIView.h */; }; 3D1C50FF221A9EE00096AE43 /* YooseeCenterViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4FE3221A9EDD0096AE43 /* YooseeCenterViewCell.h */; }; 3D1C5100221A9EE00096AE43 /* IfishCameraModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4FE4221A9EDD0096AE43 /* IfishCameraModel.h */; }; 3D1C5101221A9EE00096AE43 /* IfishP2PMonitorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D1C4FE5221A9EDD0096AE43 /* IfishP2PMonitorController.h */; }; @@ -2374,6 +2372,8 @@ CB52699F22D491D300990E86 /* GWP2P.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB52699D22D491D200990E86 /* GWP2P.framework */; }; CB5269A022D491D300990E86 /* SDK使用说明 in Resources */ = {isa = PBXBuildFile; fileRef = CB52699E22D491D300990E86 /* SDK使用说明 */; }; CB5269A122D4A1B500990E86 /* GWP2P.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = CB52699D22D491D200990E86 /* GWP2P.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + CB5B9B1922EEC4BC00F0DFB1 /* UIView+Toast.m in Sources */ = {isa = PBXBuildFile; fileRef = CB5B9B1722EEC4BB00F0DFB1 /* UIView+Toast.m */; }; + CB5B9B1A22EEC4BC00F0DFB1 /* UIView+Toast.h in Headers */ = {isa = PBXBuildFile; fileRef = CB5B9B1822EEC4BB00F0DFB1 /* UIView+Toast.h */; }; CB7D6AA022953BEB0014E5C7 /* YYDiskCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CB7D6A9822953BEB0014E5C7 /* YYDiskCache.m */; }; CB7D6AA122953BEB0014E5C7 /* YYKVStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = CB7D6A9922953BEB0014E5C7 /* YYKVStorage.h */; }; CB7D6AA222953BEB0014E5C7 /* YYCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CB7D6A9A22953BEB0014E5C7 /* YYCache.m */; }; @@ -2617,7 +2617,6 @@ 3D1C4F72221A9EDD0096AE43 /* CustomTopBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomTopBar.m; sourceTree = ""; }; 3D1C4F73221A9EDD0096AE43 /* ModifyLoginPasswordResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModifyLoginPasswordResult.h; sourceTree = ""; }; 3D1C4F74221A9EDD0096AE43 /* GetContactMessageResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GetContactMessageResult.h; sourceTree = ""; }; - 3D1C4F75221A9EDD0096AE43 /* Toast+UIView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Toast+UIView.m"; sourceTree = ""; }; 3D1C4F76221A9EDD0096AE43 /* YProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YProgressView.h; sourceTree = ""; }; 3D1C4F77221A9EDD0096AE43 /* TouchButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchButton.h; sourceTree = ""; }; 3D1C4F79221A9EDD0096AE43 /* UIViewExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIViewExt.m; sourceTree = ""; }; @@ -2712,7 +2711,6 @@ 3D1C4FDE221A9EDD0096AE43 /* ProgressImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressImageView.h; sourceTree = ""; }; 3D1C4FDF221A9EDD0096AE43 /* TouchButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TouchButton.m; sourceTree = ""; }; 3D1C4FE0221A9EDD0096AE43 /* YProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YProgressView.m; sourceTree = ""; }; - 3D1C4FE1221A9EDD0096AE43 /* Toast+UIView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Toast+UIView.h"; sourceTree = ""; }; 3D1C4FE3221A9EDD0096AE43 /* YooseeCenterViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YooseeCenterViewCell.h; sourceTree = ""; }; 3D1C4FE4221A9EDD0096AE43 /* IfishCameraModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IfishCameraModel.h; sourceTree = ""; }; 3D1C4FE5221A9EDD0096AE43 /* IfishP2PMonitorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IfishP2PMonitorController.h; sourceTree = ""; }; @@ -5770,6 +5768,8 @@ CB484E3622B8CF9A0075F050 /* OpenMtopExt.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = OpenMtopExt.framework; sourceTree = ""; }; CB52699D22D491D200990E86 /* GWP2P.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GWP2P.framework; sourceTree = ""; }; CB52699E22D491D300990E86 /* SDK使用说明 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "SDK使用说明"; sourceTree = ""; }; + CB5B9B1722EEC4BB00F0DFB1 /* UIView+Toast.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Toast.m"; sourceTree = ""; }; + CB5B9B1822EEC4BB00F0DFB1 /* UIView+Toast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Toast.h"; sourceTree = ""; }; CB7D6A9822953BEB0014E5C7 /* YYDiskCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YYDiskCache.m; sourceTree = ""; }; CB7D6A9922953BEB0014E5C7 /* YYKVStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YYKVStorage.h; sourceTree = ""; }; CB7D6A9A22953BEB0014E5C7 /* YYCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YYCache.m; sourceTree = ""; }; @@ -6114,6 +6114,8 @@ CB484D8222B8BE830075F050 /* P2PClient.m */, 3D1C4F67221A9EDD0096AE43 /* AccountResult.h */, 3D1C4F9E221A9EDD0096AE43 /* AccountResult.m */, + CB5B9B1822EEC4BB00F0DFB1 /* UIView+Toast.h */, + CB5B9B1722EEC4BB00F0DFB1 /* UIView+Toast.m */, 3D1C4F6C221A9EDD0096AE43 /* Alarm.h */, 3D1C4FA8221A9EDD0096AE43 /* Alarm.m */, 3D1C4FBB221A9EDD0096AE43 /* CheckAlarmMessageResult.h */, @@ -6159,8 +6161,6 @@ 3D1C4FB2221A9EDD0096AE43 /* SVPullToRefresh */, 3D1C4FA6221A9EDD0096AE43 /* TabView.h */, 3D1C4F6E221A9EDD0096AE43 /* TabView.m */, - 3D1C4FE1221A9EDD0096AE43 /* Toast+UIView.h */, - 3D1C4F75221A9EDD0096AE43 /* Toast+UIView.m */, 3D1C4F77221A9EDD0096AE43 /* TouchButton.h */, 3D1C4FDF221A9EDD0096AE43 /* TouchButton.m */, 3D1C4FA5221A9EDD0096AE43 /* UDManager.h */, @@ -12695,6 +12695,7 @@ CB7D6AB522954E090014E5C7 /* UIColor+HexString.h in Headers */, CB484DE122B8C8C80075F050 /* version.h in Headers */, CB484DDD22B8C8C80075F050 /* intfloat.h in Headers */, + CB5B9B1A22EEC4BC00F0DFB1 /* UIView+Toast.h in Headers */, CBA61677228F9AB100ED380D /* MASLayoutConstraint.h in Headers */, 3D1C50C6221A9EE00096AE43 /* TabView.h in Headers */, CB484DE722B8C8C80075F050 /* avconfig.h in Headers */, @@ -12730,7 +12731,6 @@ CB484E1022B8C8C90075F050 /* avcodec.h in Headers */, CB0F4E8822951A130091C76D /* SVProgressHUD.h in Headers */, 3D1C511B221A9EE00096AE43 /* ShootImgDataSource.h in Headers */, - 3D1C50FE221A9EE00096AE43 /* Toast+UIView.h in Headers */, 3D1C5132221A9EE10096AE43 /* CameraRecordViewController.h in Headers */, CB484DF122B8C8C80075F050 /* adler32.h in Headers */, 3D1C50A9221A9EDF0096AE43 /* MXSCycleScrollView.h in Headers */, @@ -14571,7 +14571,6 @@ 88597ABC1E56BAF1003D0E5C /* PopView.m in Sources */, 3D8F64C12157530000F04BD3 /* IfishHistroyVo.m in Sources */, 880707F91DE3DF540076F65A /* MineKanKanRoomInfo.m in Sources */, - 3D1C509E221A9EDF0096AE43 /* Toast+UIView.m in Sources */, 881672221EA5DE2B00BEBF23 /* UMComBriefEditViewController.m in Sources */, 3D1C511C221A9EE00096AE43 /* IfishCameraModel.m in Sources */, 881672341EA5DE2B00BEBF23 /* UMComLikeButtonTableViewCell.m in Sources */, @@ -14779,6 +14778,7 @@ 880707FE1DE6C18A0076F65A /* KanKanListDataHelper.m in Sources */, 88F5EFA91D48D08100CC7CAF /* AFHTTPRequestOperation.m in Sources */, 3D1C50CF221A9EE00096AE43 /* ConnectFailurePromptView.m in Sources */, + CB5B9B1922EEC4BC00F0DFB1 /* UIView+Toast.m in Sources */, 883E78441D48A5E50030E075 /* KeLiAiBackmassageDataUnity.m in Sources */, 881671AF1EA5DE2B00BEBF23 /* UMComUserAlbumDataController.m in Sources */, 881671B01EA5DE2B00BEBF23 /* UMComLoginManager.m in Sources */, diff --git a/Ifish/AppDelegate.h b/Ifish/AppDelegate.h index 6dbe777..8142d25 100644 --- a/Ifish/AppDelegate.h +++ b/Ifish/AppDelegate.h @@ -12,7 +12,7 @@ #define ap_address "192.168.1.1" #define NET_WORK_CHANGE @"NET_WORK_CHANGE" #import "Reachability.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "Constants.h" #import #define SMSSDK_APPKey @"18c4fdbfbdbbf" diff --git a/Ifish/AppDelegate.m b/Ifish/AppDelegate.m index de81a66..9a24300 100644 --- a/Ifish/AppDelegate.m +++ b/Ifish/AppDelegate.m @@ -192,11 +192,13 @@ //[UIApplication sharedApplication].applicationIconBadgeNumber = 10; } } + //自定义弹出框 + [self setUpToastView]; + /** * 初始化BugTags */ - // BugtagsOptions *options = [[BugtagsOptions alloc] init]; // options.trackingCrashes = YES; // 具体可设置的属性请查看 Bugtags.h // [Bugtags startWithAppKey:BUGTAGS_APPKEY invocationEvent:BTGInvocationEventBubble options:options]; @@ -363,6 +365,10 @@ if (kScreenSize.height>480) { return YES; +} +//自定义toast提示框 +-(void)setUpToastView{ + } //初始化提示框 - (void)setUpSVProgressHUD { @@ -418,7 +424,6 @@ if (kScreenSize.height>480) { self.isGoBack = YES; // [GWNetSingleton sharedClient] [[P2PClient sharedClient] p2pHungUp]; -#warning p2p appdelegate //2.3 版本 点击home 键 就直接挂起 不让app 后台运行 设置Application does not run in background =YES } @@ -508,7 +513,6 @@ if (kScreenSize.height>480) { // 禁止横屏 - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { - //return [[P2PClient sharedClient] interfaceOrientationMask]; if (self.canFullScreen) { diff --git a/Ifish/Info.plist b/Ifish/Info.plist index 1e929c4..f0090ef 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - 9.9.13 + 9.9.14 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/Ifish/controllers/FishTinkController/maincontroller/RightViewControllers/SetNameTextViewController.m b/Ifish/controllers/FishTinkController/maincontroller/RightViewControllers/SetNameTextViewController.m index f26beb5..051fdaf 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/RightViewControllers/SetNameTextViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/RightViewControllers/SetNameTextViewController.m @@ -9,7 +9,7 @@ #import "SetNameTextViewController.h" #import "AFNetworking.h" #import "MyMD5.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" @interface SetNameTextViewController () diff --git a/Ifish/controllers/HotBar/IfishHotBarVc.m b/Ifish/controllers/HotBar/IfishHotBarVc.m index 03a1ec1..82085c3 100644 --- a/Ifish/controllers/HotBar/IfishHotBarVc.m +++ b/Ifish/controllers/HotBar/IfishHotBarVc.m @@ -17,7 +17,7 @@ #import "MJExtension.h" #import "Socketsingleton.h" #import "IfishHotBarPackegeVo.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "IfishHotBarModifyNameVc.h" #import "searchDeviceModel.h" #import "IfishHotBarHeader.h" diff --git a/Ifish/controllers/IfishTabControllers/我的/mineControllers/InfoViewController.m b/Ifish/controllers/IfishTabControllers/我的/mineControllers/InfoViewController.m index 0ac7d23..d39d55e 100644 --- a/Ifish/controllers/IfishTabControllers/我的/mineControllers/InfoViewController.m +++ b/Ifish/controllers/IfishTabControllers/我的/mineControllers/InfoViewController.m @@ -21,7 +21,7 @@ #define QIANMINGCELL_TAG 12342 #import "infoSureBtnCell.h" #import "SVProgressHUD.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "IfishUserDefaultHelper.h" @interface InfoViewController () diff --git a/Ifish/controllers/IfishTabControllers/探索/IfishNewShopsFlie/IfishShopEdite/VController/IfishShopEditeNewViewController.m b/Ifish/controllers/IfishTabControllers/探索/IfishNewShopsFlie/IfishShopEdite/VController/IfishShopEditeNewViewController.m index 090022d..ec3ca63 100644 --- a/Ifish/controllers/IfishTabControllers/探索/IfishNewShopsFlie/IfishShopEdite/VController/IfishShopEditeNewViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/IfishNewShopsFlie/IfishShopEdite/VController/IfishShopEditeNewViewController.m @@ -789,7 +789,7 @@ UIGestureRecognizerDelegate> return; } - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; if (self.privence==nil) { diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m index 60cfa37..3eb9bbe 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m @@ -413,7 +413,7 @@ return; } - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; UserModel*umodel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"]; diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/LookAfterReportViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/LookAfterReportViewController.m index 89a198a..8b340d0 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/LookAfterReportViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/LookAfterReportViewController.m @@ -201,7 +201,7 @@ -(void)faSongBtnClick:(UIButton*)btn{ btn.userInteractionEnabled =NO; - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; [AFNOHeaderHttpTool sendReportWithUserId:self.listModel.userId baoGaoHtmlName:self.baGaoMod.fileName reportId:self.baGaoMod.reportId success:^(id response) { NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopEditViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopEditViewController.m index 07e02a7..649c9f9 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopEditViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopEditViewController.m @@ -910,7 +910,7 @@ } - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; AFHTTPRequestOperationManager*manager=[AFHTTPRequestOperationManager manager]; diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m index ad7b230..90006f1 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m @@ -577,7 +577,7 @@ } - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; [self screenShot]; UserModel*umodel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"]; diff --git a/Ifish/controllers/IfishTabControllers/探索/shopCertification/ShopCertificationViewController.m b/Ifish/controllers/IfishTabControllers/探索/shopCertification/ShopCertificationViewController.m index f8d5d09..a83e32d 100644 --- a/Ifish/controllers/IfishTabControllers/探索/shopCertification/ShopCertificationViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/shopCertification/ShopCertificationViewController.m @@ -1097,7 +1097,7 @@ } - [self.view makeToastActivity]; + [self.view makeToastActivity:CSToastPositionCenter]; CertifyListFourthCell *cell =[self.view viewWithTag:CERTYVIEW_CELLTAGROW9]; diff --git a/Ifish/controllers/IfishYooseeFile/.DS_Store b/Ifish/controllers/IfishYooseeFile/.DS_Store index c0123df..6423af3 100644 Binary files a/Ifish/controllers/IfishYooseeFile/.DS_Store and b/Ifish/controllers/IfishYooseeFile/.DS_Store differ diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m index d22d0f0..9b7c53c 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m @@ -10,7 +10,7 @@ #import #import #import -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "AppDelegate.h" #import "UDManager.h" #import "Utils.h" @@ -141,11 +141,11 @@ Strong UIImage *screenShotImage;//截图 } } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveRemoteMessage:) name:RECEIVE_REMOTE_MESSAGE object:nil]; - [self.bottomToolHView addObViserFromSelf]; self.navigationController.navigationBarHidden = NO; _isCanAutoOrientation = YES; //设置默认竖屏 [[AppDelegate sharedDefault] application:[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[AppDelegate sharedDefault].window]; + [self.view hideToast]; //先判断是否授权 if (!self.contact.isActive) { @@ -176,23 +176,17 @@ Strong UIImage *screenShotImage;//截图 [self.view makeToast:@"当前网络环境:未知,请检查网络"]; break; case AFNetworkReachabilityStatusNotReachable: - NSLog(@"无连接"); - //self.netStateLabel.text = @"当前网络环境:无网络,请检查网络"; + NSLog(@"无连接"); [self.view makeToast:@"当前网络环境:无网络,请检查网络"]; break; case AFNetworkReachabilityStatusReachableViaWWAN: - //self.netStateLabel.text = @"当前网络环境:3/4G,建议切换到WiFi"; [self.view makeToast:@"当前网络环境:3/4G,建议切换到WiFi"]; NSLog(@"2/3G"); break; case AFNetworkReachabilityStatusReachableViaWiFi: - NSLog(@"Wifi"); - - //self.netStateLabel.text = @"当前网络环境:WiFi,请放心观看"; - [self.view makeToast:@"当前网络环境:WiFi,请放心观看"]; break; @@ -639,7 +633,7 @@ Strong UIImage *screenShotImage;//截图 if ([weakSelf.player isPlaying]) { - [weakSelf.view makeToastActivity]; + [weakSelf.view makeToastActivity:CSToastPositionCenter]; [[GWP2PClient sharedClient] checkDeviceUpdateWithDeviceID:weakSelf.contact.cameraId devicePassword:weakSelf.contact.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { //检查更新成功之后,处理回调事件 [weakSelf checkUpdateSuccessWithDictionary:dataDictionary]; @@ -648,14 +642,7 @@ Strong UIImage *screenShotImage;//截图 [weakSelf.view makeToast:@"设备已离线"]; } - - }else if (tag == 3){ - //解除绑定关系 - - [weakSelf jieBangBtnAction]; - } - [weakSelf popAppear];//隐藏弹出框 }; } @@ -676,17 +663,11 @@ Strong UIImage *screenShotImage;//截图 } -(void)initPopOver{ [self.view addSubview:self.popView]; - BOOL isBind=[self testCameraBindDeviceOrNot]; NSArray *titleImgs =nil; NSArray *titles=nil; - if (isBind) { - titleImgs = @[@"ifishdropview_edite_device",@"ifishdropview_delect_device",@"equipment_icon_equipmentupdate",@"ifish_jieBang_device"]; - titles=@[@"修改名称",@"删除设备",@"设备升级",@"解除绑定"]; - }else{ - titleImgs = @[@"ifishdropview_edite_device",@"ifishdropview_delect_device",@"equipment_icon_equipmentupdate"]; - titles=@[@"修改名称",@"删除设备",@"设备升级"]; - } - [self.popView loadInfoWithTitle:titles Icons:titleImgs]; + titleImgs = @[@"ifishdropview_edite_device",@"ifishdropview_delect_device",@"equipment_icon_equipmentupdate"]; + titles=@[@"修改名称",@"删除设备",@"设备升级"]; + [self.popView loadInfoWithTitle:titles Icons:titleImgs]; } //判断摄像头是否有关系设备 @@ -1118,6 +1099,7 @@ Strong UIImage *screenShotImage;//截图 - (void)screenShot { // WEAK_SELF; //todo: 不停截图内存升高 + [self.player p2pScreenshot:^(UIImage *screenshot, NSTimeInterval timeInterval) { dispatch_async(dispatch_get_main_queue(), ^{ UIImage *tempImage = [[UIImage alloc] initWithCGImage:screenshot.CGImage]; @@ -1139,6 +1121,7 @@ Strong UIImage *screenShotImage;//截图 break; case SWITCH_SCREEN_BUTTON_H_TAG://切换至横屏或者竖屏 { + [self.view hideToast]; if (![self.player isPlaying]) { return; } @@ -1155,9 +1138,7 @@ Strong UIImage *screenShotImage;//截图 withObject:numb]; SEL selector = NSSelectorFromString(@"setOrientation:"); - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; - [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; @@ -1184,7 +1165,6 @@ Strong UIImage *screenShotImage;//截图 } else { - self.isFullScreen4B3 = !self.isFullScreen4B3; //设置竖屏 [AppDelegate sharedDefault].canFullScreen = NO; @@ -1577,10 +1557,8 @@ Strong UIImage *screenShotImage;//截图 } } - break; - case RET_DO_DEVICE_UPDATE: { NSInteger result = [[parameter valueForKey:@"result"] intValue]; @@ -1595,31 +1573,6 @@ Strong UIImage *screenShotImage;//截图 }else if(result==65){ [self.progressMaskView setHidden:YES]; [self.view makeToast:@"升级成功"]; - //固件下载成功,并在升级中,弹出一个框 - // YMsgBox *yBox = [[YMsgBox alloc] init]; - //yBox.yMsgTextField.secureTextEntry = YES; - // [yBox addTarget:self withAction:@selector(isUpdateFirmware:) forEvent:YMsgBoxMsgTypeButtonBeClick]; - // yBox.yMsgTitle = [YFonc gtTextWithString:NSLocalizedString(@"firmware_is_being_upgraded", nil) - // withColor:[UIColor blackColor] - // withFont:[UIFont systemFontOfSize:15] - // withAlignment:NSTextAlignmentCenter]; - // yBox.yMsgTextFieldBorderColor=RGBA(62,156,254,1.0); - // yBox.yMsgTextFieldBottomLineColor=[UIColor clearColor]; - // yBox.yMsgButtonBorderColor=RGBA(211,211,212,1.0); - // UIButton *okBtn= [[UIButton alloc ]init]; - // [okBtn setTitleColor:[UIColor colorWithRed:62.0/255.0 green:156.0/255.0 blue:254.0/255.0 alpha:1.0] forState:UIControlStateNormal]; - // [okBtn setTitleColor:[UIColor colorWithRed:27.0/255.0 green:122.0/255.0 blue:222.0/255.0 alpha:1.0] forState:UIControlStateHighlighted]; - // okBtn.titleLabel.font = [UIFont systemFontOfSize:15]; - // [okBtn setTitle:NSLocalizedString(@"i_know",nil) forState:UIControlStateNormal]; - - // UIButton *cancelBtn= [[UIButton alloc ]init]; - // cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15]; - // [cancelBtn setTitle:NSLocalizedString(@"no",nil) forState:UIControlStateNormal]; - //[cancelBtn setTitleColor:UIColorFromRGB(0x3e9cfe) forState:UIControlStateNormal]; - - // yBox.yMsgButtons = @[okBtn]; - // [yBox showMsgBoxInViewController:self]; - }else{ [self.progressMaskView setHidden:YES]; @@ -1631,20 +1584,6 @@ Strong UIImage *screenShotImage;//截图 break; } } -#pragma mark - 弹框操作 --(void)isUpdateFirmware:(YMsgBox*)box{ - if(box.yMsgButtonIndex == -1){ - return; - }else if(box.yMsgButtonIndex == -2){ //隐藏键盘 系统键盘return按钮被点击 - [box hideKeyBoard]; - }else if(box.yMsgButtonIndex == 0){ //确认按钮被点击 - // [self.navigationController popToRootViewControllerAnimated:YES]; - [self.navigationController popViewControllerAnimated:YES]; - [box hideMsgBox]; //隐藏输入框 - }else{ //取消按钮被点击 - [box hideMsgBox]; //隐藏输入框 - } -} - (void)ack_receiveRemoteMessage:(NSNotification *)notification{ NSDictionary *parameter = [notification userInfo]; @@ -2736,9 +2675,7 @@ Strong UIImage *screenShotImage;//截图 UIImage *tempImage = [[UIImage alloc] initWithCGImage:image.CGImage]; NSData *imgData = [NSData dataWithData:UIImagePNGRepresentation(tempImage)]; [Utils saveScreenshotFile:imgData]; - //[self popLXAdViewWith:tempImage]; dispatch_async(dispatch_get_main_queue(), ^{ - //[self.view makeToast:NSLocalizedString(@"screenshot_success", nil)]; [self.view makeToast:@"截图成功,请在图库中查看"]; }); } @@ -3330,43 +3267,7 @@ GWP2PCallErrorNotSupport, [self.pressView setHidden:YES]; // [[PAIOUnit sharedUnit] setSpeckState:YES]; } -// //竖屏对讲按钮 -// UIButton *talkButtonH = (UIButton *)[self.bottomToolHView viewWithTag:TALK_BUTTON_H_TAG]; -// if([AppDelegate sharedDefault].isDoorBellAlarm){//门铃推送 -// talkButtonH.selected = YES; -// }else{ -// talkButtonH.selected = NO; -// } -// //横屏对讲按钮 -// TouchButton *controllerTalkBtn = (TouchButton *)[self.controllBar viewWithTag:CONTROLLER_BTN_TAG_PRESS_TALK]; -// //非本地设备 -// NSInteger deviceType1 = [AppDelegate sharedDefault].contact.contactType; -// //本地设备 -// NSInteger deviceType2 = [[FListManager sharedFList] getType:[[P2PClient sharedClient] callId]]; -// if (deviceType1 == CONTACT_TYPE_DOORBELL || deviceType2 == CONTACT_TYPE_DOORBELL) {//支持门铃,点按开关说话 -// if([AppDelegate sharedDefault].isDoorBellAlarm){//门铃推送 -// -// [controllerTalkBtn setBackgroundImage:[UIImage imageNamed:@"ic_ctl_new_send_audio_p.png"] forState:UIControlStateNormal]; -// } -// if (controllerTalkBtn.delegate) { -// controllerTalkBtn.delegate = nil; -// } -// [controllerTalkBtn addTarget:self action:@selector(onControllerBtnPress:) forControlEvents:UIControlEventTouchUpInside]; -// }else{ -// //不是门铃,则按住说话 -// [controllerTalkBtn setBackgroundImage:[UIImage imageNamed:@"ic_ctl_new_send_audio.png"] forState:UIControlStateNormal]; -// [controllerTalkBtn removeTarget:self action:@selector(onControllerBtnPress:) forControlEvents:UIControlEventTouchUpInside]; -// controllerTalkBtn.delegate = self; -// } - - - //放在渲染之后 - //获取当前被监控帐号的灯状态 - //若设备支持灯设备时,则显示开关按钮;若不支持,则隐藏 - // NSString *contactId = [[P2PClient sharedClient] callId]; - // NSString *contactPassword = [[P2PClient sharedClient] callPassword]; - // [[P2PClient sharedClient] getLightStateWithDeviceId:contactId password:contactPassword]; - + NSString *callId = [[P2PClient sharedClient] callId]; NSString *callPassword = [[P2PClient sharedClient] callPassword]; @@ -4046,7 +3947,7 @@ GWP2PCallErrorNotSupport, -(void)guanbiShuiBeng{ //manulswitchMSModel 和摄像头sdk 中的类重名报错 - //[self.bottomFishHView makeToastActivity]; + //[self.bottomFishHView makeToastActivity:CSToastPositionCenter]; XuToLightModel*manulModel=[[XuToLightModel alloc]init]; [[Socketsingleton sharedInstance] setXuToSoketLightDataWith:manulModel]; NSString*switchString=manulModel.description; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/P2PPlaybackController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/P2PPlaybackController.m index c09195f..c36b7b8 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/P2PPlaybackController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PPlayBack/P2PPlaybackController.m @@ -14,7 +14,7 @@ #import "Utils.h" #import "Contact.h" #import "P2PClient.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "P2PPlayingbackVC.h" #import "SVPullToRefresh.h" #import "UIScrollView+SVInfiniteScrolling.h" diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/ScreenShotView/ShotScreenImgViewController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/ScreenShotView/ShotScreenImgViewController.m index 2d6735f..fae1a2a 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/ScreenShotView/ShotScreenImgViewController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/ScreenShotView/ShotScreenImgViewController.m @@ -11,7 +11,7 @@ #import "AppDelegate.h" #import "UDManager.h" #import "LoginResult.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" @interface ShotScreenImgViewController () diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm index 478acc3..4698879 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm @@ -11,7 +11,7 @@ #define WAITING_CONTENT_VIEW_HEIGHT 300 #define NAVIGATION_BAR_HEIGHT ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0 ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 44:44):(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 64:64)) #import -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "ContactDAO.h" #import "AppDelegate.h" #import "UDManager.h" diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m index b4f980f..5543f02 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/MonitorBootmView.m @@ -870,7 +870,7 @@ }else{ [BootomViewSoketBackMasgConreol RusunCommandSelectorWithBackMode148:_ruSunBack atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } }else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){ @@ -886,7 +886,7 @@ }else{ [BootomViewSoketBackMasgConreol RusunCommandSelectorWithBackMode168:_ruSun84Back atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } @@ -903,7 +903,7 @@ }else{ [BootomViewSoketBackMasgConreol RuiMeiCommandSelectorWithBackMode168:_ruiMeiBack atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } @@ -923,7 +923,7 @@ }else{ [BootomViewSoketBackMasgConreol SongnuoBDCommandSelectorWithBackMode86:_songNuoBDBack atindexPath:indexPath]; } - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; }else if ([self.device.type isEqualToString:DECICE_TYPE_XUANDUO2F]){ // 新绚多 @@ -937,7 +937,7 @@ }else{ [BootomViewSoketBackMasgConreol XuTo2ControlCommandSelectorWithBackModel73:_xuanduoBack atindexPath:indexPath]; } - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; }else{ @@ -972,7 +972,7 @@ [BootomViewSoketBackMasgConreol TwoControlCommandSelectorWithBackModel57:_twoControlBack atindexPath:indexPath]; } - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } break; @@ -985,7 +985,7 @@ return; } [BootomViewSoketBackMasgConreol threeControlCommandSelectorWithBackModel:_backModel1 atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; @@ -1004,7 +1004,7 @@ } [BootomViewSoketBackMasgConreol FourControlCommandSelectorWithBackModel85:_fourControlbackmodel atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; }else if (timerAmount == 6){ //可丽爱 @@ -1024,7 +1024,7 @@ [BootomViewSoketBackMasgConreol KeLiAiCommandSelectorWithBackModel72:_keLiAiBackmodel atindexPath:indexPath]; - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } } @@ -1049,7 +1049,7 @@ [self.MonitorBottomDelegate selectXuToAtIndex:indexPath withbackModel:_xutoback]; }else{ - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; [BootomViewSoketBackMasgConreol XuToControlCommandSelectorWithBackModel73:_xutoback atindexPath:indexPath]; } @@ -1064,7 +1064,7 @@ { //6空 - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; } break; case IFISH_DEVICE_CONTROLAMOUNT8: @@ -1087,7 +1087,7 @@ }else{ - [self makeToastActivity]; + [self makeToastActivity:CSToastPositionCenter]; [BootomViewSoketBackMasgConreol SongNuoControlCommandSelectorWithBackModel128:_songNuoBackMassage atindexPath:indexPath]; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.h deleted file mode 100644 index 8872f84..0000000 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - -Toast+UIView.h -Toast -Version 2.0 - -Copyright (c) 2013 Charles Scalesse. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -***************************************************************************/ - - -#import -#import -@interface UIView (Toast) - -// each makeToast method creates a view and displays it as toast -- (void)makeToast:(NSString *)message; -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position; -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position title:(NSString *)title; -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position title:(NSString *)title image:(UIImage *)image; -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position image:(UIImage *)image; - -// displays toast with an activity spinner -- (void)makeToastActivity; -//带黑色背景 activity -- (void)makeToastActivityBlackBack; - -- (void)makeToastActivity:(id)position; -- (void)hideToastActivity; - -// the showToast methods display any view as toast -- (void)showToast:(UIView *)toast; -- (void)showToast:(UIView *)toast duration:(CGFloat)interval position:(id)point; - -@end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.m deleted file mode 100644 index a8614e4..0000000 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Toast+UIView.m +++ /dev/null @@ -1,386 +0,0 @@ -// -// Toast+UIView.m -// Toast -// Version 2.0 -// -// Copyright 2013 Charles Scalesse. -// - -#import "Toast+UIView.h" -#import -#import - -/* - * CONFIGURE THESE VALUES TO ADJUST LOOK & FEEL, - * DISPLAY DURATION, ETC. - */ - -// general appearance -static const CGFloat CSToastMaxWidth = 0.8; // 80% of parent view width -static const CGFloat CSToastMaxHeight = 0.8; // 80% of parent view height -static const CGFloat CSToastHorizontalPadding = 10.0; -static const CGFloat CSToastVerticalPadding = 8.0; -static const CGFloat CSToastCornerRadius = 10.0; -static const CGFloat CSToastOpacity = 0.8; -static const CGFloat CSToastFontSize = 14.0; -static const CGFloat CSToastMaxTitleLines = 0; -static const CGFloat CSToastMaxMessageLines = 0; -static const CGFloat CSToastFadeDuration = 0.2; - -// shadow appearance -static const CGFloat CSToastShadowOpacity = 0.8; -static const CGFloat CSToastShadowRadius = 6.0; -static const CGSize CSToastShadowOffset = { 4.0, 4.0 }; -static const BOOL CSToastDisplayShadow = YES; - -// display duration and position -static const CGFloat CSToastDefaultDuration = 1.5; -static const NSString * CSToastDefaultPosition = @"center"; - -// image view size -static const CGFloat CSToastImageViewWidth = 80.0; -static const CGFloat CSToastImageViewHeight = 80.0; - -// activity -static const CGFloat CSToastActivityWidth = 100.0; -static const CGFloat CSToastActivityHeight = 100.0; -static const NSString * CSToastActivityDefaultPosition = @"center"; -static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey"; - - -@interface UIView (ToastPrivate) - -- (CGPoint)centerPointForPosition:(id)position withToast:(UIView *)toast; -- (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image; - -@end - - -@implementation UIView (Toast) - -#pragma mark - Toast Methods - -- (void)makeToast:(NSString *)message { - [self makeToast:message duration:CSToastDefaultDuration position:CSToastDefaultPosition]; -} - -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position { - UIView *toast = [self viewForMessage:message title:nil image:nil]; - [self showToast:toast duration:interval position:position]; -} - -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position title:(NSString *)title { - UIView *toast = [self viewForMessage:message title:title image:nil]; - [self showToast:toast duration:interval position:position]; -} - -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position image:(UIImage *)image { - UIView *toast = [self viewForMessage:message title:nil image:image]; - [self showToast:toast duration:interval position:position]; -} - -- (void)makeToast:(NSString *)message duration:(CGFloat)interval position:(id)position title:(NSString *)title image:(UIImage *)image { - UIView *toast = [self viewForMessage:message title:title image:image]; - [self showToast:toast duration:interval position:position]; -} - -- (void)showToast:(UIView *)toast { - [self showToast:toast duration:CSToastDefaultDuration position:CSToastDefaultPosition]; -} - -- (void)showToast:(UIView *)toast duration:(CGFloat)interval position:(id)point { - toast.center = [self centerPointForPosition:point withToast:toast]; - toast.alpha = 0.0; - [self addSubview:toast]; - - [UIView animateWithDuration:CSToastFadeDuration - delay:0.0 - options:UIViewAnimationOptionCurveEaseOut - animations:^{ - toast.alpha = 1.0; - } completion:^(BOOL finished) { - [UIView animateWithDuration:CSToastFadeDuration - delay:interval - options:UIViewAnimationOptionCurveEaseIn - animations:^{ - toast.alpha = 0.0; - } completion:^(BOOL finished) { - [toast removeFromSuperview]; - }]; - }]; -} - -#pragma mark - Toast Activity Methods - -- (void)makeToastActivity { - [self makeToastActivity:CSToastActivityDefaultPosition]; -} - -- (void)makeToastActivity:(id)position { - // sanity - UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey); - if (existingActivityView != nil) return; - - UIView *activityView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, CSToastActivityWidth, CSToastActivityHeight)] autorelease]; - activityView.center = [self centerPointForPosition:position withToast:activityView]; - //原 - //activityView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:CSToastOpacity]; - //改 - activityView.backgroundColor =[UIColor clearColor]; - activityView.alpha = 0.0; - activityView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); - activityView.layer.cornerRadius = CSToastCornerRadius; - - if (CSToastDisplayShadow) { - activityView.layer.shadowColor = [UIColor blackColor].CGColor; - activityView.layer.shadowOpacity = CSToastShadowOpacity; - activityView.layer.shadowRadius = CSToastShadowRadius; - activityView.layer.shadowOffset = CSToastShadowOffset; - } - - UIActivityIndicatorView *activityIndicatorView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease]; - activityIndicatorView.center = CGPointMake(activityView.bounds.size.width / 2, activityView.bounds.size.height / 2); - [activityView addSubview:activityIndicatorView]; - [activityIndicatorView startAnimating]; - - // associate ourselves with the activity view - objc_setAssociatedObject (self, &CSToastActivityViewKey, activityView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - - [self addSubview:activityView]; - //新 - - - [UIView animateWithDuration:CSToastFadeDuration - delay:0.0 - options:UIViewAnimationOptionCurveEaseOut - animations:^{ - activityView.alpha = 1.0; - } completion:nil]; -} - - -//黑色 -- (void)makeToastActivityBlackBack{ - - [self makeToastActivityBlackBack:CSToastActivityDefaultPosition]; -} - --(void)makeToastActivityBlackBack:(id)position{ - - // sanity - - - //self.alpha = 0.8; - UIView *backView=[[UIView alloc] initWithFrame:self.frame]; - backView.backgroundColor = [UIColor blackColor]; - backView.alpha= 0.8; - - [self addSubview:backView]; - - UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey); - if (existingActivityView != nil) return; - - - UIView *activityView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, CSToastActivityWidth, CSToastActivityHeight)] autorelease]; - activityView.center = [self centerPointForPosition:position withToast:activityView]; - - //原 - - activityView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:CSToastOpacity]; - - activityView.alpha = 0.0; - activityView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); - activityView.layer.cornerRadius = CSToastCornerRadius; - - if (CSToastDisplayShadow) { - activityView.layer.shadowColor = [UIColor blackColor].CGColor; - activityView.layer.shadowOpacity = CSToastShadowOpacity; - activityView.layer.shadowRadius = CSToastShadowRadius; - activityView.layer.shadowOffset = CSToastShadowOffset; - } - - UIActivityIndicatorView *activityIndicatorView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease]; - activityIndicatorView.center = CGPointMake(activityView.bounds.size.width / 2, activityView.bounds.size.height / 2); - [activityView addSubview:activityIndicatorView]; - [activityIndicatorView startAnimating]; - - // associate ourselves with the activity view - objc_setAssociatedObject (self, &CSToastActivityViewKey, activityView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - - [self addSubview:activityView]; - [self bringSubviewToFront:activityView]; - - //新 - [UIView animateWithDuration:CSToastFadeDuration - delay:0.0 - options:UIViewAnimationOptionCurveEaseOut - animations:^{ - activityView.alpha = 1.0; - } completion:nil]; - - -} -- (void)hideToastActivity { - UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey); - if (existingActivityView != nil) { - [UIView animateWithDuration:CSToastFadeDuration - delay:0.0 - options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) - animations:^{ - existingActivityView.alpha = 0.0; - } completion:^(BOOL finished) { - [existingActivityView removeFromSuperview]; - objc_setAssociatedObject (self, &CSToastActivityViewKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - }]; - } -} - -#pragma mark - Private Methods - -- (CGPoint)centerPointForPosition:(id)point withToast:(UIView *)toast { - if([point isKindOfClass:[NSString class]]) { - // convert string literals @"top", @"bottom", @"center", or any point wrapped in an NSValue object into a CGPoint - if([point caseInsensitiveCompare:@"top"] == NSOrderedSame) { - return CGPointMake(self.bounds.size.width/2, (toast.frame.size.height / 2) + CSToastVerticalPadding); - } else if([point caseInsensitiveCompare:@"bottom"] == NSOrderedSame) { - return CGPointMake(self.bounds.size.width/2, (self.bounds.size.height - (toast.frame.size.height / 2)) - CSToastVerticalPadding); - } else if([point caseInsensitiveCompare:@"center"] == NSOrderedSame) { - return CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2); - } - } else if ([point isKindOfClass:[NSValue class]]) { - return [point CGPointValue]; - } - - NSLog(@"Warning: Invalid position for toast."); - return [self centerPointForPosition:CSToastDefaultPosition withToast:toast]; -} - -- (UIView *)viewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image { - // sanity - if((message == nil) && (title == nil) && (image == nil)) return nil; - - // dynamically build a toast view with any combination of message, title, & image. - UILabel *messageLabel = nil; - UILabel *titleLabel = nil; - UIImageView *imageView = nil; - - // create the parent view - UIView *wrapperView = [[[UIView alloc] init] autorelease]; - wrapperView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); - wrapperView.layer.cornerRadius = CSToastCornerRadius; - - if (CSToastDisplayShadow) { - wrapperView.layer.shadowColor = [UIColor blackColor].CGColor; - wrapperView.layer.shadowOpacity = CSToastShadowOpacity; - wrapperView.layer.shadowRadius = CSToastShadowRadius; - wrapperView.layer.shadowOffset = CSToastShadowOffset; - } - - wrapperView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:CSToastOpacity]; - - if(image != nil) { - imageView = [[[UIImageView alloc] initWithImage:image] autorelease]; - imageView.contentMode = UIViewContentModeScaleAspectFit; - imageView.frame = CGRectMake(CSToastHorizontalPadding, CSToastVerticalPadding, CSToastImageViewWidth, CSToastImageViewHeight); - } - - CGFloat imageWidth, imageHeight, imageLeft; - - // the imageView frame values will be used to size & position the other views - if(imageView != nil) { - imageWidth = imageView.bounds.size.width; - imageHeight = imageView.bounds.size.height; - imageLeft = CSToastHorizontalPadding; - } else { - imageWidth = imageHeight = imageLeft = 0.0; - } - - if (title != nil) { - titleLabel = [[[UILabel alloc] init] autorelease]; - titleLabel.numberOfLines = CSToastMaxTitleLines; - titleLabel.font = [UIFont boldSystemFontOfSize:CSToastFontSize]; - titleLabel.textAlignment = NSTextAlignmentLeft; - titleLabel.lineBreakMode = NSLineBreakByWordWrapping; - titleLabel.textColor = [UIColor whiteColor]; - titleLabel.backgroundColor = [UIColor clearColor]; - titleLabel.alpha = 1.0; - titleLabel.text = title; - - // size the title label according to the length of the text - CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * CSToastMaxWidth) - imageWidth, self.bounds.size.height * CSToastMaxHeight); - CGSize expectedSizeTitle = [title sizeWithFont:titleLabel.font constrainedToSize:maxSizeTitle lineBreakMode:titleLabel.lineBreakMode]; - titleLabel.frame = CGRectMake(0.0, 0.0, expectedSizeTitle.width, expectedSizeTitle.height); - } - - if (message != nil) { - messageLabel = [[[UILabel alloc] init] autorelease]; - messageLabel.numberOfLines = CSToastMaxMessageLines; - messageLabel.font = [UIFont systemFontOfSize:CSToastFontSize]; - messageLabel.lineBreakMode = NSLineBreakByWordWrapping; - messageLabel.textColor = [UIColor whiteColor]; - messageLabel.backgroundColor = [UIColor clearColor]; - messageLabel.alpha = 1.0; - messageLabel.text = message; - - // size the message label according to the length of the text - CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * CSToastMaxWidth) - imageWidth, self.bounds.size.height * CSToastMaxHeight); - CGSize expectedSizeMessage = [message sizeWithFont:messageLabel.font constrainedToSize:maxSizeMessage lineBreakMode:messageLabel.lineBreakMode]; - messageLabel.frame = CGRectMake(0.0, 0.0, expectedSizeMessage.width, expectedSizeMessage.height); - } - - // titleLabel frame values - CGFloat titleWidth, titleHeight, titleTop, titleLeft; - - if(titleLabel != nil) { - titleWidth = titleLabel.bounds.size.width; - titleHeight = titleLabel.bounds.size.height; - titleTop = CSToastVerticalPadding; - titleLeft = imageLeft + imageWidth + CSToastHorizontalPadding; - } else { - titleWidth = titleHeight = titleTop = titleLeft = 0.0; - } - - // messageLabel frame values - CGFloat messageWidth, messageHeight, messageLeft, messageTop; - - if(messageLabel != nil) { - messageWidth = messageLabel.bounds.size.width; - messageHeight = messageLabel.bounds.size.height; - messageLeft = imageLeft + imageWidth + CSToastHorizontalPadding; - messageTop = titleTop + titleHeight + CSToastVerticalPadding; - } else { - messageWidth = messageHeight = messageLeft = messageTop = 0.0; - } - - - CGFloat longerWidth = MAX(titleWidth, messageWidth); - CGFloat longerLeft = MAX(titleLeft, messageLeft); - - // wrapper width uses the longerWidth or the image width, whatever is larger. same logic applies to the wrapper height - CGFloat wrapperWidth = MAX((imageWidth + (CSToastHorizontalPadding * 2)), (longerLeft + longerWidth + CSToastHorizontalPadding)); - CGFloat wrapperHeight = MAX((messageTop + messageHeight + CSToastVerticalPadding), (imageHeight + (CSToastVerticalPadding * 2))); - - wrapperView.frame = CGRectMake(0.0, 0.0, wrapperWidth, wrapperHeight); - - if(titleLabel != nil) { - titleLabel.frame = CGRectMake(titleLeft, titleTop, titleWidth, titleHeight); - [wrapperView addSubview:titleLabel]; - } - - if(messageLabel != nil) { - messageLabel.frame = CGRectMake(messageLeft, messageTop, messageWidth, messageHeight); - [wrapperView addSubview:messageLabel]; - } - - if(imageView != nil) { - [wrapperView addSubview:imageView]; - } - - return wrapperView; -} - - - - - -@end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.h new file mode 100755 index 0000000..e2b258b --- /dev/null +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.h @@ -0,0 +1,446 @@ +// +// UIView+Toast.h +// Toast +// +// Copyright (c) 2011-2017 Charles Scalesse. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#import + +extern const NSString * CSToastPositionTop; +extern const NSString * CSToastPositionCenter; +extern const NSString * CSToastPositionBottom; + +@class CSToastStyle; + +/** + Toast is an Objective-C category that adds toast notifications to the UIView + object class. It is intended to be simple, lightweight, and easy to use. Most + toast notifications can be triggered with a single line of code. + + The `makeToast:` methods create a new view and then display it as toast. + + The `showToast:` methods display any view as toast. + + */ +@interface UIView (Toast) + +/** + Creates and presents a new toast view with a message and displays it with the + default duration and position. Styled using the shared style. + + @param message The message to be displayed + */ +- (void)makeToast:(NSString *)message; + +/** + Creates and presents a new toast view with a message. Duration and position + can be set explicitly. Styled using the shared style. + + @param message The message to be displayed + @param duration The toast duration + @param position The toast's center point. Can be one of the predefined CSToastPosition + constants or a `CGPoint` wrapped in an `NSValue` object. + */ +- (void)makeToast:(NSString *)message + duration:(NSTimeInterval)duration + position:(id)position; + +/** + Creates and presents a new toast view with a message. Duration, position, and + style can be set explicitly. + + @param message The message to be displayed + @param duration The toast duration + @param position The toast's center point. Can be one of the predefined CSToastPosition + constants or a `CGPoint` wrapped in an `NSValue` object. + @param style The style. The shared style will be used when nil + */ +- (void)makeToast:(NSString *)message + duration:(NSTimeInterval)duration + position:(id)position + style:(CSToastStyle *)style; + +/** + Creates and presents a new toast view with a message, title, and image. Duration, + position, and style can be set explicitly. The completion block executes when the + toast view completes. `didTap` will be `YES` if the toast view was dismissed from + a tap. + + @param message The message to be displayed + @param duration The toast duration + @param position The toast's center point. Can be one of the predefined CSToastPosition + constants or a `CGPoint` wrapped in an `NSValue` object. + @param title The title + @param image The image + @param style The style. The shared style will be used when nil + @param completion The completion block, executed after the toast view disappears. + didTap will be `YES` if the toast view was dismissed from a tap. + */ +- (void)makeToast:(NSString *)message + duration:(NSTimeInterval)duration + position:(id)position + title:(NSString *)title + image:(UIImage *)image + style:(CSToastStyle *)style + completion:(void(^)(BOOL didTap))completion; + +/** + Creates a new toast view with any combination of message, title, and image. + The look and feel is configured via the style. Unlike the `makeToast:` methods, + this method does not present the toast view automatically. One of the showToast: + methods must be used to present the resulting view. + + @warning if message, title, and image are all nil, this method will return nil. + + @param message The message to be displayed + @param title The title + @param image The image + @param style The style. The shared style will be used when nil + @return The newly created toast view + */ +- (UIView *)toastViewForMessage:(NSString *)message + title:(NSString *)title + image:(UIImage *)image + style:(CSToastStyle *)style; + +/** + Hides the active toast. If there are multiple toasts active in a view, this method + hides the oldest toast (the first of the toasts to have been presented). + + @see `hideAllToasts` to remove all active toasts from a view. + + @warning This method has no effect on activity toasts. Use `hideToastActivity` to + hide activity toasts. + */ +- (void)hideToast; + +/** + Hides an active toast. + + @param toast The active toast view to dismiss. Any toast that is currently being displayed + on the screen is considered active. + + @warning this does not clear a toast view that is currently waiting in the queue. + */ +- (void)hideToast:(UIView *)toast; + +/** + Hides all active toast views and clears the queue. + */ +- (void)hideAllToasts; + +/** + Hides all active toast views, with options to hide activity and clear the queue. + + @param includeActivity If `true`, toast activity will also be hidden. Default is `false`. + @param clearQueue If `true`, removes all toast views from the queue. Default is `true`. + */ +- (void)hideAllToasts:(BOOL)includeActivity clearQueue:(BOOL)clearQueue; + +/** + Removes all toast views from the queue. This has no effect on toast views that are + active. Use `hideAllToasts` to hide the active toasts views and clear the queue. + */ +- (void)clearToastQueue; + +/** + Creates and displays a new toast activity indicator view at a specified position. + + @warning Only one toast activity indicator view can be presented per superview. Subsequent + calls to `makeToastActivity:` will be ignored until hideToastActivity is called. + + @warning `makeToastActivity:` works independently of the showToast: methods. Toast activity + views can be presented and dismissed while toast views are being displayed. `makeToastActivity:` + has no effect on the queueing behavior of the showToast: methods. + + @param position The toast's center point. Can be one of the predefined CSToastPosition + constants or a `CGPoint` wrapped in an `NSValue` object. + */ +- (void)makeToastActivity:(id)position; + +/** + Dismisses the active toast activity indicator view. + */ +- (void)hideToastActivity; + +/** + Displays any view as toast using the default duration and position. + + @param toast The view to be displayed as toast + */ +- (void)showToast:(UIView *)toast; + +/** + Displays any view as toast at a provided position and duration. The completion block + executes when the toast view completes. `didTap` will be `YES` if the toast view was + dismissed from a tap. + + @param toast The view to be displayed as toast + @param duration The notification duration + @param position The toast's center point. Can be one of the predefined CSToastPosition + constants or a `CGPoint` wrapped in an `NSValue` object. + @param completion The completion block, executed after the toast view disappears. + didTap will be `YES` if the toast view was dismissed from a tap. + */ +- (void)showToast:(UIView *)toast + duration:(NSTimeInterval)duration + position:(id)position + completion:(void(^)(BOOL didTap))completion; + +@end + +/** + `CSToastStyle` instances define the look and feel for toast views created via the + `makeToast:` methods as well for toast views created directly with + `toastViewForMessage:title:image:style:`. + + @warning `CSToastStyle` offers relatively simple styling options for the default + toast view. If you require a toast view with more complex UI, it probably makes more + sense to create your own custom UIView subclass and present it with the `showToast:` + methods. + */ +@interface CSToastStyle : NSObject + +/** + The background color. Default is `[UIColor blackColor]` at 80% opacity. + */ +@property (strong, nonatomic) UIColor *backgroundColor; + +/** + The title color. Default is `[UIColor whiteColor]`. + */ +@property (strong, nonatomic) UIColor *titleColor; + +/** + The message color. Default is `[UIColor whiteColor]`. + */ +@property (strong, nonatomic) UIColor *messageColor; + +/** + A percentage value from 0.0 to 1.0, representing the maximum width of the toast + view relative to it's superview. Default is 0.8 (80% of the superview's width). + */ +@property (assign, nonatomic) CGFloat maxWidthPercentage; + +/** + A percentage value from 0.0 to 1.0, representing the maximum height of the toast + view relative to it's superview. Default is 0.8 (80% of the superview's height). + */ +@property (assign, nonatomic) CGFloat maxHeightPercentage; + +/** + The spacing from the horizontal edge of the toast view to the content. When an image + is present, this is also used as the padding between the image and the text. + Default is 10.0. + */ +@property (assign, nonatomic) CGFloat horizontalPadding; + +/** + The spacing from the vertical edge of the toast view to the content. When a title + is present, this is also used as the padding between the title and the message. + Default is 10.0. + */ +@property (assign, nonatomic) CGFloat verticalPadding; + +/** + The corner radius. Default is 10.0. + */ +@property (assign, nonatomic) CGFloat cornerRadius; + +/** + The title font. Default is `[UIFont boldSystemFontOfSize:16.0]`. + */ +@property (strong, nonatomic) UIFont *titleFont; + +/** + The message font. Default is `[UIFont systemFontOfSize:16.0]`. + */ +@property (strong, nonatomic) UIFont *messageFont; + +/** + The title text alignment. Default is `NSTextAlignmentLeft`. + */ +@property (assign, nonatomic) NSTextAlignment titleAlignment; + +/** + The message text alignment. Default is `NSTextAlignmentLeft`. + */ +@property (assign, nonatomic) NSTextAlignment messageAlignment; + +/** + The maximum number of lines for the title. The default is 0 (no limit). + */ +@property (assign, nonatomic) NSInteger titleNumberOfLines; + +/** + The maximum number of lines for the message. The default is 0 (no limit). + */ +@property (assign, nonatomic) NSInteger messageNumberOfLines; + +/** + Enable or disable a shadow on the toast view. Default is `NO`. + */ +@property (assign, nonatomic) BOOL displayShadow; + +/** + The shadow color. Default is `[UIColor blackColor]`. + */ +@property (strong, nonatomic) UIColor *shadowColor; + +/** + A value from 0.0 to 1.0, representing the opacity of the shadow. + Default is 0.8 (80% opacity). + */ +@property (assign, nonatomic) CGFloat shadowOpacity; + +/** + The shadow radius. Default is 6.0. + */ +@property (assign, nonatomic) CGFloat shadowRadius; + +/** + The shadow offset. The default is `CGSizeMake(4.0, 4.0)`. + */ +@property (assign, nonatomic) CGSize shadowOffset; + +/** + The image size. The default is `CGSizeMake(80.0, 80.0)`. + */ +@property (assign, nonatomic) CGSize imageSize; + +/** + The size of the toast activity view when `makeToastActivity:` is called. + Default is `CGSizeMake(100.0, 100.0)`. + */ +@property (assign, nonatomic) CGSize activitySize; + +/** + The fade in/out animation duration. Default is 0.2. + */ +@property (assign, nonatomic) NSTimeInterval fadeDuration; + +/** + Creates a new instance of `CSToastStyle` with all the default values set. + */ +- (instancetype)initWithDefaultStyle NS_DESIGNATED_INITIALIZER; + +/** + @warning Only the designated initializer should be used to create + an instance of `CSToastStyle`. + */ +- (instancetype)init NS_UNAVAILABLE; + +@end + +/** + `CSToastManager` provides general configuration options for all toast + notifications. Backed by a singleton instance. + */ +@interface CSToastManager : NSObject + +/** + Sets the shared style on the singleton. The shared style is used whenever + a `makeToast:` method (or `toastViewForMessage:title:image:style:`) is called + with with a nil style. By default, this is set to `CSToastStyle`'s default + style. + + @param sharedStyle the shared style + */ ++ (void)setSharedStyle:(CSToastStyle *)sharedStyle; + +/** + Gets the shared style from the singlton. By default, this is + `CSToastStyle`'s default style. + + @return the shared style + */ ++ (CSToastStyle *)sharedStyle; + +/** + Enables or disables tap to dismiss on toast views. Default is `YES`. + + @param tapToDismissEnabled YES or NO + */ ++ (void)setTapToDismissEnabled:(BOOL)tapToDismissEnabled; + +/** + Returns `YES` if tap to dismiss is enabled, otherwise `NO`. + Default is `YES`. + + @return BOOL YES or NO + */ ++ (BOOL)isTapToDismissEnabled; + +/** + Enables or disables queueing behavior for toast views. When `YES`, + toast views will appear one after the other. When `NO`, multiple Toast + views will appear at the same time (potentially overlapping depending + on their positions). This has no effect on the toast activity view, + which operates independently of normal toast views. Default is `NO`. + + @param queueEnabled YES or NO + */ ++ (void)setQueueEnabled:(BOOL)queueEnabled; + +/** + Returns `YES` if the queue is enabled, otherwise `NO`. + Default is `NO`. + + @return BOOL + */ ++ (BOOL)isQueueEnabled; + +/** + Sets the default duration. Used for the `makeToast:` and + `showToast:` methods that don't require an explicit duration. + Default is 3.0. + + @param duration The toast duration + */ ++ (void)setDefaultDuration:(NSTimeInterval)duration; + +/** + Returns the default duration. Default is 3.0. + + @return duration The toast duration +*/ ++ (NSTimeInterval)defaultDuration; + +/** + Sets the default position. Used for the `makeToast:` and + `showToast:` methods that don't require an explicit position. + Default is `CSToastPositionBottom`. + + @param position The default center point. Can be one of the predefined + CSToastPosition constants or a `CGPoint` wrapped in an `NSValue` object. + */ ++ (void)setDefaultPosition:(id)position; + +/** + Returns the default toast position. Default is `CSToastPositionBottom`. + + @return position The default center point. Will be one of the predefined + CSToastPosition constants or a `CGPoint` wrapped in an `NSValue` object. + */ ++ (id)defaultPosition; + +@end diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.m new file mode 100755 index 0000000..cb25eea --- /dev/null +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/UIView+Toast.m @@ -0,0 +1,586 @@ +// +// UIView+Toast.m +// Toast +// +// Copyright (c) 2011-2017 Charles Scalesse. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +#import "UIView+Toast.h" +#import +#import + +// Positions +NSString * CSToastPositionTop = @"CSToastPositionTop"; +NSString * CSToastPositionCenter = @"CSToastPositionCenter"; +NSString * CSToastPositionBottom = @"CSToastPositionBottom"; + +// Keys for values associated with toast views +static const NSString * CSToastTimerKey = @"CSToastTimerKey"; +static const NSString * CSToastDurationKey = @"CSToastDurationKey"; +static const NSString * CSToastPositionKey = @"CSToastPositionKey"; +static const NSString * CSToastCompletionKey = @"CSToastCompletionKey"; + +// Keys for values associated with self +static const NSString * CSToastActiveKey = @"CSToastActiveKey"; +static const NSString * CSToastActivityViewKey = @"CSToastActivityViewKey"; +static const NSString * CSToastQueueKey = @"CSToastQueueKey"; + +@interface UIView (ToastPrivate) + +/** + These private methods are being prefixed with "cs_" to reduce the likelihood of non-obvious + naming conflicts with other UIView methods. + + @discussion Should the public API also use the cs_ prefix? Technically it should, but it + results in code that is less legible. The current public method names seem unlikely to cause + conflicts so I think we should favor the cleaner API for now. + */ +- (void)cs_showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)position; +- (void)cs_hideToast:(UIView *)toast; +- (void)cs_hideToast:(UIView *)toast fromTap:(BOOL)fromTap; +- (void)cs_toastTimerDidFinish:(NSTimer *)timer; +- (void)cs_handleToastTapped:(UITapGestureRecognizer *)recognizer; +- (CGPoint)cs_centerPointForPosition:(id)position withToast:(UIView *)toast; +- (NSMutableArray *)cs_toastQueue; + +@end + +@implementation UIView (Toast) + +#pragma mark - Make Toast Methods + +- (void)makeToast:(NSString *)message { + [self makeToast:message duration:[CSToastManager defaultDuration] position:[CSToastManager defaultPosition] style:nil]; +} + +- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position { + [self makeToast:message duration:duration position:position style:nil]; +} + +- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position style:(CSToastStyle *)style { + UIView *toast = [self toastViewForMessage:message title:nil image:nil style:style]; + [self showToast:toast duration:duration position:position completion:nil]; +} + +- (void)makeToast:(NSString *)message duration:(NSTimeInterval)duration position:(id)position title:(NSString *)title image:(UIImage *)image style:(CSToastStyle *)style completion:(void(^)(BOOL didTap))completion { + UIView *toast = [self toastViewForMessage:message title:title image:image style:style]; + [self showToast:toast duration:duration position:position completion:completion]; +} + +#pragma mark - Show Toast Methods + +- (void)showToast:(UIView *)toast { + [self showToast:toast duration:[CSToastManager defaultDuration] position:[CSToastManager defaultPosition] completion:nil]; +} + +- (void)showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)position completion:(void(^)(BOOL didTap))completion { + // sanity + if (toast == nil) return; + + // store the completion block on the toast view + objc_setAssociatedObject(toast, &CSToastCompletionKey, completion, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + if ([CSToastManager isQueueEnabled] && [self.cs_activeToasts count] > 0) { + // we're about to queue this toast view so we need to store the duration and position as well + objc_setAssociatedObject(toast, &CSToastDurationKey, @(duration), OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject(toast, &CSToastPositionKey, position, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + // enqueue + [self.cs_toastQueue addObject:toast]; + } else { + // present + [self cs_showToast:toast duration:duration position:position]; + } +} + +#pragma mark - Hide Toast Methods + +- (void)hideToast { + [self hideToast:[[self cs_activeToasts] firstObject]]; +} + +- (void)hideToast:(UIView *)toast { + // sanity + if (!toast || ![[self cs_activeToasts] containsObject:toast]) return; + + [self cs_hideToast:toast]; +} + +- (void)hideAllToasts { + [self hideAllToasts:NO clearQueue:YES]; +} + +- (void)hideAllToasts:(BOOL)includeActivity clearQueue:(BOOL)clearQueue { + if (clearQueue) { + [self clearToastQueue]; + } + + for (UIView *toast in [self cs_activeToasts]) { + [self hideToast:toast]; + } + + if (includeActivity) { + [self hideToastActivity]; + } +} + +- (void)clearToastQueue { + [[self cs_toastQueue] removeAllObjects]; +} + +#pragma mark - Private Show/Hide Methods + +- (void)cs_showToast:(UIView *)toast duration:(NSTimeInterval)duration position:(id)position { + toast.center = [self cs_centerPointForPosition:position withToast:toast]; + toast.alpha = 0.0; + + if ([CSToastManager isTapToDismissEnabled]) { + UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cs_handleToastTapped:)]; + [toast addGestureRecognizer:recognizer]; + toast.userInteractionEnabled = YES; + toast.exclusiveTouch = YES; + } + + [[self cs_activeToasts] addObject:toast]; + + [self addSubview:toast]; + + [UIView animateWithDuration:[[CSToastManager sharedStyle] fadeDuration] + delay:0.0 + options:(UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction) + animations:^{ + toast.alpha = 1.0; + } completion:^(BOOL finished) { + NSTimer *timer = [NSTimer timerWithTimeInterval:duration target:self selector:@selector(cs_toastTimerDidFinish:) userInfo:toast repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; + objc_setAssociatedObject(toast, &CSToastTimerKey, timer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + }]; +} + +- (void)cs_hideToast:(UIView *)toast { + [self cs_hideToast:toast fromTap:NO]; +} + +- (void)cs_hideToast:(UIView *)toast fromTap:(BOOL)fromTap { + NSTimer *timer = (NSTimer *)objc_getAssociatedObject(toast, &CSToastTimerKey); + [timer invalidate]; + + [UIView animateWithDuration:[[CSToastManager sharedStyle] fadeDuration] + delay:0.0 + options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) + animations:^{ + toast.alpha = 0.0; + } completion:^(BOOL finished) { + [toast removeFromSuperview]; + + // remove + [[self cs_activeToasts] removeObject:toast]; + + // execute the completion block, if necessary + void (^completion)(BOOL didTap) = objc_getAssociatedObject(toast, &CSToastCompletionKey); + if (completion) { + completion(fromTap); + } + + if ([self.cs_toastQueue count] > 0) { + // dequeue + UIView *nextToast = [[self cs_toastQueue] firstObject]; + [[self cs_toastQueue] removeObjectAtIndex:0]; + + // present the next toast + NSTimeInterval duration = [objc_getAssociatedObject(nextToast, &CSToastDurationKey) doubleValue]; + id position = objc_getAssociatedObject(nextToast, &CSToastPositionKey); + [self cs_showToast:nextToast duration:duration position:position]; + } + }]; +} + +#pragma mark - View Construction + +- (UIView *)toastViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image style:(CSToastStyle *)style { + // sanity + if (message == nil && title == nil && image == nil) return nil; + + // default to the shared style + if (style == nil) { + style = [CSToastManager sharedStyle]; + } + + // dynamically build a toast view with any combination of message, title, & image + UILabel *messageLabel = nil; + UILabel *titleLabel = nil; + UIImageView *imageView = nil; + + UIView *wrapperView = [[UIView alloc] init]; + wrapperView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); + wrapperView.layer.cornerRadius = style.cornerRadius; + + if (style.displayShadow) { + wrapperView.layer.shadowColor = style.shadowColor.CGColor; + wrapperView.layer.shadowOpacity = style.shadowOpacity; + wrapperView.layer.shadowRadius = style.shadowRadius; + wrapperView.layer.shadowOffset = style.shadowOffset; + } + + wrapperView.backgroundColor = style.backgroundColor; + + if(image != nil) { + imageView = [[UIImageView alloc] initWithImage:image]; + imageView.contentMode = UIViewContentModeScaleAspectFit; + imageView.frame = CGRectMake(style.horizontalPadding, style.verticalPadding, style.imageSize.width, style.imageSize.height); + } + + CGRect imageRect = CGRectZero; + + if(imageView != nil) { + imageRect.origin.x = style.horizontalPadding; + imageRect.origin.y = style.verticalPadding; + imageRect.size.width = imageView.bounds.size.width; + imageRect.size.height = imageView.bounds.size.height; + } + + if (title != nil) { + titleLabel = [[UILabel alloc] init]; + titleLabel.numberOfLines = style.titleNumberOfLines; + titleLabel.font = style.titleFont; + titleLabel.textAlignment = style.titleAlignment; + titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; + titleLabel.textColor = style.titleColor; + titleLabel.backgroundColor = [UIColor clearColor]; + titleLabel.alpha = 1.0; + titleLabel.text = title; + + // size the title label according to the length of the text + CGSize maxSizeTitle = CGSizeMake((self.bounds.size.width * style.maxWidthPercentage) - imageRect.size.width, self.bounds.size.height * style.maxHeightPercentage); + CGSize expectedSizeTitle = [titleLabel sizeThatFits:maxSizeTitle]; + // UILabel can return a size larger than the max size when the number of lines is 1 + expectedSizeTitle = CGSizeMake(MIN(maxSizeTitle.width, expectedSizeTitle.width), MIN(maxSizeTitle.height, expectedSizeTitle.height)); + titleLabel.frame = CGRectMake(0.0, 0.0, expectedSizeTitle.width, expectedSizeTitle.height); + } + + if (message != nil) { + messageLabel = [[UILabel alloc] init]; + messageLabel.numberOfLines = style.messageNumberOfLines; + messageLabel.font = style.messageFont; + messageLabel.textAlignment = style.messageAlignment; + messageLabel.lineBreakMode = NSLineBreakByTruncatingTail; + messageLabel.textColor = style.messageColor; + messageLabel.backgroundColor = [UIColor clearColor]; + messageLabel.alpha = 1.0; + messageLabel.text = message; + + CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * style.maxWidthPercentage) - imageRect.size.width, self.bounds.size.height * style.maxHeightPercentage); + CGSize expectedSizeMessage = [messageLabel sizeThatFits:maxSizeMessage]; + // UILabel can return a size larger than the max size when the number of lines is 1 + expectedSizeMessage = CGSizeMake(MIN(maxSizeMessage.width, expectedSizeMessage.width), MIN(maxSizeMessage.height, expectedSizeMessage.height)); + messageLabel.frame = CGRectMake(0.0, 0.0, expectedSizeMessage.width, expectedSizeMessage.height); + } + + CGRect titleRect = CGRectZero; + + if(titleLabel != nil) { + titleRect.origin.x = imageRect.origin.x + imageRect.size.width + style.horizontalPadding; + titleRect.origin.y = style.verticalPadding; + titleRect.size.width = titleLabel.bounds.size.width; + titleRect.size.height = titleLabel.bounds.size.height; + } + + CGRect messageRect = CGRectZero; + + if(messageLabel != nil) { + messageRect.origin.x = imageRect.origin.x + imageRect.size.width + style.horizontalPadding; + messageRect.origin.y = titleRect.origin.y + titleRect.size.height + style.verticalPadding; + messageRect.size.width = messageLabel.bounds.size.width; + messageRect.size.height = messageLabel.bounds.size.height; + } + + CGFloat longerWidth = MAX(titleRect.size.width, messageRect.size.width); + CGFloat longerX = MAX(titleRect.origin.x, messageRect.origin.x); + + // Wrapper width uses the longerWidth or the image width, whatever is larger. Same logic applies to the wrapper height. + CGFloat wrapperWidth = MAX((imageRect.size.width + (style.horizontalPadding * 2.0)), (longerX + longerWidth + style.horizontalPadding)); + CGFloat wrapperHeight = MAX((messageRect.origin.y + messageRect.size.height + style.verticalPadding), (imageRect.size.height + (style.verticalPadding * 2.0))); + + wrapperView.frame = CGRectMake(0.0, 0.0, wrapperWidth, wrapperHeight); + + if(titleLabel != nil) { + titleLabel.frame = titleRect; + [wrapperView addSubview:titleLabel]; + } + + if(messageLabel != nil) { + messageLabel.frame = messageRect; + [wrapperView addSubview:messageLabel]; + } + + if(imageView != nil) { + [wrapperView addSubview:imageView]; + } + + return wrapperView; +} + +#pragma mark - Storage + +- (NSMutableArray *)cs_activeToasts { + NSMutableArray *cs_activeToasts = objc_getAssociatedObject(self, &CSToastActiveKey); + if (cs_activeToasts == nil) { + cs_activeToasts = [[NSMutableArray alloc] init]; + objc_setAssociatedObject(self, &CSToastActiveKey, cs_activeToasts, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return cs_activeToasts; +} + +- (NSMutableArray *)cs_toastQueue { + NSMutableArray *cs_toastQueue = objc_getAssociatedObject(self, &CSToastQueueKey); + if (cs_toastQueue == nil) { + cs_toastQueue = [[NSMutableArray alloc] init]; + objc_setAssociatedObject(self, &CSToastQueueKey, cs_toastQueue, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return cs_toastQueue; +} + +#pragma mark - Events + +- (void)cs_toastTimerDidFinish:(NSTimer *)timer { + [self cs_hideToast:(UIView *)timer.userInfo]; +} + +- (void)cs_handleToastTapped:(UITapGestureRecognizer *)recognizer { + UIView *toast = recognizer.view; + NSTimer *timer = (NSTimer *)objc_getAssociatedObject(toast, &CSToastTimerKey); + [timer invalidate]; + + [self cs_hideToast:toast fromTap:YES]; +} + +#pragma mark - Activity Methods + +- (void)makeToastActivity:(id)position { + // sanity + UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey); + if (existingActivityView != nil) return; + + CSToastStyle *style = [CSToastManager sharedStyle]; + + UIView *activityView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, style.activitySize.width, style.activitySize.height)]; + activityView.center = [self cs_centerPointForPosition:position withToast:activityView]; + activityView.backgroundColor = style.backgroundColor; + activityView.alpha = 0.0; + activityView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); + activityView.layer.cornerRadius = style.cornerRadius; + + if (style.displayShadow) { + activityView.layer.shadowColor = style.shadowColor.CGColor; + activityView.layer.shadowOpacity = style.shadowOpacity; + activityView.layer.shadowRadius = style.shadowRadius; + activityView.layer.shadowOffset = style.shadowOffset; + } + + UIActivityIndicatorView *activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; + activityIndicatorView.center = CGPointMake(activityView.bounds.size.width / 2, activityView.bounds.size.height / 2); + [activityView addSubview:activityIndicatorView]; + [activityIndicatorView startAnimating]; + + // associate the activity view with self + objc_setAssociatedObject (self, &CSToastActivityViewKey, activityView, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + [self addSubview:activityView]; + + [UIView animateWithDuration:style.fadeDuration + delay:0.0 + options:UIViewAnimationOptionCurveEaseOut + animations:^{ + activityView.alpha = 1.0; + } completion:nil]; +} + +- (void)hideToastActivity { + UIView *existingActivityView = (UIView *)objc_getAssociatedObject(self, &CSToastActivityViewKey); + if (existingActivityView != nil) { + [UIView animateWithDuration:[[CSToastManager sharedStyle] fadeDuration] + delay:0.0 + options:(UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionBeginFromCurrentState) + animations:^{ + existingActivityView.alpha = 0.0; + } completion:^(BOOL finished) { + [existingActivityView removeFromSuperview]; + objc_setAssociatedObject (self, &CSToastActivityViewKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + }]; + } +} + +#pragma mark - Helpers + +- (CGPoint)cs_centerPointForPosition:(id)point withToast:(UIView *)toast { + CSToastStyle *style = [CSToastManager sharedStyle]; + + UIEdgeInsets safeInsets = UIEdgeInsetsZero; + if (@available(iOS 11.0, *)) { + safeInsets = self.safeAreaInsets; + } + + CGFloat topPadding = style.verticalPadding + safeInsets.top; + CGFloat bottomPadding = style.verticalPadding + safeInsets.bottom; + + if([point isKindOfClass:[NSString class]]) { + if([point caseInsensitiveCompare:CSToastPositionTop] == NSOrderedSame) { + return CGPointMake(self.bounds.size.width / 2.0, (toast.frame.size.height / 2.0) + topPadding); + } else if([point caseInsensitiveCompare:CSToastPositionCenter] == NSOrderedSame) { + return CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.height / 2.0); + } + } else if ([point isKindOfClass:[NSValue class]]) { + return [point CGPointValue]; + } + + // default to bottom + return CGPointMake(self.bounds.size.width / 2.0, (self.bounds.size.height - (toast.frame.size.height / 2.0)) - bottomPadding); +} + +@end + +@implementation CSToastStyle + +#pragma mark - Constructors + +- (instancetype)initWithDefaultStyle { + self = [super init]; + if (self) { + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.8]; + self.titleColor = [UIColor whiteColor]; + self.messageColor = [UIColor whiteColor]; + self.maxWidthPercentage = 0.8; + self.maxHeightPercentage = 0.8; + self.horizontalPadding = 10.0; + self.verticalPadding = 10.0; + self.cornerRadius = 10.0; + self.titleFont = [UIFont boldSystemFontOfSize:14.0]; + self.messageFont = [UIFont systemFontOfSize:14.0]; + self.titleAlignment = NSTextAlignmentLeft; + self.messageAlignment = NSTextAlignmentLeft; + self.titleNumberOfLines = 0; + self.messageNumberOfLines = 0; + self.displayShadow = NO; + self.shadowOpacity = 0.8; + self.shadowRadius = 6.0; + self.shadowOffset = CGSizeMake(4.0, 4.0); + self.imageSize = CGSizeMake(80.0, 80.0); + self.activitySize = CGSizeMake(100.0, 100.0); + self.fadeDuration = 0.2; + } + return self; +} + +- (void)setMaxWidthPercentage:(CGFloat)maxWidthPercentage { + _maxWidthPercentage = MAX(MIN(maxWidthPercentage, 1.0), 0.0); +} + +- (void)setMaxHeightPercentage:(CGFloat)maxHeightPercentage { + _maxHeightPercentage = MAX(MIN(maxHeightPercentage, 1.0), 0.0); +} + +- (instancetype)init NS_UNAVAILABLE { + return nil; +} + +@end + +@interface CSToastManager () + +@property (strong, nonatomic) CSToastStyle *sharedStyle; +@property (assign, nonatomic, getter=isTapToDismissEnabled) BOOL tapToDismissEnabled; +@property (assign, nonatomic, getter=isQueueEnabled) BOOL queueEnabled; +@property (assign, nonatomic) NSTimeInterval defaultDuration; +@property (strong, nonatomic) id defaultPosition; + +@end + +@implementation CSToastManager + +#pragma mark - Constructors + ++ (instancetype)sharedManager { + static CSToastManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + +- (instancetype)init { + self = [super init]; + if (self) { + self.sharedStyle = [[CSToastStyle alloc] initWithDefaultStyle]; + self.tapToDismissEnabled = YES; + self.queueEnabled = NO; + self.defaultDuration = 2.0; + self.defaultPosition = CSToastPositionCenter; + } + return self; +} + +#pragma mark - Singleton Methods + ++ (void)setSharedStyle:(CSToastStyle *)sharedStyle { + [[self sharedManager] setSharedStyle:sharedStyle]; +} + ++ (CSToastStyle *)sharedStyle { + return [[self sharedManager] sharedStyle]; +} + ++ (void)setTapToDismissEnabled:(BOOL)tapToDismissEnabled { + [[self sharedManager] setTapToDismissEnabled:tapToDismissEnabled]; +} + ++ (BOOL)isTapToDismissEnabled { + return [[self sharedManager] isTapToDismissEnabled]; +} + ++ (void)setQueueEnabled:(BOOL)queueEnabled { + [[self sharedManager] setQueueEnabled:queueEnabled]; +} + ++ (BOOL)isQueueEnabled { + return [[self sharedManager] isQueueEnabled]; +} + ++ (void)setDefaultDuration:(NSTimeInterval)duration { + [[self sharedManager] setDefaultDuration:duration]; +} + ++ (NSTimeInterval)defaultDuration { + return [[self sharedManager] defaultDuration]; +} + ++ (void)setDefaultPosition:(id)position { + if ([position isKindOfClass:[NSString class]] || [position isKindOfClass:[NSValue class]]) { + [[self sharedManager] setDefaultPosition:position]; + } +} + ++ (id)defaultPosition { + return [[self sharedManager] defaultPosition]; +} + +@end diff --git a/Ifish/controllers/logAddRegistController/LogInViewController.m b/Ifish/controllers/logAddRegistController/LogInViewController.m index 7a5fbfe..a31a2cf 100644 --- a/Ifish/controllers/logAddRegistController/LogInViewController.m +++ b/Ifish/controllers/logAddRegistController/LogInViewController.m @@ -35,7 +35,7 @@ #import "LoginResult.h" #import "RegisterResult.h" -#import "Toast+UIView.h" +#import "UIView+Toast.h" #import "IfishNewsModel.h" //#import //#import