fileTransfeSetViewController.m 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. //
  2. // fileTransfeSetViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/12/28.
  6. //
  7. #import "fileTransfeSetViewController.h"
  8. #import "fileSetTableViewCell.h"
  9. #import "fileTransferPathCheckViewController.h"
  10. @interface fileTransfeSetViewController ()<UITableViewDelegate,UITableViewDataSource>
  11. @property (nonatomic, strong) UITableView *tableView;
  12. @property (nonatomic, strong) UIView *tailView;
  13. @property (nonatomic, strong) UILabel *uploadFilePathLabel;
  14. @end
  15. @implementation fileTransfeSetViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. [self.toolBar setHidden:YES];
  20. [self.navigationBar setHidden:YES];
  21. [self.navBarBGView setHidden:NO];
  22. [self.titleLabel setText:NSLocalizedString(@"set_upload_download_tip",nil)];
  23. [self.view setBackgroundColor:HWF5F7FAColor];
  24. [self drawAnyView];
  25. }
  26. - (void)drawAnyView{
  27. [self.view addSubview:self.tableView];
  28. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.mas_equalTo(0);
  30. make.right.mas_equalTo(0);
  31. make.bottom.mas_equalTo(0);
  32. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  33. }];
  34. self.tableView.tableFooterView = [self tailView];
  35. }
  36. #pragma mark - 懒加载
  37. - (UITableView *)tableView{
  38. if (!_tableView) {
  39. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  40. _tableView.delegate = self;
  41. _tableView.dataSource = self;
  42. _tableView.showsVerticalScrollIndicator = NO;
  43. _tableView.showsHorizontalScrollIndicator = NO;
  44. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  45. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  46. [_tableView setSeparatorColor:[UIColor clearColor]];
  47. [_tableView setBackgroundColor:[UIColor clearColor]];
  48. [_tableView setTableFooterView:[UIView new]];
  49. [_tableView setBounces:YES];
  50. _tableView.scrollEnabled = NO;
  51. if (@available(iOS 15.0, *)) {
  52. _tableView.sectionHeaderTopPadding = 0;
  53. }
  54. }
  55. return _tableView;
  56. }
  57. #pragma mark - 懒加载
  58. - (UIView *)tailView{
  59. if (!_tailView) {
  60. _tailView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 110 +15)];
  61. UIView *tailBgView = [[UIView alloc] init];
  62. tailBgView.backgroundColor = [UIColor whiteColor];
  63. tailBgView.layer.cornerRadius = 8;
  64. [_tailView addSubview:tailBgView];
  65. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didClickTailViewFun)];
  66. [tailBgView addGestureRecognizer:tap];
  67. [tailBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(15);
  69. make.right.mas_equalTo(-15);
  70. make.bottom.mas_equalTo(0);
  71. make.top.mas_equalTo(15);
  72. }];
  73. UILabel *titleLab = [[UILabel alloc] init];
  74. titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  75. titleLab.font = [UIFont boldSystemFontOfSize:14.0];
  76. titleLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  77. [tailBgView addSubview:titleLab];
  78. [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.left.mas_equalTo(10);
  80. make.right.mas_equalTo(-50);
  81. make.height.mas_equalTo(20);
  82. make.top.mas_equalTo(20);
  83. }];
  84. /*右侧箭头*/
  85. UIImageView *rightImage = [[UIImageView alloc] init];
  86. [rightImage setBackgroundColor:[UIColor clearColor]];
  87. [rightImage setImage:[UIImage imageNamed:@"cell_right_access"]];
  88. [tailBgView addSubview:rightImage];
  89. [rightImage mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.width.mas_equalTo(28);
  91. make.right.mas_equalTo(-15.f);
  92. make.height.mas_equalTo(28);
  93. make.centerY.equalTo(titleLab.mas_centerY);
  94. }];
  95. _uploadFilePathLabel=[[UILabel alloc] init];
  96. //titleLab.text = NSLocalizedString(@"File_upload_path_set",nil);
  97. _uploadFilePathLabel.font = [UIFont systemFontOfSize:12.0];
  98. _uploadFilePathLabel.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  99. _uploadFilePathLabel.numberOfLines = 0;
  100. [tailBgView addSubview:_uploadFilePathLabel];
  101. [_uploadFilePathLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.left.mas_equalTo(10);
  103. make.right.mas_equalTo(-15);
  104. make.bottom.mas_equalTo(-20);
  105. make.top.mas_equalTo(titleLab.mas_bottom).offset(10.0);
  106. }];
  107. [self setUploadFilePathLabelTitleFun];
  108. }
  109. return _tailView;
  110. }
  111. - (void)setUploadFilePathLabelTitleFun
  112. {
  113. NSString * leftStr = NSLocalizedString(@"File_upload_path_way",nil);
  114. NSString * rightStr = @"我的空间/来自【手机设备名称】的相册备份";
  115. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  116. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  117. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  118. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  119. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  120. // 设置行间距
  121. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  122. [paragraphStyle setLineSpacing:5]; //设置行间距
  123. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  124. _uploadFilePathLabel.attributedText = noteStr;
  125. }
  126. #pragma mark 尾部事件
  127. - (void)didClickTailViewFun
  128. {
  129. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  130. vc.curType = 1;
  131. [self.navigationController pushViewController:vc animated:YES];
  132. }
  133. #pragma mark - 列表委托
  134. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  135. return 1;
  136. }
  137. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  138. return 2;
  139. }
  140. - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  141. __block NSInteger row = indexPath.row;
  142. static NSString *identifier = @"fileSetTableViewCell";
  143. fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  144. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  145. if (!cell){
  146. cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  147. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  148. [cell setBackgroundColor:[UIColor clearColor]];
  149. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  150. [cell.bgViewLayer removeFromSuperlayer];
  151. [cell.titleLabel2 setHidden:YES];
  152. [cell.rightImage setHidden:YES];
  153. [cell.lineView setHidden:NO];
  154. [cell.maskSwitch setHidden:NO];
  155. }
  156. if (row == 0){
  157. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_Cellular",nil)];
  158. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_file_Transfe_canUse_Cellular];
  159. [cell.maskSwitch setOn:haveOpenMask];
  160. /*上圆角*/
  161. //设置部分圆角 贝塞尔曲线
  162. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  163. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  164. cornerRadii:CGSizeMake(8, 8)];
  165. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  166. maskLayer.frame = cell.cellBgView.bounds;
  167. maskLayer.path = maskPath.CGPath;
  168. cell.bgViewLayer = maskLayer;
  169. cell.cellBgView.layer.mask = cell.bgViewLayer;
  170. }else if (row == 1){
  171. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  172. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_file_Transfe_battery_level];
  173. [cell.maskSwitch setOn:haveOpenMask];
  174. /*下圆角*/
  175. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  176. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  177. cornerRadii:CGSizeMake(8, 8)];
  178. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  179. maskLayer.frame = cell.cellBgView.bounds;
  180. maskLayer.path = maskPath.CGPath;
  181. cell.bgViewLayer = maskLayer;
  182. cell.cellBgView.layer.mask = cell.bgViewLayer;
  183. [cell.lineView setHidden:YES];
  184. }
  185. KWeakSelf
  186. cell.didClickSwitch = ^(BOOL SwitchOn) {
  187. [weakSelf didClickSwitchBy:SwitchOn withRow:row];
  188. };
  189. return cell;
  190. }
  191. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  192. return 60;
  193. }
  194. - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
  195. {
  196. if(row == 0){
  197. [HWDataManager setBoolWithKey:Const_file_Transfe_canUse_Cellular value:SwitchOn];
  198. }
  199. else{
  200. [HWDataManager setBoolWithKey:Const_file_Transfe_battery_level value:SwitchOn];
  201. }
  202. }
  203. @end