2017-04-05 20:56:22 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2014-04-25 01:43:47 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2014-04-25 01:43:47 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2014-04-25 01:43:47 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2014-04-25 01:43:47 +00:00
|
|
|
|
|
|
|
#import "MPCoachmarkViewController.h"
|
|
|
|
|
2017-05-07 22:36:01 +00:00
|
|
|
@interface MPCoachmarkViewController()
|
|
|
|
|
|
|
|
@property(nonatomic, strong) NSArray *views;
|
|
|
|
@property(nonatomic) NSUInteger nextView;
|
|
|
|
@property(nonatomic, weak) NSTimer *viewTimer;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPCoachmarkViewController
|
2014-05-18 00:12:59 +00:00
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
2017-05-07 22:36:01 +00:00
|
|
|
self.views = @[
|
|
|
|
self.view0, self.view1, self.view2, self.view3, self.view4, self.view5, self.view6, self.view7, self.view8, self.view9
|
|
|
|
];
|
2014-05-18 00:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2017-04-21 02:29:10 +00:00
|
|
|
self.viewProgress.visible = YES;
|
2014-05-18 00:12:59 +00:00
|
|
|
self.viewProgress.progress = 0;
|
2017-05-07 22:36:01 +00:00
|
|
|
[self.views makeObjectsPerformSelector:@selector( setVisible: ) withObject:@NO];
|
|
|
|
self.nextView = 0;
|
2014-05-18 00:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
|
|
|
[UIView animateWithDuration:0.3f animations:^{
|
2017-05-07 22:36:01 +00:00
|
|
|
[self.views[self.nextView++] setVisible:YES];
|
2014-05-18 00:12:59 +00:00
|
|
|
}];
|
|
|
|
|
2018-02-11 04:29:55 +00:00
|
|
|
if (@available(iOS 10.0, *))
|
|
|
|
self.viewTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 repeats:YES block:^(NSTimer *timer) {
|
|
|
|
self.viewProgress.progress += 1.0f / 50;
|
|
|
|
|
|
|
|
if (self.viewProgress.progress == 1)
|
|
|
|
[UIView animateWithDuration:0.3f animations:^{
|
|
|
|
self.viewProgress.progress = 0;
|
|
|
|
[self.views[self.nextView++] setVisible:YES];
|
|
|
|
|
|
|
|
if (self.nextView >= [self.views count]) {
|
|
|
|
[self.viewTimer invalidate];
|
|
|
|
self.viewProgress.visible = NO;
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}];
|
2014-05-18 00:12:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (UIStatusBarStyle)preferredStatusBarStyle {
|
|
|
|
|
|
|
|
return UIStatusBarStyleLightContent;
|
2014-04-25 01:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)close:(id)sender {
|
|
|
|
|
|
|
|
[self dismissViewControllerAnimated:YES completion:^{
|
|
|
|
self.coachmark.coached = YES;
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MPCoachmark
|
|
|
|
|
|
|
|
+ (instancetype)coachmarkForClass:(Class)coachedClass version:(NSInteger)coachedVersion {
|
2014-05-18 00:12:59 +00:00
|
|
|
|
2014-04-25 01:43:47 +00:00
|
|
|
MPCoachmark *coachmark = [self new];
|
|
|
|
coachmark.coachedClass = coachedClass;
|
|
|
|
coachmark.coachedVersion = coachedVersion;
|
|
|
|
|
|
|
|
return coachmark;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)coached {
|
|
|
|
|
2014-04-25 02:00:38 +00:00
|
|
|
return [[NSUserDefaults standardUserDefaults] boolForKey:strf( @"%@.%ld.coached", self.coachedClass, (long)self.coachedVersion )];
|
2014-04-25 01:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setCoached:(BOOL)coached {
|
|
|
|
|
2014-04-25 02:00:38 +00:00
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:coached forKey:strf( @"%@.%ld.coached", self.coachedClass, (long)self.coachedVersion )];
|
2014-10-24 04:35:05 +00:00
|
|
|
if (![[NSUserDefaults standardUserDefaults] synchronize])
|
|
|
|
wrn( @"Couldn't synchronize after coachmark updates." );
|
2014-04-25 01:43:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|