// // HomeHubSearchSuccessViewController.m // OneCable // // Created by nComz on 2017. 5. 11.. // Copyright © 2017년 ntels. All rights reserved. // #import "HomeHubSearchSuccessViewController.h" #import "CustomTableView.h" #import "CustomCheckBox.h" #import "HomeHubConnectWifiViewController.h" @interface HomeHubSearchSuccessViewController () { BLEServiceHandler *bleService; NSMutableArray *devices; NSArray *_tableZombieValues; BTLEDeivceModel *selectedModel; } @end @implementation HomeHubSearchTableViewCell @end @implementation HomeHubSearchSuccessViewController - (void)viewDidLoad { [super viewDidLoad]; [self initUI]; [self prepareViewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initUI { _btnNext.enabled = NO; [self initTableViewAsDefaultStyle:_tableView]; } - (void)prepareViewDidLoad { devices = [NSMutableArray new]; //ble bleService = [BLEServiceHandler sharedManager]; bleService.delegate = self; devices = [bleService getDeviceList]; [_tableView reloadData]; } #pragma mark - UITableView DataSource & Delegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return devices.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 108.0f; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { HomeHubSearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HubSearchCellIdentifier"]; BTLEDeivceModel *bleModel = [devices objectAtIndex:indexPath.row]; cell.lblHubName.text = bleModel.peripheralRef.name; cell.lblSerialNum.text = [NSString stringWithFormat:@"S/N : %@",bleModel.peripheralRef.identifier]; cell.chkBtn.delegate = self; cell.chkBtn.value = bleModel; cell.chkBtn.checked = [cell.chkBtn getCheckStatusFromValue]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [super tableView:tableView didSelectRowAtIndexPath:indexPath]; } #pragma mark - CustomCheckBox Delegate { - (void)didCheckBoxClicked:(id)sender { CustomCheckBox *btn = sender; btn.selected = !btn.selected; selectedModel = btn.value; _btnNext.enabled = YES ; } #pragma mark - User Event - (IBAction)btnNextTouched:(id)sender { if (selectedModel != nil) { [bleService setConDevice:selectedModel]; HomeHubConnectWifiViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubConnectWifiViewController" storyboardName:@"HomeHub"]; //vc.selectedBTLEDeviceModel = selectedModel; [self presentViewController:vc animated:YES completion:nil]; } } - (IBAction)btnCloseTouched:(id)sender { [self dismissViewControllerAnimated:YES completion:nil]; } @end