GuideViewController.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //
  2. // GuideViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by APPLE on 2023/8/11.
  6. //
  7. #import "GuideViewController.h"
  8. #import "Masonry.h"
  9. #import "UIView+View.h"
  10. #import "GuideView.h"
  11. #import "GuideLastView.h"
  12. #import "SetPWDFirstViewController.h"
  13. #import "connectDeviceManager.h"
  14. #import "inputPWDViewController.h"
  15. @interface GuideViewController ()<UIScrollViewDelegate>
  16. {
  17. UIScrollView *bgScrView;
  18. GuideView *guideView0;
  19. GuideView *guideView1;
  20. GuideView *guideView2;
  21. GuideView *guideView3;
  22. GuideLastView *guideLastView;
  23. }
  24. @end
  25. @implementation GuideViewController
  26. @synthesize delegate;
  27. @synthesize sn;
  28. - (void)viewDidLoad {
  29. [super viewDidLoad];
  30. // Do any additional setup after loading the view.
  31. self.navigationBar.hidden = YES;
  32. [self drawAnyView];
  33. if([[connectDeviceManager shareInstance] curConnectDeviceState] == DeviceConnectUnknown){
  34. [[connectDeviceManager shareInstance] getThridMsgBySN:sn needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  35. }];
  36. }
  37. }
  38. - (void)viewDidAppear:(BOOL)animated{
  39. [super viewDidAppear:animated];
  40. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  41. [self startMoveView];
  42. });
  43. }
  44. - (void)startMoveView{
  45. CGFloat x = bgScrView.contentOffset.x;
  46. NSInteger index = (x+1)/self.view.width;
  47. if (index >= 4){
  48. /*记录已经用户引导*/
  49. [HWDataManager setBoolWithKey:Const_Have_Show_Guide value:YES];
  50. if(!ksharedAppDelegate.DeviceThirdIdMod){
  51. HLog(@"没有拿到设备信息");
  52. KWeakSelf
  53. [[connectDeviceManager shareInstance] getThridMsgBySN:sn needReconnect:YES didNetEnd:^(NSInteger didSuc) {
  54. if(didSuc){
  55. }
  56. else{
  57. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  58. }
  59. [weakSelf startMoveView];
  60. }];
  61. return;
  62. }
  63. //是否已经有密码了 有就是输入密码 没有就是设置密码
  64. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  65. if(curPwd && curPwd.length > 0){
  66. BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  67. if(!haveOpenMask)
  68. {
  69. [connectDeviceManager shareInstance].isFirstInputPwdDone = YES;
  70. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  71. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  72. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  73. });
  74. return;
  75. }
  76. /*设置密码*/
  77. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  78. // nextVC.isQRCodeType = YES;
  79. // [self.navigationController pushViewController:nextVC animated:YES];
  80. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  81. }
  82. else{
  83. /*设置密码*/
  84. // SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
  85. // [self.navigationController pushViewController:nextVC animated:YES];
  86. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  87. }
  88. }else{
  89. [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
  90. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  91. [self startMoveView];
  92. });
  93. }
  94. }
  95. - (void)drawAnyView{
  96. [self.view setBackgroundColor:HWF5F7FAColor];
  97. bgScrView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
  98. [bgScrView setBackgroundColor:HWF5F7FAColor];
  99. [bgScrView setShowsVerticalScrollIndicator:NO];
  100. [bgScrView setShowsHorizontalScrollIndicator:NO];
  101. [bgScrView setPagingEnabled:YES];
  102. // [bgScrView setUserInteractionEnabled:NO];
  103. bgScrView.delegate = self;
  104. [bgScrView setContentSize:CGSizeMake(5*self.view.width,self.view.height)];
  105. [bgScrView setClipsToBounds:YES];
  106. [self.view addSubview:bgScrView];
  107. guideView0 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_0",nil)
  108. imageName:@"guide_middle_0_icon"
  109. index:0];
  110. guideView1 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_1",nil)
  111. imageName:@"guide_middle_1_icon"
  112. index:1];
  113. guideView2 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_2",nil)
  114. imageName:@"guide_middle_2_icon"
  115. index:2];
  116. guideView3 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_3",nil)
  117. imageName:@"guide_middle_3_icon"
  118. index:3];
  119. guideView0.frame = CGRectMake(0*self.view.width, 0, self.view.width,self.view.height);
  120. guideView1.frame = CGRectMake(1*self.view.width, 0, self.view.width,self.view.height);
  121. guideView2.frame = CGRectMake(2*self.view.width, 0, self.view.width,self.view.height);
  122. guideView3.frame = CGRectMake(3*self.view.width, 0, self.view.width,self.view.height);
  123. [bgScrView addSubview:guideView0];
  124. [bgScrView addSubview:guideView1];
  125. [bgScrView addSubview:guideView2];
  126. [bgScrView addSubview:guideView3];
  127. guideLastView = [[GuideLastView alloc] initWithFrame:CGRectMake(4*self.view.width, 0, self.view.width,self.view.height)];
  128. [bgScrView addSubview:guideLastView];
  129. KWeakSelf
  130. guideView0.didClickButton = ^{
  131. [weakSelf didClickSkipFun];
  132. };
  133. guideView1.didClickButton = ^{
  134. [weakSelf didClickSkipFun];
  135. };
  136. guideView2.didClickButton = ^{
  137. [weakSelf didClickSkipFun];
  138. };
  139. guideView3.didClickButton = ^{
  140. [weakSelf didClickSkipFun];
  141. };
  142. }
  143. #pragma mark 点击了跳过
  144. - (void)didClickSkipFun
  145. {
  146. [bgScrView setContentOffset:CGPointMake(4*self.view.width, 0) animated:NO];
  147. }
  148. #pragma mark 监听滚动
  149. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  150. {
  151. CGFloat x = scrollView.contentOffset.x;
  152. NSInteger index = (x+1)/self.view.width;
  153. if (index == 4){
  154. bgScrView.userInteractionEnabled = NO;
  155. }
  156. }
  157. @end