123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- //
- // GuideViewController.m
- // 双子星云手机
- //
- // Created by APPLE on 2023/8/11.
- //
- #import "GuideViewController.h"
- #import "Masonry.h"
- #import "UIView+View.h"
- #import "GuideView.h"
- #import "GuideLastView.h"
- #import "SetPWDFirstViewController.h"
- #import "connectDeviceManager.h"
- #import "inputPWDViewController.h"
- @interface GuideViewController ()<UIScrollViewDelegate>
- {
- UIScrollView *bgScrView;
- GuideView *guideView0;
- GuideView *guideView1;
- GuideView *guideView2;
- GuideView *guideView3;
- GuideLastView *guideLastView;
- }
- @end
- @implementation GuideViewController
- @synthesize delegate;
- @synthesize sn;
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- self.navigationBar.hidden = YES;
-
- [self drawAnyView];
-
-
- if(!ksharedAppDelegate.isWebSockLinkOKAginType){
- [[webRtcManager shareManager] beginToLinkWebRtcFun];
- }
- }
- - (void)viewDidAppear:(BOOL)animated{
- [super viewDidAppear:animated];
-
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [self startMoveView];
- // });
- }
- - (void)startMoveView{
- // CGFloat x = bgScrView.contentOffset.x;
- // NSInteger index = (x+1)/self.view.width;
- // if (index >= 4)
- {
- /*记录已经用户引导*/
- [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
-
-
- if(!ksharedAppDelegate.DeviceThirdIdMod){
-
- HLog(@"没有拿到设备信息");
-
- KWeakSelf
- // [[connectDeviceManager shareInstance] getThridMsgBySN:sn needReconnect:YES didNetEnd:^(NSInteger didSuc) {
- // if(didSuc){
- //
- // }
- // else{
- // [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
- // }
- //
- // [weakSelf startMoveView];
- // }];
-
- [[netWorkManager shareInstance] getThridMsgBySN:sn success:^(id _Nonnull responseObject) {
- DeviceThirdIdModel *model = responseObject;
- if([model isKindOfClass:[DeviceThirdIdModel class]]){
-
- if(model.status == 0 && model.data){
-
- }
- else{
- [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
- }
- }
- else{
- [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
- }
-
- [weakSelf startMoveView];
-
- } failure:^(NSError * _Nonnull error) {
- [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
- [weakSelf startMoveView];
- }];
-
- return;
- }
- //是否已经有密码了 有就是输入密码 没有就是设置密码
- NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
-
-
- if(curPwd && curPwd.length > 0){
- BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
- if(!haveOpenMask)
- {
- ksharedAppDelegate.isFirstInputPwdDone = YES;
- [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
-
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
- });
-
- return;
- }
-
- /*设置密码*/
- // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
- // nextVC.isQRCodeType = YES;
- // [self.navigationController pushViewController:nextVC animated:YES];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
- }
- else{
- /*设置密码*/
- // SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
- // [self.navigationController pushViewController:nextVC animated:YES];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
- }
-
-
- }
- // else{
- // [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
- // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [self startMoveView];
- // });
- // }
- }
- - (void)drawAnyView{
- [self.view setBackgroundColor:HWF5F7FAColor];
-
- bgScrView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
- [bgScrView setBackgroundColor:HWF5F7FAColor];
- [bgScrView setShowsVerticalScrollIndicator:NO];
- [bgScrView setShowsHorizontalScrollIndicator:NO];
- [bgScrView setPagingEnabled:YES];
- // [bgScrView setUserInteractionEnabled:NO];
- bgScrView.delegate = self;
- [bgScrView setContentSize:CGSizeMake(1*self.view.width,self.view.height)];
- [bgScrView setClipsToBounds:YES];
- [self.view addSubview:bgScrView];
-
- // guideView0 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_0",nil)
- // imageName:@"guide_middle_0_icon"
- // index:0];
- // guideView1 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_1",nil)
- // imageName:@"guide_middle_1_icon"
- // index:1];
- // guideView2 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_2",nil)
- // imageName:@"guide_middle_2_icon"
- // index:2];
- // guideView3 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_3",nil)
- // imageName:@"guide_middle_3_icon"
- // index:3];
- //
- // guideView0.frame = CGRectMake(0*self.view.width, 0, self.view.width,self.view.height);
- // guideView1.frame = CGRectMake(1*self.view.width, 0, self.view.width,self.view.height);
- // guideView2.frame = CGRectMake(2*self.view.width, 0, self.view.width,self.view.height);
- // guideView3.frame = CGRectMake(3*self.view.width, 0, self.view.width,self.view.height);
- //
- // [bgScrView addSubview:guideView0];
- // [bgScrView addSubview:guideView1];
- // [bgScrView addSubview:guideView2];
- // [bgScrView addSubview:guideView3];
-
- guideLastView = [[GuideLastView alloc] initWithFrame:CGRectMake(0*self.view.width, 0, self.view.width,self.view.height)];
- [bgScrView addSubview:guideLastView];
-
- KWeakSelf
- guideView0.didClickButton = ^{
- [weakSelf didClickSkipFun];
- };
-
- guideView1.didClickButton = ^{
- [weakSelf didClickSkipFun];
- };
-
- guideView2.didClickButton = ^{
- [weakSelf didClickSkipFun];
- };
-
- guideView3.didClickButton = ^{
- [weakSelf didClickSkipFun];
- };
- }
- #pragma mark 点击了跳过
- - (void)didClickSkipFun
- {
- [bgScrView setContentOffset:CGPointMake(4*self.view.width, 0) animated:NO];
- }
- #pragma mark 监听滚动
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView
- {
- CGFloat x = scrollView.contentOffset.x;
- NSInteger index = (x+1)/self.view.width;
- if (index == 4){
- bgScrView.userInteractionEnabled = NO;
- }
- }
- @end
|