previewToUploadFileView.m 7.6 KB

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