Browse Source

Major changes to Onboarding.

v1.2.4
Abhishek Banthia 9 years ago
parent
commit
41301fc520
  1. 7
      Clocker/Onboarding/CLIntroViewController.h
  2. 213
      Clocker/Onboarding/CLIntroViewController.m

7
Clocker/Onboarding/CLIntroViewController.h

@ -8,6 +8,11 @@
#import <Cocoa/Cocoa.h>
@interface CLIntroViewController : NSViewController
typedef enum : NSUInteger {
CLFloatingViewFeature,
CLKeyboardShortcutFeature,
CLFavouriteFeature
} CLFeature;
@interface CLIntroViewController : NSViewController
@end

213
Clocker/Onboarding/CLIntroViewController.m

@ -10,22 +10,38 @@
#import <QuartzCore/QuartzCore.h>
#import "ApplicationDelegate.h"
#import <pop/POP.h>
#import "CLAnimatedImages.h"
#import "CommonStrings.h"
#import "FloatingView.h"
#import "CLShortcutAnimatedView.h"
#import "CLFavouriteAnimatedView.h"
#import "PanelController.h"
@interface CLIntroViewController ()
@property (weak) IBOutlet NSImageView *onboardingImageView;
@property (weak) IBOutlet CLAnimatedImages *customView;
@property (weak) IBOutlet NSTextField *headerView;
@property (weak) IBOutlet NSView *customView;
@property (strong) FloatingView *floatingView;
@property (strong) CLShortcutAnimatedView *shortCutView;
@property (strong) CLFavouriteAnimatedView *favouriteView;
@property (strong) NSString *informativeText;
@property (strong) NSArray *headerLabelString;
@property (weak) IBOutlet NSButton *nextActionButton;
@end
@implementation CLIntroViewController
- (void)viewDidLoad {
- (void)viewDidLoad
{
[super viewDidLoad];
// Do view setup here.
// self.view.window.titleVisibility = NSWindowTitleHidden;
self.headerLabelString = @[@"Now, Clocker stays on top of all the windows", @"Access Clocker through keyboard shortcuts", @"Customize your menubar with Favourites"];
[self.headerView setWantsLayer:YES];
CALayer *viewLayer = [CALayer layer];
[viewLayer setBackgroundColor:CGColorCreateGenericRGB(255.0, 255.0, 255.0, 0.8)]; //RGB plus Alpha Channel
[self.view setWantsLayer:YES]; // view's backing store is using a Core Animation Layer
@ -33,44 +49,199 @@
self.view.window.styleMask = NSFullSizeContentViewWindowMask;
[self.customView addUntitled1Animation];
[self initializeViews];
/*
Hide continue button until the animations are over.
Faltu me animations waste hoga nahi toh.
*/
self.nextActionButton.hidden = YES;
[self addAnimationInOrderWithTag:CLFloatingViewFeature];
}
- (void)initializeViews
{
self.floatingView = [[FloatingView alloc] initWithFrame:self.customView.frame];
self.favouriteView = [[CLFavouriteAnimatedView alloc] initWithFrame:self.customView.frame];
self.shortCutView = [[CLShortcutAnimatedView alloc] initWithFrame:self.customView.frame];
}
- (void)addAnimationInOrderWithTag:(CLFeature)integer
{
switch (integer) {
case CLFloatingViewFeature:
[self showFloatingViewInformation];
break;
case CLKeyboardShortcutFeature:
[self showShortcutInformation];
break;
case CLFavouriteFeature:
[self showFavouritingAnimation];
break;
default:
[self performSkipEvent];
break;
}
}
- (void)showFloatingViewInformation
{
self.informativeText = @"Introducing the Floating Mode, now Clocker floats on your screen while you work, play or do whatever you want to.";
[self performOpacityAnimationWithString:self.headerLabelString[0] andAnimationBlock:^{
[self.view replaceSubview:self.customView with:self.floatingView];
[self.floatingView addUntitled1Animation];
[self performContinueButtonAnimationWithValue:NO];
}];
}
- (void)performContinueButtonAnimationWithValue:(BOOL)value
{
self.nextActionButton.hidden = value;
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewAlphaValue];
anim.springBounciness = 8;
anim.springSpeed = 4;
anim.toValue = @(1.0);
anim.beginTime = CACurrentMediaTime()+0.1*1;
[self.nextActionButton pop_addAnimation:anim forKey:@"appear"];
}
- (void)showShortcutInformation
{
self.floatingView.hidden = YES;
self.informativeText = @"No need to click on the Clocker icon. Set a keyboard shortcut and hit the keys.";
[self performOpacityAnimationWithString:self.headerLabelString[1] andAnimationBlock:^{
self.floatingView.hidden = NO;
[self.view replaceSubview:self.floatingView with:self.shortCutView];
[self.shortCutView addScaleAnimationAnimation];
[self performContinueButtonAnimationWithValue:NO];
}];
}
- (void)showFavouritingAnimation
{
self.shortCutView.hidden = YES;
self.informativeText = @"Favourite a city and now the menubar will display the time of the place. Customize what you want to see in the menubar. Totally upto you!";
[self performOpacityAnimationWithString:self.headerLabelString[2] andAnimationBlock:^{
self.shortCutView.hidden = NO;
[self.view replaceSubview:self.shortCutView with:self.favouriteView];
[self.favouriteView addUntitled1Animation];
[self performContinueButtonAnimationWithValue:NO];
}];
}
- (IBAction)continueOnboarding:(NSButton *)sender
{
if ([sender.title isEqualToString:@"Get Started"])
if ([[sender title] isEqualToString:@"Continue"])
{
[self performContinueButtonAnimationWithValue:YES];
[self addAnimationInOrderWithTag:CLKeyboardShortcutFeature];
[sender setTitle:@"Next"];
}
else if ([[sender title] isEqualToString:@"Next"])
{
[self performContinueButtonAnimationWithValue:YES];
[self addAnimationInOrderWithTag:CLFavouriteFeature];
sender.title = @"Get Started";
}
else
{
/*First check if there are any timezones/cities added
If not, open the Preferences window
*/
NSArray *addedTimezones = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
addedTimezones.count == 0 ? [self openPreferences] : [self performSkipEvent];
[self.view.window close];
ApplicationDelegate *delegate = (ApplicationDelegate*)[NSApplication sharedApplication].delegate;
[delegate togglePanel:nil];
return;
}
}
- (void)performOpacityAnimationWithString:(NSString *)string andAnimationBlock:(void(^)(void))animationBlock
{
self.onboardingImageView.image = [NSImage imageNamed:@"FinalOnboarding"];
[sender setTitle:@"Get Started"];
CALayer *layer = self.onboardingImageView.layer;
[layer pop_removeAllAnimations];
self.headerView.stringValue = string;
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
anim.fromValue = @(300);
anim.toValue = @(100);
anim.springBounciness = 20.0f;
POPSpringAnimation *scale = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
scale.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
scale.springBounciness = 20.f;
[layer pop_addAnimation:anim forKey:@"size"];
[self.headerView.layer pop_addAnimation:scale forKey:@"scale"];
scale.completionBlock = ^(POPAnimation *anim, BOOL finished) {
// Shrink animation done
if (finished)
{
animationBlock();
}
};
}
- (IBAction)leftAction:(id)sender
- (IBAction)skipOnboarding:(id)sender
{
[self.customView addUntitled1Animation];
[self performSkipEvent];
}
- (IBAction)rightAction:(id)sender
- (BOOL) performSkipEvent
{
[self.view.window close];
ApplicationDelegate *delegate = (ApplicationDelegate*)[NSApplication sharedApplication].delegate;
[delegate togglePanel:nil];
return YES;
}
- (void)openPreferences
{
ApplicationDelegate *delegate = (ApplicationDelegate*)[NSApplication sharedApplication].delegate;
[delegate.panelController openPreferenceWindowWithValue:YES];
}
@end

Loading…
Cancel
Save