You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ViewController.m 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // ViewController.m
  3. // healthRingDemo
  4. //
  5. // Created by 周鹏 on 2024/3/14.
  6. //
  7. #import "ViewController.h"
  8. #import "ELDeviceTypeCell.h"
  9. #import "ELDemoDeviceModel.h"
  10. #import "ELDemoScanVC.h"
  11. #import <AICareComponentRingBleSDK/ELSmartRingManager.h>
  12. #import "RingTestDemoVC.h"
  13. @interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  15. @property (weak, nonatomic) IBOutlet UILabel *versionLabel;
  16. @property (nonatomic, strong) NSArray *deviceArray;
  17. @end
  18. @implementation ViewController
  19. - (void)viewDidLoad
  20. {
  21. [super viewDidLoad];
  22. // Do any additional setup after loading the view, typically from a nib.
  23. self.title = [NSString stringWithFormat:@"%@", @"智能戒指蓝牙SDK"];
  24. self.versionLabel.text = [NSString stringWithFormat:@"SDK ver: %@ \nDemo ver: %@", ELSmartRingManager.sdkVersion, self.class.appVersion];
  25. self.deviceArray = @[
  26. [ELDemoDeviceModel modelWithIndex:@"00" imageName:@"ailink_connected_ic" title:@"智能戒指 Test" subtitle:@"1.0" entryVCName:NSStringFromClass(RingTestDemoVC.class) cids:@[@(0x005D)]]];
  27. }
  28. - (void)didReceiveMemoryWarning
  29. {
  30. [super didReceiveMemoryWarning];
  31. // Dispose of any resources that can be recreated.
  32. }
  33. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  34. return self.deviceArray.count;
  35. }
  36. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  37. return 88;
  38. }
  39. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  40. ELDemoDeviceModel *device = self.deviceArray[indexPath.row];
  41. ELDeviceTypeCell *cell = [ELDeviceTypeCell subsribeCell:tableView];
  42. cell.indexLabel.text = device.index;
  43. cell.titleLabel.text = device.titleText;
  44. cell.subtitleLabel.text = device.subtitleText;
  45. cell.iconImageView.image = [UIImage imageNamed:device.imageName];
  46. return cell;
  47. }
  48. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  49. ELDemoDeviceModel *device = self.deviceArray[indexPath.row];
  50. if (device.newType) {
  51. ELDemoScanVC *vc = [[ELDemoScanVC alloc] init];
  52. vc.cids = device.cids;
  53. vc.demoDeviceModel = device;
  54. // vc.modalPresentationStyle = UIModalPresentationFullScreen;
  55. [self.navigationController presentViewController:vc animated:YES completion:^{
  56. NSLog(@"");
  57. }];
  58. __weak typeof(self) weakSelf = self;
  59. vc.selectedBlock = ^(ELAILinkPeripheral * _Nonnull per) {
  60. UIViewController *vc = [[NSClassFromString(device.entryVCName) alloc] init];
  61. vc.title = [NSString stringWithFormat:@"%@_%@", device.titleText, device.subtitleText];
  62. [vc setValue:per forKey:@"per"];
  63. [weakSelf.navigationController pushViewController:vc animated:YES];
  64. };
  65. } else {
  66. UIViewController *vc = [[NSClassFromString(device.entryVCName) alloc] init];
  67. vc.title = [NSString stringWithFormat:@"%@_%@", device.titleText, device.subtitleText];
  68. [self.navigationController pushViewController:vc animated:YES];
  69. }
  70. }
  71. + (NSString *)appName {
  72. NSDictionary *dic = [[NSBundle mainBundle] infoDictionary];
  73. NSString *appName = [dic objectForKey:@"CFBundleDisplayName"];
  74. return appName;
  75. }
  76. + (NSString *)appVersion {
  77. NSDictionary *dic = [[NSBundle mainBundle] infoDictionary];
  78. NSString * version = [dic objectForKey:@"CFBundleShortVersionString"];
  79. return version;
  80. }
  81. @end