HomeHubSearchSuccessViewController.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // HomeHubSearchSuccessViewController.m
  3. // OneCable
  4. //
  5. // Created by nComz on 2017. 5. 11..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "HomeHubSearchSuccessViewController.h"
  9. #import "CustomTableView.h"
  10. #import "CustomCheckBox.h"
  11. #import "HomeHubConnectWifiViewController.h"
  12. @interface HomeHubSearchSuccessViewController ()<CustomCheckBoxDelegate> {
  13. BLEServiceHandler *bleService;
  14. NSMutableArray *devices;
  15. NSArray *_tableZombieValues;
  16. BTLEDeivceModel *selectedModel;
  17. }
  18. @end
  19. @implementation HomeHubSearchTableViewCell
  20. @end
  21. @implementation HomeHubSearchSuccessViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. [self initUI];
  25. [self prepareViewDidLoad];
  26. }
  27. - (void)didReceiveMemoryWarning {
  28. [super didReceiveMemoryWarning];
  29. }
  30. - (void)initUI {
  31. _btnNext.enabled = NO;
  32. [self initTableViewAsDefaultStyle:_tableView];
  33. }
  34. - (void)prepareViewDidLoad {
  35. devices = [NSMutableArray new];
  36. //ble
  37. bleService = [BLEServiceHandler sharedManager];
  38. bleService.delegate = self;
  39. devices = [bleService getDeviceList];
  40. [_tableView reloadData];
  41. }
  42. #pragma mark - UITableView DataSource & Delegate
  43. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  44. return 1;
  45. }
  46. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  47. return devices.count;
  48. }
  49. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  50. return 108.0f;
  51. }
  52. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  53. HomeHubSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HubSearchCellIdentifier"];
  54. BTLEDeivceModel *bleModel = [devices objectAtIndex:indexPath.row];
  55. cell.lblHubName.text = bleModel.peripheralRef.name;
  56. cell.lblSerialNum.text = [NSString stringWithFormat:@"S/N : %@",bleModel.peripheralRef.identifier];
  57. cell.chkBtn.delegate = self;
  58. cell.chkBtn.value = bleModel;
  59. cell.chkBtn.checked = [cell.chkBtn getCheckStatusFromValue];
  60. return cell;
  61. }
  62. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  63. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  64. }
  65. #pragma mark - CustomCheckBox Delegate {
  66. - (void)didCheckBoxClicked:(id)sender {
  67. CustomCheckBox *btn = sender;
  68. btn.selected = !btn.selected;
  69. selectedModel = btn.value;
  70. _btnNext.enabled = YES ;
  71. }
  72. #pragma mark - User Event
  73. - (IBAction)btnNextTouched:(id)sender {
  74. if (selectedModel != nil) {
  75. [bleService setConDevice:selectedModel];
  76. HomeHubConnectWifiViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubConnectWifiViewController" storyboardName:@"HomeHub"];
  77. [self.navigationController pushViewController:vc animated:YES];
  78. }
  79. }
  80. - (IBAction)btnCloseTouched:(id)sender {
  81. [self.navigationController popToRootViewControllerAnimated:YES];
  82. }
  83. @end