// // ThingsAddStartViewController.m // kneet2 // // Created by Jason Lee on 11/13/15. // Copyright © 2015 ntels. All rights reserved. // #import "JDObject.h" #import "CustomLabel.h" #import "CustomButton.h" #import "CustomImageView.h" #import "ThingsAddIncludeViewController.h" #import "ThingsAddStartViewController.h" #import "DeviceModel.h" @interface ThingsAddStartViewController () { } @end // 가스 밸브 타이틀 : 가스 밸브 삭제 // 가스 밸브 삭제 코멘트 : 안정적인 장치 추가를 위해 초기화 작업을 먼저 진행합니다. // 가스 벨브 장치 추가 코멘트 : 배터리가 제대로 장착되었는지 확인하시고 시작 버튼을 누르세요. // 가스 밸브 이미지명 : img_things_product_addimg_01_smartgasvalve // 도어센서 타이틀 : 도어 센서 추가 // 도어센서 초기화 코멘트 : 동일 // 도어센서 장치추가 코멘트 : 동일 // 도어센서 이미지 명 : img_things_product_addimg_02_mutisensor_door // 스마트플러그 타이틀 : 스마트 플러그 추가 // 스마트플러그 초기화 코멘트 : 동일 // 스마트플러그 장치추가 코멘트 : 동일 // 스마트플러그 이미지 명 : img_things_product_addimg_03_smartplug #pragma mark - Class Definition @implementation ThingsAddStartViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initUI]; [self prepareViewDidLoad]; } - (void)initUI { if (_addableDevice) { [_btnDoStart setTitle:@"추가 시작" forState:UIControlStateNormal]; _lblComment.text = @"장치 근처로 이동 후\n추가시작 버튼을 누르세요"; } else if (_removableDevice) { [_btnDoStart setTitle:@"삭제 시작" forState:UIControlStateNormal]; _lblComment.text = @"장치 근처로 이동 후\n삭제시작 버튼을 누르세요"; } } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [UIView animateWithDuration:kfAnimationDur animations:^{ _maskView.alpha = 0.7; } completion:^(BOOL finished) { _constraintPopViewTop.constant = (IPHONE_HEIGHT - _popView.height) / 2; [UIView animateWithDuration:kfAnimationDur animations:^{ [self.view layoutIfNeeded]; }]; }]; } - (void)prepareViewDidLoad { if (_addableDevice) {//inclusion _lblSensorName.text = _addableDevice[@"nodeName"]; _lblManufacturer.text = _addableDevice[@"manufacturer"]; } else if (_removableDevice) {//exclusion _lblSensorName.text = _removableDevice.deviceName; if (_removableGroups) { NSMutableString *groups = [[NSMutableString alloc] init]; for (DeviceModel *device in _removableGroups) { NSString *prefix = [groups isEmptyString] ? ksEmptyString : @","; [groups appendFormat:@"%@%@", prefix, device.deviceName]; } _lblManufacturer.text = [NSString stringWithFormat:@"이 장치를 삭제하면 %@도 함께 삭제됩니다", groups]; _lblManufacturer.backgroundColor = kUITextColor02; } } } #pragma mark - Main Logic #pragma mark - UI Events - (void)btnAddTouched:(id)sender { if ([[JDFacade facade].loginUser.homehubOnlineState isEqualToString:@"OFF"]) { [[JDFacade facade] toast:@"홈허브가 온라인 상태로\r연결되어 있을 때 시도해주세요"]; return; } ThingsAddIncludeViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddIncludeViewController" storyboardName:@"Things"]; vc.addableDevice = _addableDevice; vc.removableDevice = _removableDevice; vc.providesPresentationContextTransitionStyle = YES; vc.definesPresentationContext = YES; [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext]; [self presentViewController:vc animated:nil completion:nil]; } - (void)btnCancelTouched:(id)sender { [UIView animateWithDuration:kfAnimationDur animations:^{ _maskView.alpha = 0.0; } completion:^(BOOL finished) { [self dismissViewControllerAnimated:YES completion:nil]; }]; } #pragma mark - MemoryWarning - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end