previewToUploadFileView.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. [[uploadFileManager 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 = 32;
  47. whiteBgView.layer.masksToBounds = YES;
  48. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.mas_equalTo(0);
  50. make.right.mas_equalTo(0);
  51. make.bottom.mas_equalTo(0);
  52. make.height.mas_equalTo(180+ AdaptTabHeight);
  53. }];
  54. UILabel *titleLabel = [[UILabel alloc] init];
  55. titleLabel.font = [UIFont systemFontOfSize:18.0];
  56. titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  57. [whiteBgView addSubview:titleLabel];
  58. NSString *leftText = NSLocalizedString(@"uploadFile_title_left",nil);
  59. NSString *rightText = NSLocalizedString(@"uploadFile_title_right",nil);
  60. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
  61. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  62. NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
  63. UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
  64. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
  65. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
  66. titleLabel.attributedText = attrStr;
  67. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.mas_equalTo(25);
  69. make.right.mas_equalTo(0);
  70. make.top.mas_equalTo(20);
  71. make.height.mas_equalTo(40);
  72. }];
  73. NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
  74. NSLocalizedString(@"my_set_no_video_upload",nil)];
  75. NSArray *imageStrArr = @[@"uploadFile_image",
  76. @"uploadFile_Video"
  77. ];
  78. CGFloat curButFullWidth = SCREEN_W/4.0;
  79. for (int i = 0; i< titleArr.count; i++) {
  80. UIButton*curButton = [[UIButton alloc] init];
  81. [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  82. curButton.tag = 10+i;
  83. [whiteBgView addSubview:curButton];
  84. [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.width.mas_equalTo(curButFullWidth);
  86. make.left.mas_equalTo(i*curButFullWidth);
  87. make.height.mas_equalTo(80);
  88. make.top.equalTo(titleLabel.mas_bottom).offset(20);
  89. }];
  90. UIView *imageBgView = [[UIView alloc] init];
  91. imageBgView.userInteractionEnabled = NO;
  92. imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
  93. imageBgView.layer.cornerRadius = 8;
  94. imageBgView.layer.masksToBounds = YES;
  95. [curButton addSubview:imageBgView];
  96. [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.width.mas_equalTo(64);
  98. make.height.mas_equalTo(52);
  99. make.centerX.equalTo(curButton.mas_centerX);
  100. make.top.mas_equalTo(0);
  101. }];
  102. UIImageView *leftImageV = [[UIImageView alloc] init];
  103. leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
  104. [imageBgView addSubview:leftImageV];
  105. [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.width.mas_equalTo(25);
  107. make.height.mas_equalTo(25);
  108. make.centerX.equalTo(imageBgView.mas_centerX);
  109. make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
  110. }];
  111. UILabel *leftLabel = [[UILabel alloc] init];
  112. leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
  113. leftLabel.textAlignment = NSTextAlignmentCenter;
  114. leftLabel.font = [UIFont systemFontOfSize:12.0];
  115. leftLabel.text = titleArr[i];
  116. [curButton addSubview:leftLabel];
  117. [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  118. make.width.mas_equalTo(curButFullWidth);
  119. make.height.mas_equalTo(25);
  120. make.centerX.equalTo(curButton.mas_centerX);
  121. make.top.equalTo(imageBgView.mas_bottom).offset(10);
  122. }];
  123. }
  124. UIButton*cancelButton = [[UIButton alloc] init];
  125. //[cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  126. //[cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  127. [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  128. //cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
  129. cancelButton.tag = 100;
  130. [self addSubview:cancelButton];
  131. [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.left.mas_equalTo(0);
  133. make.right.mas_equalTo(0);
  134. make.bottom.equalTo(whiteBgView.mas_top).offset(0);
  135. make.top.mas_equalTo(40);
  136. }];
  137. //
  138. // UIView *lineView = [[UIView alloc] init];
  139. // lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
  140. // [whiteBgView addSubview:lineView];
  141. //
  142. // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  143. // make.left.mas_equalTo(25);
  144. // make.right.mas_equalTo(-25);
  145. // make.bottom.equalTo(cancelButton.mas_top).offset(-5);
  146. // make.height.mas_equalTo(1);
  147. // }];
  148. //数据埋点
  149. [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Nas_upload"];
  150. }
  151. - (void)didClickButFun:(UIButton*)but
  152. {
  153. [self removeFromSuperview];
  154. NSInteger tag = but.tag;
  155. if(tag == 100)
  156. {
  157. if(_didClickCloseFun){
  158. _didClickCloseFun();
  159. }
  160. return;
  161. }
  162. if(_didClickButtonFun){
  163. _didClickButtonFun(tag);
  164. }
  165. }
  166. @end