allVersionView.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. //
  2. // allVersionView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/27.
  6. //
  7. #import "allVersionView.h"
  8. #import "couldphoneSysInfoModel.h"
  9. #import "connectDeviceManager.h"
  10. @interface allVersionView ()<UITableViewDelegate,UITableViewDataSource>
  11. {
  12. NSMutableArray*dataArr;
  13. }
  14. @property(nonatomic,strong)UIView *whiteBgView;
  15. @property(nonatomic,strong)UITableView *tableView;
  16. @property(nonatomic,strong)couldphoneSysInfoModel *couldphoneSysInfoMod;
  17. @end
  18. @implementation allVersionView
  19. - (id)initWithFrame:(CGRect)frame{
  20. self = [super initWithFrame:frame];
  21. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getCouldPhoneBaseInfoFun:) name:getCouldPhoneSysInfoNotification object:nil];
  22. [self drawAnyView];
  23. return self;
  24. }
  25. - (void)drawAnyView{
  26. dataArr = [NSMutableArray new];
  27. NSString *str1 = NSLocalizedString(@"my_set_about_version_tap_jingxiang",nil);
  28. NSString *str2 = NSLocalizedString(@"my_set_about_version_tap_daili",nil);
  29. NSString *str3 = NSLocalizedString(@"my_set_about_version_tap_app",nil);
  30. NSString *str4 = NSLocalizedString(@"my_set_about_version_tap_sn",nil);
  31. [dataArr addObject:str1];
  32. [dataArr addObject:str2];
  33. [dataArr addObject:str3];
  34. [dataArr addObject:str4];
  35. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  36. _whiteBgView = [[UIView alloc] init];
  37. _whiteBgView.backgroundColor = [UIColor whiteColor];
  38. _whiteBgView.layer.cornerRadius = 8;
  39. [self addSubview:_whiteBgView];
  40. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.mas_equalTo(20);
  42. make.right.mas_equalTo(-20);
  43. make.height.mas_equalTo(260);
  44. make.centerY.mas_equalTo(self.center).offset(-20);
  45. }];
  46. UIButton* delBut = [[UIButton alloc] init];
  47. [delBut setImage:[UIImage imageNamed:@"common_del"] forState:UIControlStateNormal];
  48. [delBut addTarget:self action:@selector(delViewFun) forControlEvents:UIControlEventTouchUpInside];
  49. [_whiteBgView addSubview:delBut];
  50. [delBut mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.top.mas_equalTo(0);
  52. make.right.mas_equalTo(0);
  53. make.width.mas_equalTo(40);
  54. make.height.mas_equalTo(40.0);
  55. }];
  56. UILabel * versionTipLabel = [[UILabel alloc] init];
  57. versionTipLabel.text = NSLocalizedString(@"my_set_about_version_tap_tip",nil) ;
  58. versionTipLabel.textAlignment = NSTextAlignmentCenter;
  59. versionTipLabel.font = [UIFont boldSystemFontOfSize:16.0];
  60. [_whiteBgView addSubview:versionTipLabel];
  61. [versionTipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.left.mas_equalTo(15);
  63. make.right.mas_equalTo(-15);
  64. make.top.mas_equalTo(30);
  65. make.height.mas_equalTo(20.0);
  66. }];
  67. [_whiteBgView addSubview:self.tableView];
  68. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.left.mas_equalTo(15);
  70. make.right.mas_equalTo(-15);
  71. make.top.mas_equalTo(versionTipLabel.mas_bottom).offset(20);
  72. make.bottom.mas_equalTo(-16.0);
  73. }];
  74. }
  75. #pragma mark - 懒加载
  76. - (UITableView *)tableView{
  77. if (!_tableView) {
  78. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  79. _tableView.delegate = self;
  80. _tableView.dataSource = self;
  81. _tableView.showsVerticalScrollIndicator = NO;
  82. _tableView.showsHorizontalScrollIndicator = NO;
  83. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  84. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  85. [_tableView setSeparatorColor:[UIColor clearColor]];
  86. [_tableView setBackgroundColor:[UIColor hwColor:@"#D8D8D8" alpha:1.0]];
  87. [_tableView setTableFooterView:[UIView new]];
  88. [_tableView setBounces:YES];
  89. _tableView.layer.cornerRadius = 8;
  90. if (@available(iOS 15.0, *)) {
  91. _tableView.sectionHeaderTopPadding = 0;
  92. }
  93. }
  94. return _tableView;
  95. }
  96. - (void)delViewFun
  97. {
  98. [self removeFromSuperview];
  99. }
  100. #pragma mark - 列表委托
  101. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  102. return dataArr.count;
  103. }
  104. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  105. NSInteger row = indexPath.row;
  106. static NSString *identifier = @"UITableViewCell";
  107. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  108. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  109. if (!cell){
  110. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  111. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  112. [cell setBackgroundColor:[UIColor clearColor]];
  113. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  114. cell.textLabel.font = [UIFont systemFontOfSize:12.0];
  115. cell.textLabel.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
  116. cell.detailTextLabel.font = [UIFont systemFontOfSize:14.0];
  117. cell.detailTextLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  118. }
  119. if(row < dataArr.count){
  120. cell.textLabel.text = dataArr[row];
  121. }
  122. if(_couldphoneSysInfoMod){
  123. switch (row)
  124. {
  125. case 0:
  126. cell.detailTextLabel.text = _couldphoneSysInfoMod.data.data.ImageVersion;
  127. break;
  128. case 1:
  129. cell.detailTextLabel.text = _couldphoneSysInfoMod.data.data.AgentVersion.versionName;
  130. break;
  131. case 2:
  132. //cell.detailTextLabel.text = _baseInfoModel.os_info;
  133. break;
  134. case 3:
  135. //cell.detailTextLabel.text = _couldphoneSysInfoMod.data.data.sn;
  136. cell.detailTextLabel.text = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  137. break;
  138. }
  139. }
  140. return cell;
  141. }
  142. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  143. return 40;
  144. }
  145. - (void)getCouldPhoneBaseInfoFun:(NSNotification*)not
  146. {
  147. _couldphoneSysInfoMod = [not object];
  148. //HLog(@"%@",baseInfoModel);
  149. if(!_couldphoneSysInfoMod || ![_couldphoneSysInfoMod isKindOfClass:[couldphoneSysInfoModel class]]){
  150. return;
  151. }
  152. [self.tableView reloadData];
  153. }
  154. @end