Permalink
Browse files

added authentication view.

  • Loading branch information...
1 parent e3406f2 commit d81866038fac72d7e72cd1bfa5f6a349a5c8f5dd @sschroed committed Jan 19, 2009
View
@@ -72,9 +72,9 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{19, 324}, {280, 79}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <object class="NSColor" key="IBUIBackgroundColor" id="655035782">
- <int key="NSColorSpace">1</int>
- <bytes key="NSRGB">MSAxIDEAA</bytes>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">2</int>
+ <bytes key="NSRGB">MC45MjU0OTAyNiAwLjkwNTg4MjQyIDAuODAzOTIxNjQAA</bytes>
</object>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -93,7 +93,10 @@
</object>
<string key="NSFrameSize">{320, 480}</string>
<reference key="NSSuperview"/>
- <reference key="IBUIBackgroundColor" ref="655035782"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">2</int>
+ <bytes key="NSRGB">MC45MjU0OTAyNiAwLjkwNTg4MjQyIDAuODAzOTIxNjQAA</bytes>
+ </object>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
</object>
@@ -0,0 +1,24 @@
+//
+// LoginViewController.h
+// git-phone
+//
+// Created by Sam Schroeder on 1/17/09.
+// Copyright 2009 Proton Microsystems, LLC. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface LoginViewController : UIViewController <UITextFieldDelegate> {
+ IBOutlet UITextField *userName;
+ IBOutlet UILabel *systemPrefs;
+ IBOutlet UILabel *copyRight;
+}
+
+@property(nonatomic, retain) UITextField *userName;
+@property(nonatomic, retain) UILabel *systemPrefs;
+@property(nonatomic, retain) UILabel *copyRight;
+
+- (void)showAlert:(NSString *)message withTitle:(NSString *)title;
+
+@end
@@ -0,0 +1,64 @@
+//
+// LoginViewController.m
+// git-phone
+//
+// Created by Sam Schroeder on 1/17/09.
+// Copyright 2009 Proton Microsystems, LLC. All rights reserved.
+//
+
+#import "LoginViewController.h"
+#import "Models.h"
+
+@implementation LoginViewController
+
+@synthesize userName;
+@synthesize systemPrefs;
+@synthesize copyRight;
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ // Setup UITextFields
+ userName.font = [UIFont systemFontOfSize:16];
+ systemPrefs.font = [UIFont systemFontOfSize:11];
+ copyRight.font = [UIFont systemFontOfSize:11];
+}
+
+- (void)viewDidAppear:(BOOL)flag {
+ [userName becomeFirstResponder];
+}
+
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+
+ if (nil != textField.text && [textField.text length] > 0){
+ [[Config instance] setGitHubUserName:[textField text]];
+ [textField resignFirstResponder];
+ return YES;
+ } else {
+ [self showAlert:@"Please enter your GitHub username" withTitle:@"Octocat FAIL"];
+ return NO;
+ }
+
+
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+ [self dismissModalViewControllerAnimated:YES];
+}
+
+- (void)showAlert:(NSString *)message withTitle:(NSString *)title {
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
+ message:message
+ delegate:nil
+ cancelButtonTitle:@"Try Again" otherButtonTitles:nil];
+ [alertView show];
+ [alertView release];
+}
+
+- (void)dealloc {
+ [userName release];
+ [super dealloc];
+}
+
+
+@end
@@ -10,6 +10,7 @@
#import "RootViewController.h"
#import "ConnectivityController.h"
#import "ApplicationErrorViewController.h"
+#import "LoginViewController.h"
#import "Models.h"
@interface git_phoneAppDelegate()
@@ -29,7 +30,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
- // Ensure we have connectivity.
+ // Ensure we have connectivity to GitHub.
[[Config instance] setBaseURL:@"http://github.com"];
if(![ConnectivityController isGitHubWebServiceReachable:[[Config instance] baseURL]]) {
[self showError:@"Octocat cannot connect to GitHub."];
@@ -59,7 +60,9 @@ - (void) loadPreferences {
// Check if username is set
if ([[Config instance] gitHubUserName] == NULL) {
- DevLog(@"NULL");
+ LoginViewController *loginViewController = [[[LoginViewController alloc] initWithNibName:@"Login" bundle:nil] autorelease];
+ [window addSubview:[loginViewController view]];
+ [navigationController presentModalViewController:loginViewController animated:YES];
} else {
DevLog(@"NOT NULL");
}
Oops, something went wrong.

0 comments on commit d818660

Please sign in to comment.