123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- //
- // shareBySecretView.m
- // Private-X
- //
- // Created by xd h on 2024/5/17.
- //
- #import "shareBySecretView.h"
- #import "shareSecretTableViewCell.h"
- @interface shareBySecretView ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic,strong)UITableView*tableView;
- @property (nonatomic,strong)UIView *whiteBgView;
- @end
- @implementation shareBySecretView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
- return self;
- }
- - (void)setDidSelectListArr:(NSMutableArray *)didSelectListArr
- {
- _didSelectListArr = didSelectListArr;
- [self drawAnyView];
- }
- - (void)drawAnyView{
-
- NSInteger showCellNum = _didSelectListArr.count >=3 ? 3 :_didSelectListArr.count;
-
- CGFloat curTableViewCellH = 70;
- CGFloat curTableViewH = curTableViewCellH *showCellNum;
-
- CGFloat curWhiteBgH = 64 + curTableViewH + 194;
-
- _whiteBgView = [[UIView alloc] init];
- _whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:_whiteBgView];
- _whiteBgView.layer.cornerRadius = 8;
- _whiteBgView.layer.masksToBounds = YES;
-
- [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(40);
- make.right.mas_equalTo(-40);
- make.centerY.equalTo(self.mas_centerY).offset(-40);
- make.height.mas_equalTo(curWhiteBgH);
- }];
-
- if(_didSelectListArr.count <=0 ){
- return;
- }
-
- NASFilePicDataArrModel *dataModel = _didSelectListArr.firstObject;
-
- NSString *titleStr = [[NSString alloc] initWithFormat:@"%@%@%ld%@",dataModel.name,NSLocalizedString(@"share_file_more_tip",nil), _didSelectListArr.count,NSLocalizedString(@"share_file_Numbers_tip",nil)];
-
- if(_didSelectListArr.count == 1){
- titleStr = dataModel.name;
- }
-
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.text = titleStr;
- titleLabel.textAlignment = NSTextAlignmentCenter;
- titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
- titleLabel.font = [UIFont systemFontOfSize:18.0];
- titleLabel.textColor = [UIColor hwColor:@"#151515"];
- [_whiteBgView addSubview:titleLabel];
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.mas_equalTo(25);
- make.height.mas_equalTo(25);
- }];
-
- [_whiteBgView addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.mas_equalTo(64);
- make.height.mas_equalTo(curTableViewH);
- }];
-
- //文件分享有效期
- UIView *expirationDateBgView = [[UIView alloc] init];
- expirationDateBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9"];
- [_whiteBgView addSubview:expirationDateBgView];
- expirationDateBgView.layer.cornerRadius = 8;
- expirationDateBgView.layer.masksToBounds = YES;
-
- [expirationDateBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.equalTo(self.tableView.mas_bottom).offset(15);
- make.height.mas_equalTo(36);
- }];
-
- UILabel *expDateTipLab = [[UILabel alloc] init];
- expDateTipLab.font = [UIFont systemFontOfSize:14.f];
- //[expDateTipLab setTextAlignment:(NSTextAlignmentRight)];
- [expDateTipLab setTextColor:HW0A132BColor];
- expDateTipLab.text = NSLocalizedString(@"share_expiration_date_tip",nil);
- [expirationDateBgView addSubview:expDateTipLab];
-
- [expDateTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-80);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- UILabel *expDateTip2Lab = [[UILabel alloc] init];
- expDateTip2Lab.font = [UIFont systemFontOfSize:14.f];
- [expDateTip2Lab setTextAlignment:(NSTextAlignmentRight)];
- [expDateTip2Lab setTextColor:HW0A132BColor];
- [expirationDateBgView addSubview:expDateTip2Lab];
-
- NSString * expDateStr = [[NSString alloc] initWithFormat:@"7%@",NSLocalizedString(@"share_expiration_date_unit_tip",nil)];
-
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:expDateStr];
- NSRange redRange = NSMakeRange(0, 1);
- UIColor *noteColor =[UIColor hwColor:@"#01B7EA" alpha:1.0];
- [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
- expDateTip2Lab.attributedText = attrStr;
-
- [expDateTip2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(expDateTipLab.mas_right);
- make.right.mas_equalTo(-15);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
-
- //提取码
- UIView *extractCodeBgView = [[UIView alloc] init];
- extractCodeBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9"];
- [_whiteBgView addSubview:extractCodeBgView];
- extractCodeBgView.layer.cornerRadius = 8;
- extractCodeBgView.layer.masksToBounds = YES;
-
- [extractCodeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.equalTo(expirationDateBgView.mas_bottom).offset(15);
- make.height.mas_equalTo(36);
- }];
-
- UILabel *extractCodeTipLab = [[UILabel alloc] init];
- extractCodeTipLab.font = [UIFont systemFontOfSize:14.f];
- [extractCodeTipLab setTextColor:HW0A132BColor];
- extractCodeTipLab.text = NSLocalizedString(@"share_Extract_code_tip",nil);
- [extractCodeBgView addSubview:extractCodeTipLab];
-
- [extractCodeTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-80);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- UILabel *extractCodeTip2Lab = [[UILabel alloc] init];
- extractCodeTip2Lab.font = [UIFont systemFontOfSize:14.f];
- [extractCodeTip2Lab setTextAlignment:(NSTextAlignmentRight)];
- [extractCodeTip2Lab setTextColor:[UIColor hwColor:@"#01B7EA" alpha:1.0]];
- [extractCodeBgView addSubview:extractCodeTip2Lab];
- extractCodeTip2Lab.text = _addShareMod.data.extractionCode;
-
- [extractCodeTip2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(expDateTipLab.mas_right);
- make.right.mas_equalTo(-15);
- make.top.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
-
- UIButton*cancleButton = [[UIButton alloc] init];
- [cancleButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
- [cancleButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
- cancleButton.titleLabel.font = [UIFont systemFontOfSize:14.0];
- [cancleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- cancleButton.tag = 10;
- [_whiteBgView addSubview:cancleButton];
- cancleButton.layer.cornerRadius = 8;
- cancleButton.layer.masksToBounds = YES;
- cancleButton.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
-
-
- [cancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(30);
- make.right.equalTo(_whiteBgView.mas_centerX).offset(-10);
- make.bottom.mas_equalTo(-30);
- make.height.mas_equalTo(40);
- }];
-
-
- UIButton*copyButton = [[UIButton alloc] init];
- CGFloat w_btn = SCREEN_W/2.0 -15 -10;
-
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,w_btn,40.f);
- gl.startPoint = CGPointMake(0, 0.5);
- gl.endPoint = CGPointMake(1, 0.5);
- gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
- gl.locations = @[@(0), @(1.0f)];
-
- [copyButton.layer addSublayer:gl];
- [copyButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [copyButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
- [copyButton setTitle:NSLocalizedString(@"share_copy_link_tip",nil) forState:(UIControlStateNormal)];
- [copyButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [copyButton.layer setCornerRadius:8.f];
- copyButton.clipsToBounds = YES;
- copyButton.tag = 11;
-
- [_whiteBgView addSubview:copyButton];
- [copyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-30);
- make.left.equalTo(_whiteBgView.mas_centerX).offset(10);
- make.bottom.mas_equalTo(-30);
- make.height.mas_equalTo(40);
- }];
-
- }
- #pragma mark - 懒加载
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
- [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- [_tableView setSeparatorColor:[UIColor clearColor]];
- [_tableView setBackgroundColor:[UIColor hwColor:@"#F9F9F9"]];
- [_tableView setTableFooterView:[UIView new]];
- [_tableView setBounces:YES];
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- _tableView.layer.cornerRadius = 8;
- _tableView.layer.masksToBounds = YES;
- }
-
- return _tableView;
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return _didSelectListArr.count;
- }
- - (shareSecretTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- __block NSInteger row = indexPath.row;
- static NSString *identifier = @"shareSecretTableViewCell";
-
- shareSecretTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[shareSecretTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
- }
-
-
- if(row < _didSelectListArr.count){
- NASFilePicDataArrModel*dataModel = _didSelectListArr[row];
- cell.dataModel = dataModel;
- }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 70;
- }
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
-
- if(tag == 10){
- [self removeFromSuperview];
- }
- else if(tag == 11){
- [self copyLinkFun];
- }
- if(_didClickCloseFun){
- _didClickCloseFun();
- }
- }
- - (void)copyLinkFun
- {
-
- NSMutableDictionary *paraDict = [NSMutableDictionary new];
- if(_addShareMod.data.addShareId){
- //[paraDict setValue:_addShareMod.data.addShareId forKey:@"id"];
- [paraDict setValue:@[_addShareMod.data.addShareId] forKey:@"idList"];
- }
- [paraDict setValue:@0 forKey:@"status"];
-
- KWeakSelf
- //[ showNewIndicatorWithCanBack:NO canTouch:NO];
- [[netWorkManager shareInstance] CommonPostCallBackCode:updateShareInfoFun Parameters:paraDict success:^(id _Nonnull responseObject) {
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if(model && model.code == 0){
- [weakSelf copyLinkOkFun];
- }
- else{
- [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];
- }
-
- } failure:^(NSError * _Nonnull error) {
- [[iToast makeText:NSLocalizedString(@"share_fail_msg",nil)] show];
- }];
- }
- //【私密分享】通过Private-X分享到文件:文件名称文件名称文件名称..称.jpg等2个文件
- //链接:https//Private-X.com/s/hj_w
- //密码:Gj1u
- //点击链接即可打开查看好友分享的文件
- - (void)copyLinkOkFun{
-
- if(_didSelectListArr.count <=0 ){
- return;
- }
-
- [self removeFromSuperview];
-
- NASFilePicDataArrModel *dataModel = _didSelectListArr.firstObject;
-
- NSString *copyStr1 = [[NSString alloc] initWithFormat:@"%@%@%@%@%ld%@",NSLocalizedString(@"share_secret_titile_1",nil),NSLocalizedString(@"share_secret_titile_1_1",nil),dataModel.name,NSLocalizedString(@"share_file_more_tip",nil), _didSelectListArr.count,NSLocalizedString(@"share_file_Numbers_tip",nil)];
-
- if(_didSelectListArr.count == 1){
- copyStr1 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_1",nil),dataModel.name];
- }
-
- NSString *serUrl = shareService;
- NSString *shareUrl = [[NSString alloc] initWithFormat:@"%@%@",serUrl,_addShareMod.data.token];
- NSString *copyStr2 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_2",nil),shareUrl];
-
- NSString *copyStr3 = [[NSString alloc] initWithFormat:@"%@%@",NSLocalizedString(@"share_secret_titile_3",nil),_addShareMod.data.extractionCode];
- NSString *copyStr4 = NSLocalizedString(@"share_secret_titile_4",nil);
-
- NSString *copyTotalStr = [[NSString alloc] initWithFormat:@"%@\n%@\n%@\n%@",copyStr1,copyStr2,copyStr3,copyStr4];
-
- UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.string = copyTotalStr;
-
- [[iToast makeText:NSLocalizedString(@"copy_share_link_suc_tip",nil)] show];
- }
- - (void)setIsPortraitType:(BOOL)isPortraitType
- {
- _isPortraitType = isPortraitType;
-
- NSInteger showCellNum = _didSelectListArr.count >=3 ? 3 :_didSelectListArr.count;
-
- CGFloat curTableViewCellH = 70;
- CGFloat curTableViewH = curTableViewCellH *showCellNum;
-
- CGFloat curWhiteBgH = 64 + curTableViewH + 194;
-
- if(_isPortraitType){
- _whiteBgView.layer.cornerRadius = 8;
-
- [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(40);
- make.right.mas_equalTo(-40);
- make.centerY.equalTo(self.mas_centerY).offset(-40);
- make.height.mas_equalTo(curWhiteBgH);
- }];
-
- }
- else{
-
- CGFloat curFullH = SCREEN_H > SCREEN_W ? SCREEN_W :SCREEN_H;
-
- _whiteBgView.layer.cornerRadius = 0;
- [_whiteBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(400);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.height.mas_equalTo(curFullH);
- }];
-
- }
-
-
-
- }
- @end
|