-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginViewController.m
120 lines (98 loc) · 4.55 KB
/
LoginViewController.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//
// LoginViewController.m
// CourseShopper
//
// Created by Noah Fradin on 11/20/13.
// Copyright (c) 2013 Noah Fradin. All rights reserved.
//
#import "LoginViewController.h"
#import "CalendarViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface LoginViewController (){
UITextField *password;
}
@end
@implementation LoginViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIImage *logo = [UIImage imageNamed: (@"Logo")];
UIImageView *logoView = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 220.0, 300.0, 286.0)];
logoView.image = logo;
[self.view addSubview:logoView];
UITextField *username = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 275, 38)];
[username setBorderStyle: UITextBorderStyleLine];
[[username layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
username.placeholder = @" Username";
username.textColor = [UIColor grayColor];
username.tag = 1;
username.delegate = self;
[self.view addSubview:username];
UITextField *password = [[UITextField alloc] initWithFrame:CGRectMake(20, 96, 275, 38)];
password.clearsOnBeginEditing = YES;
password.secureTextEntry = YES;
// password.clearsOnBeginEditing = YES;
[password setBorderStyle: UITextBorderStyleLine];
[[password layer] setBorderColor:[[UIColor colorWithRed:171.0/255.0 green:171.0/255.0 blue:171.0/255.0 alpha:1.0] CGColor]];
password.placeholder = @" Password";
password.textColor = [UIColor grayColor];
password.tag = 2;
password.delegate = self;
[password setSecureTextEntry:YES];
[self.view addSubview:password];
UIButton *loginButton = [[UIButton alloc] initWithFrame:CGRectMake(175, 142, 120, 38)];
[loginButton.layer setBorderColor:[[UIColor grayColor] CGColor]];
[loginButton setBackgroundColor:[UIColor grayColor]];
[loginButton addTarget:self action:@selector(loginButtonWasPressed) forControlEvents:UIControlEventTouchUpInside];
[loginButton setTitle:@"Login" forState:UIControlStateNormal];
loginButton.tag = 3;
[self.view addSubview:loginButton];
}
-(void)loginButtonWasPressed{
// CalendarViewController *cal = [[CalendarViewController alloc] init];
// UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:cal];
// [navController.navigationBar setTintColor:[UIColor blackColor]];
// [self presentViewController:navController animated:YES completion:nil];
self.menuViewController = [[CalendarMenuViewController alloc] initWithNibName:nil bundle:nil];
self.mainViewController = [[CalendarViewController alloc] initWithNibName:nil bundle:nil];
//Pass starting cart for appdelegate
self.appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.mainViewController.cart = self.appDelegate.cartArray[0];
self.sideMenuViewController = [[TWTSideMenuViewController alloc] initWithMenuViewController:self.menuViewController mainViewController:[[UINavigationController alloc] initWithRootViewController:self.mainViewController]];
self.sideMenuViewController.shadowColor = [UIColor blackColor];
self.sideMenuViewController.edgeOffset = (UIOffset) { .horizontal = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 18.0f : 0.0f };
self.sideMenuViewController.zoomScale = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? 0.5634f : 0.85f;
[self presentViewController:self.sideMenuViewController animated:YES completion:nil];
// self.window.rootViewController = self.sideMenuViewController;
//
// self.window.backgroundColor = [UIColor whiteColor];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(BOOL)textFieldShouldReturn:(UITextField*)textField;
{
NSInteger nextTag = textField.tag + 1;
// Try to find next responder
UIResponder* nextResponder = [textField.superview viewWithTag:nextTag];
if (nextResponder) {
// Found next responder, so set it.
[nextResponder becomeFirstResponder];
} else {
// Not found, so remove keyboard.
[textField resignFirstResponder];
}
return NO; // We do not want UITextField to insert line-breaks.
}
@end