//
//  FirstViewController.m
//  geometrixx
//
//  Created by ATS on 1/1/15.
//  Copyright (c) 2015 Adobe Training Services. All rights reserved.
//

#import "home.h"
#import "ADBMobile.h"

@interface home ()
@property (weak, nonatomic) IBOutlet UITextField *userNameField;
@property (weak, nonatomic) IBOutlet UITextField *passwordField;
@property (weak, nonatomic) IBOutlet UILabel *welcomeLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@end


@implementation home


- (IBAction)logInButton:(id)sender {
    
    //Place Adobe tracking code here for exercise
    
   
    
    
    //Grab username
    NSString *contents = self.userNameField.text;
    NSString *message = [NSString stringWithFormat:@"Welcome %@!", contents];
    [self.welcomeLabel setText:message];
    
    //Dismiss keyboard
    [self.userNameField resignFirstResponder];
    [self.passwordField resignFirstResponder];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"geometrixx_background.png"]];
}

- (void)viewDidAppear:(BOOL)animated {
    
    // Place Adobe Tracking code here for exercise
    
   
    
    
    
    
    /* Welcome message
    NSDate * today = [NSDate date];
    NSCalendar * cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
    
    NSDateComponents * comps = [cal components:NSCalendarUnitMinute fromDate:today];
    
    if ( [comps minute] >= 0 && [comps minute] <= 659 )
        [self.timeLabel setText:@"Good morning!"];
    
    else if ( [comps minute] >= 660 && [comps minute] <= 719 )
    [self.timeLabel setText:@"Almost lunch time!"];
    
    else if ( [comps minute] >= 720 && [comps minute] <= 779 )
        [self.timeLabel setText:@"That lunch looks tasty!"];
    
    else if ( [comps minute] >= 780 && [comps minute] <= 839 )
        [self.timeLabel setText:@"Welcome back from lunch!"];
    
    else if ( [comps minute] >= 840 && [comps minute] <= 899 )
        [self.timeLabel setText:@"Take a break during this hour, okay?"];
    
    else if ( [comps minute] >= 900 && [comps minute] <= 1019 )
        [self.timeLabel setText:@"Almost quittin’ time!"];
    
    else if ( [comps minute] >= 1020 && [comps minute] <= 1440  )
        [self.timeLabel setText:@"Good evening!"];
     
     */
    
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}




- (IBAction)creditCardAdvert:(id)sender {
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
