fileTransfeSetViewController.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 * uploadDefaultPath = [HWDataManager getStringWithKey:Const_photo_upload_default_path];
  115. if(!uploadDefaultPath || uploadDefaultPath.length == 0){
  116. [HWDataManager setStringWithKey:Const_photo_upload_default_path value:Const_default_upload_path];
  117. }
  118. NSString * rightStr = uploadDefaultPath;
  119. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@%@",leftStr,rightStr];
  120. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  121. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightStr].location, [totalStr rangeOfString:rightStr].length);
  122. [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#01B7EA" alpha:0.8] range:redRange];
  123. [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  124. // 设置行间距
  125. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  126. [paragraphStyle setLineSpacing:5]; //设置行间距
  127. [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  128. _uploadFilePathLabel.attributedText = noteStr;
  129. }
  130. #pragma mark 尾部事件
  131. - (void)didClickTailViewFun
  132. {
  133. fileTransferPathCheckViewController *vc = [fileTransferPathCheckViewController new];
  134. vc.curType = 1;
  135. [self.navigationController pushViewController:vc animated:YES];
  136. }
  137. #pragma mark - 列表委托
  138. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  139. return 1;
  140. }
  141. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  142. //return 2;
  143. return 1;
  144. }
  145. - (fileSetTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  146. __block NSInteger row = indexPath.row;
  147. static NSString *identifier = @"fileSetTableViewCell";
  148. fileSetTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  149. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  150. if (!cell){
  151. cell = [[fileSetTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  152. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  153. [cell setBackgroundColor:[UIColor clearColor]];
  154. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  155. [cell.bgViewLayer removeFromSuperlayer];
  156. [cell.titleLabel2 setHidden:YES];
  157. [cell.rightImage setHidden:YES];
  158. [cell.lineView setHidden:NO];
  159. [cell.maskSwitch setHidden:NO];
  160. }
  161. if (row == 0){
  162. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_Cellular",nil)];
  163. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_file_Transfe_canUse_Cellular];
  164. [cell.maskSwitch setOn:haveOpenMask];
  165. /*上圆角*/
  166. //设置部分圆角 贝塞尔曲线
  167. // UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  168. // byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  169. // cornerRadii:CGSizeMake(8, 8)];
  170. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  171. byRoundingCorners:UIRectCornerAllCorners
  172. cornerRadii:CGSizeMake(8, 8)];
  173. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  174. maskLayer.frame = cell.cellBgView.bounds;
  175. maskLayer.path = maskPath.CGPath;
  176. cell.bgViewLayer = maskLayer;
  177. cell.cellBgView.layer.mask = cell.bgViewLayer;
  178. [cell.lineView setHidden:YES];
  179. }else if (row == 1){
  180. [cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  181. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Const_file_Transfe_battery_level];
  182. [cell.maskSwitch setOn:haveOpenMask];
  183. /*下圆角*/
  184. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  185. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  186. cornerRadii:CGSizeMake(8, 8)];
  187. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  188. maskLayer.frame = cell.cellBgView.bounds;
  189. maskLayer.path = maskPath.CGPath;
  190. cell.bgViewLayer = maskLayer;
  191. cell.cellBgView.layer.mask = cell.bgViewLayer;
  192. [cell.lineView setHidden:YES];
  193. }
  194. KWeakSelf
  195. cell.didClickSwitch = ^(BOOL SwitchOn) {
  196. [weakSelf didClickSwitchBy:SwitchOn withRow:row];
  197. };
  198. return cell;
  199. }
  200. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  201. return 60;
  202. }
  203. - (void)didClickSwitchBy:(BOOL)SwitchOn withRow:(NSInteger)row
  204. {
  205. if(row == 0){
  206. [HWDataManager setBoolWithKey:Const_file_Transfe_canUse_Cellular value:SwitchOn];
  207. }
  208. else{
  209. [HWDataManager setBoolWithKey:Const_file_Transfe_battery_level value:SwitchOn];
  210. }
  211. }
  212. @end