// // 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.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6]; [self drawAnyView]; return self; } - (void)drawAnyView{ UIView *whiteBgView = [[UIView alloc] init]; whiteBgView.backgroundColor = [UIColor whiteColor]; [self addSubview:whiteBgView]; whiteBgView.layer.cornerRadius = 32; whiteBgView.layer.masksToBounds = YES; [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", @"uploadFile_Video" ]; 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(25); make.height.mas_equalTo(25); 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