ThingsAddWallpadSubViewController.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // ThingsAddWallpadSubViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 6/30/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "RequestHandler.h"
  9. #import "JDObject.h"
  10. #import "SelectButton.h"
  11. #import "DeviceModel.h"
  12. #import "ThingsAddWallpadSubViewController.h"
  13. #import "CustomLabel.h"
  14. #import "CustomButton.h"
  15. #import "WallpadSubDevicePopupView.h"
  16. #import "ThingsAddWallPadSubTypeViewController.h"
  17. #import "ImageUtil.h"
  18. @interface ThingsAddWallpadSubViewController () {
  19. UIImage *_bgCellImage1, *_bgCellImage2;
  20. }
  21. @end
  22. #pragma mark - Class Definition
  23. @implementation ThingsAddWallpadSubViewController
  24. - (void)viewDidLoad {
  25. [super viewDidLoad];
  26. // Do any additional setup after loading the view.
  27. [self initUI];
  28. [self prepareViewDidLoad];
  29. }
  30. - (void)viewWillAppear:(BOOL)animated {
  31. [super viewWillAppear:animated];
  32. self.title = NSLocalizedString(@"새 장치 추가",nil);
  33. }
  34. - (void)initUI {
  35. //set tableview option
  36. self.tableView.delegate = self;
  37. self.tableView.dataSource = self;
  38. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  39. self.tableView.backgroundColor = [UIColor clearColor];
  40. self.tableView.tableFooterView = [[UIView alloc] init]; //this call table events;
  41. UIEdgeInsets insets = UIEdgeInsetsMake(4, 4, 4, 4);
  42. _bgCellImage1 = [ImageUtil resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch img:[UIImage imageNamed:@"tp_01_img_list_bg_02"]];
  43. _bgCellImage2 = [ImageUtil resizableImageWithCapInsets:insets resizingMode:UIImageResizingModeStretch img:[UIImage imageNamed:@"tp_01_img_list_bg_01"]];
  44. //Localization
  45. _lblTitle.text = NSLocalizedString(@"현재 등록된 COMMAX 월패드에\n더 많은 장치를 연결해보세요", @"현재 등록된 COMMAX 월패드에\n더 많은 장치를 연결해보세요");
  46. [_btnAddSubDevice setTitle:NSLocalizedString(@"장치추가", @"장치추가") forState:UIControlStateNormal];
  47. _lblManualDesc.text = NSLocalizedString(@"장치 종류별 연결방법은\n매뉴얼을 참고해주세요", @"장치 종류별 연결방법은\n매뉴얼을 참고해주세요");
  48. [_btnManual setTitle:NSLocalizedString(@"매뉴얼 보기", @"매뉴얼 보기") forState:UIControlStateNormal];
  49. }
  50. - (void)prepareViewDidLoad {
  51. _btnWallpads.dataDict = [[SortDictionary alloc] initWithDictionary:_wallpads];
  52. _btnWallpads.selectedValue = [_wallpads allKeys].firstObject;
  53. }
  54. #pragma mark - Main Logic
  55. #pragma mark - UITableView DataSource & Delegate
  56. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  57. return 1;
  58. }
  59. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  60. return 3;
  61. }
  62. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  63. UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
  64. return cell;
  65. }
  66. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  67. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  68. if (indexPath.row == 1) {
  69. [self btnAddSubDeviceTouched:nil];
  70. }
  71. }
  72. #pragma mark - UI Events
  73. - (IBAction)btnAddSubDeviceTouched:(id)sender {
  74. WallpadSubDevicePopupView *popup = [[WallpadSubDevicePopupView alloc] initFromNib];
  75. popup.wallpadId = _btnWallpads.selectedValue;
  76. [popup showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  77. if (popup.foundedDevice) {
  78. if (![popup.foundedDevice.deviceProfileId isEqualToString:ksDeviceProfileIdUnknown]) {//장치 타입이 있을 경우,
  79. //goto complete
  80. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddCompleteViewController" storyboardName:@"Things"];
  81. [[JDFacade facade] presentViewControllerByPush:vc pvc:self];
  82. } else {//UNJDOWN 타입일 경우,
  83. //goto choose device type
  84. ThingsAddWallPadSubTypeViewController *wvc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddWallPadSubTypeViewController" storyboardName:@"Things"];
  85. wvc.device = popup.foundedDevice;
  86. [[JDFacade facade] presentViewControllerByPush:wvc pvc:self];
  87. }
  88. }
  89. }];
  90. }
  91. - (IBAction)btnManualTouched:(id)sender {
  92. }
  93. #pragma mark - MemoryWarning
  94. - (void)didReceiveMemoryWarning
  95. {
  96. [super didReceiveMemoryWarning];
  97. // Dispose of any resources that can be recreated.
  98. }
  99. @end