WelcomeWindowController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. //
  2. // WelcomeWindowController.m
  3. // PDF Reader
  4. //
  5. // Created by wangshuai on 13-12-11.
  6. // Copyright (c) 2013年 zhangjie. All rights reserved.
  7. //
  8. #import "WelcomeWindowController.h"
  9. #import "WaitingView.h"
  10. #import <PDF_Master-Swift.h>
  11. #import "TCPageIndicator.h"
  12. static WelcomeWindowController *windowController = nil;
  13. static NSString * const kKMWelcomeHasShowKey = @"WelcomeHasShowKey";
  14. static NSString * const kKMWelcomeRemindMeLaterKey = @"WelcomeRemindMeLaterKey";
  15. @interface WelcomeWindowController ()
  16. @property (nonatomic,assign) IBOutlet NSScrollView *scrollView;
  17. @property (nonatomic,assign) IBOutlet NSView *content1View;
  18. @property (nonatomic,assign) IBOutlet NSView *content2View;
  19. @property (nonatomic,assign) IBOutlet NSView *content3View;
  20. @property (nonatomic,assign) IBOutlet NSView *content4View;
  21. @property (strong) IBOutlet NSView *content5View;
  22. @property (strong) IBOutlet NSView *content6View;
  23. @property (weak) IBOutlet NSImageView *imageView1;
  24. @property (weak) IBOutlet NSImageView *imageView2;
  25. @property (weak) IBOutlet NSImageView *imageView3;
  26. @property (weak) IBOutlet NSImageView *imageView4;
  27. @property (weak) IBOutlet NSImageView *imageView6;
  28. @property (weak) IBOutlet NSImageView *imageView5;
  29. @property (nonatomic,assign) IBOutlet NSTextField *title1Label;
  30. @property (nonatomic,assign) IBOutlet NSTextField *subtitle1Label;
  31. @property (nonatomic,assign) IBOutlet NSTextField *title2Label;
  32. @property (nonatomic,assign) IBOutlet NSTextField *subtitle2Label;
  33. @property (nonatomic,assign) IBOutlet NSTextField *title3Label;
  34. @property (nonatomic,assign) IBOutlet NSTextField *subtitle3Label;
  35. @property (nonatomic,assign) IBOutlet NSTextField *title4Label;
  36. @property (nonatomic,assign) IBOutlet NSTextField *subtitle4Label;
  37. @property (weak) IBOutlet NSTextField *title5Label;
  38. @property (weak) IBOutlet NSTextField *subtitle5Label;
  39. @property (weak) IBOutlet NSTextField *title6Label;
  40. @property (weak) IBOutlet NSTextField *subtitle6Label;
  41. @property (weak) IBOutlet NSBox *preBox;
  42. @property (weak) IBOutlet NSBox *nextBox;
  43. @property (nonatomic, strong) KMDesignButton *preButtonVC;
  44. @property (nonatomic, strong) KMDesignButton *nextButtonVC;
  45. @property (weak) IBOutlet NSBox *next1Box;
  46. @property (weak) IBOutlet NSBox *remindMeLaterBox;
  47. @property (weak) IBOutlet NSBox *next2Box;
  48. @property (weak) IBOutlet NSBox *next3Box;
  49. @property (weak) IBOutlet NSBox *next4Box;
  50. @property (weak) IBOutlet NSBox *next5Box;
  51. @property (weak) IBOutlet NSBox *signUpBox;
  52. @property (nonatomic, strong) KMDesignButton *next1ButtonVC;
  53. @property (nonatomic, strong) KMDesignButton *remindMeLaterButtonVC;
  54. @property (nonatomic, strong) KMDesignButton *next2ButtonVC;
  55. @property (nonatomic, strong) KMDesignButton *next3ButtonVC;
  56. @property (nonatomic, strong) KMDesignButton *next4ButtonVC;
  57. @property (nonatomic, strong) KMDesignButton *signUpButtonVC;
  58. @property (weak) IBOutlet TCPageIndicator *pageIndicator1;
  59. @property (weak) IBOutlet TCPageIndicator *pageIndicator2;
  60. @property (weak) IBOutlet TCPageIndicator *pageIndicator3;
  61. @property (weak) IBOutlet TCPageIndicator *pageIndicator4;
  62. @property (weak) IBOutlet TCPageIndicator *pageIndicator5;
  63. @property (weak) IBOutlet TCPageIndicator *pageIndicator6;
  64. @property (nonatomic,retain) NSArray *contentViews;
  65. @property (nonatomic,assign) NSInteger currentIndex;
  66. @property (weak) IBOutlet NSButton *closeButton;
  67. @property (weak) IBOutlet KMBox *closeBox;
  68. @end
  69. @implementation WelcomeWindowController
  70. - (void)dealloc {
  71. #if DEBUG
  72. NSLog(@"%s", __func__);
  73. #endif
  74. }
  75. + (void)load {
  76. // 处理再次提醒
  77. if ([[NSUserDefaults standardUserDefaults] boolForKey:kKMWelcomeRemindMeLaterKey]) {
  78. [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kKMWelcomeRemindMeLaterKey];
  79. [[NSUserDefaults standardUserDefaults] setBool:NO forKey:kKMWelcomeHasShowKey];
  80. [[NSUserDefaults standardUserDefaults] synchronize];
  81. }
  82. }
  83. + (BOOL)welcomeHasShow {
  84. return [[NSUserDefaults standardUserDefaults] boolForKey:kKMWelcomeHasShowKey];
  85. }
  86. #pragma mark Init Methods
  87. - (id)init {
  88. if (self = [super initWithWindowNibName:@"WelcomeWindowController"]) {
  89. windowController = self;
  90. }
  91. return self;
  92. }
  93. - (void)awakeFromNib {
  94. [super awakeFromNib];
  95. NSClipView *clipView = self.scrollView.contentView;
  96. // ,self.content4View
  97. self.contentViews = @[self.content1View, self.content2View, self.content3View, self.content4View, self.content6View, self.content5View];
  98. for (int i=0; i<self.contentViews.count; i++) {
  99. NSView *view = self.contentViews[i];
  100. view.frame = CGRectMake(i*clipView.bounds.size.width, 0,
  101. clipView.bounds.size.width,
  102. clipView.bounds.size.height);
  103. [self.scrollView.documentView addSubview:view];
  104. }
  105. self.scrollView.documentView.frame = CGRectMake(0, 0, clipView.bounds.size.width*self.contentViews.count, clipView.bounds.size.height);
  106. }
  107. - (void)windowDidLoad {
  108. [super windowDidLoad];
  109. [self localizedString];
  110. [self initSubViews];
  111. [self setupUI];
  112. [self reloadData];
  113. // 设置【显示】标识
  114. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kKMWelcomeHasShowKey];
  115. [[NSUserDefaults standardUserDefaults] synchronize];
  116. }
  117. - (void)localizedString {
  118. //#if VERSION_DMG
  119. // self.imageView1.image = [NSImage imageNamed:@"KMImageNameWelcomeHomeNew"];
  120. // self.imageView2.image = [NSImage imageNamed:@"KMImageNameWelcomeAnnotation"];
  121. // self.imageView3.image = [NSImage imageNamed:@"KMImageNameWelcomeEdit"];
  122. // self.imageView4.image = [NSImage imageNamed:@"KMImageNameWelcomePageEdit"];
  123. // self.imageView5.image = [NSImage imageNamed:@"KMImageNameWelcomeConvert"];
  124. // self.imageView6.image = [NSImage imageNamed:@"KMImageNameWelcome3"];
  125. //
  126. // self.title1Label.stringValue = NSLocalizedString(@"The Brand New PDF Master", nil);
  127. // self.subtitle1Label.stringValue = NSLocalizedString(@"PDF Master Beta Invites You to Enjoy All Advanced Features!\n\nEdit, Annotate and Convert PDFs with PDF Master to boost your productivity", nil);
  128. //
  129. // self.title2Label.stringValue = NSLocalizedString(@"Comment PDFs with Rich Annotation Tools", nil);
  130. // self.subtitle2Label.stringValue = NSLocalizedString(@"Add highlights, freehand, text, stamps, links, shapes, and notes to your documents. Easily mark up your PDFs anytime!", nil);
  131. //
  132. //// self.title3Label.stringValue = NSLocalizedString(@"Convert PDF to Office Fast and Easily", nil);
  133. //// self.subtitle3Label.stringValue = NSLocalizedString(@"Convert PDF to editable Word, Excel, PPT, Text and image with all your fonts and formatting preserved.", nil);
  134. // self.title3Label.stringValue = NSLocalizedString(@"Edit Original Text and Images Like Word", nil);
  135. // self.subtitle3Label.stringValue = NSLocalizedString(@"Fix a typo or add a new text box in a PDF effortlessly. Crop, replace, rotate, flip, and export images as desired.", nil);
  136. //
  137. //// self.title4Label.stringValue = NSLocalizedString(@"Fill out Form & Sign Documents", nil);
  138. //// self.subtitle4Label.stringValue = NSLocalizedString(@"Fill out forms effortlessly and add text, image or handwritten signatures to PDFs.", nil);
  139. // self.title4Label.stringValue = NSLocalizedString(@"Organize PDF Pages with Ease", nil);
  140. // self.subtitle4Label.stringValue = NSLocalizedString(@"Drag and drop page thumbnails to rearrange pages. Or easily delete, insert, rotate, split pages.", nil);
  141. //
  142. // self.title6Label.stringValue = NSLocalizedString(@"Convert PDF to Office Fast and Easily", nil);
  143. // self.subtitle6Label.stringValue = NSLocalizedString(@"Convert PDF to editable Word, Excel, PPT, Text and image with all your fonts and formatting preserved.", nil);
  144. //
  145. // self.title5Label.stringValue = NSLocalizedString(@"Sign up to Unlock Premium Features", nil);
  146. // self.subtitle5Label.stringValue = NSLocalizedString(@"All advanced features in PDF Master can be used after registration, including converting PDFs without limitation. ", nil);
  147. //#else
  148. self.imageView1.image = [NSImage imageNamed:@"KMImageNameWelcome1"];
  149. self.imageView2.image = [NSImage imageNamed:@"KMImageNameWelcome2"];
  150. self.imageView3.image = [NSImage imageNamed:@"KMImageNameWelcomeAnnotation"];
  151. self.imageView4.image = [NSImage imageNamed:@"KMImageNameWelcomeEdit"];
  152. self.imageView5.image = [NSImage imageNamed:@"KMImageNameWelcomePageEdit"];
  153. self.imageView6.image = [NSImage imageNamed:@"KMImageNameWelcomeConvert"];
  154. // self.imageView6.image = [NSImage imageNamed:@"KMImageNameWelcome3"];
  155. self.title1Label.stringValue = NSLocalizedString(@"The Brand New PDF Master", nil);
  156. self.subtitle1Label.stringValue = NSLocalizedString(@"PDF Master Invites You to Enjoy All Advanced Features! Use the new powerful software integrated with AI technology to edit your PDFs", nil);
  157. self.title2Label.stringValue = NSLocalizedString(@"Process PDF Document wit AI Robot", nil);
  158. self.subtitle2Label.stringValue = NSLocalizedString(@"Smart PDF AI robot, powered by Chatgpt helps you translate, rewrite, and correct PDFs with ease, bringing you an enhanced PDF experience.", nil);
  159. self.title3Label.stringValue = NSLocalizedString(@"Comment PDFs with Rich Annotation Tools", nil);
  160. self.subtitle3Label.stringValue = NSLocalizedString(@"Add highlights, freehand, text, stamps, links, shapes, and notes to your documents. Easily mark up your PDFs anytime!", nil);
  161. self.title4Label.stringValue = NSLocalizedString(@"Edit Original Text and Images Like Word", nil);
  162. self.subtitle4Label.stringValue = NSLocalizedString(@"Fix a typo or add a new text box in a PDF effortlessly. Crop, replace, rotate, flip, and export images as desired.", nil);
  163. self.title6Label.stringValue = NSLocalizedString(@"Organize PDF Pages with Ease", nil);
  164. self.subtitle6Label.stringValue = NSLocalizedString(@"Drag and drop page thumbnails to rearrange pages. Or easily delete, insert, rotate, split pages.", nil);
  165. self.title5Label.stringValue = NSLocalizedString(@"Convert PDF to Office Fast and Easily", nil);
  166. self.subtitle5Label.stringValue = NSLocalizedString(@"Convert PDF to editable Word, Excel, PPT, Text and image with all your fonts and formatting preserved.", nil);
  167. // self.title5Label.stringValue = NSLocalizedString(@"Sign up to Unlock Premium Features", nil);
  168. // self.subtitle5Label.stringValue = NSLocalizedString(@"All advanced features in PDF Master can be used after registration.", nil);
  169. //#endif
  170. }
  171. - (void)initSubViews {
  172. self.preBox.borderType = NSNoBorder;
  173. self.preButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeImage];
  174. [self.preBox.contentView addSubview:self.preButtonVC.view];
  175. self.preButtonVC.view.frame = self.preBox.contentView.bounds;
  176. self.preButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  177. self.preButtonVC.image = [NSImage imageNamed:@"KMImageNamePreviousPageImage"];
  178. [self.preButtonVC pagination];
  179. self.preButtonVC.target = self;
  180. self.preButtonVC.action = @selector(previousButtonAction:);
  181. self.nextBox.borderType = NSNoBorder;
  182. self.nextButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeImage];
  183. [self.nextBox.contentView addSubview:self.nextButtonVC.view];
  184. self.nextButtonVC.view.frame = self.nextBox.contentView.bounds;
  185. self.nextButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  186. self.nextButtonVC.image = [NSImage imageNamed:@"KMImageNameNextPageImage"];
  187. [self.nextButtonVC pagination];
  188. self.nextButtonVC.target = self;
  189. self.nextButtonVC.action = @selector(nextButtonAction:);
  190. for (NSBox *box in @[self.next1Box, self.next2Box, self.next3Box, self.next4Box, self.next5Box]) {
  191. box.borderType = NSNoBorder;
  192. KMDesignButton *nextButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeText];
  193. [box.contentView addSubview:nextButtonVC.view];
  194. nextButtonVC.view.frame = box.contentView.bounds;
  195. nextButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  196. // nextButtonVC.stringValue = NSLocalizedString(@"Next", nil);
  197. if (KMLightMemberManager.manager.isLogin) { // let’s start
  198. nextButtonVC.stringValue = NSLocalizedString(@"Let's Start", nil);
  199. } else {
  200. nextButtonVC.stringValue = NSLocalizedString(@"Sign up", nil);
  201. }
  202. nextButtonVC.target = self;
  203. // nextButtonVC.action = @selector(nextButtonAction:);
  204. nextButtonVC.action = @selector(signUpButtonAction:);
  205. [nextButtonVC buttonWithType:TokenButtonTypeCta size:TokenButtonSizeL height:[[NSLayoutConstraint alloc] init]];
  206. if ([box isEqual:self.next1Box]) {
  207. self.next1ButtonVC = nextButtonVC;
  208. } else if ([box isEqual:self.next2Box]) {
  209. self.next2ButtonVC = nextButtonVC;
  210. } else if ([box isEqual:self.next3Box]) {
  211. self.next3ButtonVC = nextButtonVC;
  212. } else if ([box isEqual:self.next4Box]) {
  213. self.next4ButtonVC = nextButtonVC;
  214. } else if ([box isEqual:self.next5Box]) {
  215. // self.next5
  216. }
  217. }
  218. self.remindMeLaterBox.borderType = NSNoBorder;
  219. self.remindMeLaterButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeText];
  220. [self.remindMeLaterBox.contentView addSubview:self.remindMeLaterButtonVC.view];
  221. self.remindMeLaterButtonVC.view.frame = self.remindMeLaterBox.contentView.bounds;
  222. self.remindMeLaterButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  223. self.remindMeLaterButtonVC.stringValue = NSLocalizedString(@"Remind Me Later", nil);
  224. self.remindMeLaterButtonVC.target = self;
  225. self.remindMeLaterButtonVC.action = @selector(remindMeLaterButtonAction:);
  226. // TokenButtonTypeLink
  227. [self.remindMeLaterButtonVC buttonWithType:TokenButtonTypeText size:TokenButtonSizeM height:[[NSLayoutConstraint alloc] init]];
  228. self.signUpBox.borderType = NSNoBorder;
  229. self.signUpButtonVC = [[KMDesignButton alloc] initWithType:DesignButtonTypeText];
  230. [self.signUpBox.contentView addSubview:self.signUpButtonVC.view];
  231. self.signUpButtonVC.view.frame = self.signUpBox.contentView.bounds;
  232. self.signUpButtonVC.view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  233. if (KMLightMemberManager.manager.isLogin) { // let’s start
  234. self.signUpButtonVC.stringValue = NSLocalizedString(@"Let's Start", nil);
  235. } else {
  236. self.signUpButtonVC.stringValue = NSLocalizedString(@"Sign up", nil);
  237. }
  238. self.signUpButtonVC.target = self;
  239. self.signUpButtonVC.action = @selector(signUpButtonAction:);
  240. [self.signUpButtonVC buttonWithType:TokenButtonTypeCta size:TokenButtonSizeL height:[[NSLayoutConstraint alloc] init]];
  241. // , self.pageIndicator5
  242. for (TCPageIndicator *pageindicator in @[self.pageIndicator1, self.pageIndicator2, self.pageIndicator3, self.pageIndicator4, self.pageIndicator5, self.pageIndicator6]) {
  243. pageindicator.numberOfPages = 6;
  244. pageindicator.selectedColor = [NSColor colorWithRed:39/255.f green:60/255.f blue:98/255.f alpha:1.f];
  245. pageindicator.normalColor = [NSColor colorWithRed:0/255.f green:0/255.f blue:0/255.f alpha:0.2];
  246. pageindicator.pageIndicatorSize = NSMakeSize(6, 6);
  247. pageindicator.enabled = NO;
  248. if ([pageindicator isEqual:self.pageIndicator1]) {
  249. pageindicator.currentPage = 0;
  250. } else if ([pageindicator isEqual:self.pageIndicator2]) {
  251. pageindicator.currentPage = 1;
  252. } else if ([pageindicator isEqual:self.pageIndicator3]) {
  253. pageindicator.currentPage = 2;
  254. } else if ([pageindicator isEqual:self.pageIndicator4]) {
  255. pageindicator.currentPage = 3;
  256. } else if ([pageindicator isEqual:self.pageIndicator5]) {
  257. pageindicator.currentPage = 5;
  258. } else if ([pageindicator isEqual:self.pageIndicator6]) {
  259. pageindicator.currentPage = 4;
  260. }
  261. }
  262. __weak typeof(self)weakSelf = self;
  263. self.closeBox.moveCallback = ^(BOOL mouseEntered, KMBox *mouseBox) {
  264. if (mouseEntered) {
  265. weakSelf.closeButton.image = [NSImage imageNamed:@"control_btn_icon_close_hov"];
  266. } else {
  267. weakSelf.closeButton.image = [NSImage imageNamed:@"control_btn_icon_close"];
  268. }
  269. };
  270. for (NSView *view in self.contentViews) {
  271. NSTextField *label = [NSTextField labelWithString:NSLocalizedString(@"Sign up to Unlock Premium Features", nil)];
  272. [view addSubview:label];
  273. label.frame = NSMakeRect(0, 14, NSWidth(view.frame), 18);
  274. label.alignment = NSTextAlignmentCenter;
  275. label.font = [NSFont fontWithName:@"SFProText-Regular" size:14];
  276. label.textColor = [NSColor colorWithRed:23/255.f green:112/255.f blue:244/255.f alpha:1.f];
  277. if (KMLightMemberManager.manager.isLogin) {
  278. label.hidden = YES;
  279. } else {
  280. label.hidden = NO;
  281. }
  282. }
  283. self.remindMeLaterBox.hidden = YES;
  284. }
  285. - (void)setupUI {
  286. for (NSTextField *titleLabel in @[self.title1Label, self.title2Label, self.title3Label,
  287. self.title4Label, self.title6Label, self.title5Label]) {
  288. titleLabel.font = [NSFont fontWithName:@"SFProText-Semibold" size:20];
  289. titleLabel.textColor = [NSColor colorWithRed:37/255.f green:38/255.f blue:41/255.f alpha:1.f];
  290. }
  291. NSMutableParagraphStyle *ps = [[NSMutableParagraphStyle alloc] init];
  292. ps.lineSpacing = 6;
  293. ps.alignment = NSTextAlignmentCenter;
  294. for (NSTextField *subtitleLabel in @[self.subtitle1Label, self.subtitle2Label, self.subtitle3Label,
  295. self.subtitle4Label, self.subtitle6Label, self.subtitle5Label]) {
  296. // if ([subtitleLabel isEqual:self.subtitle1Label]) {
  297. // NSMutableParagraphStyle *ps_ = [[NSMutableParagraphStyle alloc] init];
  298. // ps_.lineSpacing = 6;
  299. // ps_.alignment = NSTextAlignmentCenter;
  300. // subtitleLabel.attributedStringValue = [[NSAttributedString alloc] initWithString:subtitleLabel.stringValue attributes:@{
  301. // NSFontAttributeName : [NSFont fontWithName:@"SFProText-Regular" size:14],
  302. // NSForegroundColorAttributeName : [NSColor colorWithRed:97/255.f green:100/255.f blue:105/255.f alpha:1.f],
  303. // NSParagraphStyleAttributeName : ps_
  304. // }];
  305. // } else {
  306. subtitleLabel.attributedStringValue = [[NSAttributedString alloc] initWithString:subtitleLabel.stringValue attributes:@{
  307. NSFontAttributeName : [NSFont fontWithName:@"SFProText-Regular" size:14],
  308. NSForegroundColorAttributeName : [NSColor colorWithRed:97/255.f green:100/255.f blue:105/255.f alpha:1.f],
  309. NSParagraphStyleAttributeName : ps
  310. }];
  311. // }
  312. }
  313. }
  314. - (void)close {
  315. windowController = nil;
  316. [super close];
  317. }
  318. #pragma mark Private Methods
  319. - (void)reloadData {
  320. self.preBox.hidden = NO;
  321. self.nextBox.hidden = NO;
  322. if (self.currentIndex == 0) {
  323. self.preBox.hidden = YES;
  324. } else if (self.currentIndex == 1) {
  325. } else if (self.currentIndex == 2) {
  326. // self.nextBox.hidden = YES;
  327. } else if (self.currentIndex == 3) {
  328. } else if (self.currentIndex == 4){
  329. } else if (self.currentIndex == 5) {
  330. self.nextBox.hidden = YES;
  331. }
  332. }
  333. - (void)addWaingView:(NSView *)view {
  334. [self removeWaitingView:view];
  335. WaitingView *wView = [[WaitingView alloc] initWithFrame:view.bounds];
  336. [wView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
  337. [view addSubview:wView];
  338. [wView startAnimation];
  339. }
  340. - (void)removeWaitingView:(NSView *)view {
  341. for (id v in view.subviews) {
  342. if ([[v class] isSubclassOfClass:[WaitingView class]]) {
  343. [v removeFromSuperview];
  344. break;
  345. }
  346. }
  347. }
  348. #pragma mark Button Actions
  349. - (IBAction)previousButtonAction:(id)sender {
  350. if (self.currentIndex <= 0) {
  351. return;
  352. }
  353. self.currentIndex--;
  354. [NSAnimationContext beginGrouping];
  355. NSClipView *clipView = [self.scrollView contentView];
  356. NSPoint newOrigin = [clipView bounds].origin;
  357. newOrigin.x = clipView.bounds.size.width*self.currentIndex;
  358. [[clipView animator] setBoundsOrigin:newOrigin];
  359. [NSAnimationContext endGrouping];
  360. [self reloadData];
  361. }
  362. - (IBAction)nextButtonAction:(id)sender {
  363. if (self.currentIndex >= self.contentViews.count-1) {
  364. return;
  365. }
  366. self.currentIndex++;
  367. [NSAnimationContext beginGrouping];
  368. NSClipView *clipView = [self.scrollView contentView];
  369. NSPoint newOrigin = [clipView bounds].origin;
  370. newOrigin.x = clipView.bounds.size.width*self.currentIndex;
  371. [[clipView animator] setBoundsOrigin:newOrigin];
  372. [NSAnimationContext endGrouping];
  373. [self reloadData];
  374. }
  375. - (IBAction)closeAction:(id)sender {
  376. if (self.itemClick) {
  377. self.itemClick(1, self);
  378. }
  379. [self close];
  380. }
  381. - (void)signUpButtonAction:(NSButton *)sender {
  382. if (KMLightMemberManager.manager.isLogin) {
  383. [self closeAction:sender];
  384. } else {
  385. if (self.itemClick) {
  386. self.itemClick(3, self);
  387. }
  388. [self close];
  389. }
  390. }
  391. - (void)remindMeLaterButtonAction:(NSButton *)sender {
  392. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kKMWelcomeRemindMeLaterKey];
  393. [[NSUserDefaults standardUserDefaults] synchronize];
  394. if (self.itemClick) {
  395. self.itemClick(2, self);
  396. }
  397. [self close];
  398. }
  399. @end