filePathCreatPopView.m 13 KB

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