filePathCreatPopView.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. //
  2. // filePathCreatPopView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/12/29.
  6. //
  7. #import "filePathCreatPopView.h"
  8. #import "filePathCreatTableViewCell.h"
  9. @interface filePathCreatPopView ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
  10. {
  11. UIView *whiteBgView;
  12. UITextField *filePathNameTF;
  13. UIButton *canclButton;
  14. UIButton *okButton;
  15. }
  16. @property (nonatomic, strong) UITableView *tableView;
  17. @end
  18. @implementation filePathCreatPopView
  19. - (id)initWithFrame:(CGRect)frame{
  20. self = [super initWithFrame:frame];
  21. [self drawAnyView];
  22. return self;
  23. }
  24. - (void)drawAnyView{
  25. [self setBackgroundColor:[UIColor hwColor:@"#000000" alpha:0.6]];
  26. whiteBgView = [[UIView alloc] init];
  27. whiteBgView.backgroundColor = [UIColor whiteColor];
  28. whiteBgView.layer.cornerRadius = 12;
  29. [self addSubview:whiteBgView];
  30. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.mas_equalTo(0);
  32. make.right.mas_equalTo(0);
  33. //make.height.mas_equalTo(418+ 10 + safeArea);
  34. make.height.mas_equalTo(200+ 10 + safeArea);
  35. make.bottom.mas_equalTo(10);
  36. }];
  37. UIView *tapView = [[UIView alloc] init];
  38. [self addSubview:tapView];
  39. // UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapUpFun:)];
  40. // [tapView addGestureRecognizer:tap];
  41. [tapView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.left.mas_equalTo(0);
  43. make.right.mas_equalTo(0);
  44. make.top.mas_equalTo(0);
  45. make.bottom.mas_equalTo(whiteBgView.mas_top);
  46. }];
  47. UILabel *titleLabel = [[UILabel alloc] init];
  48. titleLabel.text = NSLocalizedString(@"File_upload_path_new",nil);
  49. titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
  50. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  51. [whiteBgView addSubview:titleLabel];
  52. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.right.mas_equalTo(0);
  54. make.height.mas_equalTo(20);
  55. make.left.mas_equalTo(15);
  56. make.top.mas_equalTo(15);
  57. }];
  58. [whiteBgView addSubview:self.tableView];
  59. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.left.mas_equalTo(15);
  61. make.right.mas_equalTo(-15);
  62. //make.height.mas_equalTo(70*2+50);
  63. make.height.mas_equalTo(0.0);
  64. make.top.equalTo(titleLabel.mas_bottom).offset(15.f);
  65. }];
  66. self.tableView.hidden = YES;
  67. UILabel *tipLabel = [[UILabel alloc] init];
  68. tipLabel.text = NSLocalizedString(@"File_upload_path_new_name_tip",nil);
  69. tipLabel.font = [UIFont systemFontOfSize:14.0];
  70. tipLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  71. [whiteBgView addSubview:tipLabel];
  72. [tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.right.mas_equalTo(0);
  74. make.height.mas_equalTo(20);
  75. make.left.mas_equalTo(15);
  76. make.top.equalTo(self.tableView.mas_bottom).offset(15);
  77. }];
  78. filePathNameTF = [[UITextField alloc] init];
  79. filePathNameTF.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
  80. filePathNameTF.layer.cornerRadius = 8;
  81. filePathNameTF.font = [UIFont systemFontOfSize:14.0];
  82. filePathNameTF.placeholder = NSLocalizedString(@"File_upload_path_new_input_tip",nil);
  83. filePathNameTF.delegate = self;
  84. filePathNameTF.returnKeyType = UIReturnKeyDone;
  85. [whiteBgView addSubview:filePathNameTF];
  86. [filePathNameTF setTintColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
  87. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 1)];
  88. filePathNameTF.leftView = leftView;
  89. filePathNameTF.leftViewMode = UITextFieldViewModeAlways;
  90. [filePathNameTF mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.right.mas_equalTo(-15);
  92. make.height.mas_equalTo(48);
  93. make.left.mas_equalTo(15);
  94. make.top.equalTo(tipLabel.mas_bottom).offset(15);
  95. }];
  96. canclButton = [[UIButton alloc] init];
  97. [canclButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  98. [canclButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:1.0] forState:UIControlStateNormal];
  99. canclButton.backgroundColor = [UIColor hwColor:@"#E3E8F1" alpha:1.0];
  100. canclButton.layer.cornerRadius = 8;
  101. canclButton.tag = 1;
  102. [canclButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  103. [whiteBgView addSubview:canclButton];
  104. [canclButton mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.left.mas_equalTo(15.0);
  106. make.right.equalTo(whiteBgView.mas_centerX).offset(-10);
  107. make.height.mas_equalTo(40);
  108. make.bottom.mas_equalTo(-safeArea -10);
  109. }];
  110. okButton = [[UIButton alloc] init];
  111. okButton.tag = 2;
  112. [okButton setTitle:NSLocalizedString(@"other_comment_ok",nil) forState:UIControlStateNormal];
  113. okButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0];
  114. okButton.layer.cornerRadius = 8;
  115. okButton.layer.masksToBounds = YES;
  116. [okButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  117. [whiteBgView addSubview:okButton];
  118. // gradient
  119. CAGradientLayer* _glayer = [CAGradientLayer layer];
  120. _glayer.startPoint = CGPointMake(0, 0.5);
  121. _glayer.endPoint = CGPointMake(1, 0.5);
  122. _glayer.colors = @[(__bridge id)[UIColor hwColor:@"#0BDDFD" alpha:1.0].CGColor, (__bridge id)[UIColor hwColor:@"#048CFB" alpha:1.0].CGColor];
  123. _glayer.locations = @[@(0), @(1.0f)];
  124. [okButton.layer insertSublayer:_glayer atIndex:0];
  125. CGRect frame = CGRectMake(0, 0, SCREEN_W/2.0, 40);
  126. _glayer.frame = frame;
  127. [okButton mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.right.mas_equalTo(-15.0);
  129. make.left.equalTo(whiteBgView.mas_centerX).offset(10);
  130. make.height.mas_equalTo(40);
  131. make.bottom.mas_equalTo(-safeArea -10);
  132. }];
  133. }
  134. #pragma mark - 懒加载
  135. - (UITableView *)tableView{
  136. if (!_tableView) {
  137. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
  138. _tableView.delegate = self;
  139. _tableView.dataSource = self;
  140. _tableView.showsVerticalScrollIndicator = NO;
  141. _tableView.showsHorizontalScrollIndicator = NO;
  142. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  143. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  144. [_tableView setSeparatorColor:[UIColor clearColor]];
  145. [_tableView setBackgroundColor:[UIColor clearColor]];
  146. [_tableView setTableFooterView:[UIView new]];
  147. [_tableView setBounces:YES];
  148. _tableView.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
  149. _tableView.layer.cornerRadius = 8;
  150. _tableView.scrollEnabled = NO;
  151. if (@available(iOS 15.0, *)) {
  152. _tableView.sectionHeaderTopPadding = 0;
  153. }
  154. }
  155. return _tableView;
  156. }
  157. #pragma mark - 列表委托
  158. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  159. return 1;
  160. }
  161. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  162. return 2;
  163. }
  164. - (filePathCreatTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  165. __block NSInteger row = indexPath.row;
  166. static NSString *identifier = @"filePathCreatTableViewCell";
  167. filePathCreatTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  168. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  169. if (!cell){
  170. cell = [[filePathCreatTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  171. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  172. [cell setBackgroundColor:[UIColor clearColor]];
  173. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  174. [cell.bgViewLayer removeFromSuperlayer];
  175. [cell.titleLabel2 setHidden:NO];
  176. [cell.rightImage setHidden:YES];
  177. [cell.lineView setHidden:YES];
  178. [cell.checkButton setHidden:NO];
  179. }
  180. if (row == 0){
  181. //[cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_Cellular",nil)];
  182. cell.titleLabel.text = @"云机系统名称";
  183. cell.checkButton.selected = YES;
  184. }else if (row == 1){
  185. //[cell.titleLabel setText:NSLocalizedString(@"File_Transfer_set_battery_level",nil)];
  186. cell.titleLabel.text = @"云机系统名称";
  187. }
  188. KWeakSelf
  189. cell.didClickSwitch = ^(BOOL SwitchOn) {
  190. };
  191. return cell;
  192. }
  193. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  194. return 70;
  195. }
  196. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  197. {
  198. return 40.0;
  199. }
  200. - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  201. {
  202. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 40)];
  203. //headView.backgroundColor = [UIColor greenColor];
  204. UILabel *titleLabel = [[UILabel alloc] init];
  205. titleLabel.text = NSLocalizedString(@"File_upload_path_new_check_tip",nil);
  206. titleLabel.font = [UIFont systemFontOfSize:14.0];
  207. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  208. [headView addSubview:titleLabel];
  209. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  210. make.left.mas_equalTo(15);
  211. make.right.mas_equalTo(-15);
  212. make.height.mas_equalTo(20);
  213. make.top.mas_equalTo(10);
  214. }];
  215. return headView;
  216. }
  217. //- (void)setFileTransferType:(NSInteger)fileTransferType
  218. //{
  219. // _fileTransferType = fileTransferType;
  220. //
  221. // NSString *uploadTitle = NSLocalizedString(@"File_upload_type_image",nil);
  222. // NSString *uploadTip = NSLocalizedString(@"File_upload_type_tip",nil);
  223. //
  224. // NSString *downloadTitle = NSLocalizedString(@"File_down_type_image",nil);
  225. // NSString *downloadTip = NSLocalizedString(@"File_down_type_tip",nil);
  226. //
  227. // if(fileTransferType == 2)
  228. // {
  229. // uploadTitle = NSLocalizedString(@"File_upload_type_video",nil);
  230. // downloadTitle = NSLocalizedString(@"File_down_type_video",nil);
  231. // }
  232. //
  233. // UILabel *uploadLabel = [[UILabel alloc] init];
  234. // uploadLabel.textColor = [UIColor whiteColor];
  235. // uploadLabel.font = [UIFont boldSystemFontOfSize:18.0];
  236. // uploadLabel.numberOfLines = 0;
  237. // [uploadButton addSubview:uploadLabel];
  238. //
  239. // NSString *totalStr = [[NSString alloc] initWithFormat:@"%@\n%@",uploadTitle,uploadTip];
  240. //
  241. // NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  242. //
  243. // NSRange redRange = NSMakeRange([totalStr rangeOfString:uploadTip].location, [totalStr rangeOfString:uploadTip].length);
  244. // [noteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] range:redRange];
  245. // [noteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:redRange];
  246. // // 设置行间距
  247. // NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  248. // [paragraphStyle setLineSpacing:5]; //设置行间距
  249. //
  250. // [noteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [totalStr length])];
  251. //
  252. // uploadLabel.attributedText = noteStr;
  253. //
  254. // [uploadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  255. // make.left.mas_equalTo(15);
  256. // make.right.mas_equalTo(-15);
  257. // make.bottom.mas_equalTo(0);
  258. // make.top.mas_equalTo(0);
  259. // }];
  260. //
  261. // UILabel *downloadLabel = [[UILabel alloc] init];
  262. // downloadLabel.textColor = [UIColor whiteColor];
  263. // downloadLabel.font = [UIFont boldSystemFontOfSize:18.0];
  264. // downloadLabel.numberOfLines = 0;
  265. // [downButton addSubview:downloadLabel];
  266. //
  267. // NSString *downTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@",downloadTitle,downloadTip];
  268. //
  269. // NSMutableAttributedString *downNoteStr = [[NSMutableAttributedString alloc] initWithString:downTotalStr];
  270. //
  271. // NSRange downredRange = NSMakeRange([downTotalStr rangeOfString:downloadTip].location, [downTotalStr rangeOfString:downloadTip].length);
  272. // [downNoteStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#FFFFFF" alpha:0.8] range:downredRange];
  273. // [downNoteStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:downredRange];
  274. // // 设置行间距
  275. //// NSMutableParagraphStyle *paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  276. //// [paragraphStyle1 setLineSpacing:5]; //设置行间距
  277. //
  278. // [downNoteStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [downTotalStr length])];
  279. //
  280. // downloadLabel.attributedText = downNoteStr;
  281. //
  282. // [downloadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  283. // make.left.mas_equalTo(15);
  284. // make.right.mas_equalTo(-15);
  285. // make.bottom.mas_equalTo(0);
  286. // make.top.mas_equalTo(0);
  287. // }];
  288. //}
  289. - (void)tapUpFun:(UITapGestureRecognizer*)tap
  290. {
  291. //[self deleteFromSuperview];
  292. }
  293. - (void)deleteFromSuperview
  294. {
  295. [self removeFromSuperview];
  296. }
  297. - (void)didClickButtonFun:(UIButton*)button
  298. {
  299. NSInteger tag = button.tag;
  300. if(tag == 1){
  301. [self deleteFromSuperview];
  302. }
  303. else if(tag == 2){
  304. NSString* folderName = filePathNameTF.text;
  305. if(!folderName || folderName.length ==0){
  306. [[iToast makeText:NSLocalizedString(@"File_upload_path_new_input_tip",nil)] show];
  307. return;
  308. }
  309. [self deleteFromSuperview];
  310. if(_didClickOkBut)
  311. {
  312. _didClickOkBut(folderName);
  313. }
  314. }
  315. }
  316. @end