123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- //
- // playerShowSecretkeyView.m
- // 隐私保护
- //
- // Created by xd h on 2023/11/6.
- //
- #import "playerShowSecretkeyView.h"
- #import "RSATool.h"
- #import "connectDeviceManager.h"
- @interface playerShowSecretkeyView()
- @property(nonatomic,strong)UIView *whiteBgView;
- @property(nonatomic,strong)UIButton *closeBut;
- @property(nonatomic,strong)NSTimer *curTimer;
- @property(nonatomic,assign) NSInteger coundDownNumber;
- @end
- @implementation playerShowSecretkeyView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
- [self drawAnyView];
-
- return self;
- }
- - (void)drawAnyView{
- _whiteBgView = [[UIView alloc] init];
- _whiteBgView.layer.cornerRadius = 8;
- _whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:_whiteBgView];
-
- [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(260);
- make.width.mas_equalTo(300.f);
- make.center.mas_equalTo(0.f);
- }];
-
-
- UILabel *titleLab = [[UILabel alloc] init];
- titleLab.text = NSLocalizedString(@"player_Secret_key_title",nil);
- titleLab.textAlignment = NSTextAlignmentCenter;
- titleLab.font = [UIFont boldSystemFontOfSize:18];
- titleLab.textColor = [UIColor blackColor];
- [_whiteBgView addSubview:titleLab];
-
- [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(20);
- make.left.mas_equalTo(0.f);
- make.right.mas_equalTo(0.f);
- make.top.mas_equalTo(30.f);
- }];
-
-
- UILabel *tipLab = [[UILabel alloc] init];
- tipLab.text = NSLocalizedString(@"player_Secret_key_tip",nil);
- tipLab.textAlignment = NSTextAlignmentCenter;
- tipLab.font = [UIFont systemFontOfSize:14];
- tipLab.numberOfLines = 0;
- tipLab.textColor = [UIColor hwColor:@"#FF5353" alpha:1.0];
- [_whiteBgView addSubview:tipLab];
-
- [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(35);
- make.left.mas_equalTo(10.f);
- make.right.mas_equalTo(-0.f);
- make.top.mas_equalTo(titleLab.mas_bottom).offset(5.f);
- }];
-
-
-
- UIView*grayBgView = [[UIView alloc] init];
- grayBgView.layer.cornerRadius = 2;
- grayBgView.backgroundColor = [UIColor hwColor:@"#F9F9F9" alpha:1.0];
- [_whiteBgView addSubview:grayBgView];
-
- [grayBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(56);
- make.left.mas_equalTo(30.f);
- make.right.mas_equalTo(-30.f);
- make.top.mas_equalTo(tipLab.mas_bottom).offset(20.f);
- }];
-
- [grayBgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copyKeyFun)]];
-
-
- NSString *snStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- NSString *secretkey = [RSATool sha256_8:snStr];
- UILabel *secretKeyLab = [[UILabel alloc] init];
- secretKeyLab.text = secretkey;
- //secretKeyLab.textAlignment = NSTextAlignmentCenter;
- secretKeyLab.font = [UIFont boldSystemFontOfSize:16];
- secretKeyLab.textColor = [UIColor hwColor:@"#3B7FFF" alpha:1.0];
- [grayBgView addSubview:secretKeyLab];
- [secretKeyLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(0.f);
- make.left.mas_equalTo(10.f);
- make.right.mas_equalTo(0.f);
- make.top.mas_equalTo(0.f);
- }];
-
-
- NSString*curStr = NSLocalizedString(@"player_Secret_key_copy",nil);
-
- UILabel *rightLab = [[UILabel alloc] init];
- rightLab.text = [[NSString alloc] initWithFormat:@"| %@",curStr];
- //@"| 复制密钥";
- rightLab.textAlignment = NSTextAlignmentRight;
- rightLab.font = [UIFont systemFontOfSize:16];
- rightLab.textColor = [UIColor hwColor:@"#666666" alpha:1.0];
- [grayBgView addSubview:rightLab];
- [rightLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(0.f);
- make.left.mas_equalTo(10.f);
- make.right.mas_equalTo(-10.f);
- make.top.mas_equalTo(0.f);
- }];
-
-
- _closeBut = [[UIButton alloc] init];
-
-
- NSString *butTitle = [[NSString alloc] initWithFormat:@"%@ %@",NSLocalizedString(@"player_Secret_key_close",nil), @"(10s)"];
- /*确认按钮*/
- _closeBut = [[UIButton alloc] init];
- CGFloat okBtn_W= 240;
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,okBtn_W,40);
- 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)];
- _closeBut.layer.cornerRadius = 8;
- _closeBut.clipsToBounds = YES;
- [_closeBut.layer addSublayer:gl];
- [_closeBut setTitle:butTitle forState:(UIControlStateNormal)];
- [_closeBut setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [_closeBut addTarget:self action:@selector(closeViewFun) forControlEvents:UIControlEventTouchUpInside];
-
- // NSString* curLanguage = [DDYLanguageTool ddy_AppLanguage];
- // if(!curLanguage || curLanguage.length == 0){
- // curLanguage = [DDYLanguageTool ddy_SystemLanguage];
- // }
- //
- // // "zh-Hant-HK", "zh-Hans-US",
- // if([curLanguage rangeOfString:@"zh-Han"].location != NSNotFound){//中文和繁体
- // [okBtn.titleLabel setFont:[UIFont systemFontOfSize:16.f]];
- // }
- // else{//en-US
- // [okBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- // }
-
- [_whiteBgView addSubview:_closeBut];
- [_closeBut mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-30.f);
- make.centerX.mas_equalTo(0.f);
- make.width.mas_equalTo(okBtn_W);
- make.height.mas_equalTo(40);
- }];
-
- [_closeBut setEnabled:NO];
- [_closeBut setAlpha:0.5];
-
- [_curTimer invalidate];
- _curTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerHandleFun) userInfo:nil repeats:YES];
-
- _coundDownNumber = 10;
- }
- #pragma mark timer fun
- - (void)timerHandleFun
- {
- _coundDownNumber -- ;
- if(_coundDownNumber > 0){
- NSString *butTitle = [[NSString alloc] initWithFormat:@"%@ (%lds)",NSLocalizedString(@"player_Secret_key_close",nil), _coundDownNumber];
- [_closeBut setTitle:butTitle forState:(UIControlStateNormal)];
- }
- else{
- NSString *butTitle = NSLocalizedString(@"player_Secret_key_close",nil);
- [_closeBut setTitle:butTitle forState:(UIControlStateNormal)];
-
- [_closeBut setEnabled:YES];
- [_closeBut setAlpha:1];
- [_curTimer invalidate];
- }
-
- }
- #pragma mark 复制
- - (void)copyKeyFun
- {
- NSString *snStr = ksharedAppDelegate.DeviceThirdIdMod.data.changeSn;
- NSString *secretkey = [RSATool sha256_8:snStr];
-
- UIPasteboard * Pasteboard = [UIPasteboard generalPasteboard];
-
- Pasteboard.string = secretkey;
-
- NSString *tipStr = NSLocalizedString(@"player_Secret_key_copy_suc",nil);
- [[iToast makeText:tipStr] show];
-
- if(_didCopySecretKeyViewTip){
- _didCopySecretKeyViewTip();
- }
-
- }
- #pragma mark 关闭按钮
- - (void)closeViewFun
- {
- [self removeFromSuperview];
-
- if(_didCloseSecretKeyViewTip){
- _didCloseSecretKeyViewTip();
- }
- }
- @end
|