summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/LoginViewController.h7
-rw-r--r--Juick/LoginViewController.m79
-rw-r--r--Juick/RevealPanelViewController.m2
3 files changed, 39 insertions, 49 deletions
diff --git a/Juick/LoginViewController.h b/Juick/LoginViewController.h
index 9ebf187..bf980fa 100644
--- a/Juick/LoginViewController.h
+++ b/Juick/LoginViewController.h
@@ -7,12 +7,9 @@
//
#import <UIKit/UIKit.h>
-#import "JVFloatLabeledTextField.h"
+#import "XLForm.h"
#import "PDKeychainbindingsController.h"
-@interface LoginViewController : UITableViewController<UITextFieldDelegate>
-
-@property(nonatomic, strong) JVFloatLabeledTextField *usernameField;
-@property(nonatomic, strong) JVFloatLabeledTextField *passwordField;
+@interface LoginViewController : XLFormViewController
@end
diff --git a/Juick/LoginViewController.m b/Juick/LoginViewController.m
index a803c48..eedc6d3 100644
--- a/Juick/LoginViewController.m
+++ b/Juick/LoginViewController.m
@@ -12,9 +12,23 @@
@implementation LoginViewController
-static NSString *CellIdentifier = @"CellIdentifier";
+- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self){
+ [self initializeForm];
+ }
+ return self;
+}
--(void) viewDidLoad {
+- (id)initWithCoder:(NSCoder *)aDecoder {
+ self = [super initWithCoder:aDecoder];
+ if (self){
+ [self initializeForm];
+ }
+ return self;
+}
+
+- (void)initializeForm {
self.title = @"Sign in";
[self.view setBackgroundColor:[ColorScheme mainBackground]];
@@ -22,8 +36,22 @@ static NSString *CellIdentifier = @"CellIdentifier";
target:self action:@selector(cancelSignIn)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self action:@selector(doneSignIn)];
- [self.usernameField setText:nil];
- [self.passwordField setText:nil];
+ XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:@"Sign in"];
+ form.rowNavigationOptions = XLFormRowNavigationOptionEnabled;
+ XLFormSectionDescriptor *section = [XLFormSectionDescriptor formSection];
+ [form addFormSection:section];
+ XLFormRowDescriptor * usernameRow = [XLFormRowDescriptor
+ formRowDescriptorWithTag:@"com.juick.username"
+ rowType:XLFormRowDescriptorTypeText title:@"Username"];
+ usernameRow.value = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"];
+ [section addFormRow:usernameRow];
+ XLFormRowDescriptor * passwordRow = [XLFormRowDescriptor
+ formRowDescriptorWithTag:@"com.juick.password"
+ rowType:XLFormRowDescriptorTypePassword title:@"Password"];
+ passwordRow.value = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"];
+ [section addFormRow:passwordRow];
+
+ self.form = form;
}
@@ -54,46 +82,11 @@ static NSString *CellIdentifier = @"CellIdentifier";
}
--(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- NSString *key;
- if (textField.tag == 0) {
- // username change
- key = @"com.juick.username";
- } else {
- key = @"com.juick.password";
- }
- [[PDKeychainBindings sharedKeychainBindings] setObject:[textField.text stringByReplacingCharactersInRange:range withString:string] forKey:key];
- return YES;
-}
-
-- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
-}
-
--(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 2;
-}
-
--(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
- }
- JVFloatLabeledTextField *textField = [[JVFloatLabeledTextField alloc] init];
- textField.tag = indexPath.row;
- textField.delegate = self;
- if (indexPath.row == 0) {
- textField.floatingLabel.text = @"Username";
- textField.placeholder = @"Username";
- textField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"];
- } else {
- textField.floatingLabel.text = @"Password";
- textField.placeholder = @"Password";
- textField.secureTextEntry = YES;
- textField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"];
+-(void) formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)formRow oldValue:(id)oldValue newValue:(id)newValue {
+ [super formRowDescriptorValueHasChanged:formRow oldValue:oldValue newValue:newValue];
+ if ([newValue isKindOfClass:[NSString class]]) {
+ [[PDKeychainBindings sharedKeychainBindings] setObject:newValue forKey:formRow.tag];
}
- [cell.contentView addSubview:textField];
- return cell;
}
@end
diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m
index b79ceff..1e9fb7b 100644
--- a/Juick/RevealPanelViewController.m
+++ b/Juick/RevealPanelViewController.m
@@ -145,7 +145,7 @@ static NSString *CellIdentifier = @"NavCell";
- (void) pushLoginForm {
[self.revealViewController revealToggle:self];
- UIViewController *loginView = [[LoginViewController alloc] initWithStyle:UITableViewStyleGrouped];
+ UIViewController *loginView = [[LoginViewController alloc] init];
UINavigationController *messages = (UINavigationController *)self.revealViewController.frontViewController;
[messages pushViewController:loginView animated:YES];
}