allVersionView.m 6.5 KB

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