HomeHubViewController.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // HomeHubViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 10/28/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "HomeHubViewController.h"
  9. #import "RequestHandler.h"
  10. #import "DeviceModel.h"
  11. #import "CustomTableView.h"
  12. #import "CustomButton.h"
  13. #import "Reachability.h"
  14. @implementation HomeHubTableViewCell
  15. @end
  16. @implementation HomeHubRegistTableViewCell
  17. - (void)didMoveToSuperview {
  18. _lblDate.hidden = YES;
  19. [self layoutIfNeeded];
  20. }
  21. @end
  22. @implementation HomeHubInfoTableViewCell
  23. @end
  24. @interface HomeHubViewController () {
  25. }
  26. @end
  27. #pragma mark - Class Definition
  28. @implementation HomeHubViewController
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. // Do any additional setup after loading the view.
  32. [self initUI];
  33. [self prepareViewDidLoad];
  34. }
  35. - (void)initUI {
  36. [self initTableViewAsDefaultStyle:_tableView];
  37. }
  38. - (void)prepareViewDidLoad {
  39. }
  40. - (void)updateHomeHubStatus {
  41. [_tableView reloadData];
  42. }
  43. #pragma mark - UITableView DataSource & Delegate
  44. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  45. return 1;
  46. }
  47. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  48. return 3;
  49. }
  50. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  51. CGFloat height = 86.0f;
  52. if (indexPath.row == 0) {
  53. height = 185.0f;
  54. } else if (indexPath.row == 1){
  55. height = 182.0f;
  56. } else if (indexPath.row == 2){
  57. height = 164.0f;
  58. }
  59. return height;
  60. }
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  62. UITableViewCell *cell = nil;
  63. if (indexPath.row == 0) {
  64. HomeHubTableViewCell *tcell = (HomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubCellIdentifier"];
  65. if (![tcell.btnSet actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  66. [tcell.btnSet addTarget:self action:@selector(btnSetTouched:) forControlEvents:UIControlEventTouchUpInside];
  67. }
  68. [self masterBtn:tcell.btnSet];
  69. if (!([[Reachability reachabilityForInternetConnection]currentReachabilityStatus] == NotReachable)) {
  70. tcell.lblNetworkStatus.text = @"온라인";
  71. tcell.lblBrokenTime.text = @"";
  72. tcell.lblNetworkStatus.textColor = kUITextColor04;
  73. tcell.imgvStatus.hidden = YES;
  74. } else {
  75. tcell.lblNetworkStatus.text = @"오프라인";
  76. tcell.lblBrokenTime.text = @"2017.04.04 15:33:30";
  77. tcell.lblNetworkStatus.textColor = kUITextColor07;
  78. tcell.lblBrokenTime.textColor = kUITextColor07;
  79. tcell.imgvStatus.hidden = NO;
  80. // tcell.imgvStatus.image = [UIImage imageNamed:@"common_bullet_alert_on"];
  81. }
  82. if([JDFacade facade].loginUser.isHomehubOnline){
  83. tcell.lblDeviceStatus.text = @"온라인";
  84. tcell.lblDeviceStatus.textColor = kUITextColor04;
  85. } else {
  86. tcell.lblDeviceStatus.text = @"오프라인";
  87. tcell.lblDeviceStatus.textColor = kUITextColor07;
  88. }
  89. cell = tcell;
  90. } else if (indexPath.row == 1) {
  91. HomeHubRegistTableViewCell *tcell = (HomeHubRegistTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"RegistCellIdentifier"];
  92. // tcell.lblDate.text = [CommonUtil formattedDate3:[JDFacade facade].loginUser.homehubCreateDatetime];
  93. [self masterBtn:tcell.btnFirmUpdate];
  94. [self masterBtn:tcell.btnSoftUpdate];
  95. if (![tcell.btnFirmUpdate actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  96. [tcell.btnFirmUpdate addTarget:self action:@selector(btnFirmwareUpdateTouched:) forControlEvents:UIControlEventTouchUpInside];
  97. }
  98. if (![tcell.btnSoftUpdate actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  99. [tcell.btnSoftUpdate addTarget:self action:@selector(btnSofrwareUpdateTouched:) forControlEvents:UIControlEventTouchUpInside];
  100. }
  101. cell = tcell;
  102. } else if (indexPath.row == 2) {
  103. HomeHubInfoTableViewCell *tcell = (HomeHubInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"HubInfoCellIdentifier"];
  104. cell = tcell;
  105. }
  106. return cell;
  107. }
  108. - (void)masterBtn:(CustomButton *)button{
  109. if ([JDFacade facade].loginUser.level < 90) {
  110. button.hidden = YES;
  111. } else {
  112. button.hidden = NO;
  113. }
  114. }
  115. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  116. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  117. }
  118. - (IBAction)btnEditTitleTouched:(id)sender {
  119. NSLog(@"타이틀 변경");
  120. }
  121. - (void)btnSetTouched:(id)sender {
  122. NSLog(@"설정");
  123. }
  124. - (void)btnFirmwareUpdateTouched:(id)sender{
  125. NSLog(@"펌웨어 업데이트");
  126. }
  127. - (void)btnSofrwareUpdateTouched:(id)sender{
  128. NSLog(@"소프트웨어 업데이트");
  129. }
  130. #pragma mark - UI Events
  131. - (IBAction)btnSecureTouched:(id)sender {
  132. }
  133. - (void)btnCloseTouched:(id)sender {
  134. [self dismissViewControllerAnimated:YES completion:nil];
  135. }
  136. #pragma mark - MemoryWarning
  137. - (void)didReceiveMemoryWarning
  138. {
  139. [super didReceiveMemoryWarning];
  140. // Dispose of any resources that can be recreated.
  141. }
  142. @end