previewToUploadFileView.m 6.2 KB

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