forked from soffes/cheddar-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDISessionsViewController.m
93 lines (71 loc) · 2.79 KB
/
CDISessionsViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// CDISessionsViewController.m
// Cheddar for iOS
//
// Created by Sam Soffes on 4/23/12.
// Copyright (c) 2012 Nothing Magical. All rights reserved.
//
#import "CDISessionsViewController.h"
#import "UIColor+CheddariOSAdditions.h"
#import "UIFont+CheddariOSAdditions.h"
@implementation CDISessionsViewController
@synthesize usernameTextField = _usernameTextField;
@synthesize passwordTextField = _passwordTextField;
- (UITextField *)usernameTextField {
if (!_usernameTextField) {
_usernameTextField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [[self class] textFieldWith], 30.0f)];
_usernameTextField.keyboardType = UIKeyboardTypeEmailAddress;
_usernameTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
_usernameTextField.autocorrectionType = UITextAutocorrectionTypeNo;
_usernameTextField.textColor = [UIColor cheddarBlueColor];
_usernameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_usernameTextField.delegate = self;
_usernameTextField.returnKeyType = UIReturnKeyNext;
_usernameTextField.font = [UIFont cheddarFontOfSize:18.0f];
}
return _usernameTextField;
}
- (UITextField *)passwordTextField {
if (!_passwordTextField) {
_passwordTextField = [[UITextField alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [[self class] textFieldWith], 30.0f)];
_passwordTextField.secureTextEntry = YES;
_passwordTextField.textColor = [UIColor cheddarBlueColor];
_passwordTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_passwordTextField.delegate = self;
_passwordTextField.returnKeyType = UIReturnKeyGo;
_passwordTextField.font = [UIFont cheddarFontOfSize:18.0f];
}
return _passwordTextField;
}
#pragma mark - Class Methods
+ (CGFloat)textFieldWith {
return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 360.0f : 180.0f;
}
#pragma mark - NSObject
- (id)init {
if ((self = [super initWithStyle:UITableViewStyleGrouped])) {
self.title = @"Cheddar";
UIImageView *title = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nav-title.png"]];
title.frame = CGRectMake(0.0f, 0.0f, 116.0f, 21.0f);
self.navigationItem.titleView = title;
}
return self;
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIView *background = [[UIView alloc] initWithFrame:CGRectZero];
background.backgroundColor = [UIColor cheddarArchesColor];
self.tableView.backgroundView = background;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.usernameTextField becomeFirstResponder];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
}
return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
@end