TriggerSelectPopupView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // TriggerSelectPopupView.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 11/23/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "CustomLabel.h"
  10. #import "CustomButton.h"
  11. #import "TriggerSelectPopupView.h"
  12. #import "DeviceSelectPopupView.h"
  13. #import "DeviceNodePopupView.h"
  14. @interface TriggerSelectPopupView () {
  15. NSMutableArray<ItemModel> *_checkedItems;
  16. }
  17. @end
  18. @implementation TriggerSelectPopupView
  19. - (id)initFromNib {
  20. for (UIView *view in [CommonUtil nibViews:@"TriggerSelectPopupView"]) {
  21. if ([view isKindOfClass:[TriggerSelectPopupView class]]) {
  22. self = (TriggerSelectPopupView *)view;
  23. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  24. self.frame = [UIScreen mainScreen].bounds;
  25. [_lblTimer addTouchEventHandler:^(id label) {
  26. [self btnTimerTouched:nil];
  27. }];
  28. [_lblSun addTouchEventHandler:^(id label) {
  29. [self btnSunTouched:nil];
  30. }];
  31. [_lblHeat addTouchEventHandler:^(id label) {
  32. [self btnHeatTouched:nil];
  33. }];
  34. [_lblDevice addTouchEventHandler:^(id label) {
  35. [self btnDeviceTouched:nil];
  36. }];
  37. //Localization
  38. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  39. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  40. }
  41. }
  42. return self;
  43. }
  44. - (void)didMoveToSuperview {
  45. }
  46. #pragma mark - Main Logic
  47. #pragma mark - UI Events
  48. - (IBAction)btnTimerTouched:(id)sender {
  49. }
  50. - (IBAction)btnSunTouched:(id)sender {
  51. }
  52. - (IBAction)btnHeatTouched:(id)sender {
  53. }
  54. - (IBAction)btnDeviceTouched:(id)sender {
  55. DeviceSelectPopupView *dpopup = [[DeviceSelectPopupView alloc] initFromNib];
  56. dpopup.refDevices = _refDevices;
  57. dpopup.typeCode = ksItemTypeCodeTrigger;
  58. [dpopup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  59. if (buttonIndex == 0) {//ok
  60. DeviceNodePopupView *npopup = [[DeviceNodePopupView alloc] initFromNib];
  61. npopup.refDevice = dpopup.selectedDevices[0];
  62. npopup.typeCode = ksItemTypeCodeTrigger;
  63. [npopup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  64. //action add
  65. if (buttonIndex == 0) {//OK
  66. npopup.refDevice.itemSubTypeCode = ksItemSubTypeCodeDevice; //트리거 타입 설정
  67. [_refTriggers addObject:npopup.refDevice];
  68. [self btnConfirmTouched:nil];
  69. }
  70. }];
  71. }
  72. }];
  73. }
  74. - (IBAction)btnConfirmTouched:(id)sender {
  75. //validate
  76. [super btnConfirmTouched:sender];
  77. }
  78. @end