From a228ce07cc5413a6ba164c12042ab1e4028aa5b3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 5 Dec 2017 01:40:51 +0300 Subject: comment --- Juick/ViewControllers/LoginViewController.h | 6 ++--- Juick/ViewControllers/LoginViewController.m | 35 ++++++++-------------------- Juick/ViewControllers/ThreadViewController.m | 12 ++++++---- 3 files changed, 20 insertions(+), 33 deletions(-) (limited to 'Juick/ViewControllers') diff --git a/Juick/ViewControllers/LoginViewController.h b/Juick/ViewControllers/LoginViewController.h index 6a834a8..7a6af5e 100644 --- a/Juick/ViewControllers/LoginViewController.h +++ b/Juick/ViewControllers/LoginViewController.h @@ -7,9 +7,9 @@ // #import -#import "XLForm.h" #import "PDKeychainBindingsController.h" -@interface LoginViewController : XLFormViewController - +@interface LoginViewController : UIViewController +@property (weak, nonatomic) IBOutlet UITextField *usernameField; +@property (weak, nonatomic) IBOutlet UITextField *passwordField; @end diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index 640cd10..a65d180 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -16,10 +16,6 @@ - (void) awakeFromNib { [super awakeFromNib]; - [self initializeForm]; -} - -- (void)initializeForm { self.title = @"Sign in"; [self.view setBackgroundColor:[ColorScheme mainBackground]]; @@ -27,22 +23,8 @@ target:self action:@selector(cancelSignIn)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(doneSignIn)]; - 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; + self.usernameField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; + self.passwordField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]; } @@ -76,12 +58,15 @@ }]; } - --(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]; +- (IBAction)passwordChanged:(id)sender { + if ([self.passwordField.text isKindOfClass:[NSString class]]) { + [[PDKeychainBindings sharedKeychainBindings] setObject:self.passwordField.text forKey:@"com.juick.password"]; } } +- (IBAction)usernameChanged:(id)sender { + if ([self.usernameField.text isKindOfClass:[NSString class]]) { + [[PDKeychainBindings sharedKeychainBindings] setObject:self.usernameField.text forKey:@"com.juick.username"]; + } +} @end diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index 2b0d3c4..95c9839 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -53,15 +53,17 @@ -(void) updateQuoteText:(Message *)message { MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; inputView.quoteText.text = message.text; - [inputView.contentView setNeedsUpdateConstraints]; - [inputView.contentView updateConstraintsIfNeeded]; - [inputView.contentView setNeedsLayout]; - [inputView.contentView layoutIfNeeded]; + [inputView.textContent becomeFirstResponder]; } -(void) sendReply { MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; Message *msg = [self.messages firstObject]; - [[APIClient sharedClient] postReplyToThread:msg.mid inReplyTo:self.replyTo text:inputView.textContent.text]; + [[APIClient sharedClient] postReplyToThread:msg.mid inReplyTo:self.replyTo text:inputView.textContent.text result:^(Message *msg, NSError *err) { + MessageInputView *inputView = (MessageInputView *)self.inputAccessoryView; + inputView.quoteText.text = @""; + [inputView.textContent endEditing:YES]; + [self refreshData]; + }]; } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { -- cgit v1.2.3