GuideViewController.m 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //
  2. // GuideViewController.m
  3. // Private-x
  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(!ksharedAppDelegate.isWebSockLinkOKAginType){
  34. [[webRtcManager shareManager] beginToLinkWebRtcFun];
  35. }
  36. }
  37. - (void)viewDidAppear:(BOOL)animated{
  38. [super viewDidAppear:animated];
  39. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  40. // [self startMoveView];
  41. // });
  42. }
  43. - (void)startMoveView{
  44. // CGFloat x = bgScrView.contentOffset.x;
  45. // NSInteger index = (x+1)/self.view.width;
  46. // if (index >= 4)
  47. {
  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. // }
  57. // else{
  58. // [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  59. // }
  60. //
  61. // [weakSelf startMoveView];
  62. // }];
  63. [[netWorkManager shareInstance] getThridMsgBySN:sn success:^(id _Nonnull responseObject) {
  64. DeviceThirdIdModel *model = responseObject;
  65. if([model isKindOfClass:[DeviceThirdIdModel class]]){
  66. if(model.status == 0 && model.data){
  67. }
  68. else{
  69. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  70. }
  71. }
  72. else{
  73. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  74. }
  75. [weakSelf startMoveView];
  76. } failure:^(NSError * _Nonnull error) {
  77. [[iToast makeText:NSLocalizedString(@"guide_qrcoede_tips_get_SdnID_fail",nil)] show];
  78. [weakSelf startMoveView];
  79. }];
  80. return;
  81. }
  82. //是否已经有密码了 有就是输入密码 没有就是设置密码
  83. NSString *curPwd = ksharedAppDelegate.DeviceThirdIdMod.data.password;
  84. if(curPwd && curPwd.length > 0){
  85. BOOL haveOpenMask = ksharedAppDelegate.DeviceThirdIdMod.data.isPrivacyMode;
  86. if(!haveOpenMask)
  87. {
  88. ksharedAppDelegate.isFirstInputPwdDone = YES;
  89. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  90. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  91. [[NSNotificationCenter defaultCenter] postNotificationName:didInputPWDNotification object:nil];
  92. });
  93. return;
  94. }
  95. /*设置密码*/
  96. // inputPWDViewController *nextVC = [[inputPWDViewController alloc] init];
  97. // nextVC.isQRCodeType = YES;
  98. // [self.navigationController pushViewController:nextVC animated:YES];
  99. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  100. }
  101. else{
  102. /*设置密码*/
  103. // SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
  104. // [self.navigationController pushViewController:nextVC animated:YES];
  105. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  106. }
  107. }
  108. // else{
  109. // [bgScrView setContentOffset:CGPointMake((index + 1)*self.view.width, 0) animated:YES];
  110. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  111. // [self startMoveView];
  112. // });
  113. // }
  114. }
  115. - (void)drawAnyView{
  116. [self.view setBackgroundColor:HWF5F7FAColor];
  117. bgScrView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
  118. [bgScrView setBackgroundColor:HWF5F7FAColor];
  119. [bgScrView setShowsVerticalScrollIndicator:NO];
  120. [bgScrView setShowsHorizontalScrollIndicator:NO];
  121. [bgScrView setPagingEnabled:YES];
  122. // [bgScrView setUserInteractionEnabled:NO];
  123. bgScrView.delegate = self;
  124. [bgScrView setContentSize:CGSizeMake(1*self.view.width,self.view.height)];
  125. [bgScrView setClipsToBounds:YES];
  126. [self.view addSubview:bgScrView];
  127. // guideView0 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_0",nil)
  128. // imageName:@"guide_middle_0_icon"
  129. // index:0];
  130. // guideView1 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_1",nil)
  131. // imageName:@"guide_middle_1_icon"
  132. // index:1];
  133. // guideView2 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_2",nil)
  134. // imageName:@"guide_middle_2_icon"
  135. // index:2];
  136. // guideView3 = [[GuideView alloc] initWithTips:NSLocalizedString(@"guide_middle_tips_3",nil)
  137. // imageName:@"guide_middle_3_icon"
  138. // index:3];
  139. //
  140. // guideView0.frame = CGRectMake(0*self.view.width, 0, self.view.width,self.view.height);
  141. // guideView1.frame = CGRectMake(1*self.view.width, 0, self.view.width,self.view.height);
  142. // guideView2.frame = CGRectMake(2*self.view.width, 0, self.view.width,self.view.height);
  143. // guideView3.frame = CGRectMake(3*self.view.width, 0, self.view.width,self.view.height);
  144. //
  145. // [bgScrView addSubview:guideView0];
  146. // [bgScrView addSubview:guideView1];
  147. // [bgScrView addSubview:guideView2];
  148. // [bgScrView addSubview:guideView3];
  149. guideLastView = [[GuideLastView alloc] initWithFrame:CGRectMake(0*self.view.width, 0, self.view.width,self.view.height)];
  150. [bgScrView addSubview:guideLastView];
  151. KWeakSelf
  152. guideView0.didClickButton = ^{
  153. [weakSelf didClickSkipFun];
  154. };
  155. guideView1.didClickButton = ^{
  156. [weakSelf didClickSkipFun];
  157. };
  158. guideView2.didClickButton = ^{
  159. [weakSelf didClickSkipFun];
  160. };
  161. guideView3.didClickButton = ^{
  162. [weakSelf didClickSkipFun];
  163. };
  164. }
  165. #pragma mark 点击了跳过
  166. - (void)didClickSkipFun
  167. {
  168. [bgScrView setContentOffset:CGPointMake(4*self.view.width, 0) animated:NO];
  169. }
  170. #pragma mark 监听滚动
  171. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  172. {
  173. CGFloat x = scrollView.contentOffset.x;
  174. NSInteger index = (x+1)/self.view.width;
  175. if (index == 4){
  176. bgScrView.userInteractionEnabled = NO;
  177. }
  178. }
  179. @end