// // HomeHubViewController.m // kneet2 // // Created by Jason Lee on 10/28/15. // Copyright © 2015 ntels. All rights reserved. // #import "HomeHubViewController.h" #import "RequestHandler.h" #import "DeviceModel.h" #import "CustomTableView.h" #import "CustomButton.h" #import "Reachability.h" @implementation HomeHubTableViewCell @end @implementation HomeHubRegistTableViewCell @end @implementation HomeHubInfoTableViewCell @end @interface HomeHubViewController () { } @end #pragma mark - Class Definition @implementation HomeHubViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self initUI]; [self prepareViewDidLoad]; } - (void)initUI { [self initTableViewAsDefaultStyle:_tableView]; } - (void)prepareViewDidLoad { } - (void)updateHomeHubStatus { [_tableView reloadData]; } #pragma mark - UITableView DataSource & Delegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat height = 86.0f; if (indexPath.row == 0) { height = 164.0f; } else if (indexPath.row == 1){ height = 181.0f; } else if (indexPath.row == 2){ height = 164.0f; } return height; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if (indexPath.row == 0) { HomeHubTableViewCell *tcell = (HomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubCellIdentifier"]; if (!([[Reachability reachabilityForInternetConnection]currentReachabilityStatus] == NotReachable)) { tcell.lblNetworkStatus.text = @"정상"; tcell.lblNetworkStatus.textColor = kUITextColor04; tcell.imgvStatus.image = nil; } else { tcell.lblNetworkStatus.text = [NSString stringWithFormat:@"단절 %@", @"2017.04.04 15:33:30"]; tcell.lblNetworkStatus.textColor = kUITextColor07; tcell.imgvStatus.image = [UIImage imageNamed:@"common_bullet_alert_on"]; } if([JDFacade facade].loginUser.isHomehubOnline){ tcell.lblDeviceStatus.text = @"정상"; tcell.lblDeviceStatus.textColor = kUITextColor04; } else { tcell.lblDeviceStatus.text = @"단절"; tcell.lblDeviceStatus.textColor = kUITextColor07; } cell = tcell; } else if (indexPath.row == 1) { HomeHubRegistTableViewCell *tcell = (HomeHubRegistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"RegistCellIdentifier"]; tcell.lblDate.text = [CommonUtil formattedDate3:[JDFacade facade].loginUser.homehubCreateDatetime]; cell = tcell; } else if (indexPath.row == 2) { HomeHubInfoTableViewCell *tcell = (HomeHubInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubInfoCellIdentifier"]; cell = tcell; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [super tableView:tableView didSelectRowAtIndexPath:indexPath]; } #pragma mark - UI Events - (IBAction)btnSecureTouched:(id)sender { } - (IBAction)btnEditTitleTouched:(id)sender { NSLog(@"타이틀 변경"); } - (void)btnCloseTouched:(id)sender { [self dismissViewControllerAnimated:YES completion:nil]; } - (IBAction)btnSetTouched:(id)sender { NSLog(@"설정"); } #pragma mark - MemoryWarning - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end