|
|
@@ -13,6 +13,8 @@
|
|
|
#import "CustomButton.h"
|
|
|
#import "Reachability.h"
|
|
|
|
|
|
+#import "HomeHubViewController.h"
|
|
|
+
|
|
|
/**
|
|
|
|
|
|
네트워크, 동글 On / Off 이미지
|
|
|
@@ -24,6 +26,9 @@
|
|
|
Off : img_homehub_list_update_off
|
|
|
**/
|
|
|
@interface MultiHomeHubViewController ()
|
|
|
+{
|
|
|
+ UIImage *_imgOnline, *_imgOffLine, *_imgUptOn, *_imgUptOff;
|
|
|
+}
|
|
|
|
|
|
@end
|
|
|
|
|
|
@@ -40,6 +45,7 @@
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
[self initUI];
|
|
|
+ [self prepareViewDidLoad];
|
|
|
}
|
|
|
|
|
|
- (void)initUI {
|
|
|
@@ -47,12 +53,22 @@
|
|
|
[self initTableViewAsDefaultStyle:_tableView];
|
|
|
}
|
|
|
|
|
|
+- (void)prepareViewDidLoad {
|
|
|
+
|
|
|
+ _imgOnline = [UIImage imageNamed:@"img_homehub_list_connect"];
|
|
|
+ _imgOffLine = [UIImage imageNamed:@"img_homehub_list_connect"];
|
|
|
+ _imgUptOn = [UIImage imageNamed:@"img_homehub_list_update_on"];
|
|
|
+ _imgUptOff = [UIImage imageNamed:@"img_homehub_list_update_off"];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+#pragma mark - TableView Delegate
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
- return 1;
|
|
|
+ return [[JDFacade facade].loginUser.deviceList count];
|
|
|
}
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
@@ -63,15 +79,78 @@
|
|
|
}
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
|
- UITableViewCell *cell = nil;
|
|
|
+ DeviceModel *info = [[JDFacade facade].loginUser.deviceList objectAtIndex:indexPath.row];
|
|
|
+
|
|
|
+ MultiHomeHubTableViewCell *cell = (MultiHomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MultiHubCellIdentifier"];
|
|
|
+
|
|
|
+ cell.lblTitle.text = [NSString stringWithFormat:@"%@", info.deviceName];
|
|
|
+ cell.btnHubDetail.tag = indexPath.row;
|
|
|
|
|
|
- MultiHomeHubTableViewCell *tcell = (MultiHomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MultiHubCellIdentifier"];
|
|
|
+ // 네트워크 연결상태 확인
|
|
|
+ if ([info isDeviceConn]) {
|
|
|
+ cell.imgNetwork.image = _imgOnline;
|
|
|
+ } else {
|
|
|
+ cell.imgNetwork.image = _imgOffLine;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Z-Wave 동작상태 확인
|
|
|
+ if ([info isDeviceOnlined]) {
|
|
|
+ cell.imgDongle.image = _imgOnline;
|
|
|
+ } else {
|
|
|
+ cell.imgDongle.image = _imgOnline;
|
|
|
+ }
|
|
|
|
|
|
- cell = tcell;
|
|
|
+ if ([info isUpdateNeed]) {
|
|
|
+ cell.imgUpdate.image = _imgUptOn;
|
|
|
+ } else {
|
|
|
+ cell.imgUpdate.image = _imgUptOff;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return cell;
|
|
|
}
|
|
|
|
|
|
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
+ [tableView deselectRowAtIndexPath:indexPath animated:NO];
|
|
|
+
|
|
|
+ [self showHomeHubDetail:indexPath];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (IBAction)btnHubDetail:(id)sender {
|
|
|
+ UIButton *senderButton = (UIButton *)sender;
|
|
|
+
|
|
|
+ NSIndexPath *indexPath = [NSIndexPath indexPathForRow:senderButton.tag inSection:0];
|
|
|
+
|
|
|
+ [self showHomeHubDetail:indexPath];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+-(void)showHomeHubDetail:(NSIndexPath *)indexPath
|
|
|
+{
|
|
|
+ DeviceModel *info = [[JDFacade facade].loginUser.deviceList objectAtIndex:indexPath.row];
|
|
|
+ HomeHubViewController *vc = (HomeHubViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubViewController" storyboardName:@"Main"];
|
|
|
+ vc.selectHub = info;
|
|
|
+
|
|
|
+// vc.providesPresentationContextTransitionStyle = YES;
|
|
|
+// vc.definesPresentationContext = YES;
|
|
|
+//
|
|
|
+// [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
+//
|
|
|
+ UIViewController *pvc = self.presentingViewController;
|
|
|
+ [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
|
|
|
+ [pvc presentViewController:vc animated:YES completion:nil];
|
|
|
+ }];
|
|
|
+
|
|
|
+// UIViewController *pvc = self.presentingViewController;
|
|
|
+// [self dismissViewControllerAnimated:NO completion:^{
|
|
|
+// [pvc presentViewController:vc animated:YES completion:nil];
|
|
|
+// }];
|
|
|
+//
|
|
|
+// [self presentViewController:vc animated:YES completion:nil];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (IBAction)btnCloseTouched:(id)sender {
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
}
|