summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Juick/LoginViewController.h7
-rw-r--r--Juick/LoginViewController.m79
-rw-r--r--Juick/RevealPanelViewController.m2
-rw-r--r--Podfile2
-rw-r--r--Podfile.lock8
5 files changed, 44 insertions, 54 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];
}
diff --git a/Podfile b/Podfile
index 00809b7..bdaa121 100644
--- a/Podfile
+++ b/Podfile
@@ -10,9 +10,9 @@ pod 'RestKit', '~> 0.26.0'
pod 'SDWebImage'
pod 'FontAwesome+iOS'
pod 'NSDate+TimeAgo'
-pod 'JVFloatLabeledTextField'
pod 'SVPullToRefresh'
pod 'SIAlertView'
+pod 'XLForm'
end
target "JuickTests" do
diff --git a/Podfile.lock b/Podfile.lock
index 633baed..badffdb 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -3,7 +3,6 @@ PODS:
- FontAwesome+iOS (0.1.4)
- ISO8601DateFormatterValueTransformer (0.6.1):
- RKValueTransformers (~> 1.1.0)
- - JVFloatLabeledTextField (1.1.1)
- MWFeedParser (1.0.1):
- MWFeedParser/FeedParser (= 1.0.1)
- MWFeedParser/NSDate+InternetDateTime (= 1.0.1)
@@ -44,10 +43,10 @@ PODS:
- SWRevealViewController (2.3.0)
- TransitionKit (2.2.1)
- TTTAttributedLabel (2.0.0)
+ - XLForm (3.2.0)
DEPENDENCIES:
- FontAwesome+iOS
- - JVFloatLabeledTextField
- MWFeedParser
- NSDate+TimeAgo
- PDKeychainBindingsController
@@ -57,12 +56,12 @@ DEPENDENCIES:
- SVPullToRefresh
- SWRevealViewController
- TTTAttributedLabel
+ - XLForm
SPEC CHECKSUMS:
AFNetworking: cf8e418e16f0c9c7e5c3150d019a3c679d015018
FontAwesome+iOS: 9070b682a9255ca0fdc34bcfb129ad0ba2b73b87
ISO8601DateFormatterValueTransformer: 52da467d6ec899d6aedda8e48280ac92e8ee97e6
- JVFloatLabeledTextField: 0e5524b097f102036214dd8279edc8ecf08b5e18
MWFeedParser: 2cf646014c1baf6ad1b08c480b40a08180079247
NSDate+TimeAgo: 35601c619b2d59290055e4fe76e61d97677a2360
PDKeychainBindingsController: fa8cb3cf99f2ea9240d61066ed0549f34e2cec3c
@@ -75,7 +74,8 @@ SPEC CHECKSUMS:
SWRevealViewController: 6d3fd97f70112fd7cef9de14df4260eacce4c63a
TransitionKit: 9ceccda4cd0cdc0a05ef85eb235e5a3292c3c250
TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656
+ XLForm: 2250b4e96ab8ffa5f3355838c79edd90de451782
-PODFILE CHECKSUM: f1516ab62dc255f2f4a95e7021a2d78d055739b2
+PODFILE CHECKSUM: 7d654a17d555aa7dc2db35b869b150e1cdfde1d6
COCOAPODS: 1.0.1