cloudPhoneModelViewController.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // cloudPhoneModelViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/11/1.
  6. //
  7. #import "cloudPhoneModelViewController.h"
  8. #import "MineViewCell.h"
  9. @interface cloudPhoneModelViewController ()<UITableViewDelegate,UITableViewDataSource>
  10. @property (nonatomic, strong, nullable) UITableView *tableView;
  11. @end
  12. @implementation cloudPhoneModelViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self.titleLabel setText:NSLocalizedString(@"mine_cloudPhone_Model_title",nil)];
  16. [self.view setBackgroundColor:HWF5F7FAColor];
  17. [self.toolBar setHidden:YES];
  18. [self.navigationBar setHidden:YES];
  19. [self.navBarBGView setHidden:NO];
  20. [self drawAnyView];
  21. }
  22. - (void)drawAnyView{
  23. [self.view addSubview:self.tableView];
  24. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.left.mas_equalTo(0);
  26. make.right.mas_equalTo(0);
  27. make.bottom.mas_equalTo(0);
  28. make.top.equalTo(self.navBarBGView.mas_bottom).offset(16.f);
  29. }];
  30. }
  31. #pragma mark - 懒加载
  32. - (UITableView *)tableView{
  33. if (!_tableView) {
  34. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  35. _tableView.delegate = self;
  36. _tableView.dataSource = self;
  37. _tableView.showsVerticalScrollIndicator = NO;
  38. _tableView.showsHorizontalScrollIndicator = NO;
  39. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  40. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  41. [_tableView setSeparatorColor:[UIColor clearColor]];
  42. [_tableView setBackgroundColor:[UIColor clearColor]];
  43. [_tableView setTableFooterView:[UIView new]];
  44. _tableView.scrollEnabled = NO;
  45. [_tableView setBounces:YES];
  46. if (@available(iOS 15.0, *)) {
  47. _tableView.sectionHeaderTopPadding = 0;
  48. }
  49. }
  50. return _tableView;
  51. }
  52. #pragma mark - 列表委托
  53. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  54. return 1;
  55. }
  56. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  57. return 1;
  58. }
  59. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  60. NSInteger row = indexPath.row;
  61. static NSString *identifier = @"MineViewCell";
  62. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  63. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  64. if (!cell){
  65. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  66. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  67. [cell setBackgroundColor:[UIColor clearColor]];
  68. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  69. }
  70. [cell.bgViewLayer removeFromSuperlayer];
  71. [cell.titleLabel2 setHidden:YES];
  72. [cell.rightImage setHidden:NO];
  73. [cell.lineView setHidden:NO];
  74. [cell.maskSwitch setHidden:YES];
  75. if (row == 0){
  76. [cell.titleLabel setText:NSLocalizedString(@"mine_cloudPhone_Model_title",nil)];
  77. cell.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
  78. [cell.mImageView setImage:[UIImage imageNamed:@"mine_cloudPhone_model_icon"]];
  79. [cell.rightImage setHidden:YES];
  80. [cell.maskSwitch setHidden:NO];
  81. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_cloudPhone_Model_Open];
  82. [cell.maskSwitch setOn:haveOpenMask];
  83. /*下圆角*/
  84. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  85. byRoundingCorners:UIRectCornerAllCorners
  86. cornerRadii:CGSizeMake(8, 8)];
  87. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  88. maskLayer.frame = cell.cellBgView.bounds;
  89. maskLayer.path = maskPath.CGPath;
  90. cell.bgViewLayer = maskLayer;
  91. cell.cellBgView.layer.mask = cell.bgViewLayer;
  92. [cell.lineView setHidden:YES];
  93. KWeakSelf
  94. cell.didClickMaskSwitch = ^(UISwitch * _Nonnull maskSwitch) {
  95. [weakSelf maskSwitchPressed:maskSwitch];
  96. };
  97. }
  98. return cell;
  99. }
  100. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  101. return 60;
  102. }
  103. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  104. {
  105. return 50;
  106. }
  107. - (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  108. {
  109. UIView *tailView = [UIView new];
  110. UILabel *tipLab = [[UILabel alloc] init];
  111. tipLab.backgroundColor = [UIColor clearColor];
  112. tipLab.font = [UIFont systemFontOfSize:12.0];
  113. tipLab.textColor = HW666666Color;
  114. tipLab.numberOfLines = 0;
  115. tipLab.text = NSLocalizedString(@"cloudPhone_Model_tip",nil);
  116. [tailView addSubview:tipLab];
  117. [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.left.mas_equalTo(15);
  119. make.right.mas_equalTo(-15);
  120. make.bottom.mas_equalTo(0);
  121. make.top.mas_equalTo(0);
  122. }];
  123. return tailView;
  124. }
  125. - (void)maskSwitchPressed:(UISwitch *)maskSwitch{
  126. [HWDataManager setBoolWithKey:Const_cloudPhone_Model_Open value:maskSwitch.on];
  127. if (maskSwitch.on) {
  128. [[iToast makeText:NSLocalizedString(@"cloudPhone_Model_open_tip",nil)] show];
  129. }
  130. else{
  131. [[iToast makeText:NSLocalizedString(@"cloudPhone_Model_close_tip",nil)] show];
  132. }
  133. }
  134. @end