123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- //
- // previewToUploadFileView.m
- // 双子星云手机
- //
- // Created by xd h on 2024/5/14.
- //
- #import "previewToUploadFileView.h"
- @interface previewToUploadFileView ()
- @end
- @implementation previewToUploadFileView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- [self checkDidHadUploadTaskFun];
- //[self drawAnyView];
- return self;
- }
- -(void)checkDidHadUploadTaskFun
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:getExtraFilesDoneNotification object:nil];/*发送通知*/
-
- KWeakSelf
- [[nasUploadFileManager shareInstance] getDataInDatabaseFun:YES complete:^(NSMutableArray * _Nonnull Arr) {
- mainBlock(^{
- if(Arr && Arr.count== 3){
- NSArray *uploadingArr = Arr.firstObject;
- if(uploadingArr.count == 0){
- [weakSelf drawAnyView];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"upload_task_not_done_tip",nil)] show];
- if(self->_didClickCloseFun){
- self->_didClickCloseFun();
- }
- [weakSelf removeFromSuperview];
- }
- }
- else{
- [weakSelf drawAnyView];
- };
- });
-
- }];
- }
- - (void)drawAnyView{
-
- self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
-
- UIView *whiteBgView = [[UIView alloc] init];
- whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:whiteBgView];
- // whiteBgView.layer.cornerRadius = 12;
- // whiteBgView.layer.masksToBounds = YES;
-
- /*上圆角*/
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W , 180+ AdaptTabHeight)
- byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight
- cornerRadii:CGSizeMake(12, 12)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = CGRectMake(0, 0, SCREEN_W, 180+ AdaptTabHeight);
- maskLayer.path = maskPath.CGPath;
- whiteBgView.layer.mask = nil;
- whiteBgView.layer.mask = maskLayer;
-
-
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(180+ AdaptTabHeight);
- }];
-
-
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.font = [UIFont systemFontOfSize:18.0];
- titleLabel.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
- [whiteBgView addSubview:titleLabel];
-
- NSString *leftText = NSLocalizedString(@"uploadFile_title_left",nil);
- NSString *rightText = NSLocalizedString(@"uploadFile_title_right",nil);
- NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",leftText,rightText];
-
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
- NSRange redRange = NSMakeRange([totalStr rangeOfString:rightText].location, [totalStr rangeOfString:rightText].length);
- UIColor *noteColor =[UIColor hwColor:@"#959799" alpha:1.0];
- [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
- [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0] range:redRange];
- titleLabel.attributedText = attrStr;
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(20);
- make.height.mas_equalTo(40);
- }];
-
-
-
- NSArray *titleArr = @[NSLocalizedString(@"my_set_no_image_upload",nil),
- NSLocalizedString(@"my_set_no_video_upload",nil)];
-
- NSArray *imageStrArr = @[@"uploadFile_image_bigger",
- @"uploadFile_Video_bigger"
- ];
-
- CGFloat curButFullWidth = SCREEN_W/4.0;
-
- for (int i = 0; i< titleArr.count; i++) {
- UIButton*curButton = [[UIButton alloc] init];
- [curButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- curButton.tag = 10+i;
- [whiteBgView addSubview:curButton];
- [curButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.left.mas_equalTo(i*curButFullWidth);
- make.height.mas_equalTo(80);
- make.top.equalTo(titleLabel.mas_bottom).offset(20);
- }];
-
- UIView *imageBgView = [[UIView alloc] init];
- imageBgView.userInteractionEnabled = NO;
- imageBgView.backgroundColor = [UIColor hwColor:@"#F5F7FA"];
- imageBgView.layer.cornerRadius = 8;
- imageBgView.layer.masksToBounds = YES;
- [curButton addSubview:imageBgView];
-
- [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(64);
- make.height.mas_equalTo(52);
- make.centerX.equalTo(curButton.mas_centerX);
- make.top.mas_equalTo(0);
- }];
-
- UIImageView *leftImageV = [[UIImageView alloc] init];
- leftImageV.image = [UIImage imageNamed:imageStrArr[i]];
- [imageBgView addSubview:leftImageV];
- [leftImageV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(35);
- make.height.mas_equalTo(35);
- make.centerX.equalTo(imageBgView.mas_centerX);
- make.centerY.equalTo(imageBgView.mas_centerY).offset(0);
- }];
- UILabel *leftLabel = [[UILabel alloc] init];
- leftLabel.textColor = [UIColor hwColor:@"#0A132B"];
- leftLabel.textAlignment = NSTextAlignmentCenter;
- leftLabel.font = [UIFont systemFontOfSize:12.0];
- leftLabel.text = titleArr[i];
- [curButton addSubview:leftLabel];
- [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(curButFullWidth);
- make.height.mas_equalTo(25);
- make.centerX.equalTo(curButton.mas_centerX);
- make.top.equalTo(imageBgView.mas_bottom).offset(10);
- }];
- }
-
-
- UIButton*cancelButton = [[UIButton alloc] init];
- //[cancelButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
- //[cancelButton setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
- [cancelButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- //cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:14];
- cancelButton.tag = 100;
- [self addSubview:cancelButton];
-
- [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.equalTo(whiteBgView.mas_top).offset(0);
- make.top.mas_equalTo(40);
- }];
- //
- // UIView *lineView = [[UIView alloc] init];
- // lineView.backgroundColor = [UIColor hwColor:@"#EAEAEA"];
- // [whiteBgView addSubview:lineView];
- //
- // [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.left.mas_equalTo(25);
- // make.right.mas_equalTo(-25);
- // make.bottom.equalTo(cancelButton.mas_top).offset(-5);
- // make.height.mas_equalTo(1);
- // }];
-
- //数据埋点
- [[netWorkManager shareInstance] DataEmbeddingPointBy:2 withEventValue:@"Nas_upload"];
- }
- - (void)didClickButFun:(UIButton*)but
- {
- [self removeFromSuperview];
-
- NSInteger tag = but.tag;
- if(tag == 100)
- {
- if(_didClickCloseFun){
- _didClickCloseFun();
- }
- return;
- }
-
- if(_didClickButtonFun){
- _didClickButtonFun(tag);
- }
- }
- @end
|