RulesTriggerOptionViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. //
  2. // RulesTriggerOptionViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/11/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "ItemModel.h"
  10. #import "DatePickerButton.h"
  11. #import "TimePickerButton.h"
  12. #import "CustomButton.h"
  13. #import "CustomCheckBox.h"
  14. #import "DaysPopupView.h"
  15. #import "ModePopTableView.h"
  16. #import "RulesTriggerOptionViewController.h"
  17. #define kfTriggerOptionTableViewCellHeight 60.0f
  18. @interface RulesTriggerOptionViewController () {
  19. NSInteger _rowCount;
  20. UIImage *_imageBtnNormal, *_imageBtnDisable;
  21. DaysPopupView *_daysPopupView;
  22. ModePopTableView *_modePopTableView;
  23. }
  24. @end
  25. #pragma mark - Class Definition
  26. @implementation RulesTriggerOptionViewController
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. // Do any additional setup after loading the view.
  30. [self initUI];
  31. [self prepareViewDidLoad];
  32. }
  33. - (void)initUI {
  34. self.tableView.scrollEnabled = NO;
  35. self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
  36. self.tableView.separatorColor = kUILineColor2;
  37. self.tableView.backgroundColor = [UIColor clearColor];
  38. self.tableView.tableFooterView = [[UIView alloc] init]; //this call table events;
  39. CGRect sr = self.view.frame;
  40. sr.size.width = IPHONE_WIDTH;
  41. self.view.frame = sr;
  42. _imageBtnNormal = [UIImage imageNamed:@"tp_01_img_input_bg_02"];
  43. _imageBtnDisable = [UIImage imageNamed:@"tp_01_img_input_bg_02_disable"];
  44. _btnDueDateFrom.date = [NSDate date];
  45. _btnDueDateFrom.placeHolder = _btnDueDateFrom.dateString;
  46. [_btnDueDateTo setTitle:ksEmptyString forState:UIControlStateNormal];
  47. // _btnDueDateTo.date = [NSDate date];
  48. // _btnDueDateTo.placeHolder = _btnDueDateTo.dateString;
  49. [_btnDueTimeFrom setHour:9 minute:0];
  50. _btnDueTimeFrom.placeHolder = _btnDueTimeFrom.timeString;
  51. [_btnDueTimeTo setTitle:ksEmptyString forState:UIControlStateNormal];
  52. // [_btnDueTimeTo setHour:10 minute:0];
  53. // _btnDueTimeTo.placeHolder = _btnDueTimeTo.timeString;
  54. [_btnDueDateFrom setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  55. [_btnDueDateTo setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  56. [_btnDaysOfWeek setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  57. [_btnDueTimeFrom setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  58. [_btnDueTimeTo setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  59. [_btnModes setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  60. [_btnExternHeat setBackgroundImage:_imageBtnDisable forState:UIControlStateNormal];
  61. [_chkDueDate setTitle:NSLocalizedString(@"기간", @"기간") forState:UIControlStateNormal];
  62. [_chkDaysOfWeek setTitle:NSLocalizedString(@"요일", @"요일") forState:UIControlStateNormal];
  63. [_chkDueTime setTitle:NSLocalizedString(@"시간", @"시간") forState:UIControlStateNormal];
  64. [_chkModes setTitle:NSLocalizedString(@"홈 모드", @"홈 모드") forState:UIControlStateNormal];
  65. [_chkExternHeat setTitle:NSLocalizedString(@"지역온도", @"지역온도") forState:UIControlStateNormal];
  66. // _modes = (NSMutableArray<ModeModel> *)[[NSMutableArray alloc] init];
  67. }
  68. - (void)prepareViewDidLoad {
  69. ItemSubModel *subItem = nil;
  70. if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {//홈모드일 경우,
  71. _rowCount = 4;
  72. if (_tmpItem.modes && _tmpItem.modes.count) {
  73. subItem = _tmpItem.modes && _tmpItem.modes.count ? _tmpItem.modes[0] : nil;
  74. }
  75. } else if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {//타이머일 경우,
  76. _rowCount = 4;
  77. if (_tmpItem.timers && _tmpItem.timers.count) {
  78. subItem = _tmpItem.timers && _tmpItem.timers.count ? _tmpItem.timers[0] : nil;
  79. }
  80. } else {
  81. if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {//디바이스일 경우,
  82. subItem = _tmpItem.predDevices && _tmpItem.predDevices.count ? _tmpItem.predDevices[0] : nil;
  83. } if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeGeoFencing]) {//지오펜싱일 경우,
  84. subItem = _tmpItem.mobileDevices && _tmpItem.mobileDevices.count ? _tmpItem.mobileDevices[0] : nil;
  85. }
  86. _rowCount = 5;
  87. }
  88. for (ItemModel *condition in subItem.conditions) {
  89. if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDueDate]) {//기간
  90. _dueDateCondition = condition;
  91. ItemSubModel *subCondition = _dueDateCondition.subItems[0];
  92. NSArray *darray = [subCondition.cmdclsValue componentsSeparatedByString:@"~"];
  93. //from
  94. [_btnDueDateFrom setTitle:darray[0] forState:UIControlStateNormal];
  95. if (darray.count > 1) {//to
  96. [_btnDueDateTo setTitle:darray[1] forState:UIControlStateNormal];
  97. }
  98. _chkDueDate.checked = YES;
  99. [_btnDueDateFrom setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  100. [_btnDueDateTo setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  101. } else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDaysOfWeek]) {//요일
  102. _daysOfWeekCondition = condition;
  103. ItemSubModel *subCondition = _daysOfWeekCondition.subItems[0];
  104. _chkDaysOfWeek.checked = YES;
  105. [_btnDaysOfWeek setTitle:subCondition.cmdclsValueMsg forState:UIControlStateNormal];
  106. [_btnDaysOfWeek setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  107. } else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDueTime]) {//시간
  108. _dueTimeCondition = condition;
  109. ItemSubModel *subCondition = _dueTimeCondition.subItems[0];
  110. NSArray *darray = [subCondition.cmdclsValue componentsSeparatedByString:@"~"];
  111. //from
  112. [_btnDueTimeFrom setTitle:darray[0] forState:UIControlStateNormal];
  113. if (darray.count > 1) {//to
  114. [_btnDueTimeTo setTitle:darray[1] forState:UIControlStateNormal];
  115. }
  116. _chkDueTime.checked = YES;
  117. [_btnDueTimeFrom setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  118. [_btnDueTimeTo setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  119. } else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeHomeMode]) {//홈모드
  120. _homeModeCondition = condition;
  121. ItemSubModel *subCondition = _homeModeCondition.subItems[0];
  122. _chkModes.checked = YES;
  123. [_btnModes setTitle:subCondition.cmdclsValueMsg forState:UIControlStateNormal];
  124. [_btnModes setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  125. } else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeExternHeat]) {//바깥온도
  126. _exterHeatCondition = condition;
  127. ItemSubModel *subCondition = _exterHeatCondition.subItems[0];
  128. _chkExternHeat.checked = YES;
  129. [_btnExternHeat setTitle:subCondition.cmdclsValueMsg forState:UIControlStateNormal];
  130. [_btnExternHeat setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  131. }
  132. }
  133. }
  134. - (void)viewDidAppear:(BOOL)animated {
  135. [super viewDidAppear:animated];
  136. }
  137. #pragma mark - Main Logic
  138. - (BOOL)hasCondition {
  139. return _chkDueDate.checked || _chkDaysOfWeek.checked || _chkDueTime.checked || _chkModes.checked || _chkExternHeat.checked;
  140. }
  141. - (NSMutableArray<ItemModel> *)conditions {
  142. _conditions = [(NSMutableArray<ItemModel> *)[NSMutableArray alloc] init];
  143. //기간
  144. if (_chkDueDate.checked) {
  145. if (!self.dueDateCondition)
  146. return nil;
  147. [_conditions addObject:self.dueDateCondition];
  148. }
  149. //요일
  150. if (_chkDaysOfWeek.checked) {
  151. if (!self.daysOfWeekCondition)
  152. return nil;
  153. [_conditions addObject:self.daysOfWeekCondition];
  154. }
  155. //시간 조건
  156. if (_chkDueTime.checked) {
  157. if (!self.dueTimeCondition)
  158. return nil;
  159. [_conditions addObject:self.dueTimeCondition];
  160. }
  161. //홈모드
  162. if (_chkModes.checked) {
  163. if (!self.homeModeCondition)
  164. return nil;
  165. [_conditions addObject:self.homeModeCondition];
  166. }
  167. //지역온도모드
  168. if (_chkExternHeat.checked) {
  169. if (!self.exterHeatCondition)
  170. return nil;
  171. [_conditions addObject:self.exterHeatCondition];
  172. }
  173. return _conditions;
  174. }
  175. - (ItemModel *)dueDateCondition {
  176. _dueDateCondition = nil;
  177. if (_chkDueDate.checked) {
  178. _dueDateCondition = [[ItemModel alloc] init];
  179. _dueDateCondition.itemName = NSLocalizedString(@"기간", @"기간");
  180. _dueDateCondition.itemSubTypeCode = ksConditionSubTypeCodeDueDate;
  181. ItemSubModel *subCondtion = [[ItemSubModel alloc] init];
  182. subCondtion.conditionTypeCode = @"09";
  183. if ([[_btnDueDateTo titleForState:UIControlStateNormal] isEmptyString]) {
  184. subCondtion.cmdclsValue = [NSString stringWithFormat:@"%@", _btnDueDateFrom.dateString];
  185. subCondtion.dueDate = [NSString stringWithFormat:@"%@", _btnDueDateFrom.formatString];
  186. } else {
  187. subCondtion.cmdclsValue = [NSString stringWithFormat:@"%@~%@", _btnDueDateFrom.dateString, _btnDueDateTo.dateString];
  188. subCondtion.dueDate = [NSString stringWithFormat:@"%@ ~ %@", _btnDueDateFrom.formatString, _btnDueDateTo.formatString];
  189. }
  190. _dueDateCondition.subItems = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithObjects:subCondtion, nil];
  191. }
  192. return _dueDateCondition;
  193. }
  194. //- (NSString *)dueDate {
  195. // _dueDate = nil;
  196. // if (_chkDueDate.checked) {
  197. // if (!_btnDueDateTo.value) {
  198. // _dueDate = [NSString stringWithFormat:@"%@", _btnDueDateFrom.dateString];
  199. // } else {
  200. // _dueDate = [NSString stringWithFormat:@"%@ ~ %@", _btnDueDateFrom.dateString, _btnDueDateTo.dateString];
  201. // }
  202. // }
  203. // return _dueDate;
  204. //}
  205. //
  206. //
  207. //- (NSString *)dueDateCommandClassValue {
  208. // _dueDateCommandClassValue = nil;
  209. // if (_chkDueDate.checked) {
  210. // if (!_btnDueDateTo.value) {
  211. // _dueDateCommandClassValue = [NSString stringWithFormat:@"%@", _btnDueDateFrom.formatString];
  212. // } else {
  213. // _dueDateCommandClassValue = [NSString stringWithFormat:@"%@ ~ %@", _btnDueDateFrom.formatString, _btnDueDateTo.formatString];
  214. // }
  215. // }
  216. // return _dueDateCommandClassValue;
  217. //}
  218. - (ItemModel *)daysOfWeekCondition {
  219. if (_chkDaysOfWeek.checked && _daysPopupView) {
  220. _daysOfWeekCondition = _daysPopupView.condition;
  221. }
  222. if (!_daysOfWeekCondition && _chkDaysOfWeek.checked) {
  223. [[JDFacade facade] alert:NSLocalizedString(@"요일을 선택해주세요", @"요일을 선택해주세요")];
  224. }
  225. return _daysOfWeekCondition;
  226. }
  227. //- (NSString *)daysOfWeek {
  228. // _daysOfWeek = nil;
  229. // if (_chkDaysOfWeek.checked) {
  230. // _daysOfWeek = _daysPopupView ? _daysPopupView.daysOfWeek : nil;
  231. // }
  232. // return _daysOfWeek;
  233. //}
  234. //
  235. //- (NSString *)daysOfWeekCommandClassValue {
  236. // _daysOfWeekCommandClassValue = nil;
  237. // if (_chkDaysOfWeek.checked) {
  238. // _daysOfWeekCommandClassValue = _daysPopupView ? _daysPopupView.commandClassValue : nil;
  239. // }
  240. // return _daysOfWeekCommandClassValue;
  241. //}
  242. - (ItemModel *)dueTimeCondition {
  243. _dueTimeCondition = nil;
  244. if (_chkDueTime.checked) {
  245. _dueTimeCondition = [[ItemModel alloc] init];
  246. _dueTimeCondition.itemName = NSLocalizedString(@"시간", @"시간");
  247. _dueTimeCondition.itemSubTypeCode = ksConditionSubTypeCodeDueTime;
  248. ItemSubModel *subCondtion = [[ItemSubModel alloc] init];
  249. subCondtion.conditionTypeCode = @"09";
  250. if ([[_btnDueTimeTo titleForState:UIControlStateNormal] isEmptyString]) {
  251. subCondtion.cmdclsValue = [NSString stringWithFormat:@"%@", _btnDueTimeFrom.timeString];
  252. subCondtion.dueTime = [NSString stringWithFormat:@"%@", [CommonUtil formattedTime2:_btnDueTimeFrom.timeString]];
  253. } else {
  254. subCondtion.cmdclsValue = [NSString stringWithFormat:@"%@~%@", _btnDueTimeFrom.timeString, _btnDueTimeTo.timeString];
  255. subCondtion.dueTime = [NSString stringWithFormat:@"%@ ~ %@", [CommonUtil formattedTime2:_btnDueTimeFrom.timeString], [CommonUtil formattedTime2:_btnDueTimeTo.timeString]];
  256. }
  257. _dueTimeCondition.subItems = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] initWithObjects:subCondtion, nil];
  258. }
  259. return _dueTimeCondition;
  260. }
  261. //- (NSString *)dueTime {
  262. // _dueTime = nil;
  263. // if (_chkDueTime.checked) {
  264. //
  265. // if (!_btnDueTimeTo.value) {
  266. // _dueTime = [NSString stringWithFormat:@"%@", _btnDueTimeFrom.timeString];
  267. // } else {
  268. // _dueTime = [NSString stringWithFormat:@"%@ ~ %@", _btnDueTimeFrom.timeString, _btnDueTimeTo.timeString];
  269. // }
  270. // }
  271. // return _dueDate;
  272. //}
  273. //
  274. //- (NSString *)dueTimeCommandClassValue {
  275. // _dueTime = nil;
  276. // if (_chkDueTime.checked) {
  277. //
  278. // if (!_btnDueTimeTo.value) {
  279. // _dueTime = [NSString stringWithFormat:@"%@", _btnDueTimeFrom.timeString];
  280. // } else {
  281. // _dueTime = [NSString stringWithFormat:@"%@ ~ %@", _btnDueTimeFrom.timeString, _btnDueTimeTo.timeString];
  282. // }
  283. // }
  284. // return _dueDate;
  285. //}
  286. - (ItemModel *)homeModeCondition {
  287. if (_chkModes.checked && _modePopTableView) {
  288. _homeModeCondition = _modePopTableView.condition;
  289. }
  290. if (!_homeModeCondition && _chkModes.checked) {
  291. [[JDFacade facade] alert:NSLocalizedString(@"홈모드를 선택해주세요", @"홈모드를 선택해주세요")];
  292. }
  293. return _homeModeCondition;
  294. }
  295. - (ItemModel *)exterHeatCondition {
  296. // if (_chkExternHeat.checked && _externHeatPopView) {
  297. // _exterHeatCondition = _externHeatPopView.condition;
  298. // }
  299. //
  300. // if (!_exterHeatCondition && _chkExternHeat.checked) {
  301. // [[JDFacade facade] alert:NSLocalizedString(@"지역온도를 선택해주세요", @"지역온도를 선택해주세요")];
  302. // }
  303. return _exterHeatCondition;
  304. }
  305. - (CGFloat)heightForTriggerOptions
  306. {
  307. return _rowCount * kfTriggerOptionTableViewCellHeight;
  308. }
  309. #pragma mark - UITableView Delegate
  310. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  311. return 1;
  312. }
  313. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  314. return _rowCount;
  315. }
  316. - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
  317. {
  318. return [super tableView:tableView indentationLevelForRowAtIndexPath:indexPath];
  319. }
  320. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  321. NSIndexPath *tmpIndexPath = indexPath;
  322. if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {
  323. if (indexPath.row >= 2) {
  324. tmpIndexPath = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section];
  325. }
  326. } else if ([_tmpItem.itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {
  327. if (indexPath.row >= 3) {
  328. tmpIndexPath = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section];
  329. }
  330. }
  331. UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:tmpIndexPath];
  332. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  333. return cell;
  334. }
  335. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  336. // Remove seperator inset
  337. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  338. [cell setSeparatorInset:UIEdgeInsetsZero];
  339. }
  340. // Prevent the cell from inheriting the Table View's margin settings
  341. if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
  342. [cell setPreservesSuperviewLayoutMargins:NO];
  343. }
  344. // Explictly set your cell's layout margins
  345. if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
  346. [cell setLayoutMargins:UIEdgeInsetsZero];
  347. }
  348. }
  349. #pragma mark - UI Events
  350. - (IBAction)chkDueDateTouched:(id)sender
  351. {
  352. CustomCheckBox *chk = (CustomCheckBox *)sender;
  353. UIImage *image = !chk.checked ? _imageBtnNormal : _imageBtnDisable;
  354. if (!chk.checked) {
  355. [_btnDueDateTo setTitle:ksEmptyString forState:UIControlStateNormal];
  356. }
  357. [_btnDueDateFrom setBackgroundImage:image forState:UIControlStateNormal];
  358. [_btnDueDateTo setBackgroundImage:image forState:UIControlStateNormal];
  359. }
  360. - (IBAction)chkDaysTouched:(id)sender
  361. {
  362. CustomCheckBox *chk = (CustomCheckBox *)sender;
  363. UIImage *image = !chk.checked ? _imageBtnNormal : _imageBtnDisable;
  364. [_btnDaysOfWeek setBackgroundImage:image forState:UIControlStateNormal];
  365. }
  366. - (IBAction)chkDueTimeTouched:(id)sender
  367. {
  368. CustomCheckBox *chk = (CustomCheckBox *)sender;
  369. UIImage *image = !chk.checked ? _imageBtnNormal : _imageBtnDisable;
  370. if (!chk.checked) {
  371. [_btnDueTimeTo setTitle:ksEmptyString forState:UIControlStateNormal];
  372. }
  373. [_btnDueTimeFrom setBackgroundImage:image forState:UIControlStateNormal];
  374. [_btnDueTimeTo setBackgroundImage:image forState:UIControlStateNormal];
  375. }
  376. - (IBAction)chkModesTouched:(id)sender
  377. {
  378. CustomCheckBox *chk = (CustomCheckBox *)sender;
  379. UIImage *image = !chk.checked ? _imageBtnNormal : _imageBtnDisable;
  380. [_btnModes setBackgroundImage:image forState:UIControlStateNormal];
  381. }
  382. - (IBAction)chkExternHeatTouched:(id)sender
  383. {
  384. CustomCheckBox *chk = (CustomCheckBox *)sender;
  385. UIImage *image = !chk.checked ? _imageBtnNormal : _imageBtnDisable;
  386. [_btnExternHeat setBackgroundImage:image forState:UIControlStateNormal];
  387. }
  388. //buttons
  389. - (IBAction)btnDueDateFromTouched:(id)sender
  390. {
  391. CustomButton *btn = (CustomButton *)sender;
  392. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  393. _chkDueDate.checked = YES;
  394. }
  395. - (IBAction)btnDueDateToTouched:(id)sender
  396. {
  397. CustomButton *btn = (CustomButton *)sender;
  398. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  399. [_btnDueDateFrom setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  400. _chkDueDate.checked = YES;
  401. }
  402. - (IBAction)btnDaysToTouched:(id)sender
  403. {
  404. CustomButton *btn = (CustomButton *)sender;
  405. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  406. _chkDaysOfWeek.checked = YES;
  407. if (!_daysPopupView) {
  408. _daysPopupView = [[DaysPopupView alloc] initFromNib];
  409. }
  410. _daysPopupView.condition = _daysOfWeekCondition;
  411. [_daysPopupView showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  412. if (buttonIndex == 0) {//선택
  413. _daysOfWeekCondition = _daysPopupView.condition;
  414. [_btnDaysOfWeek setTitle:_daysPopupView.daysOfWeek forState:UIControlStateNormal];
  415. }
  416. }];
  417. }
  418. - (IBAction)btnDueTimeFromToTouched:(id)sender
  419. {
  420. CustomButton *btn = (CustomButton *)sender;
  421. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  422. _chkDueTime.checked = YES;
  423. }
  424. - (IBAction)btnDueTimeToTouched:(id)sender
  425. {
  426. CustomButton *btn = (CustomButton *)sender;
  427. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  428. [_btnDueTimeTo setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  429. _chkDueTime.checked = YES;
  430. }
  431. - (IBAction)btnModesTouched:(id)sender
  432. {
  433. CustomButton *btn = (CustomButton *)sender;
  434. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  435. _chkModes.checked = YES;
  436. if (!_modePopTableView) {
  437. _modePopTableView = [[ModePopTableView alloc] initFromNib];
  438. }
  439. _modePopTableView.condition = _homeModeCondition;
  440. [_modePopTableView showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  441. if (buttonIndex == 0) {//선택
  442. _homeModeCondition = _modePopTableView.condition;
  443. [_btnModes setTitle:_modePopTableView.homeModes forState:UIControlStateNormal];
  444. }
  445. }];
  446. }
  447. - (IBAction)btnExternHeatTouched:(id)sender
  448. {
  449. CustomButton *btn = (CustomButton *)sender;
  450. [btn setBackgroundImage:_imageBtnNormal forState:UIControlStateNormal];
  451. _chkExternHeat.checked = YES;
  452. // if (!_externHeatPopView) {
  453. // _externHeatPopView = [[ExternHeatPopupView alloc] initFromNib];
  454. // }
  455. //
  456. // _externHeatPopView.condition = _exterHeatCondition;
  457. // [_externHeatPopView showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  458. // if (buttonIndex == 0) {//선택
  459. //
  460. // _exterHeatCondition = _externHeatPopView.condition;
  461. // [_btnExternHeat setTitle:_externHeatPopView.externHeat forState:UIControlStateNormal];
  462. // }
  463. // }];
  464. }
  465. #pragma mark - MemoryWarning
  466. - (void)didReceiveMemoryWarning
  467. {
  468. [super didReceiveMemoryWarning];
  469. // Dispose of any resources that can be recreated.
  470. }
  471. @end