diff options
author | Vitaly Takmazov | 2018-04-01 22:21:20 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-01 22:21:20 +0300 |
commit | 677397be225a3b34f4b26e573fd067f73f9eb75c (patch) | |
tree | 0cfc86aa5e344d47203e7724fcf5b3c16635074d /Juick/ViewControllers | |
parent | f2ad6e8f2bbca27cb9c4777adb581d169c77057b (diff) |
Fix login
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 4 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.m | 16 |
3 files changed, 21 insertions, 0 deletions
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index c874c25..fde23ee 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -74,6 +74,10 @@ AppDelegate *appDelegate; } } - (IBAction)filterAction:(id)sender { + if (![User isAuthenticated]) { + [self performSegueWithIdentifier:@"loginSegue" sender:self]; + return; + } UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { diff --git a/Juick/ViewControllers/LoginViewController.h b/Juick/ViewControllers/LoginViewController.h index baf71db..18ca4a4 100644 --- a/Juick/ViewControllers/LoginViewController.h +++ b/Juick/ViewControllers/LoginViewController.h @@ -13,4 +13,5 @@ @property (weak, nonatomic) IBOutlet UITextField *usernameField; @property (weak, nonatomic) IBOutlet UITextField *passwordField; @property (weak, nonatomic) IBOutlet UIVisualEffectView *visualEffectView; +@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint; @end diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index 4f63e44..fd3c2b0 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -12,6 +12,10 @@ #import "AppDelegate.h" #import "APIClient.h" +@interface LoginViewController() +@property (nonatomic, assign) int paddingValue; +@end + @implementation LoginViewController - (void) awakeFromNib { @@ -26,6 +30,18 @@ target:self action:@selector(doneSignIn)]; self.usernameField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"]; self.passwordField.text = [[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil]; +} + +-(void) keyboardDidShow:(NSNotification *)sender { + CGRect keyboardRect = [sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + self.bottomConstraint.constant = keyboardRect.size.height - self.view.safeAreaInsets.bottom + self.paddingValue; + [self.view layoutIfNeeded]; +} +-(void) keyboardWillHide:(NSNotification *)sender { + self.bottomConstraint.constant = self.paddingValue; + [self.view layoutIfNeeded]; } |