WelcomeWindowController.m 21 KB

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