ThingsAddStartViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //
  2. // ThingsAddStartViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 11/13/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "CustomLabel.h"
  10. #import "CustomButton.h"
  11. #import "CustomImageView.h"
  12. #import "ThingsAddIncludeViewController.h"
  13. #import "ThingsAddStartViewController.h"
  14. #import "DeviceModel.h"
  15. @interface ThingsAddStartViewController () {
  16. }
  17. @end
  18. // 가스 밸브 타이틀 : 가스 밸브 삭제
  19. // 가스 밸브 삭제 코멘트 : 안정적인 장치 추가를 위해 초기화 작업을 먼저 진행합니다.
  20. // 가스 벨브 장치 추가 코멘트 : 배터리가 제대로 장착되었는지 확인하시고 시작 버튼을 누르세요.
  21. // 가스 밸브 이미지명 : img_things_product_addimg_01_smartgasvalve
  22. // 도어센서 타이틀 : 도어 센서 추가
  23. // 도어센서 초기화 코멘트 : 동일
  24. // 도어센서 장치추가 코멘트 : 동일
  25. // 도어센서 이미지 명 : img_things_product_addimg_02_mutisensor_door
  26. // 스마트플러그 타이틀 : 스마트 플러그 추가
  27. // 스마트플러그 초기화 코멘트 : 동일
  28. // 스마트플러그 장치추가 코멘트 : 동일
  29. // 스마트플러그 이미지 명 : img_things_product_addimg_03_smartplug
  30. #pragma mark - Class Definition
  31. @implementation ThingsAddStartViewController
  32. - (void)viewDidLoad {
  33. [super viewDidLoad];
  34. // Do any additional setup after loading the view.
  35. [self initUI];
  36. [self prepareViewDidLoad];
  37. }
  38. - (void)initUI {
  39. if (_addableDevice) {
  40. [_btnDoStart setTitle:@"시작" forState:UIControlStateNormal];
  41. _lblComment.text = @"장치 근처로 이동 후\n추가시작 버튼을 누르세요";
  42. } else if (_removableDevice) {
  43. [_btnDoStart setTitle:@"삭제 시작" forState:UIControlStateNormal];
  44. _lblComment.text = @"장치 근처로 이동 후\n삭제시작 버튼을 누르세요";
  45. }
  46. }
  47. - (void)viewDidAppear:(BOOL)animated {
  48. [super viewDidAppear:animated];
  49. [UIView animateWithDuration:kfAnimationDur animations:^{
  50. _maskView.alpha = 0.7;
  51. } completion:^(BOOL finished) {
  52. _constraintPopViewTop.constant = (IPHONE_HEIGHT - _popView.height) / 2;
  53. [UIView animateWithDuration:kfAnimationDur animations:^{
  54. [self.view layoutIfNeeded];
  55. }];
  56. }];
  57. }
  58. - (void)prepareViewDidLoad {
  59. if (_addableDevice) {//inclusion
  60. _lblSensorName.text = _addableDevice[@"nodeName"];
  61. _lblManufacturer.text = _addableDevice[@"manufacturer"];
  62. } else if (_removableDevice) {//exclusion
  63. _lblSensorName.text = _removableDevice.deviceName;
  64. if (_removableGroups) {
  65. NSMutableString *groups = [[NSMutableString alloc] init];
  66. for (DeviceModel *device in _removableGroups) {
  67. NSString *prefix = [groups isEmptyString] ? ksEmptyString : @",";
  68. [groups appendFormat:@"%@%@", prefix, device.deviceName];
  69. }
  70. _lblManufacturer.text = [NSString stringWithFormat:@"이 장치를 삭제하면 %@도 함께 삭제됩니다", groups];
  71. _lblManufacturer.backgroundColor = kUITextColor02;
  72. }
  73. }
  74. }
  75. #pragma mark - Main Logic
  76. #pragma mark - UI Events
  77. - (void)btnAddTouched:(id)sender {
  78. if ([[JDFacade facade].loginUser.homehubOnlineState isEqualToString:@"OFF"]) {
  79. [[JDFacade facade] toast:@"홈허브가 온라인 상태로\r연결되어 있을 때 시도해주세요"];
  80. return;
  81. }
  82. ThingsAddIncludeViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddIncludeViewController" storyboardName:@"Things"];
  83. vc.addableDevice = _addableDevice;
  84. vc.removableDevice = _removableDevice;
  85. vc.providesPresentationContextTransitionStyle = YES;
  86. vc.definesPresentationContext = YES;
  87. [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
  88. [self presentViewController:vc animated:nil completion:nil];
  89. }
  90. - (void)btnCancelTouched:(id)sender {
  91. [UIView animateWithDuration:kfAnimationDur animations:^{
  92. _maskView.alpha = 0.0;
  93. } completion:^(BOOL finished) {
  94. [self dismissViewControllerAnimated:YES completion:nil];
  95. }];
  96. }
  97. #pragma mark - MemoryWarning
  98. - (void)didReceiveMemoryWarning
  99. {
  100. [super didReceiveMemoryWarning];
  101. // Dispose of any resources that can be recreated.
  102. }
  103. @end