RulesViewController.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. //
  2. // RulesViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 3/18/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "RuleModel.h"
  11. #import "CustomTableView.h"
  12. #import "CustomLabel.h"
  13. #import "CustomImageView.h"
  14. #import "JYRefreshController.h"
  15. #import "UIImageView+WebCache.h"
  16. #import "ImageUtil.h"
  17. #import "RulesViewController.h"
  18. #import "CustomCheckBox.h"
  19. #import "RulesDetailViewController.h"
  20. #import "RulesAddViewController.h"
  21. #import "CustomLabelButton.h"
  22. #import "HomeMemberViewController.h"
  23. #import "CustomSwitch.h"
  24. #define kfRulesTableViewCellHeight 101.0f
  25. @implementation RulesTableViewCell
  26. @end
  27. @implementation RulesCreateTableViewCell
  28. @end
  29. @interface RulesViewController () <UITableViewDataSource, UITableViewDelegate> {
  30. NSMutableArray<RuleModel> *_ruleList;
  31. NSString *_pagingType, *_pagingId;
  32. UIImage *_stateImageRun, *_stateImageStop;
  33. UIImage *_btnImageRun, *_btnImageStop;
  34. BOOL _isNotFirstLoading, _isDeleteMode;
  35. }
  36. @property (strong, nonatomic) JYPullToRefreshController *refreshController;
  37. @end
  38. #pragma mark - Class Definition
  39. @implementation RulesViewController
  40. - (void)viewDidLoad {
  41. [super viewDidLoad];
  42. // _ruleList = (NSMutableArray<RuleModel> *)[[NSMutableArray alloc] init];
  43. [self initUI];
  44. [self prepareViewDidLoad];
  45. }
  46. - (void)viewWillAppear:(BOOL)animated {
  47. [super viewWillAppear:animated];
  48. if (_isNotFirstLoading) {
  49. [self performSelector:@selector(requestRules) withObject:nil afterDelay:0.0f];
  50. }
  51. }
  52. - (void)initUI {
  53. //initialize tableview
  54. [self initTableViewAsDefaultStyle:_tableView];
  55. [_btnClose setHidden:YES];
  56. [_btnOption setHidden:NO];
  57. _btnImageRun = [UIImage imageNamed:@"img_rule_list_playbtn_active"];
  58. _btnImageStop = [UIImage imageNamed:@"img_rule_list_playbtn_disable"];
  59. _stateImageRun = [UIImage imageNamed:@"common_bullet_circle_red"];
  60. _stateImageStop = [UIImage imageNamed:@"common_bullet_circle_gray"];
  61. _tableView.backgroundColor = [UIColor clearColor];
  62. //[self setThingsPopoverOptions];
  63. [self setMoreBtnArray];
  64. [self initRefreshController];
  65. }
  66. - (void)initRefreshController {
  67. //set refresh controls
  68. __weak typeof(self) weakSelf = self;
  69. self.refreshController = [[JYPullToRefreshController alloc] initWithScrollView:self.tableView];
  70. self.refreshController.pullToRefreshHandleAction = ^{
  71. [weakSelf requestRules];
  72. };
  73. }
  74. - (void)setThingsPopoverOptions {
  75. //set Popover Contents
  76. __weak typeof(self) weakSelf = self;
  77. _popooverOptionArray = [[NSMutableArray alloc] init];
  78. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"새로고침",nil),
  79. @"iconName": @"img_bg_morepopup_icon_refresh",
  80. @"target": weakSelf,
  81. @"selector": [NSValue valueWithPointer:@selector(refreshRuleList)]}];
  82. if ([JDFacade facade].loginUser.level > 10) {//파워유저 이상일 경우,
  83. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"만들기", @"만들기"),
  84. @"iconName": @"img_bg_morepopup_icon_edit",
  85. @"target": weakSelf,
  86. @"selector": [NSValue valueWithPointer:@selector(addNewRule)]}];
  87. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"삭제", @"삭제"),
  88. @"iconName": @"img_bg_morepopup_icon_del",
  89. @"target": weakSelf,
  90. @"selector": [NSValue valueWithPointer:@selector(toggleEditMode)]}];
  91. }
  92. }
  93. - (void)setMoreBtnArray {
  94. _moreBtnArray = [NSMutableArray array];
  95. // if (![[JDFacade facade].loginUser hasHomeHub]) {
  96. // [_btnOption setHidden:YES];
  97. // }
  98. if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
  99. for (int i = 0; i < 3; i++) {
  100. MoreBtnModel *btnModel;
  101. switch (i) {
  102. case 0:
  103. btnModel = [[MoreBtnModel alloc] initWithTyep:Add isEnable:YES];
  104. break;
  105. case 1:
  106. btnModel = [[MoreBtnModel alloc] initWithTyep:Del isEnable:_ruleList.count > 0];
  107. break;
  108. case 2:
  109. btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  110. break;
  111. default:
  112. break;
  113. }
  114. [_moreBtnArray addObject:btnModel];
  115. }
  116. }
  117. else {
  118. MoreBtnModel *btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  119. [_moreBtnArray addObject:btnModel];
  120. }
  121. }
  122. - (void)prepareViewDidLoad {
  123. [self updateTitle];
  124. [self performSelector:@selector(requestRules) withObject:nil afterDelay:0.0f];
  125. }
  126. - (void)updateHomeHubStatusToRules {
  127. [self updateTitle];
  128. }
  129. - (void)refreshRuleList {
  130. _pagingId = nil;
  131. _pagingType = nil;
  132. if (_ruleList && _ruleList.count) {
  133. [_ruleList removeAllObjects];
  134. }
  135. [self performSelector:@selector(requestRules) withObject:nil afterDelay:0.0f];
  136. }
  137. - (void)addNewRule {
  138. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"RulesAddViewController" storyboardName:@"Rules"];
  139. [self presentViewController:vc animated:YES completion:nil];
  140. }
  141. - (void)toggleEditMode {
  142. _isDeleteMode = !_isDeleteMode;
  143. [_btnClose setHidden:!_isDeleteMode];
  144. [_btnOption setHidden:_isDeleteMode];
  145. if (_isDeleteMode) {
  146. _lblTitle.text = @"규칙 삭제";
  147. _imgvHubAlert.hidden = YES;
  148. } else {
  149. [self updateTitle];
  150. }
  151. [_tableView reloadData];
  152. // _constraintEditModeRight.constant = _isDeleteMode ? 0 : -_editModeView.width;
  153. //
  154. // [UIView animateWithDuration:kfAnimationDur animations:^{
  155. // [self.view layoutIfNeeded];
  156. // }];
  157. }
  158. #pragma mark - Main Logic
  159. //- (void)requestRuleListRecently {
  160. //
  161. // RuleModel *firstRule = [_ruleList firstObject];
  162. // _pagingType = ksListPagingTypeUpward;
  163. // _pagingId = firstRule.ruleId;
  164. //
  165. // [self performSelector:@selector(requestRules) withObject:nil afterDelay:0.0f];
  166. //}
  167. //
  168. //- (void)requestRuleListOlder {
  169. //
  170. // RuleModel *lastRule = [_ruleList lastObject];
  171. // _pagingType = ksListPagingTypeDownward;
  172. // _pagingId = lastRule.ruleId;
  173. //
  174. // [self performSelector:@selector(requestRules) withObject:nil afterDelay:0.0f];
  175. //}
  176. - (void)requestRules {
  177. if (![JDFacade facade].loginUser.hasHomeHub) {
  178. return;
  179. }
  180. // NSDictionary *parameter = @{@"rule_id": _pagingId ? _pagingId : ksEmptyString,
  181. // @"paging_type": _pagingType ? _pagingType : ksEmptyString};
  182. // NSString *path = [NSString stringWithFormat:API_GET_RULE];
  183. NSString *path = [[JDFacade facade] getUrlWithCustAndGroupID:API_GET_RULE aditional:@""];
  184. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:nil modelClass:[RuleListModel class] completion:^(id responseObject) {
  185. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  186. return;
  187. }
  188. RuleListModel *fetchedRuleList = (RuleListModel *)responseObject;
  189. if (fetchedRuleList && fetchedRuleList.rules && fetchedRuleList.rules.count) {//API 성공,
  190. _ruleList = [fetchedRuleList.rules mutableCopy];
  191. } else {
  192. if (!_ruleList.count) {//이미 로드된 데이터가 있을 경우는 출력하지 않음.
  193. _lblConnectHub.text = @"등록된 규칙이 없습니다";
  194. _imgvConnectHub.image = [UIImage imageNamed:@"img_1depth_nodevice"];
  195. }
  196. }
  197. [self updateTitle];
  198. [_tableView reloadData];
  199. //refresh controller
  200. if (self.refreshController && self.refreshController.refreshState == JYRefreshStateLoading) {
  201. [self.refreshController stopRefreshWithAnimated:YES completion:nil];
  202. }
  203. if (!_isNotFirstLoading) {
  204. _isNotFirstLoading = YES;
  205. }
  206. } failure:^(id errorObject) {
  207. JDErrorModel *error = (JDErrorModel *)errorObject;
  208. [[JDFacade facade] alert:error.errorMessage];
  209. }];
  210. }
  211. - (void)requestChangeRuleStatus:(RuleModel *)rule {
  212. //parameters
  213. NSDictionary *parameter = @{@"status_code" : [rule.useYn isEqualToString:@"Y"] ? @"03" : @"02"};
  214. NSString *path = [NSString stringWithFormat:API_POST_RULE_STATUS, rule.homegrpRuleId];
  215. [[RequestHandler handler] sendAsyncPostRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  216. rule.useYn = [rule.useYn boolValue] ? ksNO : ksYES; //toggle
  217. if ([rule.useYn boolValue]) {
  218. [[JDFacade facade] toast:@"규칙을 다시 시작합니다"];
  219. } else {
  220. [[JDFacade facade] toast:@"규칙을 중단합니다"];
  221. }
  222. // [self changeBtnRunStatus:[rule.useYn boolValue]];
  223. [self updateTitle];
  224. [_tableView reloadData];
  225. } failure:^(id errorObject) {
  226. JDErrorModel *error = (JDErrorModel *)errorObject;
  227. [[JDFacade facade] alert:error.errorMessage];
  228. }];
  229. }
  230. - (void)requestDeleteRule:(RuleModel *)rule {
  231. NSString *path = [NSString stringWithFormat:API_DELETE_RULE, rule.homegrpRuleId];
  232. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  233. [[JDFacade facade] toast:@"규칙을 삭제했습니다"];
  234. [_ruleList removeObject:rule];
  235. [self toggleEditMode];
  236. [self updateTitle];
  237. [_tableView reloadData];
  238. } failure:^(id errorObject) {
  239. JDErrorModel *error = (JDErrorModel *)errorObject;
  240. [[JDFacade facade] alert:error.errorMessage];
  241. }];
  242. }
  243. - (void)updateRule:(RuleModel *)rule {
  244. for (RuleModel *tmpRule in _ruleList) {
  245. if ([rule.homegrpRuleId isEqualToString:tmpRule.homegrpRuleId]) {
  246. tmpRule.ruleName = rule.ruleName;
  247. tmpRule.useYn = rule.useYn;
  248. break;
  249. }
  250. }
  251. [_tableView reloadData];
  252. }
  253. - (void)updateTitle {
  254. if (_isDeleteMode) {
  255. return;
  256. }
  257. NSInteger inactiveCount = [_ruleList filteredArrayUsingPredicateFormat:@"SELF.useYn != %@", ksYES].count;
  258. NSInteger activeCount = _ruleList.count > inactiveCount ? _ruleList.count - inactiveCount : inactiveCount - _ruleList.count;
  259. _lblTitle.text = [NSString stringWithFormat:@"적용 %zd / 미적용 %zd", activeCount, inactiveCount];
  260. if (![JDFacade facade].loginUser.hasHomeHub) {//홈허브 아이디가 없는 경우,
  261. [_mainView bringSubviewToFront:_addHubContainerView];
  262. _addHubContainerView.hidden = NO;
  263. _tableView.hidden = YES;
  264. _btnOption.hidden = YES;
  265. if (![JDFacade facade].loginUser.homegrpId) {//연결한 적이 없음
  266. _lblConnectHub.text = @"초대를 받아서\n시작해 보세요";
  267. _imgvHubAlert.hidden = YES;
  268. _imgvConnectHub.image = [UIImage imageNamed:@"img_1depth_invitation"];
  269. _lblLeaveAccount.hidden = YES;
  270. _lblSimpleMemberInfo.hidden = YES;
  271. } else {//홈허브가 삭제됨.
  272. _lblTitle.text = @"홈허브 삭제됨";
  273. _imgvHubAlert.hidden = NO;
  274. _lblConnectHub.text = @"홈허브를 다시 연결하려면\n고객센터에 문의해주세요";
  275. _imgvConnectHub.image = [UIImage imageNamed:@"img_things_homehub_img_hubdelete_cscenter"];
  276. if ([JDFacade facade].loginUser.level < 90) {//일반 유저일 경우,
  277. _imgvConnectHub.image = [UIImage imageNamed:@"img_things_homehub_img_hubdelete_wait"];
  278. _lblLeaveAccount.hidden = NO;
  279. _lblSimpleMemberInfo.hidden = NO;
  280. [_lblLeaveAccount setUnderLine:_lblLeaveAccount.text];
  281. if (!_lblLeaveAccount.touchHandler) {
  282. [_lblLeaveAccount addTouchEventHandler:^(id label) {
  283. [self leaveHomegroup];
  284. }];
  285. }
  286. }
  287. }
  288. } else {
  289. if (![JDFacade facade].loginUser.isHomehubOnline) {
  290. _imgvHubAlert.hidden = NO;
  291. _lblTitle.text = @"홈허브 오프라인";
  292. [_lblTitle setColor:kUITextColor01 text:_lblTitle.text];
  293. } else {
  294. _imgvHubAlert.hidden = YES;
  295. }
  296. [_mainView bringSubviewToFront:_tableView];
  297. _addHubContainerView.hidden = YES;
  298. _tableView.hidden = NO;
  299. _btnOption.hidden = NO;
  300. }
  301. //활성/비활성 업데이트
  302. if ([_lblTitle.text rangeOfString:@"활성"].location != NSNotFound) {
  303. [_lblTitle setColor:kUITextColor02 text:[NSString stringWithFormat:@"%zd", activeCount]];
  304. [_lblTitle setColor:kUITextColor03 text:[NSString stringWithFormat:@"비활성 %zd", inactiveCount]];
  305. }
  306. }
  307. - (void)leaveHomegroup {
  308. HomeMemberViewController *vc = [[HomeMemberViewController alloc] init];
  309. [vc leaveHomegroup];
  310. }
  311. #pragma mark - UITableView DataSource & Delegate
  312. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  313. NSInteger auth = [JDFacade facade].loginUser.level == 90 && !_isDeleteMode;
  314. NSInteger count = _ruleList.count > 0 ? 1 + auth : 1;
  315. return count;
  316. }
  317. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  318. NSInteger count = 1;
  319. if (_ruleList.count > 0 && section == 0) {//규칙이 있을 경우,
  320. count = _ruleList.count;
  321. }
  322. return count;
  323. }
  324. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  325. CGFloat height = kfRulesTableViewCellHeight;
  326. NSInteger section = indexPath.section;
  327. if (_ruleList.count > 0 && section == 0) {//규칙이 있을 경우,
  328. height = 77.0f;
  329. } else if (_ruleList.count > 0 && section == 1) {
  330. height = 135.0f;
  331. } else {
  332. height = IPHONE_HEIGHT - kfNavigationBarHeight - 55.0f; //header, tabbar
  333. }
  334. // if (indexPath.row == _ruleList.count) {
  335. // height = _ruleList.count ? 190.0f : IPHONE_HEIGHT - kfNavigationBarHeight;
  336. // _tableView.scrollEnabled = _ruleList.count;
  337. // }
  338. return height;
  339. }
  340. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  341. NSInteger section = indexPath.section;
  342. UITableViewCell *rcell = nil;
  343. if (_ruleList.count > 0 && section == 0) {//규칙이 있을 경우,
  344. RulesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
  345. RuleModel *rule = _ruleList[indexPath.row];
  346. [cell.imgvTrigger sd_setImageWithURL:[NSURL URLWithString:rule.imageFileName] placeholderImage:nil options:SDWebImageRefreshCached];
  347. cell.lblRuleName.text = rule.ruleName;
  348. cell.btnRulePlay.hidden = _isDeleteMode;
  349. if (!cell.btnRulePlay.hidden) {//삭제 모드일 경우,
  350. cell.btnRulePlay.hidden = [JDFacade facade].loginUser.level < 90;
  351. cell.btnDelete.hidden = YES;
  352. cell.imgvStatus.image = [rule.useYn boolValue] ? _stateImageRun : _stateImageStop;
  353. UIImage *btnImage = [rule.useYn boolValue] ? _btnImageRun : _btnImageStop;
  354. [cell.btnRulePlay setImage:btnImage forState:UIControlStateNormal];
  355. cell.btnRulePlay.value = rule;
  356. if (![cell.btnRulePlay actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  357. [cell.btnRulePlay addTarget:self action:@selector(btnRulePlayTouched:) forControlEvents:UIControlEventTouchUpInside];
  358. }
  359. } else {
  360. cell.btnDelete.hidden = NO;
  361. cell.btnDelete.value = rule;
  362. if (![cell.btnDelete actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  363. [cell.btnDelete addTarget:self action:@selector(btnDeleteTouched:) forControlEvents:UIControlEventTouchUpInside];
  364. }
  365. }
  366. rcell = cell;
  367. } else {
  368. RulesCreateTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddCellIdentifier"];
  369. if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  370. [cell.btnAdd addTarget:self action:@selector(addNewRule) forControlEvents:UIControlEventTouchUpInside];
  371. }
  372. rcell = cell;
  373. }
  374. return rcell;
  375. }
  376. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  377. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  378. if (indexPath.row == _ruleList.count) {
  379. return;
  380. }
  381. if (!_isDeleteMode) {//go to detail
  382. //goto rule details
  383. RulesDetailViewController *vc = (RulesDetailViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"RulesDetailViewController" storyboardName:@"Rules"];
  384. vc.refRule = _ruleList[indexPath.row];
  385. [self presentViewController:vc animated:YES completion:nil];
  386. }
  387. }
  388. #pragma mark - TableView UI Events
  389. - (void)btnRulePlayTouched:(id)sender {
  390. CustomButton *btnRulePlay = (CustomButton *)sender;
  391. RuleModel *rule = btnRulePlay.value;
  392. if ([rule.useYn isEqualToString:ksKneetRulesDisable]) {//규칙 비활성화 일 경우,
  393. CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:@"알림" message:@"일부 장치가 삭제되었습니다.\n편집 후 실행하세요." delegate:nil OKButtonTitle:@"편집" cancelButtonTitle:@"취소"];
  394. [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  395. if (buttonIndex == 0) {//OK
  396. dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{//RUN to background thread
  397. NSString *path = [NSString stringWithFormat:API_GET_RULE_DETAIL, rule.homegrpRuleId];
  398. RuleDetailModel *ruleDetail = [[RequestHandler handler] sendSyncGetRequestAPIPath:path parameters:nil modelClass:[RuleDetailModel class] showLoadingView:YES];
  399. RulesAddViewController *vc = (RulesAddViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"RulesAddViewController" storyboardName:@"Rules"];
  400. vc.refRuleDetail = ruleDetail;
  401. dispatch_async(dispatch_get_main_queue(), ^{
  402. [self presentViewController:vc animated:YES completion:nil];
  403. });
  404. });
  405. }
  406. }];
  407. } else {
  408. [self requestChangeRuleStatus:rule];
  409. }
  410. }
  411. - (void)btnDeleteTouched:(id)sender {
  412. [[JDFacade facade] confirmTitle:@"규칙 삭제" message:@"규칙을 삭제하시겠습니까?" completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  413. if (buttonIndex == 0) {//OK
  414. CustomButton *btnDelete = (CustomButton *)sender;
  415. RuleModel *rule = btnDelete.value;
  416. [self requestDeleteRule:rule];
  417. }
  418. }];
  419. }
  420. #pragma mark - UI Events
  421. - (IBAction)btnOptionTouched:(id)sender {
  422. //[self toggleOptions:sender];
  423. [self toggleOptionsWithArray:sender btnArray:_moreBtnArray];
  424. }
  425. - (IBAction)btnCloseTouched:(id)sender {
  426. [self toggleEditMode];
  427. }
  428. - (IBAction)btnCloseOnEditModeTouched:(id)sender {
  429. [self toggleEditMode];
  430. }
  431. #pragma mark - MemoryWarning
  432. - (void)didReceiveMemoryWarning
  433. {
  434. [super didReceiveMemoryWarning];
  435. // Dispose of any resources that can be recreated.
  436. }
  437. #pragma mark - MoreButtonDelegate
  438. -(void)moreBtnAction:(id)sender
  439. {
  440. NSInteger tag = [(UIButton *)sender tag];
  441. NSLog(@"MoreBtn Action : %li", (long)tag);
  442. switch (tag) {
  443. case Add:
  444. {
  445. [self addNewRule];
  446. }
  447. break;
  448. case Del:
  449. {
  450. [self toggleEditMode];
  451. }
  452. break;
  453. case Refresh:
  454. {
  455. }
  456. break;
  457. default:
  458. break;
  459. }
  460. }
  461. @end