KMVerificationMessageViewController.m 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
  1. //
  2. // KMVerificationMessageViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/9.
  6. //
  7. #import "KMVerificationMessageViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. #import "VerificationManager.h"
  10. #import "AIInfoManager.h"
  11. #import "KMVerificationWindowController.h"
  12. #import "KMUnlockAlertViewController.h"
  13. #define kbottomGap 0
  14. @interface KMVerificationMessageViewController ()<
  15. NSPopoverDelegate>
  16. @property (nonatomic, assign) IBOutlet NSTextField *label;
  17. @property (nonatomic, assign) IBOutlet NSButton *button;
  18. @property (nonatomic, assign) IBOutlet NSButton *secondTrialBtn;
  19. @property (assign) IBOutlet NSView *labelContentView;
  20. @property (assign) IBOutlet NSImageView *bgImg;
  21. @property (assign) IBOutlet NSView *aiContendView;
  22. @property (assign) IBOutlet NSImageView *aiIconImg;
  23. @property (assign) IBOutlet NSTextField *aiLabel;
  24. @property (weak) IBOutlet NSButton *userButton;
  25. @property (assign) IBOutlet NSView *signUpView;
  26. @property (assign) IBOutlet NSImageView *signUpImg;
  27. @property (assign) IBOutlet NSTextField *signUpLabel;
  28. @property (nonatomic, retain) NSTrackingArea *trackingArea;
  29. @property (nonatomic, retain) NSPopover *popover;
  30. @property (nonatomic, assign) BOOL isPopoverShow;
  31. @property (nonatomic, assign) BOOL checkValue;
  32. @property (nonatomic, assign) BOOL stopPopOverHide;
  33. @property (nonatomic, retain) KMUnlockAlertViewController *testVC;
  34. @property (nonatomic, retain) NSMenu *userMenu;
  35. @end
  36. @implementation KMVerificationMessageViewController
  37. #pragma mark Init Methods
  38. - (instancetype)init {
  39. if (self = [super initWithNibName:@"KMVerificationMessageViewController" bundle:nil]) {
  40. #if VERSION_DMG
  41. [[NSNotificationCenter defaultCenter] addObserver:self
  42. selector:@selector(deviceActivateStatusChangeNotification:)
  43. name:kDeviceActivateStatusChangeNotification
  44. object:nil];
  45. #else
  46. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPResultReceived:) name:KMIAPSubscriptionLoadedNotification object:nil];
  47. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPPurchaseSuccess:) name:KMIAPProductPurchasedNotification object:nil];
  48. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPRestoreFinish:) name:KMIAPProductRestoreFinishedNotification object:nil];
  49. #endif
  50. }
  51. return self;
  52. }
  53. - (void)dealloc {
  54. [[NSNotificationCenter defaultCenter] removeObserver:self];
  55. if (self.trackingArea) {
  56. [self.button removeTrackingArea:self.trackingArea];
  57. }
  58. }
  59. #pragma mark Setter Methods
  60. - (void)loadView {
  61. [super loadView];
  62. // Do view setup here.
  63. self.button.wantsLayer = YES;
  64. self.button.layer.masksToBounds = YES;
  65. self.button.layer.cornerRadius = 4.0;
  66. self.button.font = [NSFont SFProTextSemiboldFont:11];
  67. self.button.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor;
  68. [self.button setAlignment:NSTextAlignmentCenter];
  69. self.secondTrialBtn.wantsLayer = YES;
  70. self.secondTrialBtn.layer.masksToBounds = YES;
  71. self.secondTrialBtn.layer.cornerRadius = 4.0;
  72. self.secondTrialBtn.font = [NSFont SFProTextSemiboldFont:11];
  73. self.secondTrialBtn.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor;
  74. [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  75. NSString *tTips = NSLocalizedString(@"Upgrade to Pro", nil);
  76. #if VERSION_DMG
  77. tTips = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"Upgrade to Permanent License with one time purchase", nil), NSLocalizedString(@"Complete the purchase in your web browser to get a license", nil)];
  78. #else
  79. tTips = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil), NSLocalizedString(@"Choose your favorite payment and enjoy flexible upgrades.", nil)];
  80. #endif
  81. self.button.toolTip = tTips;
  82. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  83. [self.button setTitleColor:[NSColor whiteColor]];
  84. [self.button setAlignment:NSTextAlignmentCenter];
  85. self.secondTrialBtn.toolTip = tTips;
  86. self.secondTrialBtn.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  87. [self.secondTrialBtn setTitleColor:[NSColor whiteColor]];
  88. [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  89. self.secondTrialBtn.hidden = YES;
  90. self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  91. self.bgImg.wantsLayer = YES;
  92. self.bgImg.image = [NSImage imageNamed:@"Upgarde_bg_icon"];
  93. self.bgImg.layer.masksToBounds = YES;
  94. self.bgImg.layer.cornerRadius = 4.;
  95. self.bgImg.hidden = YES;
  96. self.aiLabel.font = [NSFont SFProTextSemiboldFont:11];
  97. self.aiLabel.textColor = [NSColor whiteColor];
  98. [self reloadData];
  99. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popoverShowNoti:) name:@"KMVerificationMessagePopShowNoti" object:nil];
  100. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessNotification:) name:@"MemberCenterLoginSuccess" object:nil];
  101. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logoutSuccessNotification:) name:@"MemberCenterLogoutSuccess" object:nil];
  102. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(expandPersonalCenterNotification:) name:@"ExpandPersonalCenter" object:nil];
  103. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeMenu:) name:@"CloseMenuNotification" object:nil];
  104. }
  105. - (void)reloadData {
  106. self.label.textColor = [NSColor blackColor];
  107. self.label.hidden = NO;
  108. BOOL isFree = NO;
  109. self.secondTrialBtn.hidden = YES;
  110. self.bgImg.hidden = YES;
  111. //#if VERSION_DMG
  112. //
  113. // if (self.trackingArea) {
  114. // [self.button removeTrackingArea:self.trackingArea];
  115. // }
  116. //
  117. // self.label.stringValue = @"";
  118. // if (ActivityStatusNone == [VerificationManager manager].status || isFree) {
  119. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  120. // self.label.stringValue = @"";
  121. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  122. // if (isFree) {
  123. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade to Pro", nil)];
  124. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  125. // [self.button setAlignment:NSTextAlignmentCenter];
  126. // if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  127. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  128. // } else {
  129. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  130. // }
  131. // }
  132. // self.button.layer.backgroundColor = [NSColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:133.0/255.0 alpha:1].CGColor;
  133. // [self.button setTitleColor:[NSColor whiteColor]];
  134. // } else if (ActivityStatusTrial == [VerificationManager manager].status) {
  135. // NSDate *date = [NSDate date];
  136. // NSDate *expireDate = [VerificationManager manager].detailInfo.expireDate;
  137. // NSTimeInterval time = [expireDate timeIntervalSinceDate:date];
  138. // int leftDays = ((int)time)/(3600*24);
  139. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  140. // NSString * needShowString = [NSString stringWithFormat:NSLocalizedString(@"%d days left", nil),leftDays];
  141. // if (@available(macOS 10.14, *)) {
  142. // self.label.attributedStringValue = [self numberConvertColor:[NSColor redColor] String:needShowString];
  143. // self.label.textColor = [NSColor colorWithRed:255.0/255.0 green:94.0/255.0 blue:44.0/255.0 alpha:1];
  144. // } else {
  145. // self.label.stringValue = needShowString;
  146. // self.label.textColor = [NSColor colorWithRed:255.0/255.0 green:94.0/255.0 blue:44.0/255.0 alpha:1];
  147. // }
  148. //
  149. //
  150. // self.label.wantsLayer = YES;
  151. // self.label.layer.backgroundColor = [NSColor clearColor].CGColor;
  152. // self.button.layer.backgroundColor = [NSColor colorWithRed:255.0/255.0 green:94.0/255.0 blue:44.0/255.0 alpha:1].CGColor;
  153. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  154. // [self.button setTitleColor:[KMAppearance KMColor_Layout_W0]];
  155. // [self.button setAlignment:NSTextAlignmentCenter];
  156. //
  157. // if (!self.trackingArea) {
  158. // self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.button.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways owner:self userInfo:nil];
  159. // }
  160. // [self.button addTrackingArea:self.trackingArea];
  161. // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  162. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  163. //
  164. // self.label.wantsLayer = YES;
  165. // self.label.layer.backgroundColor = [NSColor clearColor].CGColor;
  166. // self.label.stringValue = NSLocalizedString(@"Trial expired", nil);
  167. // if (@available(macOS 10.14, *)) {
  168. // self.label.textColor = [NSColor whiteColor];
  169. // } else {
  170. // self.label.textColor = [NSColor redColor];
  171. // }
  172. // self.label.stringValue = @"";
  173. //
  174. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  175. // [self.button setAlignment:NSTextAlignmentCenter];
  176. // self.bgImg.hidden = NO;
  177. // self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  178. // [self.button setTitleColor:[NSColor whiteColor]];
  179. //
  180. // if (!self.trackingArea) {
  181. // self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.button.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways owner:self userInfo:nil];
  182. // }
  183. // [self.button addTrackingArea:self.trackingArea];
  184. //
  185. // if ([VerificationManager manager].secondTrialEnabled) {
  186. //
  187. // self.label.stringValue = NSLocalizedString(@"Trial expired", nil);
  188. // self.label.hidden = YES;
  189. // self.secondTrialBtn.hidden = NO;
  190. // self.secondTrialBtn.layer.backgroundColor = [NSColor colorWithRed:0.0/255.0 green:207.0/255.0 blue:133.0/255.0 alpha:1].CGColor;
  191. // [self.secondTrialBtn setTitleColor:[NSColor whiteColor]];
  192. // [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  193. //
  194. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  195. // [self.button setTitleColor:[NSColor whiteColor]];
  196. // self.bgImg.hidden = NO;
  197. // self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  198. // [self.button setAlignment:NSTextAlignmentCenter];
  199. // }
  200. // } else if (ActivityStatusVerifExpire == [VerificationManager manager].status) {
  201. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  202. // self.label.stringValue = @"";
  203. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  204. // [self.button setTitleColor:[NSColor whiteColor]];
  205. // self.bgImg.hidden = NO;
  206. // self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  207. // [self.button setAlignment:NSTextAlignmentCenter];
  208. // } else if (ActivityStatusVerification == [VerificationManager manager].status) {
  209. // if ([VerificationManager manager].needUpgradeLicense == NO) {
  210. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  211. // } else {
  212. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  213. // self.label.stringValue = @"";
  214. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"PDF to Office Pack", nil)];
  215. // [self.button setTitleColor:[KMAppearance KMColor_Interactive_A0]];
  216. // self.button.layer.backgroundColor = [NSColor colorWithRed:229/255. green:233/255. blue:248/255. alpha:1].CGColor;
  217. // [self.button setAlignment:NSTextAlignmentCenter];
  218. // }
  219. // } else {
  220. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  221. // if ([VerificationManager manager].needUpgradeLicense) {
  222. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  223. // self.label.stringValue = @"";
  224. //
  225. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"PDF to Office Pack", nil)];
  226. // [self.button setTitleColor:[KMAppearance KMColor_Interactive_A0]];
  227. // self.button.layer.backgroundColor = [NSColor colorWithRed:229/255. green:233/255. blue:248/255. alpha:1].CGColor;
  228. // [self.button setAlignment:NSTextAlignmentCenter];
  229. // }
  230. // }
  231. //#else
  232. // isFree = YES;
  233. // if (isFree) {
  234. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  235. // self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  236. // self.label.stringValue = @"";
  237. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  238. // if (isFree) {
  239. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade to Pro", nil)];
  240. // [self.button setTitleColor:[NSColor whiteColor]];
  241. // if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  242. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  243. // } else {
  244. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  245. // }
  246. // self.bgImg.hidden = self.button.hidden;
  247. //#if !VERSION_FREE
  248. // self.bgImg.hidden = YES;
  249. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  250. // self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"PDF to Office Pack", nil)];
  251. // if ([IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice) {
  252. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  253. // }
  254. // [self.button setTitleColor:[KMAppearance KMColor_Interactive_A0]];
  255. // self.button.layer.backgroundColor = [NSColor colorWithRed:229/255. green:233/255. blue:248/255. alpha:1].CGColor;
  256. //#endif
  257. // }
  258. // } else {
  259. // self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = YES;
  260. // }
  261. //
  262. //#endif
  263. //
  264. // [self.button sizeToFit];
  265. // [self.button setAlignment:NSTextAlignmentCenter];
  266. // [self.secondTrialBtn sizeToFit];
  267. // [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  268. //
  269. // [self.label sizeToFit];
  270. // if (self.label.stringValue.length == 0) {
  271. // self.labelContentView.frame = CGRectZero;
  272. // } else {
  273. // self.labelContentView.frame = CGRectMake(0, kbottomGap, self.label.frame.size.width + self.view.frame.size.height , self.view.frame.size.height -2 *kbottomGap);
  274. //
  275. // if ([VerificationManager manager].secondTrialEnabled) {
  276. // self.labelContentView.frame = CGRectMake(0, kbottomGap, self.button.frame.size.width + self.secondTrialBtn.frame.size.width - 16, self.view.frame.size.height -2 *kbottomGap);
  277. // }
  278. // self.labelContentView.wantsLayer = YES;
  279. // self.labelContentView.layer.cornerRadius = 4.;
  280. // [self.labelContentView.layer masksToBounds];
  281. //
  282. // self.labelContentView.layer.backgroundColor = [NSColor colorWithRed:255.0/255.0 green:94.0/255.0 blue:44.0/255.0 alpha:0.15].CGColor;
  283. // if ([VerificationManager manager].secondTrialEnabled) {
  284. // self.labelContentView.layer.backgroundColor = [NSColor clearColor].CGColor;
  285. // }
  286. // self.label.frame = CGRectMake(self.labelContentView.frame.size.height/2, (self.labelContentView.frame.size.height - self.label.frame.size.height)/2, self.label.frame.size.width, self.label.frame.size.height);
  287. // }
  288. //
  289. // CGFloat totalWidth = CGRectGetMaxX(self.labelContentView.frame) + 8;
  290. //
  291. //// self.aiLabel.stringValue = NSLocalizedString(@"My AI Credit", nil);
  292. //// [self.aiLabel sizeToFit];
  293. //// CGFloat aiWidth = self.aiLabel.frame.size.width;
  294. //// aiWidth += 4;
  295. //// aiWidth += 16;
  296. //// aiWidth += 16;
  297. //// self.aiContendView.frame = CGRectMake(totalWidth, 0, aiWidth, self.view.frame.size.height);
  298. //// self.aiIconImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-8, 16, 16);
  299. //// CGRect ailabelRect = self.aiLabel.frame;
  300. //// ailabelRect.origin.x = CGRectGetMaxX(self.aiIconImg.frame) + 4;
  301. //// self.aiLabel.frame = ailabelRect;
  302. ////
  303. //// totalWidth += aiWidth;
  304. //// totalWidth += 8;
  305. // self.aiContendView.hidden = YES;
  306. //
  307. // if (self.button.hidden == NO) {
  308. // CGFloat buttonWidth = CGRectGetMaxX(self.button.frame);
  309. // NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  310. // if (fabs(buttonWidth-btnRect.size.width)>50) {
  311. // buttonWidth = btnRect.size.width + 10;
  312. // }
  313. // self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap);
  314. // totalWidth += buttonWidth;
  315. // totalWidth += 8;
  316. // }
  317. //
  318. // if (!self.secondTrialBtn.hidden) {
  319. // self.secondTrialBtn.frame = CGRectMake(MAX(CGRectGetMaxX(self.labelContentView.frame) - self.button.frame.size.width, 0), kbottomGap, self.button.frame.size.width, self.view.frame.size.height -2 *kbottomGap);
  320. // }
  321. //// if (self.view.superview) {
  322. //// self.view.frame = CGRectMake(MAX(0, CGRectGetWidth(self.view.superview.frame)-totalWidth - 8), (CGRectGetHeight(self.view.superview.frame)-CGRectGetHeight(self.view.frame))/2., totalWidth, self.view.frame.size.height);
  323. //// } else {
  324. //// if (self.button.hidden) {
  325. //// self.view.frame = CGRectMake(0,0, CGRectGetMaxX(self.aiLabel.frame) + 20 ,self.view.frame.size.height);
  326. //// } else {
  327. //// self.view.frame = CGRectMake(0,0, CGRectGetMaxX(self.button.frame) ,self.view.frame.size.height);
  328. // }
  329. // }
  330. if (self.frameUpdateHandle) {
  331. self.frameUpdateHandle(self.view.frame);
  332. }
  333. // CGRect rect = self.button.frame;
  334. // self.bgImg.frame = rect;
  335. CGFloat totalWidth = 8;
  336. self.button.hidden = YES;
  337. self.label.hidden = YES;
  338. self.secondTrialBtn.hidden = YES;
  339. self.labelContentView.hidden = YES;
  340. self.bgImg.hidden = YES;
  341. self.aiContendView.hidden = YES;
  342. self.userButton.hidden = YES;
  343. self.signUpView.hidden = YES;
  344. self.signUpLabel.stringValue = NSLocalizedStringFromTable(@"Sign in", @"MemberCenterLocalizable", nil);
  345. [self.signUpLabel sizeToFit];
  346. CGFloat signUpWidth = self.signUpLabel.frame.size.width;
  347. signUpWidth += 4;
  348. signUpWidth += 8;
  349. signUpWidth += 8;
  350. signUpWidth += 12;
  351. self.signUpImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-6, 12, 12);
  352. CGRect signUplabelRect = self.signUpLabel.frame;
  353. signUplabelRect.origin.x = CGRectGetMaxX(self.signUpImg.frame) + 4;
  354. self.signUpLabel.frame = signUplabelRect;
  355. self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  356. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade to Pro", nil)];
  357. [self.button setTitleColor:[NSColor whiteColor]];
  358. self.aiLabel.stringValue = NSLocalizedStringFromTable(@"Free to receive 1 year of AI", @"MemberCenterLocalizable", nil);
  359. [self.aiLabel sizeToFit];
  360. CGFloat aiWidth = self.aiLabel.frame.size.width;
  361. aiWidth += 4;
  362. aiWidth += 16;
  363. aiWidth += 16;
  364. self.aiIconImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-8, 16, 16);
  365. self.aiContendView.frame = CGRectMake(totalWidth, 0, aiWidth, self.view.frame.size.height);
  366. CGRect ailabelRect = self.aiLabel.frame;
  367. ailabelRect.origin.x = CGRectGetMaxX(self.aiIconImg.frame) + 4;
  368. self.aiLabel.frame = ailabelRect;
  369. // totalWidth+=aiWidth;
  370. // totalWidth+=4;
  371. // self.aiContendView.hidden = NO;
  372. CGFloat userImageWidth = 24;
  373. if ([KMMemberInfo shared].isLogin) {
  374. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture"];
  375. } else {
  376. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture1"];
  377. }
  378. CGFloat buttonWidth = CGRectGetMaxX(self.button.frame);
  379. NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  380. if (fabs(buttonWidth-btnRect.size.width)>50) {
  381. buttonWidth = btnRect.size.width + 10;
  382. }
  383. if ([[KMMemberInfo shared].isHaveAIDiscount isEqualToString:@"1"]) {
  384. self.aiContendView.hidden = NO;
  385. totalWidth+=aiWidth;
  386. totalWidth+=4;
  387. }
  388. if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type1 ||
  389. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type3 ||
  390. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type5 ||
  391. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type7 ||
  392. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type8 ||
  393. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type9 ||
  394. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type11 ||
  395. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type13) {
  396. if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type1 ||
  397. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type9) {
  398. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  399. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type3 ||
  400. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type11) {
  401. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"开通会员", nil)];
  402. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type5) {
  403. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"升级", nil)];
  404. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type7 ||
  405. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type8 ||
  406. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type13) {
  407. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"立即续费", nil)];
  408. }
  409. [self.button setTitleColor:[NSColor whiteColor]];
  410. self.bgImg.hidden = NO;
  411. self.button.hidden = NO;
  412. self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap);
  413. CGRect rect = self.button.frame;
  414. self.bgImg.frame = rect;
  415. totalWidth+=CGRectGetWidth(self.button.bounds);
  416. totalWidth+=4;
  417. }
  418. if ([KMMemberInfo shared].isLogin) {
  419. self.userButton.hidden = NO;
  420. self.userButton.frame = CGRectMake(totalWidth, 0, userImageWidth, userImageWidth);
  421. totalWidth += userImageWidth;
  422. totalWidth += 8;
  423. } else {
  424. self.signUpView.hidden = NO;
  425. self.signUpView.frame = CGRectMake(totalWidth, 0, signUpWidth, self.view.frame.size.height);
  426. totalWidth+=CGRectGetWidth(self.signUpView.bounds);
  427. }
  428. if (self.view.superview) {
  429. self.view.frame = CGRectMake(MAX(0, CGRectGetWidth(self.view.superview.frame)-totalWidth - 8), (CGRectGetHeight(self.view.superview.frame)-CGRectGetHeight(self.view.frame))/2., totalWidth, self.view.frame.size.height);
  430. } else {
  431. // if (self.button.hidden) {
  432. // self.view.frame = CGRectMake(0,0, CGRectGetMaxX(self.aiLabel.frame) + 20 ,self.view.frame.size.height);
  433. // } else {
  434. // self.view.frame = CGRectMake(0,0, CGRectGetMaxX(self.button.frame) ,self.view.frame.size.height);
  435. // }
  436. self.view.frame = CGRectMake(MAX(0, CGRectGetWidth(self.view.superview.frame)-totalWidth - 8), (CGRectGetHeight(self.view.superview.frame)-CGRectGetHeight(self.view.frame))/2., totalWidth, self.view.frame.size.height);
  437. }
  438. }
  439. #pragma mark - Button Actions
  440. - (IBAction)secondTrialAction:(NSButton *)sender {
  441. if ([VerificationManager manager].secondTrialEnabled) {
  442. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialGuide];
  443. [vc showWindow:nil];
  444. } else {
  445. [[KMProductCompareWC shared] setOrientation:NO];
  446. [[KMProductCompareWC shared] showWindow:nil];
  447. }
  448. }
  449. - (IBAction)buttonAction:(id)sender {
  450. // BOOL isFree = NO;
  451. //
  452. //#if VERSION_DMG
  453. // if (ActivityStatusNone == [VerificationManager manager].status) {
  454. // //弹出 试用弹窗UI优化-新用户试用路径 新UI 情况一 右上角按钮
  455. // KMPurchaseFirstTrialWindowController *firstTrialWC = [KMPurchaseFirstTrialWindowController currentFirstTrialWC];
  456. // firstTrialWC.buttonActionBlock = ^(KMPurchaseFirstTrialWindowController * _Nonnull ftWC, KMButton * _Nonnull btn, NSString * _Nonnull email, NSString * _Nonnull name) {
  457. // if (btn.tag == 10001) {
  458. // if (ActivityStatusNone == [VerificationManager manager].status ||
  459. // ActivityStatusTrialExpire == [VerificationManager manager].status) {
  460. //
  461. // [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
  462. // [[VerificationManager manager] trialForDays:7
  463. // email:email?:[VerificationManager manager].email
  464. // name:name?:[VerificationManager manager].accountName
  465. // complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  466. // if (error ||
  467. // status != ActivityStatusTrial) {
  468. // NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  469. // defaultButton:NSLocalizedString(@"Try Again", nil)
  470. // alternateButton:nil
  471. // otherButton:nil
  472. // informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  473. // [alert runModal];
  474. // } else {
  475. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  476. // [vc showWindow:nil];
  477. // }
  478. // }];
  479. // [ftWC close];
  480. // } else {
  481. // [ftWC close];
  482. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  483. // vc.callback = ^{
  484. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  485. // };
  486. // [vc showWindow:nil];
  487. // }
  488. // } else if (btn.tag == 10002) {
  489. // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_free_trial", Swift_oc_Tool.Store_Link_OC]];
  490. // [[NSWorkspace sharedWorkspace] openURL:url];
  491. // [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_UpgradeBuyNow"}];
  492. // } else if (btn.tag == 10003) {
  493. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
  494. // [vc showWindow:nil];
  495. // [ftWC close];
  496. // }
  497. // };
  498. // [firstTrialWC.window center];
  499. // [firstTrialWC showWindow:nil];
  500. // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  501. // ActivityStatusTrial == [VerificationManager manager].status) {
  502. // [[NSNotificationCenter defaultCenter] postNotificationName:@"KMVerificationMessagePopShowNoti" object:nil];
  503. //
  504. // if (!self.testVC) {
  505. // self.testVC = [[KMUnlockAlertViewController alloc] init];
  506. // }
  507. // [self.testVC addtrackingAreaInfo];
  508. // self.testVC.callback = ^(NSInteger index) {
  509. // if (index == 1) {
  510. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  511. // [vc showWindow:nil];
  512. // } else if (index == 2) {
  513. // KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_3"];
  514. // [embeddedWC showWindow:nil];
  515. // [[embeddedWC window] center];
  516. // }
  517. // };
  518. // self.testVC.mouseEventCall = ^(BOOL mouseEnter) {
  519. // if (mouseEnter) {
  520. // self.stopPopOverHide = YES;
  521. // if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  522. // ActivityStatusTrial == [VerificationManager manager].status) {
  523. // if (!self.popover.isShown) {
  524. // [self buttonAction:self.button];
  525. // }
  526. // }
  527. // } else {
  528. // self.stopPopOverHide = NO;
  529. // if (self.popover) {
  530. // [self.popover close];
  531. // }
  532. // [self.testVC removeTrackingAreaInfo];
  533. // }
  534. // };
  535. // NSPopover *popover = [[NSPopover alloc] init];
  536. // popover.delegate = self;
  537. // popover.contentViewController = self.testVC;
  538. // popover.animates = YES;
  539. // popover.behavior = NSPopoverBehaviorTransient;
  540. // [popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
  541. // self.popover = popover;
  542. // } else if (ActivityStatusVerifExpire == [VerificationManager manager].status) {
  543. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivateExpired];
  544. // [vc showWindow:nil];
  545. // } else if (ActivityStatusVerification == [VerificationManager manager].status) {
  546. // if ([VerificationManager manager].needUpgradeLicense) {
  547. // KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"];
  548. // [embeddedWC showWindow:nil];
  549. // [[embeddedWC window] center];
  550. // }
  551. // } else {
  552. // if ([VerificationManager manager].needUpgradeLicense) {
  553. // KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"];
  554. // [embeddedWC showWindow:nil];
  555. // [[embeddedWC window] center];
  556. // } else {
  557. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeNormal];
  558. // [vc showWindow:nil];
  559. // }
  560. // }
  561. //#else
  562. // isFree = YES;
  563. //#if VERSION_FREE
  564. // if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  565. // isFree = NO;
  566. // }
  567. // if (isFree) {
  568. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  569. // }
  570. //#else
  571. // if (![IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice) {
  572. // KMToolCompareWindowController *vc = [KMToolCompareWindowController toolCompareWithToolType:KMCompareWithToolTypeConvert selectNum:0];
  573. // [vc.window center];
  574. // [vc showWindow:nil];
  575. // }
  576. //#endif
  577. //
  578. //#endif
  579. if ([KMMemberInfo shared].isLogin) {
  580. [[KMProductCompareWC shared] setOrientation:YES];
  581. if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type1) {
  582. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  583. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type3 ||
  584. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type7 ||
  585. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type8) {
  586. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  587. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type4 ||
  588. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type5 ||
  589. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type9 ||
  590. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type11 ||
  591. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type13) {
  592. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_MacWindows];
  593. }
  594. [[KMProductCompareWC shared] showWindow:nil];
  595. } else {
  596. [KMLoginWindowsController.shared openWindow:^(BOOL success) {
  597. if (success) {
  598. [[KMProductCompareWC shared] setOrientation:YES];
  599. if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type1) {
  600. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  601. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type3 ||
  602. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type7 ||
  603. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type8) {
  604. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  605. } else if ([KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type4 ||
  606. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type5 ||
  607. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type9 ||
  608. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type11 ||
  609. [KMMemberInfo shared].userScenarioType == KMUserScenarioTypeLite_type13) {
  610. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_MacWindows];
  611. }
  612. [[KMProductCompareWC shared] showWindow:nil];
  613. }
  614. }];
  615. }
  616. }
  617. - (NSAttributedString *)numberConvertColor:(NSColor*)color String:(NSString *)string {
  618. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
  619. NSString *temp = nil;
  620. for (NSUInteger i = 0; i <string.length; i++) {
  621. temp = [string substringWithRange:NSMakeRange(i, 1)];
  622. if ([self isPureInt:temp]) {
  623. [attributedString setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
  624. color, NSForegroundColorAttributeName, nil] range:NSMakeRange(i, 1)];
  625. }
  626. }
  627. return attributedString;
  628. }
  629. - (BOOL)isPureInt:(NSString *)string {
  630. NSScanner *scan = [NSScanner scannerWithString:string];
  631. int value;
  632. return [scan scanInt:&value] && [scan isAtEnd];
  633. }
  634. - (IBAction)AIButtonAction:(NSButton *)sender {
  635. __block typeof(self) blockSelf = self;
  636. // [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_AICredit"}];
  637. // [[AIInfoManager defaultManager] fetchAIInfoWithComplention:^(NSDictionary *info, NSError *error) {
  638. //
  639. // }];
  640. // AIUserInfoController *controller = [[AIUserInfoController alloc] init];
  641. // controller.purchaseHandle = ^(AIUserInfoController * _Nonnull vc) {
  642. //#if VERSION_DMG
  643. // KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.ai.product_1"];
  644. // [embeddedWC showWindow:nil];
  645. // [[embeddedWC window] center];
  646. //#else
  647. //
  648. // [[AIPurchaseWindowController currentWC] showWindow:nil];
  649. //#endif
  650. // [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_AICredit_BuyNow"}];
  651. // };
  652. // controller.enterLicenseHandle = ^(AIUserInfoController * _Nonnull vc) {
  653. // KMVerificationWindowController *verifyVC = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivateAIInfo];
  654. // verifyVC.callback = ^{
  655. //
  656. // };
  657. // [verifyVC showWindow:nil];
  658. // };
  659. //
  660. // controller.guideHandle = ^(AIUserInfoController * _Nonnull vc) {
  661. // if (!blockSelf.guideWindowVC) {
  662. // KMFunctionGuideWindowController *guideWindowVC = [[KMFunctionGuideWindowController alloc] initWithWindowNibName:@"KMFunctionGuideWindowController"];
  663. // blockSelf.guideWindowVC = guideWindowVC;
  664. // }
  665. // ((KMFunctionGuideWindowController *)(blockSelf.guideWindowVC)).type = KMGuideInfoTypeFunctionMulti;
  666. // [blockSelf.guideWindowVC showWindow:nil];
  667. // [KMFunctionGuideWindowController setDidShowFor:KMGuideInfoTypeFunctionMultiAIGuide];
  668. // [blockSelf.guideWindowVC.window orderFront:nil];
  669. // };
  670. //
  671. // NSPopover *popover = [[NSPopover alloc] init];
  672. // popover.contentViewController = controller;
  673. // popover.animates = YES;
  674. // popover.behavior = NSPopoverBehaviorTransient;
  675. // [popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
  676. [[KMFreeGetAIWC shared] showWindow:nil];
  677. }
  678. - (IBAction)userButtonAction:(NSButton *)sender {
  679. if ([KMMemberInfo shared].isLogin) {
  680. [self personalCenterAction:sender];
  681. } else {
  682. [KMLoginWindowsController.shared showWindow:nil];
  683. }
  684. }
  685. - (IBAction)personalCenterAction:(NSButton *)sender {
  686. // 用户头像点击事件
  687. self.userMenu = [[NSMenu alloc] init];
  688. KMUserInfoViewController *userInfo = [[KMUserInfoViewController alloc] init];
  689. NSMenuItem *item = [self.userMenu addItemWithTitle:@"" action:nil target:@""];
  690. item.target = self;
  691. item.representedObject = userInfo;
  692. item.view = userInfo.view;
  693. [self.userMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(-130, 30) inView:sender];
  694. }
  695. - (IBAction)signUpAction:(NSButton *)sender {
  696. [KMLoginWindowsController.shared showWindow:nil];
  697. }
  698. #pragma mark - NSNotification Methods
  699. - (void)deviceActivateStatusChangeNotification:(NSNotification *)notification {
  700. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  701. [self reloadData];
  702. });
  703. }
  704. - (void)IAPResultReceived:(NSNotification *)notification {
  705. dispatch_async(dispatch_get_main_queue(), ^{
  706. [self reloadData];
  707. });
  708. }
  709. - (void)IAPPurchaseSuccess:(NSNotification *)notification {
  710. dispatch_async(dispatch_get_main_queue(), ^{
  711. [self reloadData];
  712. });
  713. }
  714. - (void)IAPRestoreFinish:(NSNotification *)notification {
  715. dispatch_async(dispatch_get_main_queue(), ^{
  716. [self reloadData];
  717. });
  718. }
  719. #pragma mark - Event
  720. - (void)mouseEntered:(NSEvent *)event {
  721. if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  722. ActivityStatusTrial == [VerificationManager manager].status) {
  723. [[self class] cancelPreviousPerformRequestsWithTarget:self];
  724. if (!self.popover.isShown) {
  725. [self buttonAction:self.button];
  726. }
  727. }
  728. }
  729. - (void)mouseExited:(NSEvent *)event {
  730. [super mouseExited:event];
  731. [self performSelector:@selector(popOverCloseAction) withObject:nil afterDelay:0.35];
  732. }
  733. - (void)popoverDidClose:(NSNotification *)notification {
  734. self.stopPopOverHide = NO;
  735. }
  736. - (void)popoverShowNoti:(NSNotification *)noti {
  737. if (self.popover) {
  738. [self.popover close];
  739. self.stopPopOverHide = NO;
  740. }
  741. }
  742. - (void)loginSuccessNotification:(NSNotification *)noti {
  743. _userButton.image = [NSImage imageNamed:@"UserProfilePicture"];
  744. [self reloadData];
  745. }
  746. - (void)logoutSuccessNotification:(NSNotification *)noti {
  747. _userButton.image = [NSImage imageNamed:@"UserProfilePicture1"];
  748. [self reloadData];
  749. }
  750. - (void)expandPersonalCenterNotification:(NSNotification *)noti {
  751. if (self.userMenu != nil) {
  752. [self personalCenterAction:_userButton];
  753. }
  754. }
  755. - (void)closeMenu:(NSNotification *)noti {
  756. if (self.userMenu != nil) {
  757. [self.userMenu cancelTracking];
  758. self.userMenu = nil;
  759. }
  760. }
  761. - (void)popOverCloseAction {
  762. if (self.stopPopOverHide == NO) {
  763. if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  764. ActivityStatusTrial == [VerificationManager manager].status) {
  765. if (self.popover.isShown) {
  766. [self.popover close];
  767. self.stopPopOverHide = NO;
  768. }
  769. }
  770. }
  771. }
  772. @end