previewToUploadFileView~.m 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. //
  2. // previewToUploadFileView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/14.
  6. //
  7. #import "previewToUploadFileView.h"
  8. @interface previewToUploadFileView ()
  9. @end
  10. @implementation previewToUploadFileView
  11. - (id)initWithFrame:(CGRect)frame{
  12. self = [super initWithFrame:frame];
  13. [self checkDidHadUploadTaskFun];
  14. //[self drawAnyView];
  15. return self;
  16. }
  17. -(void)checkDidHadUploadTaskFun
  18. {
  19. [[NSNotificationCenter defaultCenter] postNotificationName:getExtraFilesDoneNotification object:nil];/*发送通知*/
  20. KWeakSelf
  21. [[nasUploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
  22. mainBlock(^{
  23. if(Arr && Arr.count== 3){
  24. NSArray *uploadingArr = Arr.firstObject;
  25. if(uploadingArr.count == 0){
  26. [weakSelf drawAnyView];
  27. }
  28. else{
  29. [[iToast makeText:NSLocalizedString(@"upload_task_not_done_tip",nil)] show];
  30. if(self->_didClickCloseFun){
  31. self->_didClickCloseFun();
  32. }
  33. [weakSelf removeFromSuperview];
  34. }
  35. }
  36. else{
  37. [weakSelf drawAnyView];
  38. };
  39. });
  40. }];
  41. }
  42. - (void)drawAnyView{
  43. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  44. UIView *whiteBgView = [[UIView alloc] init];
  45. whiteBgView.backgroundColor = [UIColor whiteColor];
  46. [self addSubview:whiteBgView];
  47. // whiteBgView.layer.cornerRadius = 12;
  48. // whiteBgView.layer.masksToBounds = YES;
  49. /*上圆角*/
  50. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W , 180+ AdaptTabHeight)
  51. byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
  52. cornerRadii:CGSizeMake(12, 12)];
  53. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  54. maskLayer.frame = CGRectMake(0, 0, SCREEN_W, 180+ AdaptTabHeight);
  55. maskLayer.path = maskPath.CGPath;
  56. whiteBgView.layer.mask = nil;
  57. whiteBgView.layer.mask = maskLayer;
  58. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.left.mas_equalTo(0);
  60. make.right.mas_equalTo(0);
  61. make.bottom.mas_equalTo(0);
  62. make.height.mas_equalTo(180+ AdaptTabHeight);
  63. }];
  64. UILabel *titleLabel = [[UILabel alloc] init];
  65. titleLabel.font = [UIFont systemFontOfSize:18.0];
  66. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  67. [whiteBgView addSubview:titleLabel];
  68. NSString *leftText = NSLocalizedString(@"uploadFile_title_left",nil);
  69. NSString *rightText = NSLocalizedString(@"uploadFile_title_right",nil);
  70. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
  71. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  72. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
  73. UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
  74. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
  75. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  76. titleLabel.attributedText = attrStr;
  77. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.left.mas_equalTo(25);
  79. make.right.mas_equalTo(0);
  80. make.top.mas_equalTo(20);
  81. make.height.mas_equalTo(40);
  82. }];
  83. NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
  84. NSLocalizedString(@"my_set_no_video_upload",nil)];
  85. NSArray *imageStrArr = @[@"uploadFile_image_bigger",
  86. @"uploadFile_Video_bigger"
  87. ];
  88. CGFloat curButFullWidth = SCREEN_W/4.0;
  89. for (int i = 0; i< titleArr.count; i++) {
  90. UIButton*curButton = [[UIButton alloc] init];
  91. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  92. curButton.tag = 10+i;
  93. [whiteBgView addSubview:curButton];
  94. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.width.mas_equalTo(curButFullWidth);
  96. make.left.mas_equalTo(i*curButFullWidth);
  97. make.height.mas_equalTo(80);
  98. make.top.equalTo(titleLabel.mas_bottom).offset(20);
  99. }];
  100. UIView *imageBgView = [[UIView alloc] init];
  101. imageBgView.userInteractionEnabled = NO;
  102. imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
  103. imageBgView.layer.cornerRadius = 8;
  104. imageBgView.layer.masksToBounds = YES;
  105. [curButton addSubview:imageBgView];
  106. [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.width.mas_equalTo(64);
  108. make.height.mas_equalTo(52);
  109. make.centerX.equalTo(curButton.mas_centerX);
  110. make.top.mas_equalTo(0);
  111. }];
  112. UIImageView *leftImageV = [[UIImageView alloc] init];
  113. leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
  114. [imageBgView addSubview:leftImageV];
  115. [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.width.mas_equalTo(35);
  117. make.height.mas_equalTo(35);
  118. make.centerX.equalTo(imageBgView.mas_centerX);
  119. make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
  120. }];
  121. UILabel *leftLabel = [[UILabel alloc] init];
  122. leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
  123. leftLabel.textAlignment = NSTextAlignmentCenter;
  124. leftLabel.font = [UIFont systemFontOfSize:12.0];
  125. leftLabel.text = titleArr[i];
  126. [curButton addSubview:leftLabel];
  127. [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.width.mas_equalTo(curButFullWidth);
  129. make.height.mas_equalTo(25);
  130. make.centerX.equalTo(curButton.mas_centerX);
  131. make.top.equalTo(imageBgView.mas_bottom).offset(10);
  132. }];
  133. }
  134. UIButton*cancelButton = [[UIButton alloc] init];
  135. //[cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  136. //[cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  137. [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  138. //cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  139. cancelButton.tag = 100;
  140. [self addSubview:cancelButton];
  141. [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.left.mas_equalTo(0);
  143. make.right.mas_equalTo(0);
  144. make.bottom.equalTo(whiteBgView.mas_top).offset(0);
  145. make.top.mas_equalTo(40);
  146. }];
  147. //
  148. // UIView *lineView = [[UIView alloc] init];
  149. // lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
  150. // [whiteBgView addSubview:lineView];
  151. //
  152. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  153. // make.left.mas_equalTo(25);
  154. // make.right.mas_equalTo(-25);
  155. // make.bottom.equalTo(cancelButton.mas_top).offset(-5);
  156. // make.height.mas_equalTo(1);
  157. // }];
  158. //数据埋点
  159. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Nas_upload"];
  160. }
  161. - (void)didClickButFun:(UIButton*)but
  162. {
  163. [self removeFromSuperview];
  164. NSInteger tag = but.tag;
  165. if(tag == 100)
  166. {
  167. if(_didClickCloseFun){
  168. _didClickCloseFun();
  169. }
  170. return;
  171. }
  172. if(_didClickButtonFun){
  173. _didClickButtonFun(tag);
  174. }
  175. }
  176. @end